1 #ifndef SM_StochasticTrajectory_H
2 #define SM_StochasticTrajectory_H
5 #include "SM_StochasticOutput.h"
12 #include "SM_LandauLifschitzSystem.h"
43 std::vector<tIndex> mParticles;
46 std::vector<tIndex> mSimulations;
49 std::vector<tIndex>::const_iterator mISimulation;
56 std::valarray<tReal> mEnergies;
120 mem+=mSimulations.size()*
sizeof(tIndex);
121 mem+=mParticles.size()*
sizeof(tIndex);
122 mem+=mEnergies.size()*
sizeof(tReal);
129 inline static CORE_UniquePointer<SM_StochasticTrajectory>
New() {
136 CORE_UniquePointer<SM_StochasticTrajectory> p=
New();
165 mSimulations=simulationIndices;
166 mISimulation=mSimulations.begin();
172 mSimulations=simulationIndices;
173 mISimulation=mSimulations.begin();
185 inline void setParticles(std::initializer_list<tIndex>&& particlesIndices) {
186 mParticles=particlesIndices;
191 inline void setParticles(
const std::vector<tIndex>& particlesIndices) {
192 mParticles=particlesIndices;
210 std::sort(mSimulations.begin(),mSimulations.end());
212 std::sort(mParticles.begin(),mParticles.end());
214 mISimulation=mSimulations.begin();
238 while (mISimulation!=mSimulations.end()) {
239 if (s<(*mISimulation)) {
242 if (s==(*mISimulation)) {
249 (*mFile)<<
"#trajectory file of simulation at index "<<s<<
"\n";
251 functions_string::replaceAll(
"\n",
"\n#",str);
252 (*mFile) <<
"# X: when the particle with index does not exists \n";
253 (*mFile)<<
"#System:"<<str<<
"\n";
254 (*mFile)<<
"#timeIndex ";
255 (*mFile)<<
"\t time ";
257 (*mFile)<<
"\t epsilon ";
259 for(
const auto& p : mParticles) {
260 (*mFile)<<
"\t S_"<<p<<
".x";
261 (*mFile)<<
"\t S_"<<p<<
".y";
262 (*mFile)<<
"\t S_"<<p<<
".z";
265 (*mFile)<<
"\t Etotal";
267 std::vector<tString> names;
269 for(
const auto& name:names) (*mFile)<<
"\t E"<<name;
271 mEnergies.resize(names.size()+1);
274 (*mFile)<<
"\t DEtotal/Dt";
277 (*mFile)<<
"\t netTorque";
320 const tReal *iSp=
null;
323 (*mFile)<<
"\t"<<std::setprecision(12)<<llSystem->
getTime();
325 (*mFile)<<
"\t"<<std::setprecision(12)<<llSystem->
getNoiseRate();
327 for(
const auto& p : mParticles) {
331 (*mFile)<<
"\t"<<std::setprecision(12)<<(*iSp);
344 tReal dE=mEnergies[0];
348 for(
const auto& E : mEnergies) (*mFile)<<
"\t"<<E;
358 if (dT!=0) (*mFile)<<
"\t"<<std::setprecision(12)<<(dE/dT);
359 else (*mFile)<<
"\t"<<std::setprecision(12)<<dE;
362 (*mFile)<<
"\t"<<std::setprecision(12)<<netTorque;
376 inline tBoolean
close(
const tIndex& s,
const SM_System& system,
const tBoolean& hasSucceeded) {
398 const tIndex& rawValuesNumber,
399 const std::valarray<tReal>& rawValues)
override {
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
static constexpr tDimension DIM
space dimension
Definition: SM_Constants.h:80
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
tReal computeNetTorque() const
compute Net Torque
Definition: SM_LandauLifschitzSystem.h:347
This class describes a materials defined by state attributes:
Definition: SM_Material.h:61
const tInteger & getParticlesNumber() const
return the particles number
Definition: SM_Network.h:349
This class stores stochastic outpus computed for each trajectory of a simulation of trajectories of a...
Definition: SM_StochasticOutputComponent.h:36
const int & getRootIndex() const
get the root index of the output component
Definition: SM_StochasticOutputComponent.h:222
const tString & getPrefix() const
return the prefix
Definition: SM_StochasticOutputComponent.h:190
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
virtual void copy(const SM_StochasticOutputComponent &c)
copy
Definition: SM_StochasticOutput.h:94
This class stores stochastic trajectories for a list of points and a list of simulations for LL beam.
Definition: SM_StochasticTrajectory.h:28
void setSimulations(std::initializer_list< tIndex > &&simulationIndices)
set the simulation indices to save
Definition: SM_StochasticTrajectory.h:164
const std::vector< tIndex > & getSimulations() const
get the simulations
Definition: SM_StochasticTrajectory.h:179
static CORE_UniquePointer< SM_StochasticTrajectory > New()
build a new instance of a stochastic data
Definition: SM_StochasticTrajectory.h:129
tBoolean open(const tIndex &s, const SM_System &system)
open the stochastic data for simulation s
Definition: SM_StochasticTrajectory.h:227
tBoolean close(const SM_Beam &beam)
close stochastic data at the end of all simulations
Definition: SM_StochasticTrajectory.h:387
const std::vector< tIndex > & getParticles() const
get the simulations
Definition: SM_StochasticTrajectory.h:196
tBoolean open(const SM_Beam &beam)
open the stochastic data
Definition: SM_StochasticTrajectory.h:208
tBoolean store(const SM_System &system)
store the stochastic data during the relation method of the system
Definition: SM_StochasticTrajectory.h:299
virtual ~SM_StochasticTrajectory(void)
destroy
Definition: SM_StochasticTrajectory.h:85
static CORE_UniquePointer< SM_StochasticTrajectory > New(const SM_StochasticTrajectory &c)
build a new instance of a stochastic data
Definition: SM_StochasticTrajectory.h:135
virtual void adimensionize(const SM_Material &material) override
adimensionize the output compoent with material characteristic
Definition: SM_StochasticTrajectory.h:158
virtual tMemSize getContentsMemorySize() const
return the memory size of the included associations
Definition: SM_StochasticTrajectory.h:118
SM_StochasticTrajectory(void)
create
Definition: SM_StochasticTrajectory.h:69
tBoolean close(const tIndex &s, const SM_System &system, const tBoolean &hasSucceeded)
close the stochastic data for the simulation s
Definition: SM_StochasticTrajectory.h:376
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_StochasticTrajectory.h:397
void setSimulations(const std::vector< tIndex > &simulationIndices)
set the simulation indices to save
Definition: SM_StochasticTrajectory.h:171
virtual void copy(const SM_StochasticOutputComponent &c) override
copy the stochastic data
Definition: SM_StochasticTrajectory.h:146
void setParticles(std::initializer_list< tIndex > &&particlesIndices)
set the particle indices to save
Definition: SM_StochasticTrajectory.h:185
virtual tMemSize getMemorySize() const
return the memory size of the class and the memory size of all its attributes/associations
Definition: SM_StochasticTrajectory.h:106
void setParticles(const std::vector< tIndex > &particlesIndices)
set the particle indices to save
Definition: SM_StochasticTrajectory.h:191
This class is a one simulation of a beam for Stoch Magnet package.
Definition: SM_System.h:53
const SM_RealField & getMagneticMomentDirections() const
get the unit direction of spins at time
Definition: SM_System.h:267
virtual tString toString() const override
turn the class into a string representation
Definition: SM_System.h:749
const tReal & computeEnergies(std::valarray< tReal > &energies) const
compute the energies per operators
Definition: SM_System.h:705
const SM_Network & getNetwork() const
get the network
Definition: SM_System.h:170
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