PSCF v1.4.0
Pscf::Rpc::Simulator< D > Class Template Reference

Field theoretic simulator (base class). More...

#include <Simulator.h>

Inheritance diagram for Pscf::Rpc::Simulator< D >:
Pscf::Rp::Simulator< D, Types< D > > Util::ParamComposite Util::ParamComponent Util::Serializable Util::MpiFileIo

Public Member Functions

 Simulator (System< D > &system)
 Constructor.
virtual ~Simulator ()=default
 Destructor.
Public Member Functions inherited from Pscf::Rp::Simulator< D, Types< D > >
virtual void readParameters (std::istream &in)
 Read parameters for a simulation.
void allocate ()
 Allocate required memory during initialization.
virtual void simulate (int nStep)
 Perform a field theoretic Monte-Carlo simulation.
virtual void analyze (int min, int max, std::string classname, std::string filename)
 Read and analyze a trajectory file.
void clearData ()
 Clear field eigen-components and Hamiltonian components.
virtual void outputTimers (std::ostream &out) const
 Output timing results.
virtual void outputMdeCounter (std::ostream &out) const
 Output MDE counter.
virtual void clearTimers ()
 Clear timers.
long iStep ()
 Return the current converged simulation step index.
long iTotalStep ()
 Return the current simulation step index.
void analyzeChi ()
 Perform eigenvalue analysis of projected chi matrix.
DArray< double > const & chiEvals () const
 Get an array of the eigenvalues of the projected chi matrix.
double chiEval (int a) const
 Get a single eigenvalue of the projected chi matrix.
DMatrix< double > const & chiEvecs () const
 Get the matrix of all eigenvectors of the projected chi matrix.
double chiEvecs (int a, int i) const
 Get one element of an eigenvector of the projected chi matrix.
DArray< double > const & sc () const
 Get all components of the vector S.
double sc (int a) const
 Get a single component of the S vector.
void computeHamiltonian ()
 Compute the Hamiltonian used in PS-FTS.
double hamiltonian () const
 Get the Hamiltonian used in PS-FTS.
double idealHamiltonian () const
 Get an ideal contribution to the Hamiltonian.
double fieldHamiltonian () const
 Get the quadratic field contribution to the Hamiltonian.
double perturbationHamiltonian () const
 Get a perturbation to the standard Hamiltonian.
bool hasHamiltonian () const
 Has the Hamiltonian been computed for the current w and c fields?
void computeWc ()
 Compute eigenvector components of the current w fields.
DArray< RFieldT > const & wc () const
 Get all eigenvector components of the current w fields.
RFieldT const & wc (int a) const
 Get one eigenvector component of the current w fields.
bool hasWc () const
 Are eigen-components of the current w fields valid ?
void computeCc ()
 Compute eigenvector components of the current c fields.
DArray< RFieldT > const & cc () const
 Get all eigenvector components of the current c fields.
RFieldT const & cc (int a) const
 Get one eigenvector component of the current c fields.
bool hasCc () const
 Are eigen-components of the current c fields valid ?
void computeDc ()
 Compute functional derivatives of the Hamiltonian.
DArray< RFieldT > const & dc () const
 Get all of the current d fields.
RFieldT const & dc (int i) const
 Get one eigenvector component of the current d fields.
bool hasDc () const
 Are the current d fields valid ?
void saveState ()
 Save a copy of the current system state.
void restoreState ()
 Restore the system to the saved state.
void clearState ()
 Clear the saved copy of the system state.
Types< D >::System & system ()
 Get the parent system by reference.
Randomrandom ()
 Get the scalar random number generator by reference.
Types< D >::VecRandom & vecRandom ()
 Get the vector random number generator by reference.
bool hasCompressor () const
 Does this Simulator have a Compressor?
Types< D >::Compressor const & compressor () const
 Get the Compressor by const reference.
Types< D >::Compressor & compressor ()
 Get the Compressor by non-const reference.
bool hasPerturbation () const
 Does this Simulator have a Perturbation?
Types< D >::Perturbation const & perturbation () const
 Get a Perturbation by const reference.
Types< D >::Perturbation & perturbation ()
 Get a Perturbation by non-const reference.
bool hasRamp () const
 Does this Simulator have a Ramp?
Types< D >::Ramp const & ramp () const
 Get a Ramp by const reference.
Types< D >::Ramp & ramp ()
 Get a Ramp by non-const reference.
Public Member Functions inherited from Util::ParamComposite
 ParamComposite ()
 Constructor.
 ParamComposite (const ParamComposite &other)
 Copy constructor.
 ParamComposite (int capacity)
 Constructor.
virtual ~ParamComposite ()
 Virtual destructor.
void resetParam ()
 Resets ParamComposite to its empty state.
virtual void readParam (std::istream &in)
 Read the parameter file block.
virtual void readParamOptional (std::istream &in)
 Read optional parameter file block.
virtual void writeParam (std::ostream &out) const
 Write all parameters to an output stream.
virtual void load (Serializable::IArchive &ar)
 Load all parameters from an input archive.
virtual void loadOptional (Serializable::IArchive &ar)
 Load an optional ParamComposite.
virtual void loadParameters (Serializable::IArchive &ar)
 Load state from archive, without adding Begin and End lines.
virtual void save (Serializable::OArchive &ar)
 Saves all parameters to an archive.
void saveOptional (Serializable::OArchive &ar)
 Saves isActive flag, and then calls save() iff isActive is true.
void readParamComposite (std::istream &in, ParamComposite &child, bool next=true)
 Add and read a required child ParamComposite.
void readParamCompositeOptional (std::istream &in, ParamComposite &child, bool next=true)
 Add and attempt to read an optional child ParamComposite.
template<typename Type>
ScalarParam< Type > & read (std::istream &in, const char *label, Type &value)
 Add and read a new required ScalarParam < Type > object.
template<typename Type>
ScalarParam< Type > & readOptional (std::istream &in, const char *label, Type &value)
 Add and read a new optional ScalarParam < Type > object.
template<typename Type>
CArrayParam< Type > & readCArray (std::istream &in, const char *label, Type *value, int n)
 Add and read a required C array parameter.
template<typename Type>
CArrayParam< Type > & readOptionalCArray (std::istream &in, const char *label, Type *value, int n)
 Add and read an optional C array parameter.
template<typename Type>
DArrayParam< Type > & readDArray (std::istream &in, const char *label, DArray< Type > &array, int n)
 Add and read a required DArray < Type > parameter.
template<typename Type>
DArrayParam< Type > & readOptionalDArray (std::istream &in, const char *label, DArray< Type > &array, int n)
 Add and read an optional DArray < Type > parameter.
template<typename Type, int N>
FArrayParam< Type, N > & readFArray (std::istream &in, const char *label, FArray< Type, N > &array)
 Add and read a required FArray < Type, N > array parameter.
template<typename Type, int N>
FArrayParam< Type, N > & readOptionalFArray (std::istream &in, const char *label, FArray< Type, N > &array)
 Add and read an optional FArray < Type, N > array parameter.
template<typename Type, int N>
FSArrayParam< Type, N > & readFSArray (std::istream &in, const char *label, FSArray< Type, N > &array, int size)
 Add and read a required FSArray < Type, N > array parameter.
template<typename Type, int N>
FSArrayParam< Type, N > & readOptionalFSArray (std::istream &in, const char *label, FSArray< Type, N > &array, int size)
 Add and read an optional FSArray < Type, N > array parameter.
template<typename Type>
CArray2DParam< Type > & readCArray2D (std::istream &in, const char *label, Type *value, int m, int n, int np)
 Add and read a required CArray2DParam < Type > 2D C-array.
template<typename Type>
CArray2DParam< Type > & readOptionalCArray2D (std::istream &in, const char *label, Type *value, int m, int n, int np)
 Add and read an optional CArray2DParam < Type > 2D C-array parameter.
template<typename Type>
DMatrixParam< Type > & readDMatrix (std::istream &in, const char *label, DMatrix< Type > &matrix, int m, int n)
 Add and read a required DMatrix < Type > matrix parameter.
template<typename Type>
DMatrixParam< Type > & readOptionalDMatrix (std::istream &in, const char *label, DMatrix< Type > &matrix, int m, int n)
 Add and read an optional DMatrix < Type > matrix parameter.
template<typename Type>
DSymmMatrixParam< Type > & readDSymmMatrix (std::istream &in, const char *label, DMatrix< Type > &matrix, int n)
 Add and read a required symmetrix DMatrix.
template<typename Type>
DSymmMatrixParam< Type > & readOptionalDSymmMatrix (std::istream &in, const char *label, DMatrix< Type > &matrix, int n)
 Add and read an optional DMatrix matrix parameter.
BeginreadBegin (std::istream &in, const char *label, bool isRequired=true)
 Add and read a class label and opening bracket.
EndreadEnd (std::istream &in)
 Add and read the closing bracket.
BlankreadBlank (std::istream &in)
 Add and read a new Blank object, representing a blank line.
void loadParamComposite (Serializable::IArchive &ar, ParamComposite &child, bool next=true)
 Add and load a required child ParamComposite.
void loadParamCompositeOptional (Serializable::IArchive &ar, ParamComposite &child, bool next=true)
 Add and load an optional child ParamComposite if isActive.
template<typename Type>
ScalarParam< Type > & loadParameter (Serializable::IArchive &ar, const char *label, Type &value, bool isRequired)
 Add and load a new ScalarParam < Type > object.
template<typename Type>
ScalarParam< Type > & loadParameter (Serializable::IArchive &ar, const char *label, Type &value)
 Add and load new required ScalarParam < Type > object.
template<typename Type>
CArrayParam< Type > & loadCArray (Serializable::IArchive &ar, const char *label, Type *value, int n, bool isRequired)
 Add a C array parameter and load its elements.
template<typename Type>
CArrayParam< Type > & loadCArray (Serializable::IArchive &ar, const char *label, Type *value, int n)
 Add and load a required CArrayParam< Type > array parameter.
template<typename Type>
DArrayParam< Type > & loadDArray (Serializable::IArchive &ar, const char *label, DArray< Type > &array, int n, bool isRequired)
 Add an load a DArray < Type > array parameter.
template<typename Type>
DArrayParam< Type > & loadDArray (Serializable::IArchive &ar, const char *label, DArray< Type > &array, int n)
 Add and load a required DArray< Type > array parameter.
template<typename Type, int N>
FArrayParam< Type, N > & loadFArray (Serializable::IArchive &ar, const char *label, FArray< Type, N > &array, bool isRequired)
 Add and load an FArray < Type, N > fixed-size array parameter.
template<typename Type, int N>
FArrayParam< Type, N > & loadFArray (Serializable::IArchive &ar, const char *label, FArray< Type, N > &array)
 Add and load a required FArray < Type > array parameter.
template<typename Type, int N>
FSArrayParam< Type, N > & loadFSArray (Serializable::IArchive &ar, const char *label, FSArray< Type, N > &array, int size, bool isRequired)
 Add and load an FSArray < Type, N > array parameter.
template<typename Type, int N>
FSArrayParam< Type, N > & loadFSArray (Serializable::IArchive &ar, const char *label, FSArray< Type, N > &array, int size)
 Add and load a required FSArray < Type > array parameter.
template<typename Type>
CArray2DParam< Type > & loadCArray2D (Serializable::IArchive &ar, const char *label, Type *value, int m, int n, int np, bool isRequired)
 Add and load a CArray2DParam < Type > C 2D array parameter.
template<typename Type>
CArray2DParam< Type > & loadCArray2D (Serializable::IArchive &ar, const char *label, Type *value, int m, int n, int np)
 Add and load a required < Type > matrix parameter.
template<typename Type>
DMatrixParam< Type > & loadDMatrix (Serializable::IArchive &ar, const char *label, DMatrix< Type > &matrix, int m, int n, bool isRequired)
 Add and load a DMatrixParam < Type > matrix parameter.
template<typename Type>
DMatrixParam< Type > & loadDMatrix (Serializable::IArchive &ar, const char *label, DMatrix< Type > &matrix, int m, int n)
 Add and load a required DMatrixParam < Type > matrix parameter.
template<typename Type>
DSymmMatrixParam< Type > & loadDSymmMatrix (Serializable::IArchive &ar, const char *label, DMatrix< Type > &matrix, int n, bool isRequired)
 Add and load a symmetric DSymmMatrixParam < Type > matrix parameter.
template<typename Type>
DSymmMatrixParam< Type > & loadDSymmMatrix (Serializable::IArchive &ar, const char *label, DMatrix< Type > &matrix, int n)
 Add and load a required DSymmMatrixParam < Type > matrix parameter.
void addParamComposite (ParamComposite &child, bool next=true)
 Add a child ParamComposite object to the format array.
BeginaddBegin (const char *label)
 Add a Begin object representing a class name and bracket.
EndaddEnd ()
 Add a closing bracket.
BlankaddBlank ()
 Create and add a new Blank object, representing a blank line.
std::string className () const
 Get class name string.
bool isRequired () const
 Is this ParamComposite required in the input file?
bool isActive () const
 Is this parameter active?
Public Member Functions inherited from Util::ParamComponent
virtual ~ParamComponent ()
 Destructor.
void setIndent (const ParamComponent &parent, bool next=true)
 Set indent level.
std::string indent () const
 Return indent string for this object (string of spaces).
template<class Archive>
void serialize (Archive &ar, const unsigned int version)
 Serialize this ParamComponent as a string.
Public Member Functions inherited from Util::Serializable
virtual ~Serializable ()
 Destructor.
Public Member Functions inherited from Util::MpiFileIo
 MpiFileIo ()
 Constructor.
 MpiFileIo (const MpiFileIo &other)
 Copy constructor.
bool isIoProcessor () const
 Can this processor do file I/O ?

Additional Inherited Members

Public Types inherited from Pscf::Rp::Simulator< D, Types< D > >
using RFieldT
 Container for a real-valued periodic field.
Public Types inherited from Util::Serializable
typedef BinaryFileOArchive OArchive
 Type of output archive used by save method.
typedef BinaryFileIArchive IArchive
 Type of input archive used by load method.
Static Public Member Functions inherited from Util::ParamComponent
static void initStatic ()
 Initialize static echo member to false.
static void setEcho (bool echo=true)
 Enable or disable echoing for all subclasses of ParamComponent.
static bool echo ()
 Get echo parameter.
Protected Member Functions inherited from Pscf::Rp::Simulator< D, Types< D > >
 Simulator (typename Types< D >::System &system, typename Types< D >::Simulator &simulator)
 Constructor.
 ~Simulator ()
 Destructor.
void readRandomSeed (std::istream &in)
 Optionally read a random seed and initialize RNGs.
virtual void initializeVecRandom ()
 Initialize the vector RNG.
Types< D >::CompressorFactory & compressorFactory ()
 Get the Compressor factory by reference.
void readCompressor (std::istream &in, bool &isEnd)
 Optionally read a Compressor parameter file block.
Types< D >::PerturbationFactory & perturbationFactory ()
 Get the Perturbation factory by reference.
void readPerturbation (std::istream &in, bool &isEnd)
 Optionally read a Perturbation parameter file block.
void setPerturbation (typename Types< D >::Perturbation *ptr)
 Set the associated Perturbation.
Types< D >::RampFactory & rampFactory ()
 Get the Ramp factory by reference.
void readRamp (std::istream &in, bool &isEnd)
 Optionally read a Ramp parameter file block.
void setRamp (typename Types< D >::Ramp *ptr)
 Set the associated Ramp.
Types< D >::SimState & state ()
 Get the SimState stored internal state by reference.
void setClassName (const char *className)
 Set class name string.
void setIsRequired (bool isRequired)
 Set or unset the isActive flag.
void setIsActive (bool isActive)
 Set or unset the isActive flag.
void setParent (ParamComponent &param, bool next=true)
 Set this to the parent of a child component.
void addComponent (ParamComponent &param, bool isLeaf=true)
 Add a new ParamComponent object to the format array.
template<typename Type>
ScalarParam< Type > & add (std::istream &in, const char *label, Type &value, bool isRequired=true)
 Add a new required ScalarParam < Type > object.
template<typename Type>
CArrayParam< Type > & addCArray (std::istream &in, const char *label, Type *value, int n, bool isRequired=true)
 Add (but do not read) a required C array parameter.
template<typename Type>
DArrayParam< Type > & addDArray (std::istream &in, const char *label, DArray< Type > &array, int n, bool isRequired=true)
 Add (but do not read) a DArray < Type > parameter.
template<typename Type, int N>
FArrayParam< Type, N > & addFArray (std::istream &in, const char *label, FArray< Type, N > &array, bool isRequired=true)
 Add (but do not read) a FArray < Type, N > array parameter.
template<typename Type, int N>
FSArrayParam< Type, N > & addFSArray (std::istream &in, const char *label, FSArray< Type, N > &array, int size, bool isRequired=true)
 Add (but do not read) a FSArray < Type, N > array parameter.
template<typename Type>
CArray2DParam< Type > & addCArray2D (std::istream &in, const char *label, Type *value, int m, int n, int np, bool isRequired=true)
 Add (but do not read) a CArray2DParam < Type > 2D C-array.
template<typename Type>
DMatrixParam< Type > & addDMatrix (std::istream &in, const char *label, DMatrix< Type > &matrix, int m, int n, bool isRequired=true)
 Add and read a required DMatrix < Type > matrix parameter.
Protected Member Functions inherited from Util::ParamComponent
 ParamComponent ()
 Constructor.
 ParamComponent (const ParamComponent &other)
 Copy constructor.
Protected Attributes inherited from Pscf::Rp::Simulator< D, Types< D > >
DArray< RFieldTwc_
 Eigenvector components of w fields on a real space grid.
DArray< RFieldTcc_
 Eigenvector components of c fields on a real space grid.
DArray< RFieldTdc_
 Components of d fields on a real space grid.
Types< D >::SimState state_
 Previous state saved at the beginning of a step.
double hamiltonian_
 Total field theoretic Hamiltonian H[W] (extensive value).
double idealHamiltonian_
 Ideal gas contribution (-lnQ) to Hamiltonian.
double fieldHamiltonian_
 Quadratic field contribution to Hamiltonian.
double perturbationHamiltonian_
 Perturbation contribution to the Hamiltonian.
long iStep_
 Step counter - number of steps for which the compressor converged.
long iTotalStep_
 Step counter - total number of attempted BD or MC steps.
long seed_
 Random number generator seed (input value).
bool hasHamiltonian_
 Has the Hamiltonian been computed for the current w and c fields?
bool hasWc_
 Have eigen-components of the current w fields been computed ?
bool hasCc_
 Have eigen-components of the current c fields been computed ?
bool hasDc_
 Have functional derivatives of H[W] been computed ?

Detailed Description

template<int D>
class Pscf::Rpc::Simulator< D >

Field theoretic simulator (base class).

Specializations of this template with D=1, 2, and 3 are derived from specializations of the base class template Rp::Simlator, and inherit their entire public interface and almost all of their source code from this base class. See the documentation of this base class template for details.

Specializations of this template serve as as base classes for Rpc::BdSimulation<D> and Rpc::McSimulation<D>, for D=1, 2, and 3. For information about parameter file formats for subclasses, see:

See also
MdSimulator manual page
McSimulator manual page

Definition at line 40 of file rpc/fts/simulator/Simulator.h.

Constructor & Destructor Documentation

◆ Simulator()

template<int D>
Pscf::Rpc::Simulator< D >::Simulator ( System< D > & system)

◆ ~Simulator()

template<int D>
virtual Pscf::Rpc::Simulator< D >::~Simulator ( )
virtualdefault

Destructor.

References Simulator().


The documentation for this class was generated from the following files: