SSAGES
0.9.3
Software Suite for Advanced General Ensemble Simulations
|
ForwardFlux sampling method. More...
#include <ForwardFlux.h>
Classes | |
class | FFSConfigID |
Nested class to store different FFS Config IDs. More... | |
Public Member Functions | |
ForwardFlux (const MPI_Comm &world, const MPI_Comm &comm, double ninterfaces, std::vector< double > interfaces, unsigned int N0Target, std::vector< unsigned int > M, bool initialFluxFlag, bool saveTrajectories, unsigned int currentInterface, std::string output_directory, unsigned int frequency) | |
Constructor. More... | |
void | PreSimulation (Snapshot *snapshot, const class CVManager &cvmanager) override |
Method call prior to simulation initiation. More... | |
virtual void | PostIntegration (Snapshot *snapshot, const class CVManager &cvmanager) override=0 |
Method call post integration. More... | |
void | PostSimulation (Snapshot *snapshot, const class CVManager &cvmanager) override |
Method call post simulation. More... | |
Public Member Functions inherited from SSAGES::Method | |
Method (unsigned int frequency, const MPI_Comm &world, const MPI_Comm &comm) | |
Constructor. More... | |
void | SetCVMask (const std::vector< unsigned int > &mask) |
Sets the collective variable mask. More... | |
virtual | ~Method () |
Destructor. | |
Public Member Functions inherited from SSAGES::EventListener | |
EventListener (unsigned int frequency) | |
Constructor. More... | |
unsigned int | GetFrequency () const |
Get frequency of event listener. More... | |
virtual | ~EventListener () |
Destructor. | |
Static Public Member Functions | |
static ForwardFlux * | Build (const Json::Value &json, const MPI_Comm &world, const MPI_Comm &comm, const std::string &path) |
Build a derived method from JSON node. More... | |
Static Public Member Functions inherited from SSAGES::Method | |
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... | |
Static Public Member Functions inherited from SSAGES::EventListener | |
static unsigned int | GetWalkerID (const MPI_Comm &world, const MPI_Comm &comm) |
Get walker ID number of specified communicator. More... | |
static unsigned int | GetNumWalkers (const MPI_Comm &world, const MPI_Comm &comm) |
Get total number of walkers in the simulation. More... | |
static bool | IsMasterRank (const MPI_Comm &comm) |
Check if current processor is master. More... | |
Protected Member Functions | |
void | CheckInitialStructure (const CVList &) |
Function that checks the initial structure that user provides. | |
void | WriteInitialFlux () |
Function to compute and write the initial flux. | |
void | AddNewIDsToQueue () |
bool | HasReturnedToA (double current) |
Function checks if configuration has returned to A. More... | |
int | HasCrossedInterface (double current, double prev, unsigned int i) |
Function checks if configuration has crossed interface specified since the last check. More... | |
void | WriteFFSConfiguration (Snapshot *snapshot, FFSConfigID &ffsconfig, bool wassuccess) |
Write a file corresponding to FFSConfigID from current snapshot. More... | |
void | ReadFFSConfiguration (Snapshot *snapshot, FFSConfigID &ffsconfig, bool wassuccess) |
Read a file corresponding to a FFSConfigID into current snapshot. More... | |
void | ComputeInitialFlux (Snapshot *, const CVList &) |
Compute Initial Flux. | |
virtual void | CheckForInterfaceCrossings (Snapshot *, const class CVManager &)=0 |
Function that checks if interfaces have been crossed (different for each FFS flavor) | |
virtual void | InitializeQueue (Snapshot *, const CVList &)=0 |
Initialize the Queue. | |
void | ComputeTransitionProbabilities () |
Compute the probability of going from each lambda_i to lambda_{i+1}. More... | |
void | PrintQueue () |
Print the queue, useful for debugging. | |
void | PopQueueMPI (Snapshot *, const CVList &, unsigned) |
Pop the queue, do MPI so that all procs maintain the same queue. | |
void | FluxBruteForce (Snapshot *, const CVList &) |
Compute the flux via brute force. More... | |
void | ReconstructTrajectories (Snapshot *) |
When simulation is finished, parse through the trajectories that reached B, and reconstruct the complete trajectory from where it started at A (lambda0) | |
void | ComputeCommittorProbability (Snapshot *) |
When simulation is finished, recursively parse through the trajectories that reached B or failed back to A and calculate the Commitor Probability of that state going to B (_pB) | |
void | AppendTrajectoryFile (Snapshot *, std::ofstream &) |
void | OpenTrajectoryFile (std::ofstream &) |
Take the current config in snapshot and append it to the provided ofstream. | |
Protected Attributes | |
double | _ninterfaces |
std::vector< double > | _interfaces |
FFS Interfaces. | |
bool | _interfaces_increase |
Interfaces must monotonically increase (or decrease), this determines whether going to the 'next' interface will be higher values of CV, or lower ones. | |
double | _cvvalue_previous |
Previous cv position, used to determine if you've crossed an interface since last time. | |
double | _cvvalue |
current cv position | |
double | _rate |
rate constant | |
std::vector< FFSConfigID > | Lambda0ConfigLibrary |
Data structure that holds a Library N0 configurations at lambda0. | |
double | _N0TotalSimTime |
Total Simulation Time spent in accumulating \ _N0. | |
unsigned int | _N0Target |
Number of configurations to store at lambda0, target. | |
double | _fluxA0 |
Flux of trajectories out of state A. Denoted PhiA0 over h_A in Allen2009. | |
std::vector< unsigned int > | _M |
std::vector< unsigned int > | _A |
Number of attempts from interface i. | |
std::vector< double > | _P |
Flag to determine wheter fluxA0 should be calculated, seems not using this. More... | |
std::vector< unsigned int > | _S |
std::vector< unsigned int > | _N |
bool | _pop_tried_but_empty_queue |
bool | _initialFluxFlag |
if 1, compute initial flux | |
bool | initializeQueueFlag |
if 1, initialize the Queue | |
FFSConfigID | myFFSConfigID |
The current FFSConfigID of this MPI process. | |
bool | _saveTrajectories |
should the FFS trajectories be saved | |
unsigned int | _nfailure_total |
std::vector< std::vector< double > > | _pB |
unsigned int | _current_interface |
Current Interface. | |
std::deque< FFSConfigID > | FFSConfigIDQueue |
std::string | _output_directory |
Directory of FFS output. | |
std::ofstream | _trajectory_file |
file to which the current trajectory is written to | |
std::default_random_engine | _generator |
random number generator | |
unsigned int | iteration_ |
Method iteration counter/. | |
Protected Attributes inherited from SSAGES::Method | |
mxx::comm | world_ |
Global MPI communicator. | |
mxx::comm | comm_ |
Local MPI communicator. | |
std::vector< unsigned int > | cvmask_ |
Mask which identifies which CVs to act on. | |
ForwardFlux sampling method.
The notation used here is drawn largely from Allen, Valeriani and Rein ten Wolde. J. Phys.: Condens. Matter (2009) 21:463102. We recommend referring to this review if the reader is unfamiliar with the method, or our variable naming conventions.
Definition at line 38 of file ForwardFlux.h.
|
inline |
Constructor.
world | MPI global communicator. |
comm | MPI local communicator. |
ninterfaces | Number of interfaces. |
interfaces | Vector of interfaces. |
N0Target | Required number of initial configurations. |
M | Vector of trials. |
initialFluxFlag | Flag for first step of this method. |
saveTrajectories | Flag to save flux trajectories. |
currentInterface | The number of the current interface. |
output_directory | Directory to which trajectories are saved. |
frequency | Frequency with which this method is invoked. |
Create instance of Forward Flux
Definition at line 284 of file ForwardFlux.h.
References _A, _initialFluxFlag, _interfaces, _interfaces_increase, _N, _N0Target, _N0TotalSimTime, _nfailure_total, _ninterfaces, _output_directory, _P, _pop_tried_but_empty_queue, _S, initializeQueueFlag, Lambda0ConfigLibrary, and SSAGES::Method::world_.
|
protected |
Function that adds new FFS configurations to the Queue Different FFS flavors can have differences in this method
|
protected |
Take the current config in snapshot and append it to the provided ofstream Current format is xyz style (including vx,vy,vz)
Definition at line 279 of file ForwardFlux.cpp.
References SSAGES::Snapshot::GetAtomIDs(), SSAGES::Snapshot::GetPositions(), and SSAGES::Snapshot::GetVelocities().
Referenced by SSAGES::DirectForwardFlux::CheckForInterfaceCrossings().
|
static |
Build a derived method from JSON node.
json | JSON Value containing all input information. |
world | MPI global communicator. |
comm | MPI local communicator. |
path | Path for JSON path specification. |
This function builds a registered method from a JSON node. The difference between this function and "Build" is that this automatically determines the appropriate derived type based on the JSON node information.
Definition at line 628 of file ForwardFlux.cpp.
References Json::Requirement::GetErrors(), Json::Requirement::HasErrors(), Json::ObjectRequirement::Parse(), and Json::ObjectRequirement::Validate().
|
protected |
Compute the probability of going from each lambda_i to lambda_{i+1}.
Using number of successes and number of trials This will need to be different for each FFS flavor
Definition at line 214 of file ForwardFlux.cpp.
Compute the flux via brute force.
Eventually this should be a new class that inherits from ForwardFlux, but for the time being I'll just hard code it This function takes the configurations at lambda0 and run them until they reach B (lambdaN) or return to A
|
protected |
Function checks if configuration has crossed interface specified since the last check.
Simple function, given current and previous CV position, checks if interface i has been crossed. If crossed in positive direction, return +1, if crossed in negative direction return -1, if nothing crossed return 0.
current | Current value of CV. |
prev | Previous value of CV. |
i | Index of interface to check for crossing. |
Definition at line 79 of file ForwardFlux.cpp.
Referenced by SSAGES::DirectForwardFlux::CheckForInterfaceCrossings().
|
protected |
Function checks if configuration has returned to A.
current | Current value of CV. |
Definition at line 102 of file ForwardFlux.cpp.
Referenced by SSAGES::DirectForwardFlux::CheckForInterfaceCrossings().
|
overridepure virtual |
Method call post integration.
snapshot | Pointer to the simulation snapshot. |
cvmanager | Collective variable manager. |
This function will be called after each integration step.
Implements SSAGES::Method.
Implemented in SSAGES::DirectForwardFlux.
|
overridevirtual |
Method call post simulation.
snapshot | Pointer to the simulation snapshot. |
cvmanager | Collective variable manager. |
This function will be called after the end of the simulation run.
Implements SSAGES::Method.
Definition at line 48 of file ForwardFlux.cpp.
Referenced by SSAGES::DirectForwardFlux::CheckForInterfaceCrossings().
|
overridevirtual |
Method call prior to simulation initiation.
snapshot | Pointer to the simulation snapshot. |
cvmanager | Collective variable manager. |
This function will be called before the simulation is started.
Implements SSAGES::Method.
Definition at line 39 of file ForwardFlux.cpp.
References SSAGES::CVManager::GetCVs().
|
protected |
Read a file corresponding to a FFSConfigID into current snapshot.
snapshot | Current snaphshot of the system |
ffsconfig | ID of the current FFS configuration |
wassuccess | If the last attempt was a success |
Definition at line 297 of file ForwardFlux.cpp.
References SSAGES::ForwardFlux::FFSConfigID::aprev, SSAGES::Snapshot::GetAtomIDs(), SSAGES::Snapshot::GetForces(), SSAGES::Snapshot::GetPositions(), SSAGES::Snapshot::GetVelocities(), SSAGES::ForwardFlux::FFSConfigID::l, SSAGES::ForwardFlux::FFSConfigID::lprev, SSAGES::ForwardFlux::FFSConfigID::n, and SSAGES::ForwardFlux::FFSConfigID::nprev.
|
protected |
Write a file corresponding to FFSConfigID from current snapshot.
snapshot | Current snaphshot of the system |
ffsconfig | ID of the current FFS configuration |
wassuccess | If the last attempt was a success |
Definition at line 231 of file ForwardFlux.cpp.
References SSAGES::ForwardFlux::FFSConfigID::aprev, SSAGES::Snapshot::GetAtomIDs(), SSAGES::Snapshot::GetPositions(), SSAGES::Snapshot::GetVelocities(), SSAGES::ForwardFlux::FFSConfigID::l, SSAGES::ForwardFlux::FFSConfigID::lprev, SSAGES::ForwardFlux::FFSConfigID::n, and SSAGES::ForwardFlux::FFSConfigID::nprev.
Referenced by SSAGES::DirectForwardFlux::CheckForInterfaceCrossings().
|
protected |
Number of trials to attemt from each interface Note _M[0] sets the number of 'branches' for RBFFS and BGFFS?
Definition at line 109 of file ForwardFlux.h.
Referenced by SSAGES::DirectForwardFlux::CheckForInterfaceCrossings(), and SSAGES::DirectForwardFlux::InitializeQueue().
|
protected |
Current number of configurations currently stored at interface i This is somewhat redundant since _N[i] == _S[i-1], but for clarity N[0] - current number of configurations collected at lambda0 (first interface)
Definition at line 127 of file ForwardFlux.h.
Referenced by SSAGES::DirectForwardFlux::CheckForInterfaceCrossings(), ForwardFlux(), and SSAGES::DirectForwardFlux::InitializeQueue().
|
protected |
Counts the total number of failures eventually if I prune, will want this to be a vector, where it stores the number of failures at each interface however in the absence of pruning, a traj can only fail at lambda0, so this is just a scalar
Definition at line 149 of file ForwardFlux.h.
Referenced by SSAGES::DirectForwardFlux::CheckForInterfaceCrossings(), and ForwardFlux().
|
protected |
Number of FFS interfaces note that _ninterfaces = n+1 where n is lambda_n the interface defining B
Definition at line 78 of file ForwardFlux.h.
Referenced by SSAGES::DirectForwardFlux::CheckForInterfaceCrossings(), and ForwardFlux().
|
protected |
Flag to determine wheter fluxA0 should be calculated, seems not using this.
Probability of going from lambda_{i} to lambda_{i+1}
Definition at line 118 of file ForwardFlux.h.
Referenced by SSAGES::DirectForwardFlux::CheckForInterfaceCrossings(), and ForwardFlux().
|
protected |
commitor probability. The probability of a given configuration reaching B
Definition at line 153 of file ForwardFlux.h.
|
protected |
Keep track of jobs that have suceeded or failed but couldn't get reassigned a new task and must wait for the queue to get more jobs This could happen in DFFS once a job has finished but M[i] hasn't been reached (waiting on other jobs) If this is the case I call it a 'zombie job', since the job is running, but isnt doing anything useful. Its just burning cpu cycles waiting for the queue to repopulate
Definition at line 132 of file ForwardFlux.h.
Referenced by SSAGES::DirectForwardFlux::CheckForInterfaceCrossings(), and ForwardFlux().
|
protected |
Number of successes from lambda_{i} to lambda_{i+1} (might need to be 2d vector if multiple branches are used (with RBFFS)
Definition at line 122 of file ForwardFlux.h.
Referenced by SSAGES::DirectForwardFlux::CheckForInterfaceCrossings(), and ForwardFlux().
|
protected |
Queue When a given processor reaches an interface, it pulls a config from this Queue to figure out what it should do next This object should be syncronized between all FFS walkers (is walker the correct terminology here?) technically this is a double-ended queue, this was mostly for debugging to allow element access of the queue (which std::queue doesn't allow). I use it like a queue though.
Definition at line 163 of file ForwardFlux.h.
Referenced by SSAGES::DirectForwardFlux::CheckForInterfaceCrossings(), and SSAGES::DirectForwardFlux::InitializeQueue().