RDKit
Open-source cheminformatics and machine learning.
Loading...
Searching...
No Matches
AngleConstraints.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
11#include <RDGeneral/export.h>
12#ifndef RD_ANGLECONSTRAINTS_H
13#define RD_ANGLECONSTRAINTS_H
14#include <vector>
15#include "ForceField.h"
16#include "Contrib.h"
17
18namespace ForceFields {
19
21 unsigned int idx1{0}; //!< index of atom1 of the angle constraint
22 unsigned int idx2{0}; //!< index of atom2 of the angle constraint
23 unsigned int idx3{0}; //!< index of atom3 of the angle constraint
24 double minAngle{0.0}; //!< lower bound of the flat bottom potential
25 double maxAngle{0.0}; //!< upper bound of the flat bottom potential
26 double forceConstant{1.0}; //!< force constant for angle constraint
27 AngleConstraintContribsParams(unsigned int idx1, unsigned int idx2,
28 unsigned int idx3, double minAngle,
29 double maxAngle, double forceConstant = 1.0)
30 : idx1(idx1),
31 idx2(idx2),
32 idx3(idx3),
36};
37
38//! A term to capture all flat bottom angle constraint potentials.
40 : public ForceFieldContrib {
41 public:
43
44 //! Constructor
45 /*!
46 \param owner pointer to the owning ForceField
47 */
49 ~AngleConstraintContribs() override = default;
50 //! Add a contribution to this contrib collection
51 /*!
52 \param idx1 index of atom1 in the ForceField's positions
53 \param idx2 index of atom2 in the ForceField's positions
54 \param idx3 index of atom3 in the ForceField's positions
55 \param minAngle minimum angle
56 \param maxAngle maximum angle
57 \param forceConst force Constant
58
59 */
60 void addContrib(unsigned int idx1, unsigned int idx2, unsigned int idx3,
61 double minAngleDeg, double maxAngleDeg, double forceConst);
62 //! Add a contribution to this contrib collection
63 /*!
64 \param idx1 index of atom1 in the ForceField's positions
65 \param idx2 index of atom2 in the ForceField's positions
66 \param idx3 index of atom3 in the ForceField's positions
67 \param relative whether to add the provided angle to the current angle
68 \param minAngle minimum angle
69 \param maxAngle maximum angle
70 \param forceConst force Constant
71
72 */
73 void addContrib(unsigned int idx1, unsigned int idx2, unsigned int idx3,
74 bool relative, double minAngleDeg, double maxAngleDeg,
75 double forceConst);
76 //! return the contribution of this contrib to the energy of a given state
77 /*!
78 \param pos positions of the atoms in the current state
79 */
80 double getEnergy(double *pos) const override;
81 //! return the contribution of this contrib to the energy of a given state
82 /*!
83 \param positions positions of the atoms in the current state
84 \param energies Will resize and write the energies of every single contrib
85 of this contribs object to the energies vector
86 */
87 double getEnergy(const RDGeom::Point3DPtrVect &positions,
88 std::vector<double> &energies) const;
89 //! calculate the contribution of this contrib to the gradient at a given
90 /// state
91 /*!
92 \param pos positions of the atoms in the current state
93 \param grad gradients to be adapted
94 */
95 void getGrad(double *pos, double *grad) const override;
96 //! Copy constructor
97
98 AngleConstraintContribs *copy() const override {
99 return new AngleConstraintContribs(*this);
100 }
101
102 //! Return true if there are no contributions in this contrib
103 bool empty() const { return d_contribs.empty(); }
104
105 //! Get number of contributions in this contrib
106 unsigned int size() const { return d_contribs.size(); }
107
108 private:
109 std::vector<AngleConstraintContribsParams> d_contribs;
110};
111} // namespace ForceFields
112#endif
double getEnergy(double *pos) const override
return the contribution of this contrib to the energy of a given state
void getGrad(double *pos, double *grad) const override
AngleConstraintContribs(ForceField *owner)
Constructor.
bool empty() const
Return true if there are no contributions in this contrib.
~AngleConstraintContribs() override=default
double getEnergy(const RDGeom::Point3DPtrVect &positions, std::vector< double > &energies) const
return the contribution of this contrib to the energy of a given state
void addContrib(unsigned int idx1, unsigned int idx2, unsigned int idx3, bool relative, double minAngleDeg, double maxAngleDeg, double forceConst)
Add a contribution to this contrib collection.
AngleConstraintContribs * copy() const override
Copy constructor.
unsigned int size() const
Get number of contributions in this contrib.
void addContrib(unsigned int idx1, unsigned int idx2, unsigned int idx3, double minAngleDeg, double maxAngleDeg, double forceConst)
Add a contribution to this contrib collection.
#define RDKIT_FORCEFIELD_EXPORT
Definition export.h:201
std::vector< RDGeom::Point3D * > Point3DPtrVect
Definition point.h:541
double maxAngle
upper bound of the flat bottom potential
double minAngle
lower bound of the flat bottom potential
unsigned int idx3
index of atom3 of the angle constraint
AngleConstraintContribsParams(unsigned int idx1, unsigned int idx2, unsigned int idx3, double minAngle, double maxAngle, double forceConstant=1.0)
unsigned int idx1
index of atom1 of the angle constraint
unsigned int idx2
index of atom2 of the angle constraint
double forceConstant
force constant for angle constraint