RDKit: AngleConstraints.h Source File

| 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
20 struct AngleConstraintContribsParams {
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),
33 minAngle(minAngle),
34 maxAngle(maxAngle),
35 forceConstant(forceConstant) {};
36};
37
38//! A term to capture all flat bottom angle constraint potentials.
39 class RDKIT_FORCEFIELD_EXPORT AngleConstraintContribs
40 : public ForceFieldContrib {
41 public:
42 AngleConstraintContribs() = default;
43
44 //! Constructor
45 /*!
46 \param owner pointer to the owning ForceField
47 */
48 AngleConstraintContribs(ForceField *owner);
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
Contrib.h
ForceField.h
ForceFields::AngleConstraintContribs::getEnergy
double getEnergy(double *pos) const override
return the contribution of this contrib to the energy of a given state
ForceFields::AngleConstraintContribs::getGrad
void getGrad(double *pos, double *grad) const override
ForceFields::AngleConstraintContribs::AngleConstraintContribs
AngleConstraintContribs()=default
ForceFields::AngleConstraintContribs::AngleConstraintContribs
AngleConstraintContribs(ForceField *owner)
Constructor.
ForceFields::AngleConstraintContribs::empty
bool empty() const
Return true if there are no contributions in this contrib.
Definition AngleConstraints.h:95
ForceFields::AngleConstraintContribs::~AngleConstraintContribs
~AngleConstraintContribs() override=default
ForceFields::AngleConstraintContribs::addContrib
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.
ForceFields::AngleConstraintContribs::copy
AngleConstraintContribs * copy() const override
Copy constructor.
Definition AngleConstraints.h:90
ForceFields::AngleConstraintContribs::size
unsigned int size() const
Get number of contributions in this contrib.
Definition AngleConstraints.h:98
ForceFields::AngleConstraintContribs::addContrib
void addContrib(unsigned int idx1, unsigned int idx2, unsigned int idx3, double minAngleDeg, double maxAngleDeg, double forceConst)
Add a contribution to this contrib collection.
ForceFields::ForceFieldContrib::ForceField
friend class ForceField
Definition Contrib.h:20
ForceFields::ForceFieldContrib::ForceFieldContrib
ForceFieldContrib()
Definition Contrib.h:22
export.h
RDKIT_FORCEFIELD_EXPORT
#define RDKIT_FORCEFIELD_EXPORT
Definition export.h:201
ForceFields
Definition TorsionAngleContribs.h:21
ForceFields::AngleConstraintContribsParams
Definition AngleConstraints.h:20
ForceFields::AngleConstraintContribsParams::maxAngle
double maxAngle
upper bound of the flat bottom potential
Definition AngleConstraints.h:25
ForceFields::AngleConstraintContribsParams::minAngle
double minAngle
lower bound of the flat bottom potential
Definition AngleConstraints.h:24
ForceFields::AngleConstraintContribsParams::idx3
unsigned int idx3
index of atom3 of the angle constraint
Definition AngleConstraints.h:23
ForceFields::AngleConstraintContribsParams::AngleConstraintContribsParams
AngleConstraintContribsParams(unsigned int idx1, unsigned int idx2, unsigned int idx3, double minAngle, double maxAngle, double forceConstant=1.0)
Definition AngleConstraints.h:27
ForceFields::AngleConstraintContribsParams::idx1
unsigned int idx1
index of atom1 of the angle constraint
Definition AngleConstraints.h:21
ForceFields::AngleConstraintContribsParams::idx2
unsigned int idx2
index of atom2 of the angle constraint
Definition AngleConstraints.h:22
ForceFields::AngleConstraintContribsParams::forceConstant
double forceConstant
force constant for angle constraint
Definition AngleConstraints.h:26