faunus
Public Member Functions | Public Attributes | Protected Attributes | List of all members
Faunus::SmarterMonteCarlo::RegionSampler Class Reference

Helper class for smart MC moves that preferentially samples within Regions. More...

#include <smart_montecarlo.h>

Public Member Functions

 RegionSampler (double outside_acceptance, std::unique_ptr< Region::RegionBase > region)
 
void to_json (json &j) const
 Serialise to json.
 
template<GroupOrParticle T, std::ranges::range Range>
std::optional< Selection< T > > select (Range &range, Random &random)
 Select a random element from range and perform region check. More...
 
template<GroupOrParticle T>
double bias (const Selection< T > &selection)
 

Public Attributes

std::optional< double > fixed_number_inside
 Optionally give a fixed number inside.
 

Protected Attributes

const std::unique_ptr< Region::RegionBase > region
 This defines the smart MC region.
 

Detailed Description

Helper class for smart MC moves that preferentially samples within Regions.

Responsibilities:

Constructor & Destructor Documentation

◆ RegionSampler()

Faunus::SmarterMonteCarlo::RegionSampler::RegionSampler ( double  outside_acceptance,
std::unique_ptr< Region::RegionBase >  region 
)
Parameters
outside_acceptanceProbability to accept element outside the region
regionRegion to preferentially pick from

Member Function Documentation

◆ bias()

template<GroupOrParticle T>
double Faunus::SmarterMonteCarlo::RegionSampler::bias ( const Selection< T > &  selection)
Template Parameters
TTypically Particle or Group
Returns
Bias energy (kT) always zero if no selection has been set

This function is typically called after a MC move and will determine the bias due to non-uniform sampling which depends on the transition directions, i.e. if an element is moved from inside of the region to the outside etc.

◆ select()

template<GroupOrParticle T, std::ranges::range Range>
std::optional< Selection< T > > Faunus::SmarterMonteCarlo::RegionSampler::select ( Range &  range,
Random random 
)

Select a random element from range and perform region check.

Typically before a move.

Template Parameters
Rangerange of particles or groups
Ttypically Particle or Group
Parameters
rangeRange of particles or groups
randomRandom number object used to perform a random selection
Returns
Optional selection object

Loops until a perturbable element is found. If a max number of attempts is reached without any selection, an empty object is returned and a warning issued. The maximum number of attempts is currently set to 10x the size of the given range.


The documentation for this class was generated from the following files: