RDKit: Nonbonded.h Source File

| RDKit Open-source cheminformatics and machine learning.

Loading...
Searching...
No Matches
MMFF/Nonbonded.h
Go to the documentation of this file.
1// Copyright (C) 2013-2025 Paolo Tosco and other RDKit contributors
2//
3// @@ All Rights Reserved @@
4// This file is part of the RDKit.
5// The contents are covered by the terms of the BSD license
6// which is included in the file license.txt, found at the root
7// of the RDKit source tree.
8//
9#include <RDGeneral/export.h>
10#ifndef __RD_MMFFNONBONDED_H__
11#define __RD_MMFFNONBONDED_H__
12#include <ForceField/Contrib.h>
13#include <GraphMol/RDKitBase.h>
14#include <GraphMol/ForceFieldHelpers/MMFF/AtomTyper.h>
15
16namespace ForceFields {
17namespace MMFF {
18class MMFFVdWCollection;
19class MMFFVdW;
20
21//! combined vdW and charge terms for MMFF
22 class RDKIT_FORCEFIELD_EXPORT NonbondedContrib : public ForceFieldContrib {
23 public:
24 NonbondedContrib() {}
25 NonbondedContrib(ForceField *owner);
26 //! Track a new VdW pair
27 void addTerm(unsigned int idx1, unsigned int idx2,
28 const MMFFVdWRijstarEps *mmffVdWConstants, bool includeCharge,
29 double chargeTerm, std::uint8_t dielModel, bool is1_4);
30 double getEnergy(double *pos) const override;
31 void getGrad(double *pos, double *grad) const override;
32 NonbondedContrib *copy() const override {
33 return new NonbondedContrib(*this);
34 }
35
36 private:
37 enum ContribType {
38 VDW = 1 << 0, //!< van der Waals contribution
39 ELECTROSTATIC = 1 << 1 //!< electrostatic contribution
40 };
41 std::vector<int16_t> d_at1Idxs;
42 std::vector<int16_t> d_at2Idxs;
43 std::vector<std::uint8_t>
44 d_contribTypes; //!< bit field 0x1: vdW, 0x2: electrostatic
45 std::vector<double> d_R_ij_stars; //!< the preferred length of the contact
46 std::vector<double>
47 d_wellDepths; //!< the vdW well depth (strength of the interaction)
48 std::vector<double> d_chargeTerms;
49 std::vector<std::uint8_t> d_is_1_4s;
50 std::vector<std::uint8_t>
51 d_dielModels; //!< dielectric model (1: constant; 2: distance-dependent)
52};
53
54//! the van der Waals term for MMFF
55 class RDKIT_FORCEFIELD_EXPORT VdWContrib : public ForceFieldContrib {
56 public:
57 VdWContrib() {}
58 VdWContrib(ForceField *owner);
59 //! Track a new VdW pair
60 void addTerm(unsigned int idx1, unsigned int idx2,
61 const MMFFVdWRijstarEps *mmffVdWConstants);
62 double getEnergy(double *pos) const override;
63 void getGrad(double *pos, double *grad) const override;
64 VdWContrib *copy() const override { return new VdWContrib(*this); }
65
66 private:
67 std::vector<int16_t> d_at1Idxs;
68 std::vector<int16_t> d_at2Idxs;
69 std::vector<double> d_R_ij_stars; //!< the preferred length of the contact
70 std::vector<double>
71 d_wellDepths; //!< the vdW well depth (strength of the interaction)
72};
73
74//! the electrostatic term for MMFF
75 class RDKIT_FORCEFIELD_EXPORT EleContrib : public ForceFieldContrib {
76 public:
77 EleContrib() {}
78
79 //! Constructor
80 /*!
81 \param owner pointer to the owning ForceField
82 \param idx1 index of end1 in the ForceField's positions
83 \param idx2 index of end2 in the ForceField's positions
84
85 */
86 EleContrib(ForceField *owner);
87 void addTerm(unsigned int idx1, unsigned int idx2, double chargeTerm,
88 std::uint8_t dielModel, bool is1_4);
89 double getEnergy(double *pos) const override;
90 void getGrad(double *pos, double *grad) const override;
91
92 EleContrib *copy() const override { return new EleContrib(*this); }
93
94 private:
95 std::vector<int16_t> d_at1Idxs;
96 std::vector<int16_t> d_at2Idxs;
97 std::vector<double> d_chargeTerms;
98 std::vector<std::uint8_t> d_is_1_4s;
99 std::vector<std::uint8_t>
100 d_dielModels; //!< dielectric model (1: constant; 2: distance-dependent)
101};
102
103namespace Utils {
104//! calculates and returns the unscaled minimum distance (R*ij) for a MMFF VdW
105/// contact
106 RDKIT_FORCEFIELD_EXPORT double calcUnscaledVdWMinimum(
107 const MMFFVdWCollection *mmffVdW, const MMFFVdW *mmffVdWParamsAtom1,
108 const MMFFVdW *mmffVdWParamsAtom2);
109//! calculates and returns the unscaled well depth (epsilon) for a MMFF VdW
110/// contact
111 RDKIT_FORCEFIELD_EXPORT double calcUnscaledVdWWellDepth(
112 double R_star_ij, const MMFFVdW *mmffVdWParamsIAtom,
113 const MMFFVdW *mmffVdWParamsJAtom);
114//! scales the VdW parameters
115 RDKIT_FORCEFIELD_EXPORT void scaleVdWParams(double &R_star_ij,
116 double &wellDepth,
117 const MMFFVdWCollection *mmffVdW,
118 const MMFFVdW *mmffVdWParamsIAtom,
119 const MMFFVdW *mmffVdWParamsJAtom);
120//! calculates and returns the Van der Waals MMFF energy
121 RDKIT_FORCEFIELD_EXPORT double calcVdWEnergy(const double dist,
122 const double R_star_ij,
123 const double wellDepth);
124//! calculates and returns the electrostatic MMFF energy
125// FIX: idx1 and idx2 are not used
126 RDKIT_FORCEFIELD_EXPORT double calcEleEnergy(unsigned int idx1,
127 unsigned int idx2, double dist,
128 double chargeTerm,
129 std::uint8_t dielModel,
130 bool is1_4);
131} // namespace Utils
132} // namespace MMFF
133} // namespace ForceFields
134#endif
Contrib.h
AtomTyper.h
RDKitBase.h
pulls in the core RDKit functionality
ForceFields::ForceFieldContrib::ForceField
friend class ForceField
Definition Contrib.h:20
ForceFields::ForceFieldContrib::ForceFieldContrib
ForceFieldContrib()
Definition Contrib.h:22
ForceFields::MMFF::EleContrib::copy
EleContrib * copy() const override
return a copy
Definition MMFF/Nonbonded.h:92
ForceFields::MMFF::EleContrib::EleContrib
EleContrib()
Definition MMFF/Nonbonded.h:77
ForceFields::MMFF::EleContrib::getEnergy
double getEnergy(double *pos) const override
returns our contribution to the energy of a position
ForceFields::MMFF::EleContrib::getGrad
void getGrad(double *pos, double *grad) const override
calculates our contribution to the gradients of a position
ForceFields::MMFF::EleContrib::EleContrib
EleContrib(ForceField *owner)
Constructor.
ForceFields::MMFF::EleContrib::addTerm
void addTerm(unsigned int idx1, unsigned int idx2, double chargeTerm, std::uint8_t dielModel, bool is1_4)
ForceFields::MMFF::MMFFVdWCollection
Definition MMFF/Params.h:960
ForceFields::MMFF::MMFFVdWRijstarEps
Definition MMFF/Params.h:142
ForceFields::MMFF::MMFFVdW
class to store MMFF parameters for non-bonded Van der Waals
Definition MMFF/Params.h:132
ForceFields::MMFF::NonbondedContrib::NonbondedContrib
NonbondedContrib()
Definition MMFF/Nonbonded.h:24
ForceFields::MMFF::NonbondedContrib::NonbondedContrib
NonbondedContrib(ForceField *owner)
ForceFields::MMFF::NonbondedContrib::copy
NonbondedContrib * copy() const override
return a copy
Definition MMFF/Nonbonded.h:32
ForceFields::MMFF::NonbondedContrib::getGrad
void getGrad(double *pos, double *grad) const override
calculates our contribution to the gradients of a position
ForceFields::MMFF::NonbondedContrib::getEnergy
double getEnergy(double *pos) const override
returns our contribution to the energy of a position
ForceFields::MMFF::NonbondedContrib::addTerm
void addTerm(unsigned int idx1, unsigned int idx2, const MMFFVdWRijstarEps *mmffVdWConstants, bool includeCharge, double chargeTerm, std::uint8_t dielModel, bool is1_4)
Track a new VdW pair.
ForceFields::MMFF::VdWContrib::addTerm
void addTerm(unsigned int idx1, unsigned int idx2, const MMFFVdWRijstarEps *mmffVdWConstants)
Track a new VdW pair.
ForceFields::MMFF::VdWContrib::VdWContrib
VdWContrib()
Definition MMFF/Nonbonded.h:57
ForceFields::MMFF::VdWContrib::getEnergy
double getEnergy(double *pos) const override
returns our contribution to the energy of a position
ForceFields::MMFF::VdWContrib::copy
VdWContrib * copy() const override
return a copy
Definition MMFF/Nonbonded.h:64
ForceFields::MMFF::VdWContrib::VdWContrib
VdWContrib(ForceField *owner)
ForceFields::MMFF::VdWContrib::getGrad
void getGrad(double *pos, double *grad) const override
calculates our contribution to the gradients of a position
export.h
RDKIT_FORCEFIELD_EXPORT
#define RDKIT_FORCEFIELD_EXPORT
Definition export.h:201
ForceFields::MMFF::Utils::calcUnscaledVdWMinimum
RDKIT_FORCEFIELD_EXPORT double calcUnscaledVdWMinimum(const MMFFVdWCollection *mmffVdW, const MMFFVdW *mmffVdWParamsAtom1, const MMFFVdW *mmffVdWParamsAtom2)
ForceFields::MMFF::Utils::calcVdWEnergy
RDKIT_FORCEFIELD_EXPORT double calcVdWEnergy(const double dist, const double R_star_ij, const double wellDepth)
calculates and returns the Van der Waals MMFF energy
ForceFields::MMFF::Utils::scaleVdWParams
RDKIT_FORCEFIELD_EXPORT void scaleVdWParams(double &R_star_ij, double &wellDepth, const MMFFVdWCollection *mmffVdW, const MMFFVdW *mmffVdWParamsIAtom, const MMFFVdW *mmffVdWParamsJAtom)
scales the VdW parameters
ForceFields::MMFF::Utils::calcUnscaledVdWWellDepth
RDKIT_FORCEFIELD_EXPORT double calcUnscaledVdWWellDepth(double R_star_ij, const MMFFVdW *mmffVdWParamsIAtom, const MMFFVdW *mmffVdWParamsJAtom)
ForceFields::MMFF::Utils::calcEleEnergy
RDKIT_FORCEFIELD_EXPORT double calcEleEnergy(unsigned int idx1, unsigned int idx2, double dist, double chargeTerm, std::uint8_t dielModel, bool is1_4)
calculates and returns the electrostatic MMFF energy
ForceFields::MMFF
Definition MMFF/AngleBend.h:17
ForceFields
Definition TorsionAngleContribs.h:21