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 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 //! calculate the contribution of this contrib to the gradient at a given
82 /// state
83 /*!
84 \param pos positions of the atoms in the current state
85 \param grad gradients to be adapted
86 */
87 void getGrad(double *pos, double *grad) const override;
88 //! Copy constructor
89
90 AngleConstraintContribs *copy() const override {
91 return new AngleConstraintContribs(*this);
92 }
93
94 //! Return true if there are no contributions in this contrib
95 bool empty() const { return d_contribs.empty(); }
96
97 //! Get number of contributions in this contrib
98 unsigned int size() const { return d_contribs.size(); }
99
100 private:
101 std::vector<AngleConstraintContribsParams> d_contribs;
102 double computeAngleTerm(const double &angle,
103 const AngleConstraintContribsParams &contrib) const;
104};
105} // namespace ForceFields
106#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
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
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