RDKit
Open-source cheminformatics and machine learning.
Loading...
Searching...
No Matches
Inversions.h
Go to the documentation of this file.
1//
2// Copyright (C) 2024-2026 Niels Maeder and other RDKit contributors
3//
4// @@ All Rights Reserved @@
5// This file is part of the RDKit.
6// The contents are covered by the terms of the BSD license
7// which is included in the file license.txt, found at the root
8// of the RDKit source tree.
9//
10#include <RDGeneral/export.h>
11#ifndef RD_UFFINVERSIONS_H
12#define RD_UFFINVERSIONS_H
13#include <ForceField/Contrib.h>
14#include <Geometry/point.h>
15#include <vector>
16
17namespace ForceFields {
18namespace UFF {
19class AtomicParams;
20
22 unsigned int idx1{0}; //!< index of atom1 in the ForceField's positions
23 unsigned int idx2{0}; //!< index of atom2 in the ForceField's positions
24 unsigned int idx3{0}; //!< index of atom3 in the ForceField's positions
25 unsigned int idx4{0}; //!< index of atom4 in the ForceField's positions
26 int at2AtomicNum{0}; //!< atomic number for atom 2
27 bool isCBoundToO{false}; //!< boolean flag; true if atom 2 is sp2 carbon
28 //!< bound to sp2 oxygen
29 double C0{0.0}; //!< inversion coefficient 0
30 double C1{0.0}; //!< inversion coefficient 1
31 double C2{0.0}; //!< inversion coefficient 2
32 double forceConstant{1.0}; //!< force constant
33 InversionContribsParams(unsigned int idx1, unsigned int idx2,
34 unsigned int idx3, unsigned int idx4,
35 int at2AtomicNum, bool isCBoundToO, double C0,
36 double C1, double C2, double forceConstant = 1.0)
37 : idx1(idx1),
38 idx2(idx2),
39 idx3(idx3),
40 idx4(idx4),
43 C0(C0),
44 C1(C1),
45 C2(C2),
47};
48//! A term to capture all Inversion Contributionss.
50 public:
51 InversionContribs() = default;
52 //! Constructor
53 /*!
54 \param owner pointer to the owning ForceField
55 */
57
58 ~InversionContribs() override = default;
59 //! Add contribution to this contrib.
60 /*!
61 \param idx1 index of atom1 in the ForceField's positions
62 \param idx2 index of atom2 in the ForceField's positions
63 \param idx3 index of atom3 in the ForceField's positions
64 \param idx4 index of atom4 in the ForceField's positions
65 \param at2AtomicNum atomic number for atom 2
66 \param isCBoundToO boolean flag; true if atom 2 is sp2 C bound to
67 sp2 O
68 \param oobForceScalingFactor scaling factor for force constant
69
70 */
71 void addContrib(unsigned int idx1, unsigned int idx2, unsigned int idx3,
72 unsigned int idx4, int at2AtomicNum, bool isCBoundToO,
73 double oobForceScalingFactor = 1.0);
74 //! return the contribution of this contrib to the energy of a given state
75 /*!
76 \param pos positions of the atoms in the current state
77 */
78 double getEnergy(double *pos) const override;
79 //! return the contribution of this contrib to the energy of a given state
80 /*!
81 \param pos positions of the atoms in the current state
82 \param energies Will resize and write the energies of every single contrib
83 of this contribs object to the energies vector
84 */
85 double getEnergy(const RDGeom::Point3DPtrVect &positions,
86 std::vector<double> &energies) const;
87 //! calculate the contribution of this contrib to the gradient at a given
88 /// state
89 /*!
90 \param pos positions of the atoms in the current state
91 \param grad gradients to be adapted
92 */
93 void getGrad(double *pos, double *grad) const override;
94
95 //! Copy constructor
96 InversionContribs *copy() const override {
97 return new InversionContribs(*this);
98 }
99
100 //! Return true if there are no contributions in this contrib
101 bool empty() const { return d_contribs.empty(); }
102
103 //! Get number of contributions in this contrib
104 unsigned int size() const { return d_contribs.size(); }
105
106 private:
107 std::vector<InversionContribsParams> d_contribs;
108};
109
110} // namespace UFF
111} // namespace ForceFields
112
113#endif
class to store atomic parameters for the Universal Force Field
Definition UFF/Params.h:68
void getGrad(double *pos, double *grad) const override
InversionContribs * copy() const override
Copy constructor.
Definition Inversions.h:96
~InversionContribs() override=default
bool empty() const
Return true if there are no contributions in this contrib.
Definition Inversions.h:101
InversionContribs(ForceField *owner)
Constructor.
void addContrib(unsigned int idx1, unsigned int idx2, unsigned int idx3, unsigned int idx4, int at2AtomicNum, bool isCBoundToO, double oobForceScalingFactor=1.0)
Add contribution to this contrib.
double getEnergy(double *pos) const override
return the contribution of this contrib to the energy of a given state
unsigned int size() const
Get number of contributions in this contrib.
Definition Inversions.h:104
double getEnergy(const RDGeom::Point3DPtrVect &positions, std::vector< double > &energies) const
return the contribution of this contrib to the energy of a given state
#define RDKIT_FORCEFIELD_EXPORT
Definition export.h:201
std::vector< RDGeom::Point3D * > Point3DPtrVect
Definition point.h:541
unsigned int idx3
index of atom3 in the ForceField's positions
Definition Inversions.h:24
double C0
inversion coefficient 0
Definition Inversions.h:29
unsigned int idx1
index of atom1 in the ForceField's positions
Definition Inversions.h:22
double C2
inversion coefficient 2
Definition Inversions.h:31
int at2AtomicNum
atomic number for atom 2
Definition Inversions.h:26
InversionContribsParams(unsigned int idx1, unsigned int idx2, unsigned int idx3, unsigned int idx4, int at2AtomicNum, bool isCBoundToO, double C0, double C1, double C2, double forceConstant=1.0)
Definition Inversions.h:33
double C1
inversion coefficient 1
Definition Inversions.h:30
unsigned int idx4
index of atom4 in the ForceField's positions
Definition Inversions.h:25
unsigned int idx2
index of atom2 in the ForceField's positions
Definition Inversions.h:23