1 #ifndef SM_StochasticCurieTemperature_H
2 #define SM_StochasticCurieTemperature_H
5 #include "SM_StochasticOutput.h"
8 #include "SM_LandauLifschitzBeam.h"
11 #include "SM_System.h"
17 #include "core_string.h"
18 #include "core_numeric.h"
50 tString mCTPackedFileName;
55 std::array<tReal,SM_Constants::DIM> mBarS;
58 tUCInt mTemperatureIndex;
60 tUCInt mNSamplesIndex;
75 "<number of simulations>",
86 memset(&outputs[0],0,outputs.size()*
sizeof(tReal));
132 mem+=mCTFileName.length()*
sizeof(tChar);
133 mem+=mCTPackedFileName.length()*
sizeof(tChar);
134 mem+=mBarS.size()*
sizeof(tReal);
141 inline static CORE_UniquePointer<Self>
New() {
142 return CORE_UniquePointer<Self>(
new Self(),
148 inline static CORE_UniquePointer<Self>
New(
const Self& c) {
149 CORE_UniquePointer<Self> p=
New();
180 tString str=
"beam:"+beam.
toString();
181 core_string::replaceAll(
"\n",
"\n#",str);
182 file<<
"#"<<str<<
"\n";
186 core_string::replaceAll(
"\n",
"\n#",str);
187 file<<
"#"<<str<<
"\n";
195 file<<
"# T: temperature N : simulations number\n";
196 file<<
"# for all simulation s in [0,N[:\n";
197 file<<
"# \t for all step t in [1,T[, bar S_k(s,t)=frac{1}{P} sum_{p=0}^{p=P-1} S^s_k(t,p) \n"; file<<
"# \t for all step t in [1,T[, bar S_k(s,t)=frac{1}{P} sum_{p=0}^{p=P-1} S^s_k(t,p) \n";
198 file<<
"# \t E_s=frac{1}{T} sum_{t=0}^{t=T-1} |bar S_k(s,t)|\n";
199 file<<
"# E=frac{1}{N} sum_{s=0}^{s=N-1} E_s\n";
201 file<<
"# Curie Temperature: "<<Tc<<
"\n";
222 tString routineName=
"SM_StochasticCurieTemperature::open()";
230 mStepIndex=core_numeric::getInfinity<tIndex>();
241 mCTPackedFileName=mCTFileName;
245 mCTPackedFileName+=
".ct";
250 std::ofstream file(mCTPackedFileName.c_str(),std::ios::out);
255 std::cout<<
"Fatal Error : "<<mCTPackedFileName<<
" can not be opened \n";
273 memset(&rawValues[0],0,rawValues.size()*
sizeof(tReal));
291 tString routineName=
"SM_StochasticCurieTemperature::open(s,system)";
296 mStepIndex=core_numeric::getInfinity<tIndex>();
309 tString routineName=
"SM_StochasticCurieTemperature::store()";
329 inline tBoolean
close(
const tIndex& s,
const SM_System& system,
const tBoolean& hasSucceeded) {
331 tString routineName=
"SM_StochasticCurieTemperature::close(s,system,hasSucceeded)";
337 computeEsperanceContribution(system.
getStepIndex(),system);
352 tString routineName=
"SM_StochasticCurieTemperature::close(beam)";
362 std::ofstream file(mCTPackedFileName.c_str(),std::ios::app);
388 const tIndex& rawValuesNumber,
389 const std::valarray<tReal>& rawValues)
override {
390 tString routineName=
"SM_StochasticCurieTemperature::closePackedSimulations(beam,nRaws,raws)";
394 std::ofstream file(mCTFileName,std::ios::out);
402 flushStochasticOutput(file,rawValuesNumber,rawValues);
412 std::stringstream ret;
428 inline void computeEsperanceContribution(
const tIndex& stepIndex,
const SM_System& system) {
431 if (mStepIndex!=stepIndex) {
433 mStepIndex=stepIndex;
441 for(
const auto& Sk:mBarS) {
459 inline void flushStochasticOutput(std::ofstream& file,
460 const tIndex& rawValuesNumber,
461 const std::valarray<tReal>& rawValues) {
463 outputs[mMeanSIndex]=rawValues[0]/rawValuesNumber;
464 outputs[mNSamplesIndex]=rawValuesNumber;
465 outputs[mNSimsIndex]=rawValues[1];
466 for(
const auto v:outputs) {
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
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
static const tString & GetSoftName()
get soft name
Definition: CORE_Run.h:115
static const tString & GetVersion()
get the version
Definition: CORE_Run.h:129
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 & getBeamSize() const
get the beam size
Definition: SM_Beam.h:166
static constexpr tReal K_B
Boltzmann constants : .
Definition: SM_Constants.h:44
const tUCInt & getCoordinationNumber() const
get the coodination number
Definition: SM_CrystalStructure.h:169
This class describes a materials defined by state attributes:
Definition: SM_Material.h:61
const tReal & getExchangeEnergyFactor() const
get the exchange energy
Definition: SM_Material.h:316
const tReal & getSpinWaveMFCorrection() const
get the spin wave MF correction
Definition: SM_Material.h:340
const SM_CrystalStructure & getCrystalStructure() const
get the crystal structure
Definition: SM_Material.h:198
This class stores stochastic Curie temperature esperance for a dimension D.
Definition: SM_StochasticCurieTemperature.h:34
virtual tString toString() const override
return the string representation of the class
Definition: SM_StochasticCurieTemperature.h:411
SM_StochasticCurieTemperature(void)
create
Definition: SM_StochasticCurieTemperature.h:69
tBoolean close(const tIndex &s, const SM_System &system, const tBoolean &hasSucceeded)
close the stochastic data for the simulation at index s
Definition: SM_StochasticCurieTemperature.h:329
static CORE_UniquePointer< Self > New()
build a new instance of a stochastic data
Definition: SM_StochasticCurieTemperature.h:141
tBoolean open(const SM_Beam &beam)
open the stochastic data at the begininf of simulations
Definition: SM_StochasticCurieTemperature.h:221
tBoolean store(const SM_System &system)
store the stochastic data during the evolution method of the system
Definition: SM_StochasticCurieTemperature.h:308
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_StochasticCurieTemperature.h:387
tBoolean open(const tIndex &s, const SM_System &system)
open the stochastic data for simulation at index s
Definition: SM_StochasticCurieTemperature.h:289
virtual void copy(const SM_StochasticOutputComponent &c) override
copy the stochastic data
Definition: SM_StochasticCurieTemperature.h:159
virtual tMemSize getMemorySize() const
return the memory size of the class and the memory size of all its attributes/associations
Definition: SM_StochasticCurieTemperature.h:118
virtual tMemSize getContentsMemorySize() const
return the memory size of the included associations
Definition: SM_StochasticCurieTemperature.h:130
virtual ~SM_StochasticCurieTemperature(void)
destroy
Definition: SM_StochasticCurieTemperature.h:97
virtual void adimensionize(const SM_Material &material) override
adimensionize the output compoent with material characteristic
Definition: SM_StochasticCurieTemperature.h:167
tBoolean close(const SM_Beam &beam)
close stochastic data at the end of one packed simulations
Definition: SM_StochasticCurieTemperature.h:351
void printHeader(std::ofstream &file, const SM_Beam &beam)
print he file header
Definition: SM_StochasticCurieTemperature.h:174
static CORE_UniquePointer< Self > New(const Self &c)
build a new instance of a stochastic data
Definition: SM_StochasticCurieTemperature.h:148
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
std::valarray< tReal > & getPackedRawValues()
get the packed raw values
Definition: SM_StochasticOutputComponent.h:301
void setOutputDescription(const std::vector< tString > &v)
et the output description
Definition: SM_StochasticOutputComponent.h:323
const tString & getPrefix() const
return the prefix
Definition: SM_StochasticOutputComponent.h:190
const tInteger & getPackedSimulationsIndex() const
get packed simulations index
Definition: SM_StochasticOutputComponent.h:257
const std::vector< tString > & getOutputDescription() const
get the string representation of the output values
Definition: SM_StochasticOutputComponent.h:316
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 tBoolean & hasLogPerPackedSimulations() const
return true if the stochastic output has log per pack of simulations
Definition: SM_StochasticOutputComponent.h:274
const tInteger & getPackedSimulationsNumber() const
get packed simulations number
Definition: SM_StochasticOutputComponent.h:269
const std::valarray< tReal > & getOutputValues() const
get the output values of the stochastic output for reading
Definition: SM_StochasticOutputComponent.h:330
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 is a one simulation of a beam for Stoch Magnet package.
Definition: SM_System.h:53
void computeMagneticMomentDirectionsMeanOverNetworks(const int &rootNetwork, std::array< tReal, SM_Constants::DIM > &meanS) const
compute the mean over the domain of magneticmoment directions
Definition: SM_System.h:477
const SM_Material & getMaterial() const
get the material of the network
Definition: SM_System.h:193
const tReal & getNoiseTemperature() const
get the noise temperature in Kelvin
Definition: SM_System.h:399
const tIndex & getStepIndex() const
get the step index
Definition: SM_System.h:415