Debian Codegraph @

avogadro/calc/uff.h

raw
1 /******************************************************************************
2 This source file is part of the Avogadro project.
3 This source code is released under the 3-Clause BSD License, (see "LICENSE").
4 ******************************************************************************/
5
6 #ifndef AVOGADRO_CALC_UFF_H
7 #define AVOGADRO_CALC_UFF_H
8
9 #include "avogadrocalcexport.h"
10 #include <avogadro/calc/energycalculator.h>
11
12 namespace Avogadro {
13 namespace Core {
14 class Molecule;
15 }
16
17 namespace Calc {
18
19 class UFFPrivate;
20
21 class AVOGADROCALC_EXPORT UFF : public EnergyCalculator
22 {
23 public:
24 UFF();
25 ~UFF() override;
26
27 UFF* newInstance() const override { return new UFF; }
28
29 std::string identifier() const override { return "UFF"; }
30
31 std::string name() const override { return "UFF"; }
32
33 std::string description() const override { return "Universal Force Field"; }
34
35 Core::Molecule::ElementMask elements() const override { return (m_elements); }
36
37 Real value(const Eigen::VectorXd& x) override;
38 void gradient(const Eigen::VectorXd& x, Eigen::VectorXd& grad) override;
39 Real evaluate(const Eigen::VectorXd& x, Eigen::VectorXd* grad) override;
40
41 // handle both ions and radicals
42 // (at least we will do what we can)
43 bool acceptsIons() const override { return true; }
44 bool acceptsRadicals() const override { return true; }
45 bool acceptsUnitCell() const override { return true; }
46
47 // components
48 Real bondEnergy(const Eigen::VectorXd& x);
49 Real angleEnergy(const Eigen::VectorXd& x);
50 Real oopEnergy(const Eigen::VectorXd& x);
51 Real torsionEnergy(const Eigen::VectorXd& x);
52 Real vdwEnergy(const Eigen::VectorXd& x);
53
54 void bondGradient(const Eigen::VectorXd& x, Eigen::VectorXd& grad);
55 void angleGradient(const Eigen::VectorXd& x, Eigen::VectorXd& grad);
56 void oopGradient(const Eigen::VectorXd& x, Eigen::VectorXd& grad);
57 void torsionGradient(const Eigen::VectorXd& x, Eigen::VectorXd& grad);
58 void vdwGradient(const Eigen::VectorXd& x, Eigen::VectorXd& grad);
59
60 /**
61 * Called when the current molecule changes.
62 */
63 void setMolecule(Core::Molecule* mol) override;
64
65 protected:
66 Core::Molecule* m_molecule;
67
68 Core::Molecule::ElementMask m_elements;
69
70 // track the particular calculations for a molecule
71 UFFPrivate* d = nullptr;
72 };
73
74 } // namespace Calc
75 } // namespace Avogadro
76
77 #endif // AVOGADRO_CALC_UFF_H