C++ mpi module for stochmagnet_main Package
Public Member Functions | Protected Member Functions | List of all members
SM_MonteCarloSystem Class Referenceabstract

This class is a simulation of one Monte carlo trajectory class for Stoch Magnet package. The magnetic moment direction change is defined by \( \sigma=\frac{2}{25}*\left( \frac{T*k_B}{\mu_B} \right))^{\frac{1}{5}} \). More...

#include <SM_MonteCarloSystem.h>

Inheritance diagram for SM_MonteCarloSystem:
Inheritance graph
[legend]
Collaboration diagram for SM_MonteCarloSystem:
Collaboration graph
[legend]

Public Member Functions

virtual tMemSize getMemorySize () const
 return the memory size of the class and the memory size of all its attributes/associations More...
 
virtual tMemSize getContentsMemorySize () const
 return the memory size of the included associations More...
 
virtual void setNoiseTemperature (const tReal &T) override
 set the noise as a temperature in Kelvin More...
 
const tReal & getNoiseRate () const
 get the noise rate constant More...
 
const tReal & getEnergyScaling () const
 get the energy scaling More...
 
const tIndex & getRejectsNumber () const
 get the rejects number More...
 
const tIndex & getMovesNumber () const
 get the moves number More...
 
virtual void normalize (const tBoolean &isAdimensionized) override
 normalize the system More...
 
virtual void discretize () override
 discretize the system
 
virtual tULLInt getGeneratedRandomNumbers () const override
 get the generated of random number within a stochastic run
 
template<class StochOutputImplement >
tBoolean deterministicRun (const tIndex &steppersNumber, SM_StochasticOutput< StochOutputImplement > &data)
 compute deterministic running of steppers number of the system with computing statistics More...
 
tBoolean stochasticRun (const tIndex &steppersNumber, SM_MultiStochasticFunctionsInterface &sfs)
 compute the steppers number of system for reaching the relaxed state More...
 
template<class StochOutputImplement >
tBoolean stochasticRun (const tIndex &steppersNumber, SM_MultiStochasticFunctionsInterface &sfs, SM_StochasticOutput< StochOutputImplement > &statistics)
 compute steppers number with statisics More...
 
template<class StochFunctionsImplement >
tBoolean stochasticRunWithSCStochasticFunctions (const tIndex &steppersNumber, SM_MultiStochasticFunctions< StochFunctionsImplement > &sfs)
 compute the relaxation process by calling only virtual methods More...
 
template<class StochFunctionsImplement , class StochOutputImplement >
tBoolean stochasticRunWithSCStochasticFunctions (const tIndex &steppersNumber, SM_MultiStochasticFunctions< StochFunctionsImplement > &sfs, SM_StochasticOutput< StochOutputImplement > &statistics)
 compute the relaxation process by calling only virtual methods More...
 
virtual tString toString () const override
 turn the class into a string representation More...
 
- Public Member Functions inherited from SM_System
void setNetwork (CORE_UniquePointer< SM_Network > net)
 set the network More...
 
const SM_NetworkgetNetwork () const
 get the network More...
 
SM_NetworkgetNetwork ()
 get the network More...
 
tBoolean hasNetwork () const
 return true if the system has a network More...
 
const SM_MaterialgetMaterial () const
 get the material of the network More...
 
SM_MaterialgetMaterial ()
 get the material of the network More...
 
void setInitialMagneticMomentDirections (const std::valarray< tReal > &S0)
 set the initial unit direction of spins More...
 
void setInitialMagneticMomentDirections (const SM_RealField &S0)
 set the initial unit direction of spins More...
 
void setInitialMagneticMomentDirections (const tIndex &N, const std::array< tReal, SM_Constants::DIM > &S0)
 set the initial unit direction of spins More...
 
virtual tBoolean updateInitialMagneticMomentDirections (const SM_RealField &S0)
 update the initial unit direction of spins More...
 
const SM_RealFieldgetInitialMagneticMomentDirections () const
 get the initial unit direction of spins More...
 
SM_RealFieldgetInitialMagneticMomentDirections ()
 get the initial unit direction of spins for writting More...
 
const SM_RealFieldgetMagneticMomentDirections () const
 get the unit direction of spins at time More...
 
SM_RealFieldgetMagneticMomentDirections ()
 get the unit direction of spins at time for writting More...
 
virtual tBoolean initializeMagneticMomentDirections ()
 initialize magnetic moments direction More...
 
void addOperator (CORE_UniquePointer< SM_Operator > op)
 add operator More...
 
const SM_SliceOperatorgetOperator (const tString &name) const
 get the operator with name More...
 
SM_SliceOperatorgetOperator (const tString &name)
 get the operator with name More...
 
void copyOperators (const SM_System &system)
 copy the operator More...
 
const std::map< tString, CORE_UniquePointer< SM_Operator > > & getOperators () const
 get the operators More...
 
std::map< tString, CORE_UniquePointer< SM_Operator > > & getOperators ()
 get the operators More...
 
tIndex getOperatorsNumber () const
 get the operators number More...
 
void getOperatorsName (std::vector< tString > &names) const
 get the operator names More...
 
virtual void setStochasticNoise (const tReal &eps)
 set the stochastic noise without dimension More...
 
const tReal & getStochasticNoise () const
 get the stochastic noise without dimension More...
 
const tReal & getNoiseTemperature () const
 get the noise temperature in Kelvin More...
 
const tIndex & getStepIndex () const
 get the step index More...
 
tIndex & getStepIndex ()
 get the step index More...
 
virtual void sumOverNetworks (const int &rootNetwork, tIndex &n, const tIndex &nValues, tReal *values) const
 sum the values of all network More...
 
void computeMagneticMomentDirectionsSumOverNetworks (const int &rootNetwork, std::array< tReal, SM_Constants::DIM > &sumS) const
 compute the sum over the domain of magnetic moment dierctions More...
 
void computeMagneticMomentDirectionsMeanOverNetworks (const int &rootNetwork, std::array< tReal, SM_Constants::DIM > &meanS) const
 compute the mean over the domain of magneticmoment directions More...
 
void computeMagneticMomentDirectionsSum (const tInteger &start, const tInteger &end, std::array< tReal, SM_Constants::DIM > &sumS) const
 compute the sum of magnetic moment directions over the network More...
 
void updateOperatorsState (const tIndex &timeIndex, const SM_Network &network, const SM_Material &material, const SM_RealField &S)
 update the operators state before computeing magnetic field More...
 
void computeMagneticField (const tIndex &timeIndex, const SM_Network &network, const SM_Material &material, const SM_RealField &S, SM_RealField &H) const
 compute the magnetic field at time step index t by calling the virtual method SM_Operator::computeMagneticField() More...
 
tReal computeSpinEnergy (const tIndex &i, const SM_Network &network, const SM_Material &material, const SM_RealField &S) const
 compute the energy of the spin of the system More...
 
tReal computeSpinEnergy (const tIndex &i, const tIndex &timeIndex, const SM_Network &network, const SM_Material &material, const SM_RealField &S) const
 compute the energy of the spin of the system More...
 
const tReal & computeEnergies (std::valarray< tReal > &energies) const
 compute the energies per operators More...
 
const tReal & computeEnergies (const tIndex &timeIndex, std::valarray< tReal > &energies) const
 compute the energies per operators More...
 
- Public Member Functions inherited from SM_Object
 SM_Object (void)
 create
 
virtual ~SM_Object (void)
 destroy
 
- Public Member Functions inherited from CORE_Object
template<class T >
std::shared_ptr< T > getSharedPointer ()
 return the shared pointer for this More...
 
template<class T >
std::shared_ptr< const T > getConstSharedPointer () const
 return a const shared pointer for this More...
 
template<class T >
tBoolean isInstanceOf () const
 test if the clas T is an instance of this class More...
 
tString getClassName () const
 return the name of the class More...
 
tString getPointerString () const
 retrun the pointer of the class as a string More...
 
tString getIdentityString () const
 retrun the string identification of the class More...
 

Protected Member Functions

 SM_MonteCarloSystem (void)
 create a class
 
virtual ~SM_MonteCarloSystem (void)
 destroy the class
 
tIndex & getMovesNumber ()
 get the move number More...
 
tIndex & getRejectsNumber ()
 get the rejects number More...
 
virtual void updateStateForNextStep (SM_RealField &St)=0
 update the state for next step More...
 
void MCStep (SM_MultiStochasticFunctionsInterface &multiStochasticFunctions, const SM_Material &material, const SM_Network &network, SM_RealField &S, const tIndex &stepIndex, const tReal &alpha, const tReal &sigma, tIndex &nMoves, tIndex &nRejects)
 stepper step More...
 
template<class StochFunctionsImplement >
void MCStepWithSCStochasticFunctions (SM_MultiStochasticFunctions< StochFunctionsImplement > &multiStochasticFunctions, const SM_Material &material, const SM_Network &network, SM_RealField &S, const tIndex &stepIndex, const tReal &alpha, const tReal &sigma, tIndex &nMoves, tIndex &nRejects)
 stepper step with templated stochastic function More...
 
template<class StochFunctionsImplement >
void randomTrialMoveWithSCStochasticFunctions (SM_StochasticFunctions< StochFunctionsImplement > &stochasticFunctions, const tReal &sigma, tReal *bS, const tReal *eS) const
 make a trial move More...
 
void randomTrialMove (SM_StochasticFunctionsInterface &stochasticFunctions, const tReal &sigma, tReal *bS, const tReal *eS) const
 make a trial move More...
 
- Protected Member Functions inherited from SM_System
 SM_System (void)
 create a class
 
virtual ~SM_System (void)
 destroy the class
 
tReal computeEnergy (const SM_Network &network, const SM_Material &material, const SM_RealField &S) const
 compute the energy of the system More...
 
tReal computeEnergy (const tIndex &timeIndex, const SM_Network &network, const SM_Material &material, const SM_RealField &S) const
 compute the energy of the system More...
 
- Protected Member Functions inherited from CORE_Object
 CORE_Object ()
 build an instance of the object
 
virtual ~CORE_Object ()
 destroy the instance of object std

 

Additional Inherited Members

- Static Public Member Functions inherited from SM_System
static void ComputeFieldSum (const tInteger &start, const tInteger &end, const SM_RealField &F, std::array< tReal, SM_Constants::DIM > &sumF)
 compute the sum of F over the network More...
 
- Static Public Member Functions inherited from CORE_Object
static tBoolean EnableMemoryStack (const tBoolean &isMemoryChecked)
 enable the memory stack More...
 
static void EnableMemoryStack ()
 enable the memory stack
 
static void DisableMemoryStack ()
 disable the memory stack
 
static tBoolean IsMemoryStackEnabled ()
 return trur if the memory stack is enabled
 
static tString MemoryStackToString ()
 get the memory stack in string More...
 
static tIndex GetRegisteredClassesNumber ()
 get the memory stack in string More...
 

Detailed Description

This class is a simulation of one Monte carlo trajectory class for Stoch Magnet package. The magnetic moment direction change is defined by \( \sigma=\frac{2}{25}*\left( \frac{T*k_B}{\mu_B} \right))^{\frac{1}{5}} \).

The general algorithm of Monte Carlo is

Author
Stephane Despreaux
Version
2.0

Member Function Documentation

◆ deterministicRun()

template<class StochOutputImplement >
tBoolean SM_MonteCarloSystem::deterministicRun ( const tIndex &  steppersNumber,
SM_StochasticOutput< StochOutputImplement > &  data 
)
inline

compute deterministic running of steppers number of the system with computing statistics

Template Parameters
StochOutputImplement: implemented class of SM_StochasticOutput
Parameters
[in]steppersNumbernumber of steppers to run
[in,out]datastochastic data to compute

◆ getContentsMemorySize()

virtual tMemSize SM_MonteCarloSystem::getContentsMemorySize ( ) const
inlinevirtual

return the memory size of the included associations

Returns
the memory size of the storage in bytes 1 Kb = 1024 bytes 1 Mb = 1024 Kb 1 Gb = 1024 Mb 1 Tb = 1024 Gb 1 Hb = 1024 Tb

Reimplemented from SM_System.

Reimplemented in SMOMPI_MonteCarloSystem.

◆ getEnergyScaling()

const tReal& SM_MonteCarloSystem::getEnergyScaling ( ) const
inline

get the energy scaling

Returns
\( \alpha= \frac{\bar E }{k_B.T} \)

◆ getMemorySize()

virtual tMemSize SM_MonteCarloSystem::getMemorySize ( ) const
inlinevirtual

return the memory size of the class and the memory size of all its attributes/associations

Returns
the memory size of the class and the memory size of its attributes/associations in bytes The mamory size is :
  • the added size of the base classes which contains:
    • the primary attributes size depends on the order: (first delare the smallest attributes size
    • all virtual functions costs <pointer-size> (4 32xor 8 64x) bytes by virtual function
    • virtual inherihtance will increase of (4 or 8) bytes
  • we add the size of the contains values of the attributes : for example the size of a string is the length of the string 1 octet = 1 byte 1 Ko = 1024 bytes 1 Mo = 1024 Ko 1 Go = 1024 Mo

Reimplemented from SM_System.

Reimplemented in SMOMPI_MonteCarloSystem.

◆ getMovesNumber() [1/2]

tIndex& SM_MonteCarloSystem::getMovesNumber ( )
inlineprotected

get the move number

Returns
the nuumber of moves

◆ getMovesNumber() [2/2]

const tIndex& SM_MonteCarloSystem::getMovesNumber ( ) const
inline

get the moves number

Returns
the number of accepted spin moment direction change

◆ getNoiseRate()

const tReal& SM_MonteCarloSystem::getNoiseRate ( ) const
inline

get the noise rate constant

Returns
\( \sigma=\frac{2}{25}*\left( \frac{T*k_B}{\mu_B} \right))^{\frac{1}{5}} \)

◆ getRejectsNumber() [1/2]

tIndex& SM_MonteCarloSystem::getRejectsNumber ( )
inlineprotected

get the rejects number

Returns
the nuumber of rejected moves

◆ getRejectsNumber() [2/2]

const tIndex& SM_MonteCarloSystem::getRejectsNumber ( ) const
inline

get the rejects number

Returns
the number of rejected the spin moment direction change

◆ MCStep()

void SM_MonteCarloSystem::MCStep ( SM_MultiStochasticFunctionsInterface multiStochasticFunctions,
const SM_Material material,
const SM_Network network,
SM_RealField S,
const tIndex &  stepIndex,
const tReal &  alpha,
const tReal &  sigma,
tIndex &  nMoves,
tIndex &  nRejects 
)
protected

stepper step

Parameters
[in]multiStochasticFunctions: stochatic functions
[in]material: material of the particles
[in]network: particles network
[in,out]S: magnetic moment directions of the particles
[in]stepIndex: index of the step of the trajectory
[in]alpha: \( \frac{\bar E}{k_B.T} \) probability of move
[in]sigma: min probability to accept the move : \( \sigma=\frac{2}{25}*\left( \frac{T*k_B}{\mu_B} \right))^{\frac{1}{5}} \)
[out]nMovesnumber of moves
[out]nRejects: number of rejected moves

◆ MCStepWithSCStochasticFunctions()

template<class StochFunctionsImplement >
void SM_MonteCarloSystem::MCStepWithSCStochasticFunctions ( SM_MultiStochasticFunctions< StochFunctionsImplement > &  multiStochasticFunctions,
const SM_Material material,
const SM_Network network,
SM_RealField S,
const tIndex &  stepIndex,
const tReal &  alpha,
const tReal &  sigma,
tIndex &  nMoves,
tIndex &  nRejects 
)
inlineprotected

stepper step with templated stochastic function

Template Parameters
StochFunctionsImplement: implemented class SM_StochasticFunctions
Parameters
[in]multiStochasticFunctions: stochatic functions
[in]material: material of the particles
[in]network: particles network
[in,out]S: magnetic moment directions of the particles
[in]stepIndex: index of the step of the trajectory
[in]alpha: \( \frac{\bar E}{k_B.T} \) probability of move
[in]sigma: min probability to accept the move : \( \sigma=\frac{2}{25}*\left( \frac{T*k_B}{\mu_B} \right))^{\frac{1}{5}} \)
[out]nMovesnumber of moves
[out]nRejects: number of rejected moves

◆ normalize()

virtual void SM_MonteCarloSystem::normalize ( const tBoolean &  isAdimensionized)
inlineoverridevirtual

normalize the system

Parameters
[in]isAdimensionizedtrue to adimensionize the system

Reimplemented from SM_System.

◆ randomTrialMove()

void SM_MonteCarloSystem::randomTrialMove ( SM_StochasticFunctionsInterface stochasticFunctions,
const tReal &  sigma,
tReal *  bS,
const tReal *  eS 
) const
protected

make a trial move

Parameters
[in,out]stochasticFunctions: normal stochastic function
[in]sigmaamplitude of the trial move
[in,out]bS: begin iterator of direction at particle
[in]eS: end iterator of direction at particle

the trial move is computed as folow

  • compute an uniform random U in [0,1] and do either
  • trial moves:
    • a spin flip move : \( S^'_i=-S_i \)
    • a gaussian trial move : \( S_p=S_i+\sigma. N(0,1) and S^'_i=S_p/|S_p| with sigma=\frac{2}{25}.(\frac{k_B.T}{\mu_B})^{1/5} \)
    • a random point : \( S_p=N(0,1) and S^'_i=S_p/|S_p| \)

◆ randomTrialMoveWithSCStochasticFunctions()

template<class StochFunctionsImplement >
void SM_MonteCarloSystem::randomTrialMoveWithSCStochasticFunctions ( SM_StochasticFunctions< StochFunctionsImplement > &  stochasticFunctions,
const tReal &  sigma,
tReal *  bS,
const tReal *  eS 
) const
inlineprotected

make a trial move

Template Parameters
StochFunctionsImplement: implemented class SM_StochasticFunctions
Parameters
[in,out]stochasticFunctions: normal stochastic function
[in]sigmaamplitude of the trial move
[in,out]bS: begin iterator of direction at particle
[in]eS: end iterator of direction at particle

the trial move is computed as folow

  • compute an uniform random U in [0,1] and do either
  • trial moves:
  • a spin flip move : \( S^'_i=-S_i \)
    • a gaussian trial move : \( S_p=S_i+\sigma.N(0,1) \) and \( S^'_i=S_p/|S_p| \) with \( sigma=\frac{2}{25}.(\frac{k_B.T}{\mu_B})^{1/5} \)
    • a random point : \( S_p=N(0,1) and S^'_i=S_p/|S_p| \)

◆ setNoiseTemperature()

virtual void SM_MonteCarloSystem::setNoiseTemperature ( const tReal &  T)
inlineoverridevirtual

set the noise as a temperature in Kelvin

Parameters
[in]T: temperature It computes noise attributes:
  • \( \alpha= \frac{\delta E }{k_B.T} \)
  • \( \sigma=\frac{2}{25}*\left( \frac{T*k_B}{\mu_B} \right))^{\frac{1}{5}} \)

Reimplemented from SM_System.

◆ stochasticRun() [1/2]

tBoolean SM_MonteCarloSystem::stochasticRun ( const tIndex &  steppersNumber,
SM_MultiStochasticFunctionsInterface sfs 
)

compute the steppers number of system for reaching the relaxed state

Parameters
[in]steppersNumbernumber of steppers to run
[in]sfs: stochastic function to generate random numbers

◆ stochasticRun() [2/2]

template<class StochOutputImplement >
tBoolean SM_MonteCarloSystem::stochasticRun ( const tIndex &  steppersNumber,
SM_MultiStochasticFunctionsInterface sfs,
SM_StochasticOutput< StochOutputImplement > &  statistics 
)
inline

compute steppers number with statisics

Template Parameters
StochOutputImplement: implemented class of SM_StochasticOutput
Parameters
[in]steppersNumbernumber of steppers to run
[in,out]sfs: stochastic functions to generate random numbers
[in,out]statisticsstochastic data to compute

◆ stochasticRunWithSCStochasticFunctions() [1/2]

template<class StochFunctionsImplement >
tBoolean SM_MonteCarloSystem::stochasticRunWithSCStochasticFunctions ( const tIndex &  steppersNumber,
SM_MultiStochasticFunctions< StochFunctionsImplement > &  sfs 
)
inline

compute the relaxation process by calling only virtual methods

Template Parameters
StochFunctionsImplement: implemented class SM_StochasticFunctions
Parameters
[in]steppersNumbernumber of steppers to run
[in,out]sfs: stochastic functions to generate random numbers

◆ stochasticRunWithSCStochasticFunctions() [2/2]

template<class StochFunctionsImplement , class StochOutputImplement >
tBoolean SM_MonteCarloSystem::stochasticRunWithSCStochasticFunctions ( const tIndex &  steppersNumber,
SM_MultiStochasticFunctions< StochFunctionsImplement > &  sfs,
SM_StochasticOutput< StochOutputImplement > &  statistics 
)
inline

compute the relaxation process by calling only virtual methods

Template Parameters
StochFunctionsImplement: implemented class SM_StochasticFunctions
StochOutputImplement: implemented class of SM_StochasticOutput
Parameters
[in]steppersNumbernumber of steppers to run
[in,out]sfs: stochastic functions to generate random numbers
[in,out]statisticsstochastic data to compute

◆ toString()

tString SM_MonteCarloSystem::toString ( ) const
overridevirtual

turn the class into a string representation

Returns
a string representation of the class

Reimplemented from SM_System.

◆ updateStateForNextStep()

virtual void SM_MonteCarloSystem::updateStateForNextStep ( SM_RealField St)
protectedpure virtual

update the state for next step

Parameters
[in,out]StSt feild used to update state

Implemented in SMOMPI_MonteCarloSystem.


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