Skip to content

Commit 1e40129

Browse files
authored
Merge pull request #29 from Geode-solutions/x_node_monitoring
feat(FractureModel): add x node monitoring parameter.
2 parents 18b6007 + 6d1b00a commit 1e40129

5 files changed

Lines changed: 78 additions & 9 deletions

File tree

bindings/python/src/stochastic/sampling/mcmc/helpers/fracture_simulation_runner.hpp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,11 @@ namespace geode
6060
module, "FractureSimulationRunner" )
6161
.def( pybind11::init< const SpatialDomain< 2 >& >(),
6262
pybind11::arg( "box" ) )
63+
.def( "add_x_node_monitoring",
64+
&FractureSimulationRunner::add_x_node_monitoring,
65+
pybind11::arg( "double" ),
66+
"Add a monitoring value for x node, value should be "
67+
"in[0.,1.]." )
6368
.def( "add_fracture_set_descriptor",
6469
&FractureSimulationRunner::add_fracture_set_descriptor,
6570
pybind11::arg( "descriptor" ),
@@ -71,6 +76,9 @@ namespace geode
7176
&FractureSimulationRunner::check_statistics,
7277
pybind11::arg( "statistic_monitoring" ),
7378
"Check computed statistics after simulation." )
79+
.def( "string", &FractureSimulationRunner::string,
80+
"Return a detailed description of the simulation "
81+
"configurator." )
7482
// Explicit overload bindings
7583
// .def( "run",
7684
// static_cast< const ObjectSets< OwnerSegment2D >& (

bindings/python/src/stochastic/sampling/mcmc/helpers/simulation_runner.hpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,8 @@ namespace geode
4343
.def_readwrite( "printer", &SimulationConfigurator::printer,
4444
"Optional SimulationPrinter for output" )
4545
.def( "string", &SimulationConfigurator::string,
46-
"Return a detailed description of the simulation configurator" )
46+
"Return a detailed description of the object set simulation "
47+
"configurator" )
4748
.def( "__repr__", []( const SimulationConfigurator& self ) {
4849
return "<SimulationConfigurator realizations="
4950
+ std::to_string( self.realizations ) + ">";

bindings/python/tests/stochastic/test-py-mh-fractures.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,7 @@ def test_two_fracture_sets_simulator():
122122
runner = stochastic.FractureSimulationRunner(domain)
123123
runner.add_fracture_set_descriptor(setA)
124124
runner.add_fracture_set_descriptor(setB)
125+
runner.add_x_node_monitoring(0.3)
125126
runner.initialize()
126127

127128
printer_config = stochastic.SimulationPrinterConfigurator()

include/geode/stochastic/sampling/mcmc/helpers/fracture_simulation_runner.hpp

Lines changed: 66 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,13 @@ namespace geode
5959
std::string string() const
6060
{
6161
auto message = absl::StrCat( "FractureSetDescription: ", name );
62+
for( const auto& fixed_object : observed_fractures )
63+
{
64+
absl::StrAppend( &message,
65+
"\n\t --> observation (x,y,z)start: ",
66+
fixed_object[0].string(),
67+
" (x,y,z)end: ", fixed_object[1].string() );
68+
}
6269
absl::StrAppend(
6370
&message, "\n\t --> length distribution: ", length.string() );
6471
absl::StrAppend(
@@ -81,6 +88,13 @@ namespace geode
8188
{
8289
}
8390

91+
void add_x_node_monitoring( double beta_x_node )
92+
{
93+
OPENGEODE_EXCEPTION( beta_x_node <= 1.0 && beta_x_node >= 0.,
94+
"[FractureSimulationRunner] x node should be inhibitated, "
95+
"please provise a value in [0., 1.]." );
96+
beta_x_node_ = beta_x_node;
97+
}
8498
void add_fracture_set_descriptor(
8599
const FractureSetDescription& descriptor )
86100
{
@@ -134,23 +148,43 @@ namespace geode
134148
set_desc.p20, std::vector< uuid >{ set_id },
135149
this->domain_ ) ) );
136150
// spacing
137-
if( set_desc.minimal_spacing < GLOBAL_EPSILON )
151+
if( set_desc.minimal_spacing > GLOBAL_EPSILON )
138152
{
139-
continue;
153+
auto interaction = std::make_unique<
154+
EuclideanCutoffInteraction< OwnerSegment2D > >(
155+
set_desc.minimal_spacing,
156+
PairwiseInteraction<
157+
OwnerSegment2D >::SCOPE::same_set );
158+
159+
this->ordered_energy_terms_.push_back(
160+
this->energy_terms_collection_.add_energy_term(
161+
std::make_unique< PairwiseTerm< OwnerSegment2D > >(
162+
absl::StrCat( set_desc.name, "_min_spacing" ),
163+
0., std::vector< uuid >{ set_id },
164+
std::move( interaction ), this->domain_ ) ) );
165+
}
166+
}
167+
// x node monitoring
168+
if( std::fabs( beta_x_node_ - 1. ) > GLOBAL_EPSILON )
169+
{
170+
std::vector< uuid > set_uuids;
171+
set_uuids.reserve( name_to_uuid.size() );
172+
for( const auto& [name, id] : name_to_uuid )
173+
{
174+
set_uuids.push_back( id );
140175
}
141176
auto interaction = std::make_unique<
142177
EuclideanCutoffInteraction< OwnerSegment2D > >(
143-
set_desc.minimal_spacing,
144-
PairwiseInteraction< OwnerSegment2D >::SCOPE::same_set );
178+
0., PairwiseInteraction<
179+
OwnerSegment2D >::SCOPE::different_set );
145180

146181
this->ordered_energy_terms_.push_back(
147182
this->energy_terms_collection_.add_energy_term(
148183
std::make_unique< PairwiseTerm< OwnerSegment2D > >(
149-
absl::StrCat( set_desc.name, "_min_spacing" ), 0.,
150-
std::vector< uuid >{ set_id },
151-
std::move( interaction ), this->domain_ ) ) );
184+
absl::StrCat( "inter_set_x_nodes" ), beta_x_node_,
185+
set_uuids, std::move( interaction ),
186+
this->domain_ ) ) );
152187
}
153-
154188
this->mh_sampler_ =
155189
std::make_unique< MetropolisHastings< OwnerSegment2D > >(
156190
this->energy_terms_collection_,
@@ -173,8 +207,32 @@ namespace geode
173207
}
174208
}
175209

210+
std::string string() const
211+
{
212+
auto message =
213+
absl::StrCat( "Fracture Simulation Runner description" );
214+
for( const auto& desc : set_descriptors_ )
215+
{
216+
absl::StrAppend( &message, "\n\t ", desc.string() );
217+
}
218+
if( std::fabs( beta_x_node_ - 1. ) > GLOBAL_EPSILON )
219+
{
220+
absl::StrAppend( &message,
221+
"\n\t --> x node monitioring (beta inhibition value): ",
222+
beta_x_node_ );
223+
}
224+
else
225+
{
226+
absl::StrAppend(
227+
&message, "\n\t --> x node monitioring : no inhibition." );
228+
}
229+
return message;
230+
}
231+
176232
private:
177233
std::vector< FractureSetDescription > set_descriptors_;
234+
// x node monitoring
235+
double beta_x_node_{ 1. };
178236
};
179237

180238
} // namespace geode

tests/stochastic/sampling/mcmc/test-mh-fractures.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -146,6 +146,7 @@ namespace
146146
geode::FractureSimulationRunner runner( domain );
147147
runner.add_fracture_set_descriptor( setA );
148148
runner.add_fracture_set_descriptor( setB );
149+
runner.add_x_node_monitoring( 0.3 );
149150

150151
runner.initialize();
151152

0 commit comments

Comments
 (0)