diff --git a/bindings/python/src/stochastic/sampling/mcmc/helpers/fracture_simulation_runner.hpp b/bindings/python/src/stochastic/sampling/mcmc/helpers/fracture_simulation_runner.hpp index f552311..760369a 100644 --- a/bindings/python/src/stochastic/sampling/mcmc/helpers/fracture_simulation_runner.hpp +++ b/bindings/python/src/stochastic/sampling/mcmc/helpers/fracture_simulation_runner.hpp @@ -60,6 +60,11 @@ namespace geode module, "FractureSimulationRunner" ) .def( pybind11::init< const SpatialDomain< 2 >& >(), pybind11::arg( "box" ) ) + .def( "add_x_node_monitoring", + &FractureSimulationRunner::add_x_node_monitoring, + pybind11::arg( "double" ), + "Add a monitoring value for x node, value should be " + "in[0.,1.]." ) .def( "add_fracture_set_descriptor", &FractureSimulationRunner::add_fracture_set_descriptor, pybind11::arg( "descriptor" ), @@ -71,6 +76,9 @@ namespace geode &FractureSimulationRunner::check_statistics, pybind11::arg( "statistic_monitoring" ), "Check computed statistics after simulation." ) + .def( "string", &FractureSimulationRunner::string, + "Return a detailed description of the simulation " + "configurator." ) // Explicit overload bindings // .def( "run", // static_cast< const ObjectSets< OwnerSegment2D >& ( diff --git a/bindings/python/src/stochastic/sampling/mcmc/helpers/simulation_runner.hpp b/bindings/python/src/stochastic/sampling/mcmc/helpers/simulation_runner.hpp index cd58757..ac1b2ee 100644 --- a/bindings/python/src/stochastic/sampling/mcmc/helpers/simulation_runner.hpp +++ b/bindings/python/src/stochastic/sampling/mcmc/helpers/simulation_runner.hpp @@ -43,7 +43,8 @@ namespace geode .def_readwrite( "printer", &SimulationConfigurator::printer, "Optional SimulationPrinter for output" ) .def( "string", &SimulationConfigurator::string, - "Return a detailed description of the simulation configurator" ) + "Return a detailed description of the object set simulation " + "configurator" ) .def( "__repr__", []( const SimulationConfigurator& self ) { return ""; diff --git a/bindings/python/tests/stochastic/test-py-mh-fractures.py b/bindings/python/tests/stochastic/test-py-mh-fractures.py index d5ee211..7450563 100644 --- a/bindings/python/tests/stochastic/test-py-mh-fractures.py +++ b/bindings/python/tests/stochastic/test-py-mh-fractures.py @@ -122,6 +122,7 @@ def test_two_fracture_sets_simulator(): runner = stochastic.FractureSimulationRunner(domain) runner.add_fracture_set_descriptor(setA) runner.add_fracture_set_descriptor(setB) + runner.add_x_node_monitoring(0.3) runner.initialize() printer_config = stochastic.SimulationPrinterConfigurator() diff --git a/include/geode/stochastic/sampling/mcmc/helpers/fracture_simulation_runner.hpp b/include/geode/stochastic/sampling/mcmc/helpers/fracture_simulation_runner.hpp index 92c7bc0..f885a50 100644 --- a/include/geode/stochastic/sampling/mcmc/helpers/fracture_simulation_runner.hpp +++ b/include/geode/stochastic/sampling/mcmc/helpers/fracture_simulation_runner.hpp @@ -59,6 +59,13 @@ namespace geode std::string string() const { auto message = absl::StrCat( "FractureSetDescription: ", name ); + for( const auto& fixed_object : observed_fractures ) + { + absl::StrAppend( &message, + "\n\t --> observation (x,y,z)start: ", + fixed_object[0].string(), + " (x,y,z)end: ", fixed_object[1].string() ); + } absl::StrAppend( &message, "\n\t --> length distribution: ", length.string() ); absl::StrAppend( @@ -81,6 +88,13 @@ namespace geode { } + void add_x_node_monitoring( double beta_x_node ) + { + OPENGEODE_EXCEPTION( beta_x_node <= 1.0 && beta_x_node >= 0., + "[FractureSimulationRunner] x node should be inhibitated, " + "please provise a value in [0., 1.]." ); + beta_x_node_ = beta_x_node; + } void add_fracture_set_descriptor( const FractureSetDescription& descriptor ) { @@ -134,23 +148,43 @@ namespace geode set_desc.p20, std::vector< uuid >{ set_id }, this->domain_ ) ) ); // spacing - if( set_desc.minimal_spacing < GLOBAL_EPSILON ) + if( set_desc.minimal_spacing > GLOBAL_EPSILON ) { - continue; + auto interaction = std::make_unique< + EuclideanCutoffInteraction< OwnerSegment2D > >( + set_desc.minimal_spacing, + PairwiseInteraction< + OwnerSegment2D >::SCOPE::same_set ); + + this->ordered_energy_terms_.push_back( + this->energy_terms_collection_.add_energy_term( + std::make_unique< PairwiseTerm< OwnerSegment2D > >( + absl::StrCat( set_desc.name, "_min_spacing" ), + 0., std::vector< uuid >{ set_id }, + std::move( interaction ), this->domain_ ) ) ); + } + } + // x node monitoring + if( std::fabs( beta_x_node_ - 1. ) > GLOBAL_EPSILON ) + { + std::vector< uuid > set_uuids; + set_uuids.reserve( name_to_uuid.size() ); + for( const auto& [name, id] : name_to_uuid ) + { + set_uuids.push_back( id ); } auto interaction = std::make_unique< EuclideanCutoffInteraction< OwnerSegment2D > >( - set_desc.minimal_spacing, - PairwiseInteraction< OwnerSegment2D >::SCOPE::same_set ); + 0., PairwiseInteraction< + OwnerSegment2D >::SCOPE::different_set ); this->ordered_energy_terms_.push_back( this->energy_terms_collection_.add_energy_term( std::make_unique< PairwiseTerm< OwnerSegment2D > >( - absl::StrCat( set_desc.name, "_min_spacing" ), 0., - std::vector< uuid >{ set_id }, - std::move( interaction ), this->domain_ ) ) ); + absl::StrCat( "inter_set_x_nodes" ), beta_x_node_, + set_uuids, std::move( interaction ), + this->domain_ ) ) ); } - this->mh_sampler_ = std::make_unique< MetropolisHastings< OwnerSegment2D > >( this->energy_terms_collection_, @@ -173,8 +207,32 @@ namespace geode } } + std::string string() const + { + auto message = + absl::StrCat( "Fracture Simulation Runner description" ); + for( const auto& desc : set_descriptors_ ) + { + absl::StrAppend( &message, "\n\t ", desc.string() ); + } + if( std::fabs( beta_x_node_ - 1. ) > GLOBAL_EPSILON ) + { + absl::StrAppend( &message, + "\n\t --> x node monitioring (beta inhibition value): ", + beta_x_node_ ); + } + else + { + absl::StrAppend( + &message, "\n\t --> x node monitioring : no inhibition." ); + } + return message; + } + private: std::vector< FractureSetDescription > set_descriptors_; + // x node monitoring + double beta_x_node_{ 1. }; }; } // namespace geode \ No newline at end of file diff --git a/tests/stochastic/sampling/mcmc/test-mh-fractures.cpp b/tests/stochastic/sampling/mcmc/test-mh-fractures.cpp index 1a68938..97fc99c 100644 --- a/tests/stochastic/sampling/mcmc/test-mh-fractures.cpp +++ b/tests/stochastic/sampling/mcmc/test-mh-fractures.cpp @@ -146,6 +146,7 @@ namespace geode::FractureSimulationRunner runner( domain ); runner.add_fracture_set_descriptor( setA ); runner.add_fracture_set_descriptor( setB ); + runner.add_x_node_monitoring( 0.3 ); runner.initialize();