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>
15
16namespace ForceFields {
17namespace MMFF {
19class MMFFVdW;
20
21//! combined vdW and charge terms for MMFF
23 public:
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
56 public:
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
76 public:
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 */
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
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
112 double R_star_ij, const MMFFVdW *mmffVdWParamsIAtom,
113 const MMFFVdW *mmffVdWParamsJAtom);
114//! scales the VdW parameters
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
121RDKIT_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
126RDKIT_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
pulls in the core RDKit functionality
EleContrib * copy() const override
return a copy
double getEnergy(double *pos) const override
returns our contribution to the energy of a position
void getGrad(double *pos, double *grad) const override
calculates our contribution to the gradients of a position
EleContrib(ForceField *owner)
Constructor.
void addTerm(unsigned int idx1, unsigned int idx2, double chargeTerm, std::uint8_t dielModel, bool is1_4)
class to store MMFF parameters for non-bonded Van der Waals
NonbondedContrib * copy() const override
return a copy
void getGrad(double *pos, double *grad) const override
calculates our contribution to the gradients of a position
double getEnergy(double *pos) const override
returns our contribution to the energy of a position
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.
void addTerm(unsigned int idx1, unsigned int idx2, const MMFFVdWRijstarEps *mmffVdWConstants)
Track a new VdW pair.
double getEnergy(double *pos) const override
returns our contribution to the energy of a position
VdWContrib * copy() const override
return a copy
VdWContrib(ForceField *owner)
void getGrad(double *pos, double *grad) const override
calculates our contribution to the gradients of a position
#define RDKIT_FORCEFIELD_EXPORT
Definition export.h:201
RDKIT_FORCEFIELD_EXPORT double calcUnscaledVdWMinimum(const MMFFVdWCollection *mmffVdW, const MMFFVdW *mmffVdWParamsAtom1, const MMFFVdW *mmffVdWParamsAtom2)
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
RDKIT_FORCEFIELD_EXPORT void scaleVdWParams(double &R_star_ij, double &wellDepth, const MMFFVdWCollection *mmffVdW, const MMFFVdW *mmffVdWParamsIAtom, const MMFFVdW *mmffVdWParamsJAtom)
scales the VdW parameters
RDKIT_FORCEFIELD_EXPORT double calcUnscaledVdWWellDepth(double R_star_ij, const MMFFVdW *mmffVdWParamsIAtom, const MMFFVdW *mmffVdWParamsJAtom)
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