RDKit
Open-source cheminformatics and machine learning.
Loading...
Searching...
No Matches
TorsionAngleContribs.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_TORSIONANGLECONTRIBS_H
13#define RD_TORSIONANGLECONTRIBS_H
14#include <ForceField/Contrib.h>
15#include <vector>
16
17namespace RDGeom {
18class Point3D;
19}
20
21namespace ForceFields {
22class ForceField;
24} // namespace ForceFields
25
26namespace ForceFields {
27namespace CrystalFF {
28
29//! A term to capture all torsion constraint potentials.
30//!
32 unsigned int idx1{0};
33 unsigned int idx2{0};
34 unsigned int idx3{0};
35 unsigned int idx4{0};
36 std::vector<double> forceConstants{6, 1.0};
37 std::vector<int> signs{6, 1};
38 TorsionAngleContribsParams(unsigned int idx1, unsigned int idx2,
39 unsigned int idx3, unsigned int idx4,
40 std::vector<double> forceConstants,
41 std::vector<int> signs)
42 : idx1(idx1),
43 idx2(idx2),
44 idx3(idx3),
45 idx4(idx4),
46 forceConstants(forceConstants),
47 signs(signs) {}
48};
49
51 : public ForceFieldContrib {
52 public:
54
55 //! Constructor
56 /*!
57 \param owner pointer to the owning ForceField
58 */
61 //! Add contribution to this collection.
62 /*!
63 \param idx1 index of atom1 in the ForceField's positions
64 \param idx2 index of atom2 in the ForceField's positions
65 \param idx3 index of atom3 in the ForceField's positions
66 \param idx4 index of atom4 in the ForceField's positions
67 \param forceConstants force constants for the torsion potentials
68 \param signs phase for the torsion potentials (-1 or 1)
69
70 */
71 void addContrib(unsigned int idx1, unsigned int idx2, unsigned int idx3,
72 unsigned int idx4, std::vector<double> forceConstants,
73 std::vector<int> signs);
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 //! calculate the contribution of this contrib to the gradient at a given
80 /// state
81 /*!
82 \param pos positions of the atoms in the current state
83 \param grad gradients to be adapted
84 */
85 void getGrad(double *pos, double *grad) const override;
86 //! Copy constructor
87 TorsionAngleContribs *copy() const override {
88 return new TorsionAngleContribs(*this);
89 }
90
91 //! Return true if there are no contributions in this contrib
92 bool empty() const { return d_contribs.empty(); }
93
94 //! Get number of contributions in this contrib
95 unsigned int size() const { return d_contribs.size(); }
96
97 private:
98 std::vector<TorsionAngleContribsParams> d_contribs;
99};
100
101//! Calculate the torsion energy as described in 10.1021/acs.jcim.5b00654, this
102//! can be used with any i > 0.
103/*!
104 \param forceConstants Force constants for the different cosine fits
105 \param signs Phases of the cosine fits
106 \param cosPhi cosine of the torsion angle phi
107*/
109 const std::vector<double> &forceConstants, const std::vector<int> &signs,
110 const double cosPhi);
111
112} // namespace CrystalFF
113} // namespace ForceFields
114
115#endif
unsigned int size() const
Get number of contributions in this contrib.
void addContrib(unsigned int idx1, unsigned int idx2, unsigned int idx3, unsigned int idx4, std::vector< double > forceConstants, std::vector< int > signs)
Add contribution to this collection.
double getEnergy(double *pos) const override
return the contribution of this contrib to the energy of a given state
TorsionAngleContribs * copy() const override
Copy constructor.
void getGrad(double *pos, double *grad) const override
TorsionAngleContribs(ForceField *owner)
Constructor.
bool empty() const
Return true if there are no contributions in this contrib.
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_FORCEFIELDHELPERS_EXPORT
Definition export.h:193
RDKIT_FORCEFIELDHELPERS_EXPORT double calcTorsionEnergy(const std::vector< double > &forceConstants, const std::vector< int > &signs, const double cosPhi)
TorsionAngleContribsParams(unsigned int idx1, unsigned int idx2, unsigned int idx3, unsigned int idx4, std::vector< double > forceConstants, std::vector< int > signs)