23 #include "DirectForwardFlux.h"
25 #include "CVs/CVManager.h"
87 unsigned int fail_local=
false,success_local=
false;
89 std::vector<unsigned int> successes (
world_.size());
90 std::vector<unsigned int> failures (
world_.size());
97 else if (hascrossed == 1)
99 else if (hascrossed == -1)
113 MPI_Allgather(&success_local,1,MPI_UNSIGNED,successes.data(),1,MPI_UNSIGNED,
world_);
114 MPI_Allgather(&fail_local,1,MPI_UNSIGNED,failures.data(),1,MPI_UNSIGNED,
world_);
116 int success_count = 0, fail_count = 0;
119 for (
int i=0;i<
world_.size();i++)
121 int l,n,a,lprev,nprev,aprev;
127 if (successes[i] ==
true)
140 if (failures[i] ==
true)
160 if (success_local || fail_local)
172 if ((success_local) || (fail_local))
174 std::cout <<
"Iteration: "<<
iteration_ <<
", proc " <<
world_.rank() <<
"\n";
191 std::cout << a <<
" ";
196 std::cout << s <<
" ";
201 std::cout << m <<
" ";
222 MPI_Abort(
world_, EXIT_FAILURE);
227 std::vector<unsigned int> picks;
228 picks.resize(npicks);
232 for (
unsigned int i=0; i < npicks ; i++)
235 MPI_Bcast(picks.data(),npicks,MPI_UNSIGNED,0,
world_);
239 std::vector<unsigned int> attempt_count;
242 for (
unsigned int i=0; i < npicks ; i++)
244 unsigned int mypick = picks[i];
245 int l,n,a,lprev,nprev,aprev;
252 a = attempt_count[mypick];
253 attempt_count[mypick]++;
260 std::cout <<
"DFFS should be finished here, do something special? like exit?\n";
269 unsigned int shouldpop_local =
false;
270 std::vector<unsigned int> shouldpop(
world_.size(),0);
273 shouldpop_local =
true;
287 unsigned int npicks =
_M[0];
288 std::vector<unsigned int> picks;
289 picks.resize(npicks);
293 std::uniform_int_distribution<int> distribution(0,
_N[0]-1);
294 for (
unsigned int i=0; i < npicks ; i++)
297 MPI_Bcast(picks.data(),npicks,MPI_UNSIGNED,0,
world_);
300 std::vector<unsigned int> attempt_count;
301 attempt_count.resize(
_N[0],0);
304 for (
unsigned int i=0; i < npicks ; i++)
306 unsigned int mypick = picks[i];
307 int l,n,a,lprev,nprev,aprev;
316 a = attempt_count[mypick];
317 attempt_count[mypick]++;
320 std::cout <<
"FFSConfigIDQueue has " <<
FFSConfigIDQueue.size() <<
" entries upon initialization\n";
325 unsigned int shouldpop_local =
true;
Collective variable manager.
CVList GetCVs(const std::vector< unsigned int > &mask=std::vector< unsigned int >()) const
Get CV iterator.
void CheckForInterfaceCrossings(Snapshot *, const class CVManager &) override
Function that checks if interfaces have been crossed (different for each FFS flavor)
void PostIntegration(Snapshot *snapshot, const class CVManager &cvmanager) override
Post-integration hook.
void InitializeQueue(Snapshot *, const CVList &) override
Initialize the Queue.
static bool IsMasterRank(const MPI_Comm &comm)
Check if current processor is master.
Nested class to store different FFS Config IDs.
unsigned int a
Attempt number.
unsigned int n
Configuration Number.
unsigned int l
Interface number.
std::vector< FFSConfigID > Lambda0ConfigLibrary
Data structure that holds a Library N0 configurations at lambda0.
bool _pop_tried_but_empty_queue
void AppendTrajectoryFile(Snapshot *, std::ofstream &)
void PostSimulation(Snapshot *snapshot, const class CVManager &cvmanager) override
Method call post simulation.
double _cvvalue_previous
Previous cv position, used to determine if you've crossed an interface since last time.
unsigned int _nfailure_total
std::vector< double > _interfaces
FFS Interfaces.
unsigned int iteration_
Method iteration counter/.
std::vector< unsigned int > _M
FFSConfigID myFFSConfigID
The current FFSConfigID of this MPI process.
bool _saveTrajectories
should the FFS trajectories be saved
void ComputeInitialFlux(Snapshot *, const CVList &)
Compute Initial Flux.
void PrintQueue()
Print the queue, useful for debugging.
bool _initialFluxFlag
if 1, compute initial flux
std::vector< unsigned int > _N
void WriteFFSConfiguration(Snapshot *snapshot, FFSConfigID &ffsconfig, bool wassuccess)
Write a file corresponding to FFSConfigID from current snapshot.
std::ofstream _trajectory_file
file to which the current trajectory is written to
void CheckInitialStructure(const CVList &)
Function that checks the initial structure that user provides.
std::vector< unsigned int > _S
std::vector< double > _P
Flag to determine wheter fluxA0 should be calculated, seems not using this.
bool initializeQueueFlag
if 1, initialize the Queue
std::default_random_engine _generator
random number generator
unsigned int _current_interface
Current Interface.
double _cvvalue
current cv position
void PopQueueMPI(Snapshot *, const CVList &, unsigned)
Pop the queue, do MPI so that all procs maintain the same queue.
std::deque< FFSConfigID > FFSConfigIDQueue
int HasCrossedInterface(double current, double prev, unsigned int i)
Function checks if configuration has crossed interface specified since the last check.
bool HasReturnedToA(double current)
Function checks if configuration has returned to A.
std::vector< unsigned int > _A
Number of attempts from interface i.
std::vector< unsigned int > cvmask_
Mask which identifies which CVs to act on.
mxx::comm world_
Global MPI communicator.
Class containing a snapshot of the current simulation in time.
std::vector< CollectiveVariable * > CVList
List of Collective Variables.