84 const std::vector<std::shared_ptr<Matter>> &path,
85 long numImages,
int atoms,
double maxEnergy,
double E_ref) {
95 double avgPotForce = 0.0;
96 double avgPathCurvature = 0.0;
98 for (
long j = 1; j <= numImages; j++) {
99 avgPotForce += path[j]->getForces().norm();
100 AtomMatrix next = path[j + 1]->getPositions();
101 AtomMatrix prev = path[j - 1]->getPositions();
103 AtomMatrix curvVec = path[j]->pbc(next + prev - 2.0 * curr);
104 avgPathCurvature += curvVec.norm();
107 if (count > 0 && avgPathCurvature > 1e-6) {
109 base_k = scale * (avgPotForce / avgPathCurvature);
116 std::vector<AtomMatrix> L_vecs(numImages + 2);
117 for (
long j = 0; j <= numImages + 1; j++) {
118 L_vecs[j].resize(atoms, 3);
119 if (j == 0 || j == numImages + 1) {
122 const AtomMatrix &forces = path[j]->getForces();
124 for (
int k = 0; k < atoms; k++) {
125 L_vecs[j].row(k) = alpha_k * forces.row(k);
135 std::vector<double> springConstants(numImages + 2, k_l);
137 double energyRange = maxEnergy - E_ref;
138 if (energyRange < 1e-10) {
139 std::fill(springConstants.begin(), springConstants.end(), k_l);
141 for (
int idx = 1; idx <= numImages + 1; idx++) {
142 double Ei = std::max(path[idx]->getPotentialEnergy(),
143 path[idx - 1]->getPotentialEnergy());
145 double alpha_i = (maxEnergy - Ei) / energyRange;
146 alpha_i = std::max(0.0, std::min(1.0, alpha_i));
147 springConstants[idx - 1] = (1.0 - alpha_i) * k_u + alpha_i * k_l;
149 springConstants[idx - 1] = k_l;
SpringStrategy buildSpringStrategy(const Parameters ¶ms, const std::vector< std::shared_ptr< Matter > > &path, long numImages, int atoms, double maxEnergy, double E_ref)
Build the appropriate spring strategy from parameters and current path state.
SpringResult compute(long i, const AtomMatrix &tangent, const AtomMatrix &posNext, const AtomMatrix &posPrev, const AtomMatrix &pos, const std::shared_ptr< Matter > &image) const