8 #include "SM_Network.h"
11 #include "SM_Material.h"
14 #include "SM_Operator.h"
63 CORE_UniquePointer<SM_Network> mNetwork;
70 std::map<tString,CORE_UniquePointer<SM_Operator>> mOperators;
82 tReal mNoiseRateTemperature;
85 tReal mStochasticNoise;
97 mNoiseRateTemperature=0;
142 mem+=(mNetwork.get()==
null)?0:mNetwork->getContentsMemorySize();
146 std::for_each(mOperators.cbegin(),mOperators.cend(),
147 [&](
const auto& op) {
148 mem+=op.first.size();
149 mem+=op.second->getMemorySize();
164 mNetwork=std::move(net);
171 return *mNetwork.get();
177 return *mNetwork.get();
184 return (mNetwork.get()!=
null);
232 const std::array<tReal,SM_Constants::DIM>& S0) {
299 if (op.get()!=
null) mOperators[op->getName()]=std::move(op);
306 auto op=mOperators.find(name);
307 if (op!=mOperators.end()) {
308 return &(op->second->getSliceOperator());
316 auto op=mOperators.find(name);
317 if (op!=mOperators.end()) {
318 return &(op->second->getSliceOperator());
327 const std::map<tString,CORE_UniquePointer<SM_Operator>>& operators=system.
getOperators();
328 CORE_UniquePointer<SM_Operator> cop;
329 for_each(operators.begin(),operators.end(),
330 [&](
const auto& op) {
331 cop=op.second->NewInstance();
332 cop->copy(*op.second.get());
333 mOperators[op.first]=std::move(cop);
339 inline const std::map<tString,CORE_UniquePointer<SM_Operator>>&
getOperators()
const {
346 inline std::map<tString,CORE_UniquePointer<SM_Operator>>&
getOperators() {
353 return mOperators.size();
360 for(
const auto& op : mOperators) {
361 names.push_back(op.first);
380 mStochasticNoise=eps;
386 return mStochasticNoise;
393 mNoiseRateTemperature=T;
400 return mNoiseRateTemperature;
431 virtual void normalize(
const tBoolean& isAdimensionized) {
437 if (isAdimensionized) {
440 for(
auto& op:mOperators) {
441 op.second->adimensionize(
getMaterial().getCharacteristicField());
457 virtual void sumOverNetworks(
const int& rootNetwork,tIndex& n,
const tIndex& nValues,tReal* values)
const {
478 std::array<tReal,SM_Constants::DIM>& meanS)
const {
490 for(
auto& meanSk:meanS) {
502 std::array<tReal,SM_Constants::DIM>& sumS)
const {
515 std::array<tReal,SM_Constants::DIM>& sumF) {
518 tReal *iSumF=sumF.data();
531 while (iSumF!=eSumF) {
558 for(
auto& op : mOperators) {
559 op.second->discretize(network,material);
577 std::map<tString,CORE_UniquePointer<SM_Operator>>& operators=
getOperators();
578 for(
auto& op : operators) {
579 op.second->updateState(timeIndex,network,material,S);
598 tString routineName=
"SM_System::computeMagneticField()";
607 const std::map<tString,CORE_UniquePointer<SM_Operator>>& operators=
getOperators();
608 for(
const auto& op : operators) {
609 op.second->computeMagneticField(timeIndex,network,material,S,1,H);
646 const tIndex& timeIndex,
654 const std::map<tString,CORE_UniquePointer<SM_Operator>>& operators=
getOperators();
655 for(
const auto& op : operators) {
656 E+=op.second->computeSpinEnergy(i,timeIndex,network,material,S);
693 const std::map<tString,CORE_UniquePointer<SM_Operator>>& operators=
getOperators();
694 for(
const auto& op : operators) {
695 E+=op.second->computeEnergy(timeIndex,network,material,S);
714 inline const tReal&
computeEnergies(
const tIndex& timeIndex,std::valarray<tReal>& energies)
const {
715 if (energies.size()<mOperators.size()+1) energies.resize(mOperators.size()+1);
720 tReal *iE=&energies[0];
730 const std::map<tString,CORE_UniquePointer<SM_Operator>>& operators=
getOperators();
731 for(
const auto& op : operators) {
733 (*iE)=op.second->computeEnergy(timeIndex,network,material,mSt);
750 std::stringstream ret;
756 ret<<
"Material:"<<mMaterial.
toString()<<
"\n";
759 ret<<
"Network:"<<mNetwork->toString()<<
"\n";
767 ret<<
"\t"<<op.first<<
":"<<op.second->toString();
771 tUInt nPrintedValues=10;
776 tInteger mod=N/nPrintedValues;
780 for (i=0;i<N;i+=mod) {
782 ret<<
"\t S0["<<i<<
"]=[";
787 ret.seekp(-1,ret.cur);
virtual tMemSize getContentsMemorySize() const override
return the memory size of the included associations
Definition: CORE_Field.h:102
tIndex getElementsNumber() const
return the number values of the container
Definition: CORE_Field.h:135
void setElementsNumber(const tInteger &n)
set the number of element of the container
Definition: CORE_Field.h:121
virtual tMemSize getContentsMemorySize() const
return nthe memory size of the included associations
Definition: CORE_Object.h:278
virtual tString toString() const
return the string representation of the object node
Definition: CORE_Object.h:333
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
void normalize()
normalize all the elements of the field return false if the method is not compatible with the floatin...
Definition: CORE_StdPtrField.h:429
void initialize(const Q &v)
initailize all the values with v
Definition: CORE_StdPtrField.h:192
static constexpr tDimension DIM
space dimension
Definition: SM_Constants.h:80
This class describes a materials defined by state attributes:
Definition: SM_Material.h:61
virtual tString toString() const override
turn the class into a string representation
Definition: SM_Material.cpp:138
virtual tMemSize getContentsMemorySize() const
return the memory size of the included associations
Definition: SM_Material.h:171
void computeCharacteristicValues(const tBoolean &isAdimensionized)
compute the characteristic values
Definition: SM_Material.cpp:43
This class is describes a network composed by.
Definition: SM_Network.h:66
const tInteger & getHaloParticlesNumber() const
return the halo particles number
Definition: SM_Network.h:355
const tInteger & getParticlesNumber() const
return the particles number
Definition: SM_Network.h:349
This class is a base class for Stoch Microm package.
Definition: SM_Object.h:36
This class is describes an operator operating on slice of particles of a network SM_Network.
Definition: SM_SliceOperator.h:32
This class is a one simulation of a beam for Stoch Magnet package.
Definition: SM_System.h:53
tReal computeEnergy(const tIndex &timeIndex, const SM_Network &network, const SM_Material &material, const SM_RealField &S) const
compute the energy of the system
Definition: SM_System.h:686
void setNetwork(CORE_UniquePointer< SM_Network > net)
set the network
Definition: SM_System.h:163
tIndex getOperatorsNumber() const
get the operators number
Definition: SM_System.h:352
virtual void discretize()
discretize the system
Definition: SM_System.h:546
SM_System(void)
create a class
Definition: SM_System.h:92
const SM_RealField & getMagneticMomentDirections() const
get the unit direction of spins at time
Definition: SM_System.h:267
SM_Network & getNetwork()
get the network
Definition: SM_System.h:176
const tReal & computeEnergies(const tIndex &timeIndex, std::valarray< tReal > &energies) const
compute the energies per operators
Definition: SM_System.h:714
std::map< tString, CORE_UniquePointer< SM_Operator > > & getOperators()
get the operators
Definition: SM_System.h:346
static void ComputeFieldSum(const tInteger &start, const tInteger &end, const SM_RealField &F, std::array< tReal, SM_Constants::DIM > &sumF)
compute the sum of F over the network
Definition: SM_System.h:512
const std::map< tString, CORE_UniquePointer< SM_Operator > > & getOperators() const
get the operators
Definition: SM_System.h:339
virtual tULLInt getGeneratedRandomNumbers() const =0
get the generated of random number
void updateOperatorsState(const tIndex &timeIndex, const SM_Network &network, const SM_Material &material, const SM_RealField &S)
update the operators state before computeing magnetic field
Definition: SM_System.h:573
void setInitialMagneticMomentDirections(const std::valarray< tReal > &S0)
set the initial unit direction of spins
Definition: SM_System.h:214
virtual void setStochasticNoise(const tReal &eps)
set the stochastic noise without dimension
Definition: SM_System.h:379
void copyOperators(const SM_System &system)
copy the operator
Definition: SM_System.h:326
virtual void normalize(const tBoolean &isAdimensionized)
normalize the system
Definition: SM_System.h:431
tReal computeEnergy(const SM_Network &network, const SM_Material &material, const SM_RealField &S) const
compute the energy of the system
Definition: SM_System.h:673
const SM_SliceOperator * getOperator(const tString &name) const
get the operator with name
Definition: SM_System.h:305
void setInitialMagneticMomentDirections(const SM_RealField &S0)
set the initial unit direction of spins
Definition: SM_System.h:222
const SM_RealField & getInitialMagneticMomentDirections() const
get the initial unit direction of spins
Definition: SM_System.h:253
void setInitialMagneticMomentDirections(const tIndex &N, const std::array< tReal, SM_Constants::DIM > &S0)
set the initial unit direction of spins
Definition: SM_System.h:231
void addOperator(CORE_UniquePointer< SM_Operator > op)
add operator
Definition: SM_System.h:298
SM_RealField & getInitialMagneticMomentDirections()
get the initial unit direction of spins for writting
Definition: SM_System.h:260
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
virtual tMemSize getContentsMemorySize() const
return the memory size of the included associations
Definition: SM_System.h:140
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
tBoolean hasNetwork() const
return true if the system has a network
Definition: SM_System.h:183
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
virtual void sumOverNetworks(const int &rootNetwork, tIndex &n, const tIndex &nValues, tReal *values) const
sum the values of all network
Definition: SM_System.h:457
virtual void setNoiseTemperature(const tReal &T)
set the noise as a temperature in Kelvin
Definition: SM_System.h:392
SM_SliceOperator * getOperator(const tString &name)
get the operator with name
Definition: SM_System.h:315
virtual ~SM_System(void)
destroy the class
Definition: SM_System.h:106
SM_Material & getMaterial()
get the material of the network
Definition: SM_System.h:200
tIndex & getStepIndex()
get the step index
Definition: SM_System.h:421
virtual tMemSize getMemorySize() const
return the memory size of the class and the memory size of all its attributes/associations
Definition: SM_System.h:128
tReal computeSpinEnergy(const tIndex &i, const tIndex &timeIndex, const SM_Network &network, const SM_Material &material, const SM_RealField &S) const
compute the energy of the spin of the system
Definition: SM_System.h:645
SM_RealField & getMagneticMomentDirections()
get the unit direction of spins at time for writting
Definition: SM_System.h:274
tReal computeSpinEnergy(const tIndex &i, const SM_Network &network, const SM_Material &material, const SM_RealField &S) const
compute the energy of the spin of the system
Definition: SM_System.h:629
void computeMagneticMomentDirectionsSum(const tInteger &start, const tInteger &end, std::array< tReal, SM_Constants::DIM > &sumS) const
compute the sum of magnetic moment directions over the network
Definition: SM_System.h:500
const tReal & getStochasticNoise() const
get the stochastic noise without dimension
Definition: SM_System.h:385
void computeMagneticMomentDirectionsSumOverNetworks(const int &rootNetwork, std::array< tReal, SM_Constants::DIM > &sumS) const
compute the sum over the domain of magnetic moment dierctions
Definition: SM_System.h:464
void computeMagneticField(const tIndex &timeIndex, const SM_Network &network, const SM_Material &material, const SM_RealField &S, SM_RealField &H) const
compute the magnetic field at time step index t by calling the virtual method SM_Operator::computeMag...
Definition: SM_System.h:593
const tIndex & getStepIndex() const
get the step index
Definition: SM_System.h:415
virtual tBoolean initializeMagneticMomentDirections()
initialize magnetic moments direction
Definition: SM_System.h:283
virtual tBoolean updateInitialMagneticMomentDirections(const SM_RealField &S0)
update the initial unit direction of spins
Definition: SM_System.h:241