C++ mpi module for stochmagnet_main Package
SM_MonteCarloSystem.h
1 #ifndef SM_MonteCarloSystem_H
2 #define SM_MonteCarloSystem_H
3 
4 //base class
5 #include "SM_System.h"
6 
7 
8 //stochastic output data header
9 #include "SM_StochasticOutput.h"
10 
11 //stochastic function
12 #include "SM_MultiStochasticFunctions.h"
13 
14 //network
15 #include "SM_Network.h"
16 
17 //material
18 #include "SM_Material.h"
19 
20 //operator
21 #include "SM_Operator.h"
22 
23 
24 //array manipulating
25 #include <valarray>
26 
40 
41  //attributes
42 private :
43 
44  typedef SM_MonteCarloSystem Self;
45  typedef SM_System SuperClass;
46 
47 
48  //mAlpha=\frac{\bar E}{k_B.T}
49  tReal mAlpha;
50  //mSigma=\frac{2}{25}*\left( \frac{T*k_B}{\mu_B} \right))^{\frac{1}{5}}
51  tReal mSigma;
52 
53  //statistics
54  tIndex mRejectsNumber;
55  tIndex mMovesNumber;
56 
57 
58 protected:
59  // CONSTRUCTORS
63  mAlpha=0;
64  mSigma=0;
65  mRejectsNumber=0;
66  mMovesNumber=0;
67  }
68 
69  // DESTRUCTORS
72  virtual ~SM_MonteCarloSystem(void) {
73  }
74 
75 public :
76 
77 
78  //MEMORY
79 
93  virtual tMemSize getMemorySize() const {
94  return sizeof(*this)+getContentsMemorySize();
95  }
96 
105  virtual tMemSize getContentsMemorySize() const {
106  tMemSize mem=SuperClass::getContentsMemorySize();
107 
108  return mem;
109  }
110 
111 
112 
119  virtual void setNoiseTemperature(const tReal& T) override {
121  mAlpha/=SM_Constants::K_B;
122  mAlpha/=T;
123 
124  mSigma=0.08L;//(2.L/25.L);
125  mSigma*=pow((T*SM_Constants::CK_B)/SM_Constants::CMU_B,0.2L);
126 
127 
129  }
130 
134  inline const tReal& getNoiseRate() const {
135  return mSigma;
136  }
140  inline const tReal& getEnergyScaling() const {
141  return mAlpha;
142  }
143 
147  inline const tIndex& getRejectsNumber() const {
148  return mRejectsNumber;
149  }
150 
154  inline const tIndex& getMovesNumber() const {
155  return mMovesNumber;
156  }
157 
158 protected:
162  inline tIndex& getMovesNumber() {
163  return mMovesNumber;
164  }
165 
169  inline tIndex& getRejectsNumber() {
170  return mRejectsNumber;
171  }
172 
173  //computational methods
174  //=====================
175 
176 public:
177 
178 
179 
183  virtual void normalize(const tBoolean& isAdimensionized) override {
184  SuperClass::normalize(isAdimensionized);
185  }
186 
187 
190  virtual void discretize() override {
191 
193 
194  mRejectsNumber=0;
195  mMovesNumber=0;
196 
197 
198  }
199 
200  //simulation methods
201  //===================
202 
205  virtual tULLInt getGeneratedRandomNumbers() const override {
206 
207  //random particles number + random move type + SM_Constants::DIM x random coordinates + random for p
208  tULLInt nRNGPerCore=3+SM_Constants::DIM;
209  nRNGPerCore*=getNetwork().getParticlesNumber();
210  return nRNGPerCore;
211  }
212 
213 
214 
220  template<class StochOutputImplement>
221  inline tBoolean deterministicRun(const tIndex& steppersNumber,SM_StochasticOutput<StochOutputImplement>& data) {
222  std::cout<<"No deterministic running method for Monte Carlo system \n";
223  return false;
224  }
225 
230  tBoolean stochasticRun(const tIndex& steppersNumber,
232 
239  template<class StochOutputImplement>
240  tBoolean stochasticRun(const tIndex& steppersNumber,
243 
244 
250  template<class StochFunctionsImplement>
251  tBoolean stochasticRunWithSCStochasticFunctions(const tIndex& steppersNumber,
260  template<class StochFunctionsImplement,class StochOutputImplement>
261  inline tBoolean stochasticRunWithSCStochasticFunctions(const tIndex& steppersNumber,
264 
265 
266 
267 protected:
268 
273 
285  void MCStep(SM_MultiStochasticFunctionsInterface& multiStochasticFunctions,
286  const SM_Material& material,const SM_Network& network,
287  SM_RealField& S,
288  const tIndex& stepIndex,const tReal& alpha,const tReal& sigma,
289  tIndex& nMoves,tIndex& nRejects);
290 
303  template<class StochFunctionsImplement>
305  const SM_Material& material,const SM_Network& network,
306  SM_RealField& S,
307  const tIndex& stepIndex,const tReal& alpha,const tReal& sigma,
308  tIndex& nMoves,tIndex& nRejects);
309 
324  template<class StochFunctionsImplement>
326  const tReal& sigma,
327  tReal *bS,const tReal* eS) const;
328 
342  void randomTrialMove(SM_StochasticFunctionsInterface& stochasticFunctions,
343  const tReal& sigma,
344  tReal *bS,const tReal* eS) const ;
345 
346 public:
350  virtual tString toString() const override;
351 
352 };
353 
354 #include "SM_MonteCarloSystem.hpp"
355 #endif
static constexpr tDimension DIM
space dimension
Definition: SM_Constants.h:80
static constexpr tReal K_B
Boltzmann constants : .
Definition: SM_Constants.h:44
static constexpr tReal CMU_B
constant of Bohr magneton :
Definition: SM_Constants.h:24
static constexpr tReal CK_B
constant of Boltzmann constants :
Definition: SM_Constants.h:40
This class describes a materials defined by state attributes:
Definition: SM_Material.h:61
const tReal & getCharacteristicEnergy() const
get the characteristic energy in J
Definition: SM_Material.h:361
This class is a simulation of one Monte carlo trajectory class for Stoch Magnet package....
Definition: SM_MonteCarloSystem.h:39
const tReal & getEnergyScaling() const
get the energy scaling
Definition: SM_MonteCarloSystem.h:140
virtual void updateStateForNextStep(SM_RealField &St)=0
update the state for next step
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
Definition: SM_MonteCarloSystem.cpp:61
virtual tMemSize getContentsMemorySize() const
return the memory size of the included associations
Definition: SM_MonteCarloSystem.h:105
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
Definition: SM_MonteCarloSystem.hpp:229
virtual void normalize(const tBoolean &isAdimensionized) override
normalize the system
Definition: SM_MonteCarloSystem.h:183
SM_MonteCarloSystem(void)
create a class
Definition: SM_MonteCarloSystem.h:62
const tIndex & getRejectsNumber() const
get the rejects number
Definition: SM_MonteCarloSystem.h:147
virtual tULLInt getGeneratedRandomNumbers() const override
get the generated of random number within a stochastic run
Definition: SM_MonteCarloSystem.h:205
tIndex & getRejectsNumber()
get the rejects number
Definition: SM_MonteCarloSystem.h:169
const tIndex & getMovesNumber() const
get the moves number
Definition: SM_MonteCarloSystem.h:154
void randomTrialMove(SM_StochasticFunctionsInterface &stochasticFunctions, const tReal &sigma, tReal *bS, const tReal *eS) const
make a trial move
Definition: SM_MonteCarloSystem.cpp:133
virtual void setNoiseTemperature(const tReal &T) override
set the noise as a temperature in Kelvin
Definition: SM_MonteCarloSystem.h:119
tIndex & getMovesNumber()
get the move number
Definition: SM_MonteCarloSystem.h:162
virtual void discretize() override
discretize the system
Definition: SM_MonteCarloSystem.h:190
virtual tMemSize getMemorySize() const
return the memory size of the class and the memory size of all its attributes/associations
Definition: SM_MonteCarloSystem.h:93
tBoolean deterministicRun(const tIndex &steppersNumber, SM_StochasticOutput< StochOutputImplement > &data)
compute deterministic running of steppers number of the system with computing statistics
Definition: SM_MonteCarloSystem.h:221
tBoolean stochasticRunWithSCStochasticFunctions(const tIndex &steppersNumber, SM_MultiStochasticFunctions< StochFunctionsImplement > &sfs)
compute the relaxation process by calling only virtual methods
Definition: SM_MonteCarloSystem.hpp:89
const tReal & getNoiseRate() const
get the noise rate constant
Definition: SM_MonteCarloSystem.h:134
virtual tString toString() const override
turn the class into a string representation
Definition: SM_MonteCarloSystem.cpp:180
tBoolean stochasticRun(const tIndex &steppersNumber, SM_MultiStochasticFunctionsInterface &sfs)
compute the steppers number of system for reaching the relaxed state
Definition: SM_MonteCarloSystem.cpp:3
void randomTrialMoveWithSCStochasticFunctions(SM_StochasticFunctions< StochFunctionsImplement > &stochasticFunctions, const tReal &sigma, tReal *bS, const tReal *eS) const
make a trial move
Definition: SM_MonteCarloSystem.hpp:300
virtual ~SM_MonteCarloSystem(void)
destroy the class
Definition: SM_MonteCarloSystem.h:72
This class describes a multi stochastic functions based on same random number generator which impleme...
Definition: SM_MultiStochasticFunctionsInterface.h:18
This class describes a multi stochastic functions based on same random number generator which impleme...
Definition: SM_MultiStochasticFunctions.h:26
This class is describes a network composed by.
Definition: SM_Network.h:66
const tInteger & getParticlesNumber() const
return the particles number
Definition: SM_Network.h:349
This class describes a stochastic functions based on same random number generator which implement ran...
Definition: SM_StochasticFunctionsInterface.h:18
This class describes a stochastic functions with templated methods.
Definition: SM_StochasticFunctions.h:25
this class implements the virtual methods of its base class SM_StochasticOutputComponent with templat...
Definition: SM_StochasticOutput.h:24
This class is a one simulation of a beam for Stoch Magnet package.
Definition: SM_System.h:53
virtual void discretize()
discretize the system
Definition: SM_System.h:546
virtual void normalize(const tBoolean &isAdimensionized)
normalize the system
Definition: SM_System.h:431
const SM_Network & getNetwork() const
get the network
Definition: SM_System.h:170
virtual tMemSize getContentsMemorySize() const
return the memory size of the included associations
Definition: SM_System.h:140
const SM_Material & getMaterial() const
get the material of the network
Definition: SM_System.h:193
virtual void setNoiseTemperature(const tReal &T)
set the noise as a temperature in Kelvin
Definition: SM_System.h:392