|
PSCF v1.4.0
|
Base class template for a complex CL-FTS system. More...
#include <System.h>
Public Member Functions | |
Construction and Destruction | |
| System (typename T::System &system) | |
| Constructor. | |
| ~System () | |
| Destructor. | |
Lifetime Actions | |
| void | setOptions (int argc, char **argv) |
| Process command line options. | |
| virtual void | readParam (std::istream &in) |
| Read input parameters (with opening and closing lines). | |
| void | readParam () |
| Read input parameters from default param file. | |
| virtual void | readParameters (std::istream &in) |
| Read body of parameter block (without opening and closing lines). | |
| void | readCommands (std::istream &in) |
| Read and process commands from an input stream. | |
| void | readCommands () |
| Read and process commands from the default command file. | |
Field Theory Computations | |
| void | compute (bool needStress=false) |
| Solve the modified diffusion equation once, without iteration. | |
| void | simulate (int nStep) |
| Perform a field theoretic simulation (PS-FTS). | |
| void | clearCFields () |
| Mark c-fields and free energy as outdated or invalid. | |
Unit Cell Modifiers | |
| void | setUnitCell (UnitCell< D > const &unitCell) |
| Set parameters of the associated unit cell. | |
| void | setUnitCell (FSArray< double, 6 > const ¶meters) |
| Set parameters of the associated unit cell. | |
| void | clearUnitCellData () |
| Notify System members that unit cell parameters have been modified. | |
Field Containers | |
| T::CFields const & | c () const |
| Get the monomer concentration (c) fields (const). | |
| T::WFields & | w () |
| Get the chemical potential (w) fields (non-const). | |
| T::WFields const & | w () const |
| Get the chemical potential (w) fields (const). | |
Component Object Accessors | |
| T::Mixture const & | mixture () const |
| Get the Mixture (const). | |
| T::Interaction & | interaction () |
| Get the Interaction (non-const). | |
| T::Interaction const & | interaction () const |
| Get the Interaction (const). | |
| T::Domain const & | domain () const |
| Get the Domain (const). | |
| FileMaster & | fileMaster () |
| Get the FileMaster (non-const). | |
| FileMaster const & | fileMaster () const |
| Get the FileMaster (const). | |
| 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 | 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. | |
| Begin & | readBegin (std::istream &in, const char *label, bool isRequired=true) |
| Add and read a class label and opening bracket. | |
| End & | readEnd (std::istream &in) |
| Add and read the closing bracket. | |
| Blank & | readBlank (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. | |
| Begin & | addBegin (const char *label) |
| Add a Begin object representing a class name and bracket. | |
| End & | addEnd () |
| Add a closing bracket. | |
| Blank & | addBlank () |
| 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 ? | |
Protected Member Functions | |
| virtual void | setThreadCount (int nThread) |
| Set the number of threads given as a command line argument. | |
| 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 ¶m, bool next=true) |
| Set this to the parent of a child component. | |
| void | addComponent (ParamComponent ¶m, 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. | |
Additional Inherited Members | |
| 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. | |
Base class template for a complex CL-FTS system.
Template parameters and typename aliases:
D - integer dimensionality of space (D=1, 2, or 3) T - "Types" class collection of aliases for related classes
Usage : A specialization of System<D, T> is used as a base class for System<D> classes defined in namespaces Cpc and Cpg, for D=1, 2, or 3. In this usage, template parameter T must be a specialization named Types<D> of a template <int D> class Types that is defined in each of these two namespaces. For example, in namespace Cpc, for each value of D, class Cpc::System<D> is derived from the class Prdc::System< D, Cpc::Types<D> >. For each such program level namespace, Types<D> defines a set of of typename aliases for classes used in that namespace, for the specified value of D. For example, the typename Cpc::Types<D>Mixture is an alias for the type Cpc::Mixture<D> used to represent a mixture in the Cpc namespace for systems of dimension D. See the definitions of Cpc::Types and Cpg::Types for details.
In the remainder of the documentation for this template, Cp::System, unqualified names such as "Mixture", "Iterator", etc. are often used as shorthand for typename aliases such as T::Mixture, T::Iterator that are defined in class T (i.e., in Cpc::Types<D> or Cpg::Types<D>)
Class Components : A System object has:
Definition at line 73 of file cp/system/System.h.
| Pscf::Cp::System< D, T >::System | ( | typename T::System< D, T > & | system | ) |
Constructor.
When a specialization of System<D,T> is used as a base class for a concrete System class, such as Cpc::System<D>, the typename T::System must be an alias for the name of the subclass. In this usage, in the member initialization list of the T::System subclass constructor, a reference to the subclass instance must be passed as "*this" to this System base class constructor. The address of the instance of the T::System subclass is then retained in the Cp::System base class instance by a private member variable named systemPtr_ that is of type T::System* . See definitions of the constructors for the Cpc::System and Cpc::System class templates for examples of this usage.
| system | instance of System subclass |
Definition at line 41 of file cp/system/System.tpp.
References Util::Signal< T >::addObserver(), clearCFields(), clearUnitCellData(), Util::BracketPolicy::set(), and Util::ParamComposite::setClassName().
| Pscf::Cp::System< D, T >::~System | ( | ) |
Destructor.
Definition at line 104 of file cp/system/System.tpp.
| void Pscf::Cp::System< D, T >::setOptions | ( | int | argc, |
| char ** | argv ) |
Process command line options.
This function takes the same arguments as any C/C++ main program function. The arguments of the main function should d be passed to this function unaltered, to allow this function to process the command line options.
| argc | number of command line arguments |
| argv | array of pointers to command line arguments |
Definition at line 123 of file cp/system/System.tpp.
|
virtual |
Read input parameters (with opening and closing lines).
| in | input parameter stream |
Reimplemented from Util::ParamComposite.
Definition at line 303 of file cp/system/System.tpp.
References Util::ParamComposite::className(), Util::ParamComposite::readBegin(), Util::ParamComposite::readEnd(), and readParameters().
Referenced by readParam().
| void Pscf::Cp::System< D, T >::readParam | ( | ) |
Read input parameters from default param file.
This function reads the parameter file set by the -p command line option.
Definition at line 314 of file cp/system/System.tpp.
References fileMaster(), and readParam().
|
virtual |
Read body of parameter block (without opening and closing lines).
| in | input parameter stream |
Reimplemented from Util::ParamComposite.
Definition at line 228 of file cp/system/System.tpp.
References Pscf::PolymerModel::isLocked(), Util::ParamComposite::readOptional(), and Pscf::PolymerModel::setModel().
Referenced by readParam().
| void Pscf::Cp::System< D, T >::readCommands | ( | std::istream & | in | ) |
Read and process commands from an input stream.
| in | command script input stream |
Definition at line 321 of file cp/system/System.tpp.
References c(), compute(), Util::Log::file(), fileMaster(), setUnitCell(), simulate(), UTIL_CHECK, w(), and Util::ParamComposite::writeParam().
Referenced by readCommands().
| void Pscf::Cp::System< D, T >::readCommands | ( | ) |
Read and process commands from the default command file.
This function reads the parameter file set by the -c command line option.
Definition at line 474 of file cp/system/System.tpp.
References fileMaster(), readCommands(), and UTIL_THROW.
| void Pscf::Cp::System< D, T >::compute | ( | bool | needStress = false | ) |
Solve the modified diffusion equation once, without iteration.
This function calls the Mixture::compute() function to solve the statistical mechanics problem for a non-interacting system subjected to the currrent system chemical potential fields. This requires solution of the modified diffusion equation for all polymers, computation of Boltzmann weights for all solvents, computation of molecular partition functions for all species, computation of concentration fields for all blocks and solvents, and computation of overall concentrations for all monomer types. This function does not compute the canonical (Helmholtz) free energy or grand-canonical free energy (i.e., pressure).
This function also computes the stress, by calling computeStress(), if and only if the argument needStress is true.
| needStress | true if stress is needed, false otherwise |
Definition at line 488 of file cp/system/System.tpp.
References clearCFields(), and UTIL_CHECK.
Referenced by readCommands().
| void Pscf::Cp::System< D, T >::simulate | ( | int | nStep | ) |
Perform a field theoretic simulation (PS-FTS).
Perform a complex Langevin field theoretic simulation (Cl-FTS). The number of CL steps to be performed is given by the parameter "nStep".
| nStep | number of simulation (BD or MC) steps |
Referenced by readCommands().
| void Pscf::Cp::System< D, T >::clearCFields | ( | ) |
Mark c-fields and free energy as outdated or invalid.
This function should be called whenever any of the inputs to the solution of the modified diffusion equation are modified, including the w fields or unit cell parameters. Upon return, c().hasData() will return false.
Definition at line 522 of file cp/system/System.tpp.
Referenced by clearUnitCellData(), compute(), and System().
| void Pscf::Cp::System< D, T >::setUnitCell | ( | UnitCell< D > const & | unitCell | ) |
Set parameters of the associated unit cell.
The lattice (i.e., lattice system type) set in the UnitCell<D> unitCell input parameter must agree with the lattice enum value that was set previously in the parameter file.
If a space group has been declared but a basis has not yet been initialized, then a symmetry-adapted basis will be constructed.
| unitCell | new UnitCell<D> (with new parameters) |
Definition at line 531 of file cp/system/System.tpp.
References UTIL_CHECK.
Referenced by readCommands().
| void Pscf::Cp::System< D, T >::setUnitCell | ( | FSArray< double, 6 > const & | parameters | ) |
Set parameters of the associated unit cell.
The lattice type must have been set before this function is called. The logical size of the FSArray<double, 6> "parameters" array must match the expected number of parameters for the current lattice type.
If a space group has been declared but a basis has not yet been initialized, then a symmetry-adapted basis will be constructed.
| parameters | array of new unit cell parameters |
Definition at line 550 of file cp/system/System.tpp.
References UTIL_CHECK.
| void Pscf::Cp::System< D, T >::clearUnitCellData | ( | ) |
Notify System members that unit cell parameters have been modified.
This function should be called whenever the unit cell parameters are modified. It calls functions mixture().clearUnitCellData(), domain().wavelist().clearUnitCellData(), and clearCFields().
Definition at line 572 of file cp/system/System.tpp.
References clearCFields().
Referenced by System().
|
inline |
Get the monomer concentration (c) fields (const).
Definition at line 559 of file cp/system/System.h.
Referenced by readCommands().
|
inline |
Get the chemical potential (w) fields (non-const).
Definition at line 564 of file cp/system/System.h.
Referenced by readCommands().
|
inline |
Get the chemical potential (w) fields (const).
Definition at line 569 of file cp/system/System.h.
|
inline |
Get the Mixture (const).
Definition at line 495 of file cp/system/System.h.
|
inline |
Get the Interaction (non-const).
Definition at line 510 of file cp/system/System.h.
References UTIL_ASSERT.
|
inline |
Get the Interaction (const).
Definition at line 518 of file cp/system/System.h.
References UTIL_ASSERT.
|
inline |
Get the Domain (const).
Definition at line 526 of file cp/system/System.h.
|
inline |
Get the FileMaster (non-const).
Access (non-const) is used in some unit tests.
Definition at line 549 of file cp/system/System.h.
Referenced by readCommands(), readCommands(), and readParam().
|
inline |
Get the FileMaster (const).
Definition at line 554 of file cp/system/System.h.
|
inlineprotectedvirtual |
Set the number of threads given as a command line argument.
This function is called in the setOpts function that processes command line arguments. The argument nThread may be passed to the main program as the argument of the -t option. This value gives the number of threads in a threaded CPU implementation or an explicit choice for the maximum number of threads per block in GPU code.
The do-nothing default implementation is used by CPU code that has not implemented threading (the current status).
| nThread | thread count |
Definition at line 377 of file cp/system/System.h.