C++ mpi module for stochmagnet_main Package
SM_MonteCarloBeam.hpp
1 #ifndef SM_MonteCarloBeam_HPP
2 #define SM_MonteCarloBeam_HPP
3 
4 
5 //stochastic functions header for templated casting
6 #include "SM_TRNGStochasticFunctions.h"
7 #include "SM_TRNGStochasticFunctions_MT19937.h"
8 #include "SM_BoostStochasticFunctions.h"
9 #include "SM_STDStochasticFunctions.h"
10 #include "SM_MTStochasticFunctions.h"
11 
12 
13 template<class StochOutputImplement>
15 
16  //casting with stochastic function
18 
20  if (fstd!=null) {
21  return runWithSCStochasticFunctions(*fstd,outputSData);
22  }
23 
25  if (fboost!=null) {
26  return runWithSCStochasticFunctions(*fboost,outputSData);
27  }
29  if (ftrng!=null) {
30  return runWithSCStochasticFunctions(*ftrng,outputSData);
31  }
32 
34  if (ftrngp_lcg64!=null) {
35  return runWithSCStochasticFunctions(*ftrngp_lcg64,outputSData);
36  }
37 
39  if (ftrngp_yarn2!=null) {
40  return runWithSCStochasticFunctions(*ftrngp_yarn2,outputSData);
41  }
43  if (ftrngp_mrg2!=null) {
44  return runWithSCStochasticFunctions(*ftrngp_mrg2,outputSData);
45  }
47  if (ftrngp_mrg3!=null) {
48  return runWithSCStochasticFunctions(*ftrngp_mrg3,outputSData);
49  }
51  if (ftrngp_mrg3s!=null) {
52  return runWithSCStochasticFunctions(*ftrngp_mrg3s,outputSData);
53  }
55  if (ftrngp_mrg4!=null) {
56  return runWithSCStochasticFunctions(*ftrngp_mrg4,outputSData);
57  }
59  if (ftrngp_mrg5!=null) {
60  return runWithSCStochasticFunctions(*ftrngp_mrg5,outputSData);
61  }
63  if (ftrngp_mrg5s!=null) {
64  return runWithSCStochasticFunctions(*ftrngp_mrg5s,outputSData);
65  }
67  if (fvampire!=null) {
68  return runWithSCStochasticFunctions(*fvampire,outputSData);
69  }
70 
71  //default runs
72  return run(outputSData);
73 
74 }
75 
76 
77 
78 template<class StochFunctionsImplement, class StochOutputImplement>
81 
82  tString routineName="SM_MonteCarloBeam::templatedRun<S,O>()";
84 
85  //get the size of the beam
86  tIndex s0,s1;
87  getBeamSize(s0,s1);
88 
89  //has simulation succeeded
90  tBoolean ok=true;
91 
92  //system of the beam
93  System& system=*dynamic_cast<System*>(&getSystem());
94 
95  //open the stochastic at the beginning of the simulations running of the beam
96  if (!outputSData.open(*this)) {
97  std::cout<<"stochastic output "<<outputSData.getIdentityString()<<" not compatible with the system \n";
98  return false;
99  }
100 
101  for (tIndex s=s0;s<s1;s++) {
102 
103  //St=S0
104  if (!system.initializeMagneticMomentDirections()) {
105  //St=S0
106 
107  throw CORE_Exception("stochmagnet/monteCarlo",
108  "SM_MonteCarloBeam::runWithSCStochasticFunctions(stochF,SM_StochasticOutput<StochOutputImplement>& outputSData)",
109  "initialization of S(t=0) failed");
110 
111  }
112 
113  //open the stochastic output the simulation 0 of the system
114  outputSData.open(s,system);
115 
116 
117  //running the system until the equilibrium
119 
120  //running the system during loop steppers number
121  ok= ok && system.stochasticRunWithSCStochasticFunctions(getStepsNumber(),stochFunctions,outputSData);
122 
123 
124  //close the outputSData for simulation s at the end of simulations
125  outputSData.close(s,system,ok);
126  }
127 
128 
129  //close the stochastic output at the end of the runnings of the simulations
130  outputSData.close(*this);
131  CORE_Profiler::EndCallRoutine(routineName);
132  return true;
133 }
134 #endif
this class describes the exceptions raised for CORE package
Definition: CORE_Exception.h:17
tString getIdentityString() const
retrun the string identification of the class
Definition: CORE_Object.h:321
static void EndCallRoutine(const tString &routineName)
end calling routine
Definition: CORE_Profiler.h:91
static void StartCallRoutine(const tString &routineName)
start calling routine
Definition: CORE_Profiler.h:61
const SM_System & getSystem() const
get the system
Definition: SM_Beam.h:264
const SM_MultiStochasticFunctionsInterface & getStochasticFunctions() const
get the stochastic functions
Definition: SM_Beam.h:236
const tIndex & getBeamSize() const
get the beam size
Definition: SM_Beam.h:166
const tIndex & getStepsNumber() const
get the number of steps for stochastic computation
Definition: SM_Beam.h:207
const tIndex & getPreconditioningStepsNumber() const
get the number of steps for precoditioning
Definition: SM_Beam.h:194
tBoolean runWithSCStochasticFunctions(SM_StochasticOutput< StochOutputImplement > &outputSData)
run the simulations
Definition: SM_MonteCarloBeam.hpp:14
tBoolean run(SM_StochasticOutput< StochOutputImplement > &outputSData)
run the simulations
Definition: SM_MonteCarloBeam.h:95
This class is a simulation of one Monte carlo trajectory class for Stoch Magnet package....
Definition: SM_MonteCarloSystem.h:39
tBoolean stochasticRunWithSCStochasticFunctions(const tIndex &steppersNumber, SM_MultiStochasticFunctions< StochFunctionsImplement > &sfs)
compute the relaxation process by calling only virtual methods
Definition: SM_MonteCarloSystem.hpp:89
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 implements the virtual methods of its base class SM_StochasticOutputComponent with templat...
Definition: SM_StochasticOutput.h:24
tBoolean close(const tIndex &s, const SM_System &system, const tBoolean &hasSucceeded)
close the stochastic data for the simulation s
Definition: SM_StochasticOutput.h:172
tBoolean open(const SM_Beam &beam)
open the stochastic data
Definition: SM_StochasticOutput.h:147
virtual tBoolean initializeMagneticMomentDirections()
initialize magnetic moments direction
Definition: SM_System.h:283