SSAGES
0.1
A MetaDynamics Package
|
Basis Function Sampling Algorithm. More...
#include <BasisFunc.h>
Public Member Functions | |
Basis (const MPI_Comm &world, const MPI_Comm &comm, Histogram< int > *hist, const std::vector< unsigned int > &polyord, const std::vector< double > &restraint, const std::vector< double > &boundUp, const std::vector< double > &boundLow, unsigned int cyclefreq, unsigned int frequency, const std::string bnme, const std::string cnme, const double temperature, const double tol, const double weight, bool converge) | |
Constructor. More... | |
void | PreSimulation (Snapshot *snapshot, const class CVManager &cvmanager) override |
Pre-simulation hook. More... | |
void | PostIntegration (Snapshot *snapshot, const class CVManager &cvmanager) override |
Post-integration hook. More... | |
void | PostSimulation (Snapshot *snapshot, const class CVManager &cvmanager) override |
Post-simulation hook. More... | |
void | SetIteration (const int iter) |
Set the current iteration. More... | |
void | SetBasis (const std::vector< double > &coeff, std::vector< double > &unbias) |
Set the values for the basis. More... | |
~Basis () | |
Destructor. | |
![]() | |
Method (uint frequency, const MPI_Comm &world, const MPI_Comm &comm) | |
Constructor. More... | |
void | SetCVMask (const std::vector< uint > &mask) |
Sets the collective variable mask. | |
virtual | ~Method () |
Destructor. | |
![]() | |
EventListener (uint frequency) | |
Constructor. More... | |
uint | GetFrequency () const |
Get frequency of event listener. More... | |
virtual | ~EventListener () |
Destructor. | |
Static Public Member Functions | |
static Basis * | Build (const Json::Value &json, const MPI_Comm &world, const MPI_Comm &comm, const std::string &path) |
![]() | |
static Method * | BuildMethod (const Json::Value &json, const MPI_Comm &world, const MPI_Comm &comm, const std::string &path) |
Build a derived method from JSON node. More... | |
Private Member Functions | |
void | UpdateBias (const CVList &cvs, const double) |
Updates the bias projection of the PMF. More... | |
void | CalcBiasForce (const CVList &cvs) |
Computes the bias force. More... | |
void | PrintBias (const CVList &cvs, const double beta) |
Prints the current bias to a defined file from the JSON. More... | |
void | BasisInit (const CVList &cvs) |
Initializes the look up tables for polynomials. More... | |
Private Attributes | |
Histogram< int > * | hist_ |
Histogram of visited states. More... | |
std::vector< Map > | coeff_ |
Globally located coefficient values. More... | |
std::vector< double > | unbias_ |
The biased histogram of states. More... | |
std::vector< double > | coeff_arr_ |
The coefficient array for restart runs. | |
std::vector< BasisLUT > | LUT_ |
The Basis set lookup table, also defined globally. | |
std::vector< double > | derivatives_ |
Derivatives of the bias potential. More... | |
std::vector< unsigned int > | polyords_ |
The order of the basis polynomials. | |
std::vector< double > | restraint_ |
Spring constants for restrained system. More... | |
std::vector< double > | boundUp_ |
Upper position of the spring restraint. | |
std::vector< double > | boundLow_ |
Lower position of the spring restraint. | |
unsigned int | cyclefreq_ |
Frequency of coefficient updates. | |
unsigned int | mpiid_ |
The node that the current system belongs to, primarily for printing and debugging. | |
double | weight_ |
Weighting for potentially faster sampling. More... | |
double | temperature_ |
Self-defined temperature. More... | |
double | tol_ |
The tolerance criteria for the system . | |
bool | bounds_ |
A variable to check to see if the simulation is in bounds or not. | |
bool | converge_exit_ |
A check to see if you want the system to end when it reaches the convergence criteria. | |
std::ofstream | basisout_ |
Output stream for basis projection data. | |
std::ofstream | coeffout_ |
Output stream for coefficients (for reading purposes) | |
std::string | bnme_ |
std::string | cnme_ |
Coefficient filename. | |
uint | iteration_ |
Iteration counter. | |
Additional Inherited Members | |
![]() | |
mxx::comm | world_ |
Global MPI communicator. | |
mxx::comm | comm_ |
Local MPI communicator. | |
std::vector< uint > | cvmask_ |
Mask which identifies which CVs to act on. | |
Basis Function Sampling Algorithm.
Implementation of the Basis Function Sampling Method based on [4].
Definition at line 89 of file BasisFunc.h.
|
inline |
Constructor.
world | MPI global communicator. |
comm | MPI local communicator. |
polyord | Order of Legendre polynomials. |
restraint | Restraint spring constants. |
boundUp | Upper bounds of restraint springs. |
boundLow | Lower bounds of restraint springs. |
cyclefreq | Cycle frequency. |
frequency | Frequency with which this Method is applied. |
bnme | Basis file name. |
cnme | Coefficient file name. |
temperature | Automatically set temperature. |
tol | Threshold for tolerance criterion. |
weight | Weight for improved sampling. |
converge | If True quit on convergence. |
Constructs an instance of the Basis function sampling method. The coefficients describes the basis projection of the system. This is updated once every cyclefreq_. For now, only the Legendre polynomial is implemented. Others will be added later.
Definition at line 240 of file BasisFunc.h.
|
private |
Initializes the look up tables for polynomials.
cvs | List of collective variables. |
Definition at line 198 of file BasisFunc.cpp.
|
static |
Definition at line 521 of file BasisFunc.cpp.
References Json::Requirement::GetErrors(), Json::Requirement::HasErrors(), Json::ObjectRequirement::Parse(), and Json::ObjectRequirement::Validate().
|
private |
Computes the bias force.
cvs | List of collective variables. |
Definition at line 440 of file BasisFunc.cpp.
|
overridevirtual |
Post-integration hook.
snapshot | Simulation snapshot. |
cvmanager | Collective variable manager. |
Implements SSAGES::Method.
Definition at line 124 of file BasisFunc.cpp.
References SSAGES::CVManager::GetCVs(), SSAGES::Snapshot::GetForces(), SSAGES::Snapshot::GetIteration(), SSAGES::Snapshot::GetKb(), SSAGES::Snapshot::GetTemperature(), and SSAGES::Snapshot::GetVirial().
|
overridevirtual |
Post-simulation hook.
snapshot | Simulation snapshot. |
cvmanager | Collective variable manager. |
Implements SSAGES::Method.
Definition at line 190 of file BasisFunc.cpp.
|
overridevirtual |
Pre-simulation hook.
snapshot | Simulation snapshot. |
cvmanager | Collective variable manager. |
Resize the polynomial vector so that it doesn't crash here
And now reinitialize the vector
Implements SSAGES::Method.
Definition at line 36 of file BasisFunc.cpp.
References SSAGES::CVManager::GetCVs(), and SSAGES::Snapshot::GetWalkerID().
|
private |
Prints the current bias to a defined file from the JSON.
cvs | List of collective variables. |
beta | Scale parameter. |
Definition at line 365 of file BasisFunc.cpp.
References SSAGES::Histogram< T >::begin().
|
inline |
Set the values for the basis.
coeff | List of coefficients. |
unbias | List of unbiased values. |
This function is used to set starting values at the beginning of a run. For example when continuing from a restart value.
Definition at line 305 of file BasisFunc.h.
References coeff_arr_, and unbias_.
|
inline |
Set the current iteration.
iter | New value for the current iteration. |
This function is used to set the current iteration, for example when continuing from a restart.
Definition at line 292 of file BasisFunc.h.
References iteration_.
|
private |
Updates the bias projection of the PMF.
cvs | List of collective variables. |
beta | Temperature equivalent. |
Definition at line 244 of file BasisFunc.cpp.
References SSAGES::Histogram< T >::begin(), and SSAGES::GridBase< T >::data().
|
private |
The option to name both the basis and coefficient files will be given Basis filename
Definition at line 209 of file BasisFunc.h.
|
private |
Globally located coefficient values.
As coefficients are updated at the same time, the coefficients should only be defined globally.
Definition at line 104 of file BasisFunc.h.
|
private |
Derivatives of the bias potential.
The derivatives of the bias potential imposed on the system. They are evaluated by using the lookup table.
Definition at line 125 of file BasisFunc.h.
|
private |
Histogram of visited states.
Histogram is stored locally.
Definition at line 97 of file BasisFunc.h.
Referenced by ~Basis().
|
private |
Spring constants for restrained system.
The system uses this to determine if the system is to be restrained on the defined interval. The user inputs the spring constants if the system is not periodic.
Definition at line 136 of file BasisFunc.h.
|
private |
Self-defined temperature.
In the case of the MD engine using a poorly defined temperature, the option to throw it into the method is available. If not provided it takes the value from the engine.
Definition at line 164 of file BasisFunc.h.
|
private |
The biased histogram of states.
The biased histogram of states has the form hist_*exp(phi*beta), where phi is the bias potential and beta is the inverse of the temperature. It is defined globally.
Definition at line 112 of file BasisFunc.h.
Referenced by SetBasis().
|
private |
Weighting for potentially faster sampling.
Weighting can be used to potentially sample faster, however it can cause the simulation to explode. By default this value will be set to 1.0
Definition at line 156 of file BasisFunc.h.