Loading...
Searching...
No Matches
ObjectiveFunction.h
Go to the documentation of this file.
1/*
2** This file is part of eOn.
3**
4** SPDX-License-Identifier: BSD-3-Clause
5**
6** Copyright (c) 2010--present, eOn Development Team
7** All rights reserved.
8**
9** Repo:
10** https://github.com/TheochemUI/eOn
11*/
12#pragma once
13
14#include "Matter.h"
15
16#include <optional>
17
18namespace eonc {
19
21protected:
23
24public:
25 ObjectiveFunction(const Parameters &paramsPassed) : params{paramsPassed} {}
26 virtual ~ObjectiveFunction() {}
27 virtual double getEnergy() = 0;
28 virtual VectorXd getGradient(bool fdstep = false) = 0;
29 virtual void setPositions(const VectorXd &x) = 0;
30 virtual VectorXd getPositions() = 0;
31 virtual int degreesOfFreedom() = 0;
32 virtual bool isConverged() = 0;
33 virtual double getConvergence() = 0;
34 virtual VectorXd difference(const VectorXd &a, const VectorXd &b) = 0;
35 // Allow the initial finite-difference curvature estimate used by L-BFGS.
36 virtual bool supportsFiniteDifferenceCurvature() const { return true; }
37 // A curvature the objective already knows (eV / A^2, magnitude), so
38 // L-BFGS can seed H0 from it instead of spending a force call on the
39 // finite-difference probe. Empty when nothing is known.
40 virtual std::optional<double> knownCurvature() const { return std::nullopt; }
41 // Packwood/Kermode pair preconditioner: MIC of one Cartesian pair.
42 // Default leaves dr unchanged (no cell).
43 virtual void minimumImage(Eigen::Ref<Eigen::Vector3d> /*dr*/) const {}
44 // Per-atom masses of the free atoms (length N, not 3N). Empty if unknown.
45 virtual VectorXd getMasses() const { return VectorXd(); }
46 // True when the geometry uses periodic boundaries (Sella proj_rot off).
47 virtual bool getPeriodic() const { return false; }
48};
49
50} // namespace eonc
virtual bool supportsFiniteDifferenceCurvature() const
virtual VectorXd getGradient(bool fdstep=false)=0
virtual VectorXd difference(const VectorXd &a, const VectorXd &b)=0
ObjectiveFunction(const Parameters &paramsPassed)
virtual VectorXd getMasses() const
virtual bool getPeriodic() const
virtual bool isConverged()=0
const Parameters & params
virtual VectorXd getPositions()=0
virtual std::optional< double > knownCurvature() const
virtual void setPositions(const VectorXd &x)=0
virtual double getEnergy()=0
virtual double getConvergence()=0
virtual int degreesOfFreedom()=0
virtual void minimumImage(Eigen::Ref< Eigen::Vector3d >) const
RAII resource manager for the ARTn C library with global synchronization.