RDKit
Open-source cheminformatics and machine learning.
Loading...
Searching...
No Matches
MMFF/TorsionAngle.h
Go to the documentation of this file.
1//
2// Copyright (C) 2013-2025 Paolo Tosco 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#include <RDGeneral/export.h>
11#ifndef RD_MMFFTORSIONANGLE_H
12#define RD_MMFFTORSIONANGLE_H
13
14#include <ForceField/Contrib.h>
15#include <tuple>
16#include <vector>
17
18namespace RDGeom {
19class Point3D;
20}
21
22namespace ForceFields {
23namespace MMFF {
24class MMFFTor;
25
26//! the torsion term for MMFF
28 public:
30 //! Constructor
32 /*!
33 Adds a torsion term to the force field contrib.
34
35 The torsion is between atom1 - atom2 - atom3 - atom4
36 (i.e the angle between bond atom1-atom2 and bond atom3-atom4
37 while looking down bond atom2-atom3)
38
39 \param idx1 index of atom1 in the ForceField's positions
40 \param idx2 index of atom2 in the ForceField's positions
41 \param idx3 index of atom3 in the ForceField's positions
42 \param idx4 index of atom4 in the ForceField's positions
43 \param torsionType MMFF type of the torsional bond between atoms 2 and 3
44 */
45 void addTerm(unsigned int idx1, unsigned int idx2, unsigned int idx3,
46 unsigned int idx4, const MMFFTor *mmffTorParams);
47 double getEnergy(double *pos) const override;
48 void getGrad(double *pos, double *grad) const override;
49 TorsionAngleContrib *copy() const override {
50 return new TorsionAngleContrib(*this);
51 }
52
53 private:
54 std::vector<int16_t> d_at1Idx;
55 std::vector<int16_t> d_at2Idx;
56 std::vector<int16_t> d_at3Idx;
57 std::vector<int16_t> d_at4Idx;
58 std::vector<double> d_V1;
59 std::vector<double> d_V2;
60 std::vector<double> d_V3;
61};
62
63namespace Utils {
64//! calculates and returns the cosine of a torsion angle
65RDKIT_FORCEFIELD_EXPORT double calcTorsionCosPhi(const RDGeom::Point3D &iPoint,
66 const RDGeom::Point3D &jPoint,
67 const RDGeom::Point3D &kPoint,
68 const RDGeom::Point3D &lPoint);
69//! returns the 3-tuple of a torsion angle force constants
70RDKIT_FORCEFIELD_EXPORT std::tuple<double, double, double>
71calcTorsionForceConstant(const MMFFTor *mmffTorParams);
72//! calculates and returns the torsional MMFF energy
73RDKIT_FORCEFIELD_EXPORT double calcTorsionEnergy(const double V1,
74 const double V2,
75 const double V3,
76 const double cosPhi);
77RDKIT_FORCEFIELD_EXPORT void calcTorsionGrad(RDGeom::Point3D *r,
78 RDGeom::Point3D *t, double *d,
79 double **g, double &sinTerm,
80 double &cosPhi);
81} // namespace Utils
82} // namespace MMFF
83} // namespace ForceFields
84#endif
abstract base class for contributions to ForceFields
Definition Contrib.h:18
A class to store forcefields and handle minimization.
Definition ForceField.h:79
class to store MMFF parameters for torsions
void getGrad(double *pos, double *grad) const override
calculates our contribution to the gradients of a position
TorsionAngleContrib(ForceField *owner)
Constructor.
double getEnergy(double *pos) const override
returns our contribution to the energy of a position
void addTerm(unsigned int idx1, unsigned int idx2, unsigned int idx3, unsigned int idx4, const MMFFTor *mmffTorParams)
TorsionAngleContrib * copy() const override
return a copy
#define RDKIT_FORCEFIELD_EXPORT
Definition export.h:185