23 #include "DirectForwardFlux.h"
25 #include "CVs/CVManager.h"
53 else if (initializeQueueFlag)
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 <<
" ";
216 _current_interface += 1;
219 if (
_N[_current_interface] == 0)
221 std::cerr <<
"Error! No successes from interface " << _current_interface-1 <<
" to " << _current_interface <<
"! Try turning up M["<<_current_interface-1<<
"] or spacing interfaces closer together.\n";
222 MPI_Abort(
world_, EXIT_FAILURE);
227 std::vector<unsigned int> picks;
228 picks.resize(npicks);
231 std::uniform_int_distribution<int> distribution(0,
_N[_current_interface]-1);
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;
240 attempt_count.resize(
_N[_current_interface],0);
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 (
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";
321 initializeQueueFlag =
false;
325 unsigned int shouldpop_local =
true;
void PostSimulation(Snapshot *snapshot, const class CVManager &cvmanager) override
Post-simulation hook.
Collective variable manager.
std::vector< unsigned int > _M
std::vector< CollectiveVariable * > CVList
List of Collective Variables.
std::vector< unsigned int > _S
std::vector< unsigned int > _A
Number of attempts from interface i.
unsigned int _current_interface
Current Interface.
bool _pop_tried_but_empty_queue
std::vector< unsigned int > _N
Class containing a snapshot of the current simulation in time.
void CheckInitialStructure(const CVList &)
Function that checks the initial structure that user provides.
void WriteFFSConfiguration(Snapshot *snapshot, FFSConfigID &ffsconfig, bool wassuccess)
Write a file corresponding to FFSConfigID from current snapshot.
void CheckForInterfaceCrossings(Snapshot *, const class CVManager &) override
Function that checks if interfaces have been crossed (different for each FFS flavor) ...
double _cvvalue_previous
Previous cv position, used to determine if you've crossed an interface since last time...
mxx::comm world_
Global MPI communicator.
uint iteration_
Method iteration counter/.
void ComputeInitialFlux(Snapshot *, const CVList &)
Compute Initial Flux.
double _cvvalue
current cv position
bool HasReturnedToA(double)
Function checks if configuration has returned to A.
bool _initialFluxFlag
if 1 compute initial flux
unsigned int a
Attempt number.
std::deque< FFSConfigID > FFSConfigIDQueue
std::vector< CollectiveVariable * > GetCVs(const std::vector< uint > &mask=std::vector< uint >()) const
Get CV iterator.
Nested class to store different FFS Config IDs.
std::ofstream _trajectory_file
file to which the current trajectory is written to
int HasCrossedInterface(double, double, unsigned int interface)
Function checks if configuration has crossed interface specified since the last check.
void AppendTrajectoryFile(Snapshot *, std::ofstream &)
std::vector< double > _P
Flag to determine wheter fluxA0 should be calculated, seems not using this.
unsigned int _nfailure_total
void PrintQueue()
Print the queue, useful for debugging.
void PostIntegration(Snapshot *snapshot, const class CVManager &cvmanager) override
Post-integration hook.
std::vector< uint > cvmask_
Mask which identifies which CVs to act on.
unsigned int n
Configuration Number.
bool _saveTrajectories
should the FFS trajectories be saved
std::default_random_engine _generator
random number generator
void InitializeQueue(Snapshot *, const CVList &) override
Initialize the Queue.
std::vector< double > _interfaces
FFS Interfaces.
FFSConfigID myFFSConfigID
The current FFSConfigID of this MPI process.
unsigned int l
Interface number.
std::vector< FFSConfigID > Lambda0ConfigLibrary
Data structure that holds a Library N0 configurations at lambda0.
void PopQueueMPI(Snapshot *, const CVList &, unsigned)
Pop the queue, do MPI so that all procs maintain the same queue.