44 matter->setPositionsFreeV(x);
50 return 3 *
static_cast<int>(
matter->numberOfFreeAtoms());
55 params.neb_options().initialization.force_tolerance;
65 VectorXd
difference(
const VectorXd &a,
const VectorXd &b)
override {
66 return matter->pbcV(a - b);
92 const int nfree =
static_cast<int>(
path[0].numberOfFreeAtoms());
93 const int seg = 3 * nfree;
94 for (
size_t i = 1; i <
path.size() - 1; ++i) {
95 path[i].setPositionsFreeV(x.segment(seg *
static_cast<int>(i - 1), seg));
100 const int nfree =
static_cast<int>(
path[0].numberOfFreeAtoms());
101 const int seg = 3 * nfree;
102 const int n_free_images =
static_cast<int>(
path.size()) - 2;
103 VectorXd pos(seg * n_free_images);
104 for (
size_t i = 1; i <
path.size() - 1; ++i) {
105 pos.segment(seg *
static_cast<int>(i - 1), seg) =
106 path[i].getPositionsFreeV();
112 return 3 *
static_cast<int>(
path[0].numberOfFreeAtoms()) *
113 (
static_cast<int>(
path.size()) - 2);
119 params.neb_options().initialization.force_tolerance;
124 VectorXd
difference(
const VectorXd &a,
const VectorXd &b)
override {
147 std::shared_ptr<Potential> zbl,
160 VectorXd grad =
idpp_obj->getGradient(fdstep);
163 int n_images =
path.size();
164 int atoms_per_image =
path[0].numberOfAtoms();
166 const int nfree =
static_cast<int>(
path[0].numberOfFreeAtoms());
167 const int seg = 3 * nfree;
168 for (
int i = 1; i < n_images - 1; ++i) {
169 AtomMatrix forces = MatrixXd::Zero(atoms_per_image, 3);
173 path[i].getAtomicNrs().data(), forces.data(), &energy,
174 nullptr,
path[i].getCell().data());
176 VectorXd zbl_free(seg);
178 for (
int a = 0; a < atoms_per_image; ++a) {
179 if (!
path[i].getFixed(a)) {
180 zbl_free[k++] = forces(a, 0);
181 zbl_free[k++] = forces(a, 1);
182 zbl_free[k++] = forces(a, 2);
185 grad.segment((i - 1) * seg, seg) -= (zbl_free *
zbl_weight);
198 VectorXd
difference(
const VectorXd &a,
const VectorXd &b)
override {
Eigen::Matrix< double, Eigen::Dynamic, Eigen::Dynamic, eOnStorageOrder > MatrixXd
Eigen::Matrix< double, Eigen::Dynamic, 3, eOnStorageOrder > AtomMatrix
bool gradientMatchesEnergy() const override
void setPositions(const VectorXd &x) override
double getConvergence() override
MatrixXd getDistanceMatrix(const Matter &m)
int degreesOfFreedom() override
CollectiveIDPPObjectiveFunction(std::vector< Matter > &pathRef, const Parameters ¶msPassed)
std::vector< Matter > & path
bool isConverged() override
VectorXd difference(const VectorXd &a, const VectorXd &b) override
VectorXd getPositions() override
VectorXd getGradient(bool fdstep=false) override
MatrixXd getIDPPForces(const Matter &m, const MatrixXd &dTarget)
double getEnergy() override
bool isConverged() override
std::shared_ptr< Matter > matter
double getConvergence() override
double getEnergy() override
VectorXd difference(const VectorXd &a, const VectorXd &b) override
VectorXd getPositions() override
IDPPObjectiveFunction(std::shared_ptr< Matter > matterPassed, const Parameters ¶msPassed, const MatrixXd &targetDistances)
void setPositions(const VectorXd &x) override
int degreesOfFreedom() override
VectorXd getGradient(bool fdstep=false) override
ObjectiveFunction(const Parameters ¶msPassed)
const Parameters & params
double getEnergy() override
std::shared_ptr< Potential > zbl_pot
int degreesOfFreedom() override
void setPositions(const VectorXd &x) override
std::vector< Matter > & path
double getConvergence() override
std::shared_ptr< ObjectiveFunction > idpp_obj
VectorXd difference(const VectorXd &a, const VectorXd &b) override
ZBLRepulsiveIDPPObjective(std::shared_ptr< ObjectiveFunction > idpp, std::shared_ptr< Potential > zbl, std::vector< Matter > &p, const Parameters ¶ms, double weight=1.0)
bool isConverged() override
VectorXd getGradient(bool fdstep=false) override
VectorXd getPositions() override
RAII resource manager for the ARTn C library with global synchronization.