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 <iostream>
16#include "ForceField.h"
17#include "Contrib.h"
18
19namespace ForceFields {
20
22 unsigned int idx1{0}; //!< index of atom1 of the angle constraint
23 unsigned int idx2{0}; //!< index of atom2 of the angle constraint
24 unsigned int idx3{0}; //!< index of atom3 of the angle constraint
25 double minAngle{0.0}; //!< lower bound of the flat bottom potential
26 double maxAngle{0.0}; //!< upper bound of the flat bottom potential
27 double forceConstant{1.0}; //!< force constant for angle constraint
28 AngleConstraintContribsParams(unsigned int idx1, unsigned int idx2,
29 unsigned int idx3, double minAngle,
30 double maxAngle, double forceConstant = 1.0)
31 : idx1(idx1),
32 idx2(idx2),
33 idx3(idx3),
37};
38
39//! A term to capture all flat bottom angle constraint potentials.
41 : public ForceFieldContrib {
42 public:
44
45 //! Constructor
46 /*!
47 \param owner pointer to the owning ForceField
48 */
50 ~AngleConstraintContribs() override = default;
51 //! Add a contribution to this contrib collection
52 /*!
53 \param idx1 index of atom1 in the ForceField's positions
54 \param idx2 index of atom2 in the ForceField's positions
55 \param idx3 index of atom3 in the ForceField's positions
56 \param minAngle minimum angle
57 \param maxAngle maximum angle
58 \param forceConst force Constant
59
60 */
61 void addContrib(unsigned int idx1, unsigned int idx2, unsigned int idx3,
62 double minAngleDeg, double maxAngleDeg, double forceConst);
63 //! Add a contribution to this contrib collection
64 /*!
65 \param idx1 index of atom1 in the ForceField's positions
66 \param idx2 index of atom2 in the ForceField's positions
67 \param idx3 index of atom3 in the ForceField's positions
68 \param relative whether to add the provided angle to the current angle
69 \param minAngle minimum angle
70 \param maxAngle maximum angle
71 \param forceConst force Constant
72
73 */
74 void addContrib(unsigned int idx1, unsigned int idx2, unsigned int idx3,
75 bool relative, double minAngleDeg, double maxAngleDeg,
76 double forceConst);
77 //! return the contribution of this contrib to the energy of a given state
78 /*!
79 \param pos positions of the atoms in the current state
80 */
81 double getEnergy(double *pos) const override;
82 //! calculate the contribution of this contrib to the gradient at a given
83 /// state
84 /*!
85 \param pos positions of the atoms in the current state
86 \param grad gradients to be adapted
87 */
88 void getGrad(double *pos, double *grad) const override;
89 //! Copy constructor
90
91 AngleConstraintContribs *copy() const override {
92 return new AngleConstraintContribs(*this);
93 }
94
95 //! Return true if there are no contributions in this contrib
96 bool empty() const { return d_contribs.empty(); }
97
98 //! Get number of contributions in this contrib
99 unsigned int size() const { return d_contribs.size(); }
100
101 private:
102 std::vector<AngleConstraintContribsParams> d_contribs;
103 double computeAngleTerm(const double &angle,
104 const AngleConstraintContribsParams &contrib) const;
105};
106} // namespace ForceFields
107#endif
A term to capture all flat bottom angle constraint potentials.
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.
abstract base class for contributions to ForceFields
Definition Contrib.h:18
A class to store forcefields and handle minimization.
Definition ForceField.h:79
#define RDKIT_FORCEFIELD_EXPORT
Definition export.h:185
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