23 auto seed = std::make_shared<Matter>(
pot,
params);
24 std::string reactantFilename =
27 QUILL_LOG_CRITICAL(
log,
"Failed to load {}", reactantFilename);
28 throw std::runtime_error(
"failed to load " + reactantFilename);
34std::shared_ptr<Matter>
37 throw std::runtime_error(
"runFromMatter: initial Matter is null");
50 QUILL_LOG_DEBUG(
log,
"Minimizing initial reactant");
75 const std::vector<std::shared_ptr<Matter>> &buff,
Matter *react) {
76 QUILL_LOG_TRACE_L1(
log,
"Refining transition time.");
79 long hi =
static_cast<long>(buff.size()) - 1;
81 while ((hi - lo) > 1) {
82 long mid = lo + (hi - lo) / 2;
90 return (lo + hi) / 2 + 1;
95 static_cast<long>(
params.parallel_replica_options.dephase_time /
96 params.dynamics_options.time_step);
98 QUILL_LOG_DEBUG(
log,
"Dephasing for {:.2f} fs",
99 params.parallel_replica_options.dephase_time *
100 params.constants.timeUnit);
102 long step = 0, loop = 0;
104 while (step < DephaseSteps) {
105 long dephaseBufferLength = DephaseSteps - step;
107 std::vector<std::shared_ptr<Matter>> dephaseBuffer(dephaseBufferLength);
109 for (
long i = 0; i < dephaseBufferLength; i++) {
110 dephaseBuffer[i] = std::make_shared<Matter>(
pot,
params);
117 if (transitionFlag) {
119 QUILL_LOG_DEBUG(
log,
"loop = {}; dephase refine step = {}", loop,
121 long ts = dephaseRefineStep - 1;
122 ts = (ts > 0) ? ts : 0;
125 "Dephasing warning: in a new state, inverse the momentum and restart "
130 velocity = velocity * (-1);
131 current->setVelocities(velocity);
134 step = step + dephaseBufferLength;
135 QUILL_LOG_TRACE_L1(
log,
"Successful dephasing for {} steps", step);
138 if ((
params.parallel_replica_options.dephase_loop_stop) &&
139 (loop >
params.parallel_replica_options.dephase_loop_max)) {
142 "Reach dephase loop maximum, stop dephasing! Dephased for {} steps",
146 QUILL_LOG_DEBUG(
log,
"Successfully Dephased for {:.2f} fs",
147 step *
params.dynamics_options.time_step *
148 params.constants.timeUnit);
153 std::string resultsFilename(
"results.dat");
158 std::ofstream out(resultsFilename, std::ios::binary);
161 "{} potential_type\n",
162 magic_enum::enum_name<PotType>(
params.potential_options.potential));
163 out << std::format(
"{} random_seed\n",
params.main_options.randomSeed);
164 out << std::format(
"{:f} potential_energy_reactant\n",
166 out << std::format(
"{} total_force_calls\n", totalFCalls);
167 out << std::format(
"{} force_calls_dephase\n",
dephaseFCalls);
168 out << std::format(
"{} force_calls_dynamics\n",
mdFCalls);
170 out << std::format(
"{} force_calls_refine\n",
refineFCalls);
171 out << std::format(
"{} transition_found\n", (
newStateFlag) ? 1 : 0);
174 out << std::format(
"{:e} transition_time_s\n",
176 params.constants.timeUnit);
177 out << std::format(
"{:f} potential_energy_product\n",
178 product->getPotentialEnergy());
179 out << std::format(
"{:f} moved_distance\n",
183 out << std::format(
"{:e} simulation_time_s\n",
185 out << std::format(
"{:f} speedup\n",
187 params.dynamics_options.time_step);
191 std::string reactantFilename(
"reactant.con");
194 QUILL_LOG_ERROR(
log,
"Failed to write {}", reactantFilename);
198 std::string productFilename(
"product.con");
201 QUILL_LOG_ERROR(
log,
"Failed to write {}", productFilename);
204 if (
params.parallel_replica_options.refine_transition) {
205 std::string saddleFilename(
"saddle.con");
208 QUILL_LOG_ERROR(
log,
"Failed to write {}", saddleFilename);
Eigen::Matrix< double, Eigen::Dynamic, 3, eOnStorageOrder > AtomMatrix
std::vector< std::string > run() override
Virtual run; used solely for dynamic dispatch.
void oneStep(int stepNumber=-1)
RAII wrapper for tracking force calls over a scope.
std::shared_ptr< Potential > pot
bool relax(bool quiet=false, bool writeMovie=false, bool checkpoint=false, std::string prefixMovie=std::string(), std::string prefixCheckpoint=std::string(), bool retainMovieFrames=false)
bool compare(const Matter &matter, bool indistinguishable=false)
void dephase()
Dephase the trajectory to ensure thermal independence.
std::vector< std::string > returnFiles
std::shared_ptr< Matter > saddle
std::shared_ptr< Matter > product
std::shared_ptr< Matter > runFromMatter(std::shared_ptr< Matter > initial)
Matter-first entry: seed geometry, skip con2matter load.
long refine(const std::vector< std::shared_ptr< Matter > > &buff, Matter *reactant)
Binary search for the transition frame in a snapshot buffer.
virtual int dynamics()=0
The accelerated dynamics loop. Returns status (1 = transition, 0 = none).
std::shared_ptr< Matter > finalState
virtual void initExtra()
Create any extra matter objects needed by the subclass.
virtual void reportResults()
Post-dynamics logging (override for job-specific messages).
std::shared_ptr< Matter > reactant
void saveData(int status)
Write results.dat and structure con files.
std::shared_ptr< Matter > current
bool checkState(Matter *current, Matter *reactant)
Minimize a copy of current and compare to reactant.
std::shared_ptr< Matter > finalStateTmp
std::string getRelevantFile(std::string filename)
constexpr bool io_ok(IoStatus s) noexcept