RDKit
Open-source cheminformatics and machine learning.
Toggle main menu visibility
Loading...
Searching...
No Matches
GaussianTorsionAngleContribs.h
Go to the documentation of this file.
1
//
2
// Copyright (C) 2026 ETH Zurich and other RDKit contributors
3
// Author: Niels Maeder
4
//
5
// @@ All Rights Reserved @@
6
// This file is part of the RDKit.
7
// The contents are covered by the terms of the BSD license
8
// which is included in the file license.txt, found at the root
9
// of the RDKit source tree.
10
//
11
12
#include <
RDGeneral/export.h
>
13
#ifndef RD_GAUSSIANTORSIONANGLECONTRIBS_H
14
#define RD_GAUSSIANTORSIONANGLECONTRIBS_H
15
#include <
ForceField/Contrib.h
>
16
#include <vector>
17
18
namespace
RDGeom
{
19
class
Point3D
;
20
}
21
22
namespace
ForceFields
{
23
class
ForceField
;
24
class
ForceFieldContrib
;
25
}
// namespace ForceFields
26
27
namespace
ForceFields
{
28
namespace
CrystalFF
{
29
30
//! Size of the energies and gradients lookup table
31
//! This is used in `torsionPreferences.cpp`.
32
constexpr
std::size_t
lookup_grid_size
= 180;
33
34
//! A term to capture all torsion constraint potentials.
35
//!
36
struct
RDKIT_FORCEFIELDHELPERS_EXPORT
GaussianTorsionAngleContribsParams
{
37
std::size_t
idx1
{0};
38
std::size_t
idx2
{0};
39
std::size_t
idx3
{0};
40
std::size_t
idx4
{0};
41
std::vector<double>
energies
{};
42
std::vector<double>
gradients
{};
43
double
scaling
{1.0};
44
GaussianTorsionAngleContribsParams
(std::size_t
idx1
, std::size_t
idx2
,
45
std::size_t
idx3
, std::size_t
idx4
,
46
std::vector<double>
energies
,
47
std::vector<double>
gradients
,
48
double
scaling
= 1.0)
49
:
idx1
(
idx1
),
50
idx2
(
idx2
),
51
idx3
(
idx3
),
52
idx4
(
idx4
),
53
energies
(std::move(
energies
)),
54
gradients
(std::move(
gradients
)),
55
scaling
(
scaling
) {}
56
};
57
58
class
RDKIT_FORCEFIELDHELPERS_EXPORT
GaussianTorsionAngleContribs
59
:
public
ForceFieldContrib
{
60
public
:
61
GaussianTorsionAngleContribs
() =
default
;
62
63
//! Constructor
64
/*!
65
\param owner pointer to the owning ForceField
66
*/
67
GaussianTorsionAngleContribs
(
ForceField
*owner);
68
~GaussianTorsionAngleContribs
() =
default
;
69
//! Add contribution to this collection.
70
//! The caller is responsible that the energies and gradient lookuptables
71
//! have at least to elements each!
72
/*!
73
\param idx1 index of atom1 in the ForceField's positions
74
\param idx2 index of atom2 in the ForceField's positions
75
\param idx3 index of atom3 in the ForceField's positions
76
\param idx4 index of atom4 in the ForceField's positions
77
\param energies lookup table for the energies
78
\param gradients lookup table for the gradients
79
\param scaling Scaling factor for energy and gradient (for K terms)
80
*/
81
void
addContrib
(std::size_t idx1, std::size_t idx2, std::size_t idx3,
82
std::size_t idx4, std::vector<double> energies,
83
std::vector<double> gradients,
double
scaling = 1.0);
84
//! return the contribution of this contrib to the energy of a given state
85
/*!
86
\param pos positions of the atoms in the current state
87
*/
88
double
getEnergy
(
double
*pos)
const override
;
89
//! calculate the contribution of this contrib to the gradient at a given
90
/// state
91
/*!
92
\param pos positions of the atoms in the current state
93
\param grad gradients to be adapted
94
*/
95
void
getGrad
(
double
*pos,
double
*grad)
const override
;
96
//! Copy constructor
97
GaussianTorsionAngleContribs
*
copy
()
const override
{
98
return
new
GaussianTorsionAngleContribs
(*
this
);
99
}
100
101
//! Return true if there are no contributions in this contrib
102
bool
empty
()
const
{
return
d_contribs.empty(); }
103
104
//! Get number of contributions in this contrib
105
unsigned
int
size
()
const
{
return
d_contribs.size(); }
106
107
private
:
108
std::vector<GaussianTorsionAngleContribsParams> d_contribs;
109
};
110
111
//! Calculate the torsion energy as described in 10.1021/acs.jcim.5b00654, this
112
//! can be used with any any number of heights, positions and widths.
113
//! The caller is responsible that the size of the three parameter objects are
114
//! the same and non zero. `widths` need to be strictly positive.
115
/*!
116
\param heights heights of the gaussians
117
\param positions positions of the gaussians
118
\param widths widths of the gaussians
119
\param phi the torsion angle in radians
120
*/
121
RDKIT_FORCEFIELDHELPERS_EXPORT
double
getEnergy
(
122
const
std::vector<double> &heights,
const
std::vector<double> &positions,
123
const
std::vector<double> &widths,
const
double
phi);
124
125
//! Calculate the torsion gradient as described in 10.1021/acs.jcim.5b00654,
126
//! this can be used with any any number of heights, positions and widths. The
127
//! caller is responsible that the size of the three parameter objects are the
128
//! same and non zero. `widths` need to be strictly positive.
129
/*!
130
\param heights heights of the gaussians
131
\param positions positions of the gaussians
132
\param widths widths of the gaussians
133
\param phi the torsion angle in radians
134
*/
135
RDKIT_FORCEFIELDHELPERS_EXPORT
double
getdEdPhi
(
136
const
std::vector<double> &heights,
const
std::vector<double> &positions,
137
const
std::vector<double> &widths,
const
double
phi);
138
}
// namespace CrystalFF
139
}
// namespace ForceFields
140
141
#endif
Contrib.h
ForceFields::CrystalFF::GaussianTorsionAngleContribs::getGrad
void getGrad(double *pos, double *grad) const override
ForceFields::CrystalFF::GaussianTorsionAngleContribs::addContrib
void addContrib(std::size_t idx1, std::size_t idx2, std::size_t idx3, std::size_t idx4, std::vector< double > energies, std::vector< double > gradients, double scaling=1.0)
ForceFields::CrystalFF::GaussianTorsionAngleContribs::size
unsigned int size() const
Get number of contributions in this contrib.
Definition
GaussianTorsionAngleContribs.h:105
ForceFields::CrystalFF::GaussianTorsionAngleContribs::~GaussianTorsionAngleContribs
~GaussianTorsionAngleContribs()=default
ForceFields::CrystalFF::GaussianTorsionAngleContribs::GaussianTorsionAngleContribs
GaussianTorsionAngleContribs()=default
ForceFields::CrystalFF::GaussianTorsionAngleContribs::getEnergy
double getEnergy(double *pos) const override
return the contribution of this contrib to the energy of a given state
ForceFields::CrystalFF::GaussianTorsionAngleContribs::GaussianTorsionAngleContribs
GaussianTorsionAngleContribs(ForceField *owner)
Constructor.
ForceFields::CrystalFF::GaussianTorsionAngleContribs::empty
bool empty() const
Return true if there are no contributions in this contrib.
Definition
GaussianTorsionAngleContribs.h:102
ForceFields::CrystalFF::GaussianTorsionAngleContribs::copy
GaussianTorsionAngleContribs * copy() const override
Copy constructor.
Definition
GaussianTorsionAngleContribs.h:97
ForceFields::ForceFieldContrib
abstract base class for contributions to ForceFields
Definition
Contrib.h:18
ForceFields::ForceFieldContrib::ForceField
friend class ForceField
Definition
Contrib.h:20
ForceFields::ForceFieldContrib::ForceFieldContrib
ForceFieldContrib()
Definition
Contrib.h:22
ForceFields::ForceField
A class to store forcefields and handle minimization.
Definition
ForceField.h:79
RDGeom::Point3D
Definition
point.h:53
export.h
RDKIT_FORCEFIELDHELPERS_EXPORT
#define RDKIT_FORCEFIELDHELPERS_EXPORT
Definition
export.h:261
ForceFields::CrystalFF
Definition
GaussianTorsionAngleContribs.h:28
ForceFields::CrystalFF::getdEdPhi
RDKIT_FORCEFIELDHELPERS_EXPORT double getdEdPhi(const std::vector< double > &heights, const std::vector< double > &positions, const std::vector< double > &widths, const double phi)
ForceFields::CrystalFF::getEnergy
RDKIT_FORCEFIELDHELPERS_EXPORT double getEnergy(const std::vector< double > &heights, const std::vector< double > &positions, const std::vector< double > &widths, const double phi)
ForceFields::CrystalFF::lookup_grid_size
constexpr std::size_t lookup_grid_size
Definition
GaussianTorsionAngleContribs.h:32
ForceFields
Definition
GaussianTorsionAngleContribs.h:22
RDGeom
Definition
Embedder.h:30
ForceFields::CrystalFF::GaussianTorsionAngleContribsParams::idx1
std::size_t idx1
Definition
GaussianTorsionAngleContribs.h:37
ForceFields::CrystalFF::GaussianTorsionAngleContribsParams::idx3
std::size_t idx3
Definition
GaussianTorsionAngleContribs.h:39
ForceFields::CrystalFF::GaussianTorsionAngleContribsParams::energies
std::vector< double > energies
Definition
GaussianTorsionAngleContribs.h:41
ForceFields::CrystalFF::GaussianTorsionAngleContribsParams::idx4
std::size_t idx4
Definition
GaussianTorsionAngleContribs.h:40
ForceFields::CrystalFF::GaussianTorsionAngleContribsParams::scaling
double scaling
Definition
GaussianTorsionAngleContribs.h:43
ForceFields::CrystalFF::GaussianTorsionAngleContribsParams::idx2
std::size_t idx2
Definition
GaussianTorsionAngleContribs.h:38
ForceFields::CrystalFF::GaussianTorsionAngleContribsParams::GaussianTorsionAngleContribsParams
GaussianTorsionAngleContribsParams(std::size_t idx1, std::size_t idx2, std::size_t idx3, std::size_t idx4, std::vector< double > energies, std::vector< double > gradients, double scaling=1.0)
Definition
GaussianTorsionAngleContribs.h:44
ForceFields::CrystalFF::GaussianTorsionAngleContribsParams::gradients
std::vector< double > gradients
Definition
GaussianTorsionAngleContribs.h:42
GraphMol
ForceFieldHelpers
CrystalFF
GaussianTorsionAngleContribs.h
Generated on
for RDKit by
1.17.0