PSCF v1.4.0
Pscf::Rp::SweepParameter< D, T > Class Template Reference

Class template for storing data about an individual sweep parameter. More...

#include <SweepParameter.h>

Public Member Functions

void setSystem (typename T::System &system)
 Set the system associated with this object.
void setParameterTypesArray (GArray< ParameterType > &array)
 Set the pointer to the array of specialized sweep parameter types.
ParameterTypeparameterType () const
 Get the ParameterType object for a specialized sweep parameter.
int parameterTypeId () const
 Get the array index for the specialized sweep parameter.
bool isSpecialized () const
 Is this SweepParameter a specialized parameter type?
void getInitial ()
 Get initial value of this parameter.
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 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 sweep.
template<class Archive>
void serialize (Archive ar, const unsigned int version)
 Serialize to or from an archive.

Protected Member Functions

 SweepParameter ()
 Default constructor.
 SweepParameter (typename T::System &system)
 Constructor - creates association with parent system.

Detailed Description

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

Class template for storing data about an individual sweep parameter.

Specializations of this class template are used as base classes for two closely analogous class templates, also named SweepParameter, that are defined in Rpc and Rpg namespaces and used in the pscf_rpc and pscf_rpg programs, respectively.

Template parameters:

This class stores the information required to sweep a single parameter value of any of several types. The type of parameter is indicated in the public interface and parameter file format by a string identifier with any of several allowed values. Each parameter is 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 subobject or array element with which the parameter is associated applied.

Allowed string representations and meanings of parameter types are shown in the table 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.

| 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 |
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 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 SweepParameter also has a "change" value that gives the intended difference between the final and initial value of the parameter over the course of a sweep, corresponding to a change sweep 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 sweep, and thus does not need to be supplied as part of the text format for a SweepParameter.

A SweepParameter<D> object is initialized by reading the parameter type, index or index and change value from a parameter file as a a single line. An overloaded >> operator is defined that allows a SweepParameter<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".

All of the parameter types in the table above are hard-coded into this class, but certain classes can also add "specialized" parameters to the list SweepTmpl::parameterTypes_ by using the function SweepTmpl::addParameterTypes. This list of specialized parameters is then consulted if the user-specified parameter type is not found in the list of hard-coded parameter names. In order to add parameters to SweepTmpl::parameterTypes_, a class must be a subclass of ParameterModifier.

Currently, the only classes that can add parameters to parameterTypes_ are Iterators. The Iterator for a given calculation is determined via a Factory, so the type of Iterator is not known until run time. Therefore, Iterators can add sweepable parameters to parameterTypes_ as necessary at run time, depending on the type of Iterator used in that calculation. As a design principle, an object that is created by a Factory and used for SCFT calculations should also be a subclass of ParameterModifier so that it can add sweepable parameters at run time.

Definition at line 115 of file rp/scft/sweep/SweepParameter.h.

Constructor & Destructor Documentation

◆ SweepParameter() [1/2]

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

Default constructor.

Definition at line 32 of file SweepParameter.tpp.

References SweepParameter().

Referenced by SweepParameter(), and SweepParameter().

◆ SweepParameter() [2/2]

template<int D, class T>
Pscf::Rp::SweepParameter< D, T >::SweepParameter ( typename T::System & system)
protected

Constructor - creates association with parent system.

Parameters
systemparent system

Definition at line 47 of file SweepParameter.tpp.

References SweepParameter().

Member Function Documentation

◆ setSystem()

template<int D, class T>
void Pscf::Rp::SweepParameter< D, T >::setSystem ( typename T::System & system)
inline

Set the system associated with this object.

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

Parameters
systemparent system

Definition at line 128 of file rp/scft/sweep/SweepParameter.h.

◆ setParameterTypesArray()

template<int D, class T>
void Pscf::Rp::SweepParameter< D, T >::setParameterTypesArray ( GArray< ParameterType > & array)
inline

Set the pointer to the array of specialized sweep parameter types.

Parameters
arrayarray of specialized parameter types

Definition at line 136 of file rp/scft/sweep/SweepParameter.h.

◆ parameterType()

template<int D, class T>
ParameterType & Pscf::Rp::SweepParameter< D, T >::parameterType ( ) const

Get the ParameterType object for a specialized sweep parameter.

An error will result if this SweepParameter is not specialized and this function is called.

Definition at line 134 of file SweepParameter.tpp.

References isSpecialized(), and UTIL_CHECK.

◆ parameterTypeId()

template<int D, class T>
int Pscf::Rp::SweepParameter< D, T >::parameterTypeId ( ) const
inline

Get the array index for the specialized sweep parameter.

Definition at line 150 of file rp/scft/sweep/SweepParameter.h.

◆ isSpecialized()

template<int D, class T>
bool Pscf::Rp::SweepParameter< D, T >::isSpecialized ( ) const
inline

Is this SweepParameter a specialized parameter type?

Definition at line 156 of file rp/scft/sweep/SweepParameter.h.

Referenced by parameterType().

◆ getInitial()

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

Get initial value of this parameter.

This function is called before a sweep begins, and simply gets current values of this parameter.

Definition at line 145 of file SweepParameter.tpp.

◆ update()

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

Update the corresponding parameter value in the system.

Parameters
newValnew value for this parameter (input)

Definition at line 152 of file SweepParameter.tpp.

◆ type()

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

Return a string representation of the parameter type.

Definition at line 159 of file SweepParameter.tpp.

Referenced by writeParamType().

◆ writeParamType()

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

Write the parameter type to an output stream.

Parameters
outoutput file stream

Definition at line 127 of file SweepParameter.tpp.

References type().

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

◆ id()

template<int D, class T>
int Pscf::Rp::SweepParameter< 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 this array store indices associating the parameter with a particular subobject or array element. 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 197 of file rp/scft/sweep/SweepParameter.h.

References UTIL_CHECK.

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

◆ nId()

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

Number of indices associated with this parameter.

See documentation of id(int).

Definition at line 209 of file rp/scft/sweep/SweepParameter.h.

◆ current()

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

Get the current system parameter value.

Definition at line 215 of file rp/scft/sweep/SweepParameter.h.

◆ initial()

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

Get the initial system parameter value.

Definition at line 221 of file rp/scft/sweep/SweepParameter.h.

◆ change()

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

Get the total change planned for this parameter during sweep.

Definition at line 227 of file rp/scft/sweep/SweepParameter.h.

◆ serialize()

template<int D, class T>
template<class Archive>
void Pscf::Rp::SweepParameter< 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 320 of file rp/scft/sweep/SweepParameter.h.

References Util::serializeEnum().


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