RDKit
Open-source cheminformatics and machine learning.
Loading...
Searching...
No Matches
PositionConstraint.h
Go to the documentation of this file.
1//
2// Copyright (C) 2013-2024 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_POSITIONCONSTRAINT_H
12#define RD_POSITIONCONSTRAINT_H
13#include "Contrib.h"
14#include <Geometry/point.h>
15
16namespace ForceFields {
17
18//! A position constraint of the type 0.5k * deltaX^2
20 : public ForceFieldContrib {
21 public:
23 //! Constructor
24 /*!
25 \param owner pointer to the owning ForceField
26 \param idx index of the atom in the ForceField's positions
27 \param minDispl minimum displacement
28 \param maxDispl maximum displacement
29 \param forceConst force constant
30
31 */
32 PositionConstraintContrib(ForceField *owner, unsigned int idx,
33 double maxDispl, double forceConst);
34
35 ~PositionConstraintContrib() override = default;
36 double getEnergy(double *pos) const override;
37
38 void getGrad(double *pos, double *grad) const override;
39 PositionConstraintContrib *copy() const override {
40 return new PositionConstraintContrib(*this);
41 }
42
43 private:
44 int d_atIdx{-1}; //!< index of the restrained atom
45 double d_maxDispl; //!< maximum allowed displacement
46 RDGeom::Point3D d_pos0; //!< reference position
47 double d_forceConstant; //!< force constant of the bond
48};
49} // namespace ForceFields
50#endif
abstract base class for contributions to ForceFields
Definition Contrib.h:18
A class to store forcefields and handle minimization.
Definition ForceField.h:79
A position constraint of the type 0.5k * deltaX^2.
~PositionConstraintContrib() override=default
PositionConstraintContrib(ForceField *owner, unsigned int idx, double maxDispl, double forceConst)
Constructor.
PositionConstraintContrib * 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
#define RDKIT_FORCEFIELD_EXPORT
Definition export.h:185