PSCF v1.5.0
Pscf::Rp::RampParameter< D, T > Class Template Reference

Data about an individual linear ramp parameter. More...

#include <RampParameter.h>

Public Member Functions

 RampParameter ()
 Default constructor.
 RampParameter (Simulator< D, T > &simulator)
 Constructor that stores a pointer to parent Simulator.
 ~RampParameter ()=default
 Destructor.
void setSimulator (Simulator< D, T > &simulator)
 Set the simulator and system associated with this object.
void getInitial ()
 Get and store initial value this parameters.
void checkIds () const
 Check that any indices of this parameter are in range.
void update (double newVal)
 Update the corresponding parameter value in the System.
std::string type () const
 Return a string representation of the parameter type.
void writeParamType (std::ostream &out) const
 Write the parameter type to an output stream.
int id (int i) const
 Get id for a sub-object or element to which this is applied.
int nId () const
 Number of indices associated with this type of parameter.
double current ()
 Get the current system parameter value.
double initial () const
 Get the initial system parameter value.
double change () const
 Get the total change planned for this parameter during ramp.
template<class Archive>
void serialize (Archive &ar, const unsigned int version)
 Serialize to or from an archive.

Detailed Description

template<int D, class T>
class Pscf::Rp::RampParameter< D, T >

Data about an individual linear ramp parameter.

Template parameters:

  • D : dimension
  • T : backend identifier class (CPT or CUT)

This class template stores information required to ramp a single parameter value of any of several types. The parameter type is indicated in the public interface and parameter file format by a string identifier with any of several allowed values. Most types of parameter are also identified by one or two associated index values, denoted here by id(0) and id(1), that specify the index or indices for a sub-object or array element with which the parameter is associated.

Allowed string representations and meanings of parameter types are specified below, along with the meaning of any associated index value or pair of values. To indicate the meaning of index values, we use mId to denote a monomer type index, pId to denote a polymer species index, bId to denote the index of a block within a polymer, sId to denote a solvent species index, and lId to denote a lattice parameter index. The lambda_pert and vMonomer parameter types do not take an index.

| Type | Meaning | id(0) | id(1)
| ----------- | ---------------------------------- | ----- | -----
| kuhn | monomer segment length | mId |
| chi | Flory-Huggins parameter | mId | mId
| block | block length | pId | bId
| solvent | solvent size | sId |
| phi_polymer | polymer volume fraction | pId |
| mu_polymer | polymer chemical potential | pId |
| phi_solvent | solvent volume fraction | sId |
| mu_solvent | solvent chemical potential | sId |
| cell_param | lattice parameter | lId |
| v_monomer | monomer reference volume | - |
| lambda_pert | perturbation parameter | - |
int id(int i) const
Get id for a sub-object or element to which this is applied.

The two indices for a Flory-Huggins chi parameter refer to indices in the chi matrix maintained by an Interaction. Changes to element chi(i, j) automatically also update chi(j, i) for i !\ j, thus maintaining the symmetry of the chi matrix.

Each RampParameter also has a "change" value that gives the intended difference between the final and initial value of the parameter over the course of a ramp, corresponding to a change ramp parameter s over the range [0,1]. The initial value of each parameter is obtained from a query of the state of the parent system at the beginning of a ramp, and thus does not need to be supplied as part of the text format for a RampParameter.

A RampParameter<D> object is initialized by reading the parameter type, index or indices (if any) and change value from a parameter file as a a single line. An overloaded >> operator is defined that allows a RampParameter<D> object named "parameter" to be read from an istream named "in" using the syntax "in >> parameter".

The text format for a parameter of a type that requires a single index id(0) is:

type id(0) change

where type indicates a type string, id(0) is an integer index value, and change is the a floating point value for the change in parameter value. The corresponding format for a parameter that requires two indices (e.g., block or chi) is instead: "type id(0) id(1) change".

See also
Manual Page

Definition at line 105 of file RampParameter.h.

Constructor & Destructor Documentation

◆ RampParameter() [1/2]

template<int D, class T>
Pscf::Rp::RampParameter< D, T >::RampParameter ( )

Default constructor.

Definition at line 41 of file RampParameter.tpp.

References RampParameter().

Referenced by RampParameter(), and RampParameter().

◆ RampParameter() [2/2]

template<int D, class T>
Pscf::Rp::RampParameter< D, T >::RampParameter ( Simulator< D, T > & simulator)

Constructor that stores a pointer to parent Simulator.

Parameters
simulatorparent Simulator

Definition at line 55 of file RampParameter.tpp.

References RampParameter().

◆ ~RampParameter()

template<int D, class T>
Pscf::Rp::RampParameter< D, T >::~RampParameter ( )
default

Member Function Documentation

◆ setSimulator()

template<int D, class T>
void Pscf::Rp::RampParameter< D, T >::setSimulator ( Simulator< D, T > & simulator)

Set the simulator and system associated with this object.

Invoke this function on objects created with the default constructor to create an association with a parent simulator and system.

Parameters
simulatorparent simulator

Definition at line 69 of file RampParameter.tpp.

References Pscf::Rp::Simulator< D, T >::system().

Referenced by ~RampParameter().

◆ getInitial()

template<int D, class T>
void Pscf::Rp::RampParameter< D, T >::getInitial ( )

Get and store initial value this parameters.

This function is called before a ramp begins. It checks the indices of this parameter (see checkIds) and gets the current value of this parameter.

Definition at line 147 of file RampParameter.tpp.

References checkIds().

Referenced by ~RampParameter().

◆ checkIds()

template<int D, class T>
void Pscf::Rp::RampParameter< D, T >::checkIds ( ) const

Check that any indices of this parameter are in range.

Throws an Exception if a polymer, block, solvent, monomer or lattice parameter index is not in the range of valid index values for the parent system.

Definition at line 159 of file RampParameter.tpp.

References Pscf::PolymerSpecies< WT >::nBlock(), Pscf::Composition< WT >::nMonomer(), Pscf::Composition< WT >::nPolymer(), Pscf::Composition< WT >::nSolvent(), Pscf::Rp::Mixture< D, T >::polymer(), and UTIL_CHECK.

Referenced by getInitial(), and ~RampParameter().

◆ update()

template<int D, class T>
void Pscf::Rp::RampParameter< D, T >::update ( double newVal)

Update the corresponding parameter value in the System.

Parameters
newValnew value for this parameter (input)

Definition at line 201 of file RampParameter.tpp.

Referenced by ~RampParameter().

◆ type()

template<int D, class T>
std::string Pscf::Rp::RampParameter< D, T >::type ( ) const

Return a string representation of the parameter type.

Definition at line 208 of file RampParameter.tpp.

References Pscf::PolymerModel::isThread(), UTIL_CHECK, and UTIL_THROW.

Referenced by writeParamType(), and ~RampParameter().

◆ writeParamType()

template<int D, class T>
void Pscf::Rp::RampParameter< D, T >::writeParamType ( std::ostream & out) const

Write the parameter type to an output stream.

Parameters
outoutput file stream

Definition at line 139 of file RampParameter.tpp.

References type().

Referenced by Pscf::Rp::operator<<(), and ~RampParameter().

◆ id()

template<int D, class T>
int Pscf::Rp::RampParameter< D, T >::id ( int i) const
inline

Get id for a sub-object or element to which this is applied.

This function returns a value from the id_ array. Elements of array store indices associating with a parameter value, which may, for example, identify a molecule type index, one or more monomer type indices or a unit cell parameter index.

Different types of parameters require either 1 or 2 such identifiers. The number of required identifiers is returned by the function nId().

Parameters
iarray index to access

Definition at line 189 of file RampParameter.h.

References UTIL_CHECK.

Referenced by Pscf::Rp::operator<<().

◆ nId()

template<int D, class T>
int Pscf::Rp::RampParameter< D, T >::nId ( ) const
inline

Number of indices associated with this type of parameter.

See documentation of id(int).

Definition at line 200 of file RampParameter.h.

◆ current()

template<int D, class T>
double Pscf::Rp::RampParameter< D, T >::current ( )
inline

Get the current system parameter value.

Definition at line 206 of file RampParameter.h.

◆ initial()

template<int D, class T>
double Pscf::Rp::RampParameter< D, T >::initial ( ) const
inline

Get the initial system parameter value.

Definition at line 212 of file RampParameter.h.

◆ change()

template<int D, class T>
double Pscf::Rp::RampParameter< D, T >::change ( ) const
inline

Get the total change planned for this parameter during ramp.

Definition at line 218 of file RampParameter.h.

◆ serialize()

template<int D, class T>
template<class Archive>
void Pscf::Rp::RampParameter< D, T >::serialize ( Archive & ar,
const unsigned int version )

Serialize to or from an archive.

Parameters
arArchive object
versionarchive format version index

Definition at line 322 of file RampParameter.h.

References Util::serializeEnum().


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