1 #ifndef SM_StochasticEnergy_H
2 #define SM_StochasticEnergy_H
4 #include "SM_StochasticOutput.h"
7 #include "SM_LandauLifschitzSystem.h"
37 tIndex mTimeStepsNumber;
40 tUCInt mEnergiesNumber;
45 std::valarray<tReal> mTimes;
46 std::valarray<tReal> mEpsilons;
48 std::valarray<tReal> mEnergies;
49 std::valarray<tReal> mEnergiesAtS;
50 std::valarray<tReal> mEs;
108 mem+= mEnergies.size()*
sizeof(tReal);
109 mem+= mEpsilons.size()*
sizeof(tReal);
110 mem+= mTimes.size()*
sizeof(tReal);
111 mem+= mEnergiesAtS.size()*
sizeof(tReal);
112 mem+= mEs.size()*
sizeof(tReal);
119 inline static CORE_UniquePointer<SM_StochasticEnergy>
New() {
148 mTimes.resize(mTimeStepsNumber);
153 mEpsilons.resize(mTimeStepsNumber);
156 mEnergies.resize(mTimeStepsNumber*mEnergiesNumber);
158 mEnergiesAtS.resize(mTimeStepsNumber*mEnergiesNumber);
161 mEs.resize(mEnergiesNumber);
175 if (llSystem==
null)
return false;
192 if ((mEpsilonIndex==0)&&(llSystem!=
null)) {
194 mFile=
new std::ofstream(fn,std::ios::out);
195 if ((mFile==
null) || !(*mFile)) {
196 std::cout<<
"Fatal error "<<fn<<
" can not be written \n";
201 functions_string::replaceAll(
"\n",
"\n#",str);
202 (*mFile)<<
"#"<<str<<
"\n";
203 (*mFile)<<
"#time epsilon ";
204 (*mFile)<<
"\t Etotal";
205 std::vector<tString> names;
207 for(
const auto& name:names) (*mFile)<<
"\t E"<<name;
240 const tReal& time=llSystem->
getTime();
245 if (mTimeStepsNumber==1) {
248 if (fabs(mTimes[0]-time)<dt) {
250 const tReal *Es=&mEs[0];
252 tReal *EAtS=&mEnergiesAtS[0];
253 for (tUCInt k=0;k<mEnergiesNumber;k++) {
259 mEpsilons[0]=epsilon_t;
267 const tReal *Es=&mEs[0];
271 mTimes[timeIndex]=time;
273 mEpsilons[timeIndex]=epsilon_t;
276 tReal *EAtS=&mEnergiesAtS[timeIndex*mEnergiesNumber];
277 for (tUCInt k=0;k<mEnergiesNumber;k++) {
295 inline tBoolean
close(
const tIndex& s,
const SM_System& system,
const tBoolean& hasSucceeded) {
302 tReal *Es=&mEnergies[0];
303 const tReal *EAtS=&mEnergiesAtS[0];
304 const tReal *EAtSe=EAtS+mEnergiesAtS.size();
305 while (EAtS!=EAtSe) {
322 tReal *Es=&mEnergies[0];
323 const tReal *Ese=Es+mEnergies.size();
331 const tReal *iEpsilon=&mEpsilons[0];
332 const tReal *iEnergies=&mEnergies[0];
333 const tReal *iT=&mTimes[0];
336 (*mFile) <<std::setprecision(12);
337 for (t=0;t<mTimeStepsNumber;t++) {
341 (*mFile)<<
"\t"<<(*iEpsilon);
344 for (k=0;k<mEnergiesNumber;k++) {
345 (*mFile)<<
"\t"<<(*iEnergies);
375 const tIndex& rawValuesNumber,
376 const std::valarray<tReal>& rawValues)
override {
384 std::stringstream ret;
static tString GetAbsolutePath(const tString &path)
get the absolute path of the path
Definition: CORE_IO.h:365
class Free introduced for deleting a smart pointer
Definition: CORE_Object.h:113
This class defines a general stochastic beam of trajectories of system.
Definition: SM_Beam.h:61
const SM_System & getSystem() const
get the system
Definition: SM_Beam.h:264
virtual tString toString() const override
turn the class into a string representation
Definition: SM_Beam.h:315
const tIndex & getStepsNumber() const
get the number of steps for stochastic computation
Definition: SM_Beam.h:207
This class is a simulation of one trajectory class for Stoch Magnet package.
Definition: SM_LandauLifschitzSystem.h:59
const tIndex & getTimeIndex() const
get the time index
Definition: SM_LandauLifschitzSystem.h:221
const tReal & getTime() const
get the time
Definition: SM_LandauLifschitzSystem.h:214
const SM_TimeStepper & getTimeStepper() const
get the time stepper
Definition: SM_LandauLifschitzSystem.h:200
const tReal & getNoiseRate() const
get the noise rate
Definition: SM_LandauLifschitzSystem.h:251
This class describes a materials defined by state attributes:
Definition: SM_Material.h:61
This class stores stochastic energy:
Definition: SM_StochasticEnergy.h:21
virtual void adimensionize(const SM_Material &material) override
adimensionize the output compoent with material characteristic
Definition: SM_StochasticEnergy.h:132
tBoolean open(const tIndex &s, const SM_System &system)
open the stochastic data for simulation s
Definition: SM_StochasticEnergy.h:223
virtual tMemSize getMemorySize() const
return the memory size of the class and the memory size of all its attributes/associations
Definition: SM_StochasticEnergy.h:94
tBoolean open(const SM_Beam &beam)
open the stochastic data
Definition: SM_StochasticEnergy.h:171
virtual tMemSize getContentsMemorySize() const
return the memory size of the included associations
Definition: SM_StochasticEnergy.h:106
tBoolean store(const SM_System &system)
store the stochastic data during the relations method of the system
Definition: SM_StochasticEnergy.h:232
virtual ~SM_StochasticEnergy(void)
destroy
Definition: SM_StochasticEnergy.h:73
virtual tString toString() const override
return the string representation of the class
Definition: SM_StochasticEnergy.h:383
tBoolean close(const tIndex &s, const SM_System &system, const tBoolean &hasSucceeded)
close the stochastic data for the simulation s
Definition: SM_StochasticEnergy.h:295
void initialize(const SM_Beam &beam)
set the number of epsilon & energies
Definition: SM_StochasticEnergy.h:138
tBoolean close(const SM_Beam &beam)
close stochastic data at the end of all simulations
Definition: SM_StochasticEnergy.h:318
static CORE_UniquePointer< SM_StochasticEnergy > New()
build a new instance of a stochastic data
Definition: SM_StochasticEnergy.h:119
virtual void closePackedSimulations(const SM_Beam &beam, const tIndex &rawValuesNumber, const std::valarray< tReal > &rawValues) override
close stochastic data at the end of all packed simulations
Definition: SM_StochasticEnergy.h:374
SM_StochasticEnergy(void)
create
Definition: SM_StochasticEnergy.h:60
const tString & getPrefix() const
return the prefix
Definition: SM_StochasticOutputComponent.h:190
virtual tString toString() const override
return the string representation of the class
Definition: SM_StochasticOutputComponent.h:398
const tIndex & getPackedRawValuesNumber() const
get the packed raw values number
Definition: SM_StochasticOutputComponent.h:286
const int & getIndex() const
get the index of the output component
Definition: SM_StochasticOutputComponent.h:217
const tString & getOutputPath() const
return the output path
Definition: SM_StochasticOutputComponent.h:178
this class implements the virtual methods of its base class SM_StochasticOutputComponent with templat...
Definition: SM_StochasticOutput.h:24
virtual tMemSize getContentsMemorySize() const
return the memory size of the included associations
Definition: SM_StochasticOutput.h:84
This class is a one simulation of a beam for Stoch Magnet package.
Definition: SM_System.h:53
tIndex getOperatorsNumber() const
get the operators number
Definition: SM_System.h:352
const tReal & computeEnergies(std::valarray< tReal > &energies) const
compute the energies per operators
Definition: SM_System.h:705
void getOperatorsName(std::vector< tString > &names) const
get the operator names
Definition: SM_System.h:358
const tReal & getTimeStep() const
return the time step
Definition: SM_TimeStepper.h:108