Loading...
Searching...
No Matches
forcefield.h
Go to the documentation of this file.
/**********************************************************************
forcefield.h - Handle OBForceField class.
Copyright (C) 2006-2007 by Tim Vandermeersch <tim.vandermeersch@gmail.com>
This file is part of the Open Babel project.
For more information, see <http://openbabel.org/>
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation version 2 of the License.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
***********************************************************************/
#ifndef OB_FORCEFIELD_H
#define OB_FORCEFIELD_H
#include <vector>
#include <string>
#include <openbabel/babelconfig.h>
#include <openbabel/mol.h> // TODO: Move OBMol code out of the header (use OBMol*)
#include <openbabel/atom.h> // TODO: Move OBAtom code out of the header
#include <openbabel/plugin.h>
#include <openbabel/bitvec.h>
#include <float.h>
namespace OpenBabel
{
class OBGridData;
// log levels
#define OBFF_LOGLVL_NONE 0
#define OBFF_LOGLVL_LOW 1
#define OBFF_LOGLVL_MEDIUM 2
#define OBFF_LOGLVL_HIGH 3
// terms
#define OBFF_ENERGY (1 << 0)
#define OBFF_EBOND (1 << 1)
#define OBFF_EANGLE (1 << 2)
#define OBFF_ESTRBND (1 << 3)
#define OBFF_ETORSION (1 << 4)
#define OBFF_EOOP (1 << 5)
#define OBFF_EVDW (1 << 6)
#define OBFF_EELECTROSTATIC (1 << 7)
// constraint types
#define OBFF_CONST_IGNORE (1 << 0)
#define OBFF_CONST_ATOM (1 << 1)
#define OBFF_CONST_ATOM_X (1 << 2)
#define OBFF_CONST_ATOM_Y (1 << 3)
#define OBFF_CONST_ATOM_Z (1 << 4)
#define OBFF_CONST_DISTANCE (1 << 5)
#define OBFF_CONST_ANGLE (1 << 6)
#define OBFF_CONST_TORSION (1 << 7)
#define OBFF_CONST_CHIRAL (1 << 8)
// mode arguments for SteepestDescent, ConjugateGradients, ...
#define OBFF_NUMERICAL_GRADIENT (1 << 0)
#define OBFF_ANALYTICAL_GRADIENT (1 << 1)
const double KCAL_TO_KJ = 4.1868;
const double GAS_CONSTANT = 8.31446261815324e-3 / KCAL_TO_KJ;
// inline if statements for logging.
#define IF_OBFF_LOGLVL_LOW if(_loglvl >= OBFF_LOGLVL_LOW)
#define IF_OBFF_LOGLVL_MEDIUM if(_loglvl >= OBFF_LOGLVL_MEDIUM)
#define IF_OBFF_LOGLVL_HIGH if(_loglvl >= OBFF_LOGLVL_HIGH)
struct LineSearchType
{
enum {
Simple, Newton2Num
};
};
/*
struct ConstraintType
{
enum {
Ignore, Atom, AtomX, AtomY, AtomZ, Distance, Angle, Torsion, Chiral
};
};
*/
class OBFPRT OBFFParameter {
public:
int a, b, c, d;
std::string _a, _b, _c, _d;
std::vector<int> _ipar;
std::vector<double> _dpar;
OBFFParameter& operator=(const OBFFParameter &ai)
{
if (this != &ai) {
a = ai.a;
b = ai.b;
c = ai.c;
d = ai.d;
_a = ai._a;
_b = ai._b;
_c = ai._c;
_d = ai._d;
_ipar = ai._ipar;
_dpar = ai._dpar;
}
return *this;
}
void clear ()
{
a = b = c = d = 0;
_ipar.clear();
_dpar.clear();
}
}; // class OBFFParameter
// specific class introductions in forcefieldYYYY.cpp (for YYYY calculations)
class OBFPRT OBFFCalculation2
{
public:
double energy;
OBAtom *a, *b;
int idx_a, idx_b;
double *pos_a, *pos_b;
double force_a[3], force_b[3];
virtual ~OBFFCalculation2()
{
}
virtual void SetupPointers()
{
if (!a || !b) return;
pos_a = a->GetCoordinate();
idx_a = a->GetIdx();
pos_b = b->GetCoordinate();
idx_b = b->GetIdx();
}
};
class OBFPRT OBFFCalculation3: public OBFFCalculation2
{
public:
OBAtom *c;
int idx_c;
double *pos_c;
double force_c[3];
virtual ~OBFFCalculation3()
{
}
virtual void SetupPointers()
{
if (!a || !b || !c) return;
pos_a = a->GetCoordinate();
idx_a = a->GetIdx();
pos_b = b->GetCoordinate();
idx_b = b->GetIdx();
pos_c = c->GetCoordinate();
idx_c = c->GetIdx();
}
};
class OBFPRT OBFFCalculation4: public OBFFCalculation3
{
public:
OBAtom *d;
int idx_d;
double *pos_d;
double force_d[3];
virtual ~OBFFCalculation4()
{
}
void SetupPointers()
{
if (!a || !b || !c || !d) return;
pos_a = a->GetCoordinate();
idx_a = a->GetIdx();
pos_b = b->GetCoordinate();
idx_b = b->GetIdx();
pos_c = c->GetCoordinate();
idx_c = c->GetIdx();
pos_d = d->GetCoordinate();
idx_d = d->GetIdx();
}
};
class OBFPRT OBFFConstraint
{
public:
double factor, constraint_value;
double rab0, rbc0;
int type, ia, ib, ic, id;
OBAtom *a, *b, *c, *d;
vector3 grada, gradb, gradc, gradd;
OBFFConstraint()
{
a = b = c = d = nullptr;
ia = ib = ic = id = 0;
constraint_value = 0.0;
factor = 0.0;
}
~OBFFConstraint()
{
}
vector3 GetGradient(int a)
{
if (a == ia)
return grada;
else if (a == ib)
return gradb;
else if (a == ic)
return gradc;
else if (a == id)
return gradd;
else
return VZero;
}
};
class OBFPRT OBFFConstraints
{
public:
OBFFConstraints();
~OBFFConstraints()
{
_constraints.clear();
_ignored.Clear();
_fixed.Clear();
_Xfixed.Clear();
_Yfixed.Clear();
_Zfixed.Clear();
}
void Clear();
double GetConstraintEnergy();
vector3 GetGradient(int a);
OBFFConstraints& operator=(const OBFFConstraints &ai)
{
if (this != &ai) {
_constraints = ai._constraints;
_ignored = ai._ignored;
_fixed = ai._fixed;
_Xfixed = ai._Xfixed;
_Yfixed = ai._Yfixed;
_Zfixed = ai._Zfixed;
}
return *this;
}
void Setup(OBMol &mol);
// Set Constraints //
void SetFactor(double factor);
void AddIgnore(int a);
void AddAtomConstraint(int a);
void AddAtomXConstraint(int a);
void AddAtomYConstraint(int a);
void AddAtomZConstraint(int a);
void AddDistanceConstraint(int a, int b, double length);
void AddAngleConstraint(int a, int b, int c, double angle);
void AddTorsionConstraint(int a, int b, int c, int d, double torsion);
void DeleteConstraint(int index);
// Get Constraints //
double GetFactor();
int Size() const;
int GetConstraintType(int index) const;
double GetConstraintValue(int index) const;
int GetConstraintAtomA(int index) const;
int GetConstraintAtomB(int index) const;
int GetConstraintAtomC(int index) const;
int GetConstraintAtomD(int index) const;
bool IsIgnored(int a);
bool IsFixed(int a);
bool IsXFixed(int a);
bool IsYFixed(int a);
bool IsZFixed(int a);
OBBitVec GetIgnoredBitVec() { return _ignored; }
OBBitVec GetFixedBitVec() { return _fixed; }
private:
std::vector<OBFFConstraint> _constraints;
OBBitVec _ignored;
OBBitVec _fixed;
OBBitVec _Xfixed;
OBBitVec _Yfixed;
OBBitVec _Zfixed;
double _factor;
};
// Class OBForceField
// class introduction in forcefield.cpp
class OBFPRT OBForceField : public OBPlugin
{
MAKE_PLUGIN(OBForceField)
protected:
OBFFParameter* GetParameter(int a, int b, int c, int d, std::vector<OBFFParameter> &parameter);
OBFFParameter* GetParameter(const char* a, const char* b, const char* c, const char* d,
std::vector<OBFFParameter> &parameter);
int GetParameterIdx(int a, int b, int c, int d, std::vector<OBFFParameter> &parameter);
vector3 NumericalDerivative(OBAtom *a, int terms = OBFF_ENERGY);
vector3 NumericalSecondDerivative(OBAtom *a, int terms = OBFF_ENERGY);
/*
* NEW gradients functions
*/
void SetGradient(double *grad, int idx)
{
const int coordIdx = (idx - 1) * 3;
for (unsigned int i = 0; i < 3; ++i) {
_gradientPtr[coordIdx + i] = grad[i];
}
}
void AddGradient(double *grad, int idx)
{
const int coordIdx = (idx - 1) * 3;
for (unsigned int i = 0; i < 3; ++i) {
_gradientPtr[coordIdx + i] += grad[i];
}
}
virtual void ClearGradients()
{
// We cannot use memset because IEEE floating point representations
// are not guaranteed by C/C++ standard, but this loop can be
// unrolled or vectorized by compilers
for (unsigned int i = 0; i < _ncoords; ++i)
_gradientPtr[i] = 0.0;
// memset(_gradientPtr, '\0', sizeof(double)*_ncoords);
}
bool IsInSameRing(OBAtom* a, OBAtom* b);
// general variables
OBMol _mol;
bool _init;
std::string _parFile;
bool _validSetup;
double *_gradientPtr;
// logging variables
std::ostream* _logos;
char _logbuf[BUFF_SIZE+1];
int _loglvl;
int _origLogLevel;
// conformer genereation (rotor search) variables
int _current_conformer;
std::vector<double> _energies;
// minimization variables
double _econv, _gconv, _e_n1;
int _cstep, _nsteps;
double *_grad1;
unsigned int _ncoords;
int _linesearch;
// molecular dynamics variables
double _timestep;
double _temp;
double *_velocityPtr;
// contraint varibles
static OBFFConstraints _constraints;
static unsigned int _fixAtom;
static unsigned int _ignoreAtom;
// cut-off variables
bool _cutoff;
double _rvdw;
double _rele;
double _epsilon;
OBBitVec _vdwpairs;
OBBitVec _elepairs;
int _pairfreq;
// group variables
std::vector<OBBitVec> _intraGroup;
std::vector<OBBitVec> _interGroup;
std::vector<std::pair<OBBitVec, OBBitVec> > _interGroups;
public:
virtual OBForceField* MakeNewInstance()=0;
virtual ~OBForceField()
{
if (_grad1 != nullptr) {
delete [] _grad1;
_grad1 = nullptr;
}
if (_gradientPtr != nullptr) {
delete [] _gradientPtr;
_gradientPtr = nullptr;
}
}
const char* TypeID()
{
return "forcefields";
}
static OBForceField* FindForceField(const std::string& ID)
{
return FindType(ID.c_str());
}
static OBForceField* FindForceField(const char *ID)
{
return FindType(ID);
}
/*
*
*/
void SetParameterFile(const std::string &filename)
{
_parFile = filename;
_init = false;
}
virtual std::string GetUnit() { return std::string("au"); }
/* Does this force field have analytical gradients defined for all
* calculation components (bonds, angles, non-bonded, etc.)
* If this is true, code should default to using OBFF_ANALYTICAL_GRADIENT
* for SteepestDescent() or ConjugateGradients().
* \return True if all analytical gradients are implemented.
*/
virtual bool HasAnalyticalGradients() { return false; }
bool Setup(OBMol &mol);
bool Setup(OBMol &mol, OBFFConstraints &constraints);
// move to protected in future version
virtual bool ParseParamFile() { return false; }
// move to protected in future version
virtual bool SetTypes() { return false; }
// move to protected in future version
virtual bool SetFormalCharges() { return false; }
// move to protected in future version
virtual bool SetPartialCharges() { return false; }
// move to protected in future version
virtual bool SetupCalculations() { return false; }
// move to protected in future version
virtual bool SetupPointers() { return false; }
bool IsSetupNeeded(OBMol &mol);
bool GetAtomTypes(OBMol &mol);
bool GetPartialCharges(OBMol &mol);
bool GetCoordinates(OBMol &mol);
bool UpdateCoordinates(OBMol &mol) {return GetCoordinates(mol); }
bool GetConformers(OBMol &mol);
bool UpdateConformers(OBMol &mol) { return GetConformers(mol); }
bool SetCoordinates(OBMol &mol);
bool SetConformers(OBMol &mol);
OBGridData *GetGrid(double step, double padding, const char *type, double pchg);
// Interacting groups //
void AddIntraGroup(OBBitVec &group);
void AddInterGroup(OBBitVec &group);
void AddInterGroups(OBBitVec &group1, OBBitVec &group2);
void ClearGroups();
bool HasGroups();
// Cut-off //
void EnableCutOff(bool enable)
{
_cutoff = enable;
}
bool IsCutOffEnabled()
{
return _cutoff;
}
void SetVDWCutOff(double r)
{
_rvdw = r;
}
double GetVDWCutOff()
{
return _rvdw;
}
void SetElectrostaticCutOff(double r)
{
_rele = r;
}
double GetElectrostaticCutOff()
{
return _rele;
}
void SetDielectricConstant(double epsilon)
{
_epsilon = epsilon;
}
/* Get the dielectric permittivity used for electrostatic calculations
* \rreturn The current relative permittivity
*/
double GetDielectricConstant()
{
return _epsilon;
}
void SetUpdateFrequency(int f)
{
_pairfreq = f;
}
int GetUpdateFrequency()
{
return _pairfreq;
}
void UpdatePairsSimple();
//void UpdatePairsGroup(); TODO
unsigned int GetNumPairs();
unsigned int GetNumElectrostaticPairs();
unsigned int GetNumVDWPairs();
void EnableAllPairs()
{
// TODO: OBBitVec doesn't seem to be allocating it's memory correctly
//_vdwpairs.SetRangeOn(0, _numpairs-1);
//_elepairs.SetRangeOn(0, _numpairs-1);
}
virtual vector3 GetGradient(OBAtom *a, int /*terms*/ = OBFF_ENERGY)
{
const int coordIdx = (a->GetIdx() - 1) * 3;
return _gradientPtr + coordIdx;
}
double* GetGradientPtr()
{
return _gradientPtr;
}
// Energy Evaluation //
virtual double Energy(bool UNUSED(gradients) = true) { return 0.0f; }
virtual double E_Bond(bool UNUSED(gradients) = true) { return 0.0f; }
virtual double E_Angle(bool UNUSED(gradients) = true) { return 0.0f; }
virtual double E_StrBnd(bool UNUSED(gradients) = true) { return 0.0f; }
virtual double E_Torsion(bool UNUSED(gradients) = true) { return 0.0f; }
virtual double E_OOP(bool UNUSED(gradients) = true) { return 0.0f; }
virtual double E_VDW(bool UNUSED(gradients) = true) { return 0.0f; }
virtual double E_Electrostatic(bool UNUSED(gradients) = true) { return 0.0f; }
// Logging //
void PrintTypes();
void PrintFormalCharges();
void PrintPartialCharges();
void PrintVelocities();
bool SetLogFile(std::ostream *pos);
bool SetLogLevel(int level);
int GetLogLevel() { return _loglvl; }
void OBFFLog(std::string msg)
{
if (!_logos)
return;
*_logos << msg;
}
void OBFFLog(const char *msg)
{
if (!_logos)
return;
*_logos << msg;
}
// Structure Generation //
void DistanceGeometry();
void SystematicRotorSearch(unsigned int geomSteps = 2500, bool sampleRingBonds = false);
int SystematicRotorSearchInitialize(unsigned int geomSteps = 2500, bool sampleRingBonds = false);
bool SystematicRotorSearchNextConformer(unsigned int geomSteps = 2500);
void RandomRotorSearch(unsigned int conformers, unsigned int geomSteps = 2500,
bool sampleRingBonds = false);
void RandomRotorSearchInitialize(unsigned int conformers, unsigned int geomSteps = 2500,
bool sampleRingBonds = false);
bool RandomRotorSearchNextConformer(unsigned int geomSteps = 2500);
void WeightedRotorSearch(unsigned int conformers, unsigned int geomSteps,
bool sampleRingBonds = false);
int FastRotorSearch(bool permute = true);
#ifdef HAVE_EIGEN
int DiverseConfGen(double rmsd, unsigned int nconfs = 0, double energy_gap = 50, bool verbose = false);
#endif
// Energy Minimization //
void SetLineSearchType(int type)
{
_linesearch = type;
}
int GetLineSearchType()
{
return _linesearch;
}
vector3 LineSearch(OBAtom *atom, vector3 &direction);
double LineSearch(double *currentCoords, double *direction);
double Newton2NumLineSearch(double *direction);
void LineSearchTakeStep(double *origCoords, double *direction, double step);
void SteepestDescent(int steps, double econv = 1e-6f, int method = OBFF_ANALYTICAL_GRADIENT);
void SteepestDescentInitialize(int steps = 1000, double econv = 1e-6f, int method = OBFF_ANALYTICAL_GRADIENT);
bool SteepestDescentTakeNSteps(int n);
void ConjugateGradients(int steps, double econv = 1e-6f, int method = OBFF_ANALYTICAL_GRADIENT);
void ConjugateGradientsInitialize(int steps = 1000, double econv = 1e-6f, int method = OBFF_ANALYTICAL_GRADIENT);
bool ConjugateGradientsTakeNSteps(int n);
// Molecular Dynamics //
void GenerateVelocities();
void CorrectVelocities();
void MolecularDynamicsTakeNSteps(int n, double T, double timestep = 0.001, int method = OBFF_ANALYTICAL_GRADIENT);
// Constraints //
OBFFConstraints& GetConstraints();
void SetConstraints(OBFFConstraints& constraints);
void SetFixAtom(int index);
void UnsetFixAtom();
void SetIgnoreAtom(int index);
void UnsetIgnoreAtom();
static bool IgnoreCalculation(int a, int b);
static bool IgnoreCalculation(int a, int b, int c);
static bool IgnoreCalculation(int a, int b, int c, int d);
// Validation //
bool DetectExplosion();
vector3 ValidateLineSearch(OBAtom *atom, vector3 &direction);
void ValidateSteepestDescent(int steps);
void ValidateConjugateGradients(int steps);
virtual bool Validate() { return false; }
virtual bool ValidateGradients() { return false; }
vector3 ValidateGradientError(vector3 &numgrad, vector3 &anagrad);
// Vector Analysis //
static double VectorBondDerivative(double *pos_a, double *pos_b,
double *force_a, double *force_b);
static double VectorDistanceDerivative(const double* const pos_i, const double* const pos_j,
double *force_i, double *force_j);
static double VectorLengthDerivative(vector3 &a, vector3 &b);
static double VectorAngleDerivative(double *pos_a, double *pos_b, double *pos_c,
double *force_a, double *force_b, double *force_c);
static double VectorAngleDerivative(vector3 &a, vector3 &b, vector3 &c);
static double VectorOOPDerivative(double *pos_a, double *pos_b, double *pos_c, double *pos_d,
double *force_a, double *force_b, double *force_c, double *force_d);
static double VectorOOPDerivative(vector3 &a, vector3 &b, vector3 &c, vector3 &d);
static double VectorTorsionDerivative(double *pos_a, double *pos_b, double *pos_c, double *pos_d,
double *force_a, double *force_b, double *force_c, double *force_d);
static double VectorTorsionDerivative(vector3 &a, vector3 &b, vector3 &c, vector3 &d);
static void VectorSubtract(double *i, double *j, double *result)
{
for (unsigned int c = 0; c < 3; ++c)
result[c] = i[c] - j[c];
}
static void VectorSubtract(const double* const i, const double* const j, double *result)
{
for (unsigned int c = 0; c < 3; ++c)
result[c] = i[c] - j[c];
}
static void VectorAdd(double *i, double *j, double *result)
{
for (unsigned int c = 0; c < 3; ++c)
result[c] = i[c] + j[c];
}
static void VectorDivide(double *i, double n, double *result)
{
for (unsigned int c = 0; c < 3; ++c)
result[c] = i[c] / n;
}
static void VectorMultiply(double *i, double n, double *result)
{
for (unsigned int c = 0; c < 3; ++c)
result[c] = i[c] * n;
}
static void VectorMultiply(const double* const i, const double n, double *result)
{
for (unsigned int c = 0; c < 3; ++c)
result[c] = i[c] * n;
}
static void VectorSelfMultiply(double *i, double n)
{
for (unsigned int c = 0; c < 3; ++c)
i[c] *= n;
}
static void VectorNormalize(double *i)
{
double length = VectorLength(i);
for (unsigned int c = 0; c < 3; ++c)
i[c] /= length;
}
static void VectorCopy(double *from, double *to)
{
for (unsigned int c = 0; c < 3; ++c)
to[c] = from[c];
}
static double VectorLength(double *i)
{
return sqrt( i[0]*i[0] + i[1]*i[1] + i[2]*i[2] );
}
static double VectorDistance(double *pos_i, double *pos_j)
{
double ij[3];
VectorSubtract(pos_i, pos_j, ij);
const double rij = VectorLength(ij);
return rij;
}
static double VectorAngle(double *i, double *j, double *k);
static double VectorTorsion(double *i, double *j, double *k, double *l);
static double VectorOOP(double *i, double *j, double *k, double *l);
static void VectorClear(double *i)
{
for (unsigned int c = 0; c < 3; ++c)
i[c] = 0.0;
}
static double VectorDot(double *i, double *j)
{
double result = 0.0;
// Written as a loop for vectorization
// Loop will be unrolled by compiler otherwise
for (unsigned int c = 0; c < 3; ++c)
result += i[c]*j[c];
return result;
}
static void VectorCross(double *i, double *j, double *result)
{
result[0] = i[1]*j[2] - i[2]*j[1];
result[1] = - i[0]*j[2] + i[2]*j[0];
result[2] = i[0]*j[1] - i[1]*j[0];
}
static void PrintVector(double *i)
{
std::cout << "<" << i[0] << ", " << i[1] << ", " << i[2] << ">" << std::endl;
}
}; // class OBForceField
}// namespace OpenBabel
#endif // OB_FORCEFIELD_H
atom.h
Handle atoms.
bitvec.h
Fast and efficient bitstring class.
OpenBabel::OBAtom
Atom class.
Definition atom.h:72
OpenBabel::OBAtom::GetIdx
unsigned int GetIdx() const
Definition atom.h:189
OpenBabel::OBBitVec
A speed-optimized vector of bits.
Definition bitvec.h:58
OpenBabel::OBFFCalculation2
Internal class for OBForceField to hold energy and gradient calculations on specific force fields.
Definition forcefield.h:138
OpenBabel::OBFFCalculation2::~OBFFCalculation2
virtual ~OBFFCalculation2()
Destructor.
Definition forcefield.h:151
OpenBabel::OBFFCalculation2::idx_b
int idx_b
Definition forcefield.h:145
OpenBabel::OBFFCalculation2::energy
double energy
Used to store the energy for this OBFFCalculation.
Definition forcefield.h:141
OpenBabel::OBFFCalculation2::idx_a
int idx_a
Used to store the index of atoms for this OBFFCalculation.
Definition forcefield.h:145
OpenBabel::OBFFCalculation2::b
OBAtom * b
Definition forcefield.h:143
OpenBabel::OBFFCalculation2::force_b
double force_b[3]
Definition forcefield.h:149
OpenBabel::OBFFCalculation2::a
OBAtom * a
Used to store the atoms for this OBFFCalculation.
Definition forcefield.h:143
OpenBabel::OBFFCalculation2::pos_a
double * pos_a
Pointer to atom coordinates as double[3].
Definition forcefield.h:147
OpenBabel::OBFFCalculation2::SetupPointers
virtual void SetupPointers()
Definition forcefield.h:156
OpenBabel::OBFFCalculation2::pos_b
double * pos_b
Definition forcefield.h:147
OpenBabel::OBFFCalculation2::force_a
double force_a[3]
Pointer to atom forces.
Definition forcefield.h:149
OpenBabel::OBFFCalculation3
Internal class for OBForceField to hold energy and gradient calculations on specific force fields.
Definition forcefield.h:169
OpenBabel::OBFFCalculation3::~OBFFCalculation3
virtual ~OBFFCalculation3()
Destructor.
Definition forcefield.h:180
OpenBabel::OBFFCalculation3::pos_c
double * pos_c
Pointer to atom coordinates as double[3].
Definition forcefield.h:176
OpenBabel::OBFFCalculation3::force_c
double force_c[3]
Pointer to atom forces.
Definition forcefield.h:178
OpenBabel::OBFFCalculation3::idx_c
int idx_c
Used to store the index of atoms for this OBFFCalculation.
Definition forcefield.h:174
OpenBabel::OBFFCalculation3::SetupPointers
virtual void SetupPointers()
Definition forcefield.h:185
OpenBabel::OBFFCalculation3::c
OBAtom * c
Used to store the atoms for this OBFFCalculation.
Definition forcefield.h:172
OpenBabel::OBFFCalculation4
Internal class for OBForceField to hold energy and gradient calculations on specific force fields.
Definition forcefield.h:200
OpenBabel::OBFFCalculation4::force_d
double force_d[3]
Pointer to atom forces.
Definition forcefield.h:209
OpenBabel::OBFFCalculation4::SetupPointers
void SetupPointers()
Definition forcefield.h:216
OpenBabel::OBFFCalculation4::d
OBAtom * d
Used to store the atoms for this OBFFCalculation.
Definition forcefield.h:203
OpenBabel::OBFFCalculation4::idx_d
int idx_d
Used to store the index of atoms for this OBFFCalculation.
Definition forcefield.h:205
OpenBabel::OBFFCalculation4::~OBFFCalculation4
virtual ~OBFFCalculation4()
Destructor.
Definition forcefield.h:211
OpenBabel::OBFFCalculation4::pos_d
double * pos_d
Pointer to atom coordinates as double[3].
Definition forcefield.h:207
OpenBabel::OBFFConstraint::ib
int ib
Definition forcefield.h:240
OpenBabel::OBFFConstraint::ia
int ia
Definition forcefield.h:240
OpenBabel::OBFFConstraint::factor
double factor
Used to store the contraint energy for this OBFFConstraint.
Definition forcefield.h:237
OpenBabel::OBFFConstraint::rbc0
double rbc0
Definition forcefield.h:238
OpenBabel::OBFFConstraint::constraint_value
double constraint_value
Definition forcefield.h:237
OpenBabel::OBFFConstraint::gradd
vector3 gradd
Definition forcefield.h:244
OpenBabel::OBFFConstraint::b
OBAtom * b
Definition forcefield.h:242
OpenBabel::OBFFConstraint::~OBFFConstraint
~OBFFConstraint()
Destructor.
Definition forcefield.h:255
OpenBabel::OBFFConstraint::gradb
vector3 gradb
Definition forcefield.h:244
OpenBabel::OBFFConstraint::id
int id
Definition forcefield.h:240
OpenBabel::OBFFConstraint::grada
vector3 grada
Used to store the gradients for this OBFFCalculation.
Definition forcefield.h:244
OpenBabel::OBFFConstraint::c
OBAtom * c
Definition forcefield.h:242
OpenBabel::OBFFConstraint::ic
int ic
Definition forcefield.h:240
OpenBabel::OBFFConstraint::a
OBAtom * a
Used to store the atoms for this OBFFCostraint.
Definition forcefield.h:242
OpenBabel::OBFFConstraint::gradc
vector3 gradc
Definition forcefield.h:244
OpenBabel::OBFFConstraint::rab0
double rab0
Definition forcefield.h:238
OpenBabel::OBFFConstraint::GetGradient
vector3 GetGradient(int a)
Definition forcefield.h:259
OpenBabel::OBFFConstraint::OBFFConstraint
OBFFConstraint()
Constructor.
Definition forcefield.h:247
OpenBabel::OBFFConstraint::d
OBAtom * d
Definition forcefield.h:242
OpenBabel::OBFFConstraint::type
int type
Used to store the contraint type for this OBFFConstraint.
Definition forcefield.h:240
OpenBabel::OBFFConstraints
Internal class for OBForceField to handle constraints.
Definition forcefield.h:278
OpenBabel::OBFFConstraints::GetFixedBitVec
OBBitVec GetFixedBitVec()
Definition forcefield.h:400
OpenBabel::OBFFConstraints::GetIgnoredBitVec
OBBitVec GetIgnoredBitVec()
Definition forcefield.h:397
OpenBabel::OBFFConstraints::~OBFFConstraints
~OBFFConstraints()
Destructor.
Definition forcefield.h:283
OpenBabel::OBFFConstraints::operator=
OBFFConstraints & operator=(const OBFFConstraints &ai)
Get the constrain gradient for the atom.
Definition forcefield.h:299
OpenBabel::OBFFConstraints::OBFFConstraints
OBFFConstraints()
Constructor.
Definition forcefield.cpp:419
OpenBabel::OBFFParameter
Internal class for OBForceField to hold forcefield parameters.
Definition forcefield.h:93
OpenBabel::OBFFParameter::b
int b
Definition forcefield.h:96
OpenBabel::OBFFParameter::_dpar
std::vector< double > _dpar
Used to store double type parameters (force constants, bond lengths, angles, ...).
Definition forcefield.h:103
OpenBabel::OBFFParameter::_ipar
std::vector< int > _ipar
Used to store integer type parameters (bondtypes, multiplicity, ...).
Definition forcefield.h:101
OpenBabel::OBFFParameter::_d
std::string _d
Definition forcefield.h:98
OpenBabel::OBFFParameter::c
int c
Definition forcefield.h:96
OpenBabel::OBFFParameter::_c
std::string _c
Definition forcefield.h:98
OpenBabel::OBFFParameter::d
int d
Definition forcefield.h:96
OpenBabel::OBFFParameter::_a
std::string _a
used to store string atom types
Definition forcefield.h:98
OpenBabel::OBFFParameter::operator=
OBFFParameter & operator=(const OBFFParameter &ai)
Assignment.
Definition forcefield.h:106
OpenBabel::OBFFParameter::a
int a
Used to store integer atom types.
Definition forcefield.h:96
OpenBabel::OBFFParameter::clear
void clear()
Reset the atom types and set all parameters to zero.
Definition forcefield.h:125
OpenBabel::OBFFParameter::_b
std::string _b
Definition forcefield.h:98
OpenBabel::OBForceField
Base class for molecular mechanics force fields.
Definition forcefield.h:416
OpenBabel::OBForceField::OBFFLog
void OBFFLog(std::string msg)
Definition forcefield.h:1020
OpenBabel::OBForceField::VectorNormalize
static void VectorNormalize(double *i)
Definition forcefield.h:1636
OpenBabel::OBForceField::_parFile
std::string _parFile
Definition forcefield.h:529
OpenBabel::OBForceField::SetFormalCharges
virtual bool SetFormalCharges()
Definition forcefield.h:649
OpenBabel::OBForceField::GetUnit
virtual std::string GetUnit()
Definition forcefield.h:616
OpenBabel::OBForceField::_origLogLevel
int _origLogLevel
Definition forcefield.h:536
OpenBabel::OBForceField::VectorCopy
static void VectorCopy(double *from, double *to)
Definition forcefield.h:1647
OpenBabel::OBForceField::_logbuf
char _logbuf[BUFF_SIZE+1]
Temporary buffer for logfile output.
Definition forcefield.h:534
OpenBabel::OBForceField::GetElectrostaticCutOff
double GetElectrostaticCutOff()
Definition forcefield.h:818
OpenBabel::OBForceField::E_StrBnd
virtual double E_StrBnd(bool gradients=true)
Definition forcefield.h:934
OpenBabel::OBForceField::VectorSubtract
static void VectorSubtract(const double *const i, const double *const j, double *result)
Definition forcefield.h:1578
OpenBabel::OBForceField::_grad1
double * _grad1
Used for conjugate gradients and steepest descent(Initialize and TakeNSteps).
Definition forcefield.h:543
OpenBabel::OBForceField::_rele
double _rele
Electrostatic cut-off distance.
Definition forcefield.h:557
OpenBabel::OBForceField::_rvdw
double _rvdw
VDW cut-off distance.
Definition forcefield.h:556
OpenBabel::OBForceField::_temp
double _temp
Molecular dynamics temperature in Kelvin.
Definition forcefield.h:548
OpenBabel::OBForceField::_constraints
static OBFFConstraints _constraints
Constraints.
Definition forcefield.h:551
OpenBabel::OBForceField::OBFFLog
void OBFFLog(const char *msg)
Definition forcefield.h:1030
OpenBabel::OBForceField::FindForceField
static OBForceField * FindForceField(const char *ID)
Definition forcefield.h:602
OpenBabel::OBForceField::NumericalDerivative
vector3 NumericalDerivative(OBAtom *a, int terms=OBFF_ENERGY)
Definition forcefield.cpp:3082
OpenBabel::OBForceField::VectorSelfMultiply
static void VectorSelfMultiply(double *i, double n)
Definition forcefield.h:1627
OpenBabel::OBForceField::_validSetup
bool _validSetup
< parameter file name
Definition forcefield.h:530
OpenBabel::OBForceField::SetLineSearchType
void SetLineSearchType(int type)
Definition forcefield.h:1205
OpenBabel::OBForceField::_elepairs
OBBitVec _elepairs
Electrostatic pairs that should be calculated.
Definition forcefield.h:560
OpenBabel::OBForceField::PrintVector
static void PrintVector(double *i)
Definition forcefield.h:1732
OpenBabel::OBForceField::VectorMultiply
static void VectorMultiply(const double *const i, const double n, double *result)
Definition forcefield.h:1617
OpenBabel::OBForceField::VectorAdd
static void VectorAdd(double *i, double *j, double *result)
Definition forcefield.h:1589
OpenBabel::OBForceField::EnableAllPairs
void EnableAllPairs()
Definition forcefield.h:875
OpenBabel::OBForceField::IsCutOffEnabled
bool IsCutOffEnabled()
Definition forcefield.h:789
OpenBabel::OBForceField::_init
bool _init
Used to make sure we only parse the parameter file once, when needed.
Definition forcefield.h:528
OpenBabel::OBForceField::GetVDWCutOff
double GetVDWCutOff()
Definition forcefield.h:803
OpenBabel::OBForceField::_econv
double _econv
Definition forcefield.h:541
OpenBabel::OBForceField::ParseParamFile
virtual bool ParseParamFile()
Definition forcefield.h:639
OpenBabel::OBForceField::MakeNewInstance
virtual OBForceField * MakeNewInstance()=0
OpenBabel::OBForceField::NumericalSecondDerivative
vector3 NumericalSecondDerivative(OBAtom *a, int terms=OBFF_ENERGY)
OB 3.0.
Definition forcefield.cpp:3198
OpenBabel::OBForceField::_loglvl
int _loglvl
Log level for output.
Definition forcefield.h:535
OpenBabel::OBForceField::Validate
virtual bool Validate()
Validate the force field implementation (debugging).
Definition forcefield.h:1484
OpenBabel::OBForceField::GetDielectricConstant
double GetDielectricConstant()
Definition forcefield.h:832
OpenBabel::OBForceField::_mol
OBMol _mol
Molecule to be evaluated or minimized.
Definition forcefield.h:527
OpenBabel::OBForceField::ValidateGradients
virtual bool ValidateGradients()
Definition forcefield.h:1489
OpenBabel::OBForceField::UpdateConformers
bool UpdateConformers(OBMol &mol)
Definition forcefield.h:720
OpenBabel::OBForceField::SetTypes
virtual bool SetTypes()
Definition forcefield.h:644
OpenBabel::OBForceField::_epsilon
double _epsilon
Dielectric constant for electrostatics.
Definition forcefield.h:558
OpenBabel::OBForceField::_velocityPtr
double * _velocityPtr
pointer to the velocities
Definition forcefield.h:549
OpenBabel::OBForceField::_interGroup
std::vector< OBBitVec > _interGroup
groups for which intra-molecular interactions should be calculated
Definition forcefield.h:564
OpenBabel::OBForceField::GetGradientPtr
double * GetGradientPtr()
Definition forcefield.h:893
OpenBabel::OBForceField::VectorDistance
static double VectorDistance(double *pos_i, double *pos_j)
Definition forcefield.h:1662
OpenBabel::OBForceField::FindForceField
static OBForceField * FindForceField(const std::string &ID)
Definition forcefield.h:595
OpenBabel::OBForceField::_cutoff
bool _cutoff
true = cut-off enabled
Definition forcefield.h:555
OpenBabel::OBForceField::_fixAtom
static unsigned int _fixAtom
SetFixAtom()/UnsetFixAtom().
Definition forcefield.h:552
OpenBabel::OBForceField::_gconv
double _gconv
Definition forcefield.h:541
OpenBabel::OBForceField::HasAnalyticalGradients
virtual bool HasAnalyticalGradients()
Definition forcefield.h:623
OpenBabel::OBForceField::_pairfreq
int _pairfreq
The frequence to update non-bonded pairs.
Definition forcefield.h:561
OpenBabel::OBForceField::_ignoreAtom
static unsigned int _ignoreAtom
SetIgnoreAtom()/UnsetIgnoreAtom().
Definition forcefield.h:553
OpenBabel::OBForceField::_timestep
double _timestep
Molecular dynamics time step in picoseconds.
Definition forcefield.h:547
OpenBabel::OBForceField::_energies
std::vector< double > _energies
used to hold the energies for all conformers
Definition forcefield.h:539
OpenBabel::OBForceField::SetupPointers
virtual bool SetupPointers()
Definition forcefield.h:665
OpenBabel::OBForceField::SetDielectricConstant
void SetDielectricConstant(double epsilon)
Definition forcefield.h:825
OpenBabel::OBForceField::E_Electrostatic
virtual double E_Electrostatic(bool gradients=true)
Definition forcefield.h:962
OpenBabel::OBForceField::GetUpdateFrequency
int GetUpdateFrequency()
Definition forcefield.h:848
OpenBabel::OBForceField::VectorCross
static void VectorCross(double *i, double *j, double *result)
Definition forcefield.h:1725
OpenBabel::OBForceField::SetVDWCutOff
void SetVDWCutOff(double r)
Definition forcefield.h:796
OpenBabel::OBForceField::E_OOP
virtual double E_OOP(bool gradients=true)
Definition forcefield.h:948
OpenBabel::OBForceField::VectorDot
static double VectorDot(double *i, double *j)
Definition forcefield.h:1710
OpenBabel::OBForceField::GetCoordinates
bool GetCoordinates(OBMol &mol)
Definition forcefield.cpp:1022
OpenBabel::OBForceField::SetElectrostaticCutOff
void SetElectrostaticCutOff(double r)
Definition forcefield.h:811
OpenBabel::OBForceField::GetParameterIdx
int GetParameterIdx(int a, int b, int c, int d, std::vector< OBFFParameter > &parameter)
Get index for vector<OBFFParameter> ...
Definition forcefield.cpp:210
OpenBabel::OBForceField::E_VDW
virtual double E_VDW(bool gradients=true)
Definition forcefield.h:955
OpenBabel::OBForceField::GetLineSearchType
int GetLineSearchType()
Definition forcefield.h:1212
OpenBabel::OBForceField::_gradientPtr
double * _gradientPtr
pointer to the gradients (used by AddGradient(), minimization functions, ...)
Definition forcefield.h:531
OpenBabel::OBForceField::_logos
std::ostream * _logos
Output for logfile.
Definition forcefield.h:533
OpenBabel::OBForceField::GetLogLevel
int GetLogLevel()
Definition forcefield.h:1016
OpenBabel::OBForceField::E_Angle
virtual double E_Angle(bool gradients=true)
Definition forcefield.h:927
OpenBabel::OBForceField::AddGradient
void AddGradient(double *grad, int idx)
Definition forcefield.h:497
OpenBabel::OBForceField::SetGradient
void SetGradient(double *grad, int idx)
Definition forcefield.h:487
OpenBabel::OBForceField::_interGroups
std::vector< std::pair< OBBitVec, OBBitVec > > _interGroups
Definition forcefield.h:565
OpenBabel::OBForceField::_ncoords
unsigned int _ncoords
Number of coordinates for conjugate gradients.
Definition forcefield.h:544
OpenBabel::OBForceField::~OBForceField
virtual ~OBForceField()
Destructor.
Definition forcefield.h:574
OpenBabel::OBForceField::SetPartialCharges
virtual bool SetPartialCharges()
Definition forcefield.h:654
OpenBabel::OBForceField::_current_conformer
int _current_conformer
used to hold i for current conformer (needed by UpdateConformers)
Definition forcefield.h:538
OpenBabel::OBForceField::UpdateCoordinates
bool UpdateCoordinates(OBMol &mol)
Definition forcefield.h:713
OpenBabel::OBForceField::E_Torsion
virtual double E_Torsion(bool gradients=true)
Definition forcefield.h:941
OpenBabel::OBForceField::_cstep
int _cstep
Definition forcefield.h:542
OpenBabel::OBForceField::VectorDivide
static void VectorDivide(double *i, double n, double *result)
Definition forcefield.h:1600
OpenBabel::OBForceField::_vdwpairs
OBBitVec _vdwpairs
VDW pairs that should be calculated.
Definition forcefield.h:559
OpenBabel::OBForceField::EnableCutOff
void EnableCutOff(bool enable)
Definition forcefield.h:783
OpenBabel::OBForceField::GetGradient
virtual vector3 GetGradient(OBAtom *a, int=OBFF_ENERGY)
Definition forcefield.h:885
OpenBabel::OBForceField::GetConformers
bool GetConformers(OBMol &mol)
Definition forcefield.cpp:1053
OpenBabel::OBForceField::_e_n1
double _e_n1
Used for conjugate gradients and steepest descent(Initialize and TakeNSteps).
Definition forcefield.h:541
OpenBabel::OBForceField::VectorMultiply
static void VectorMultiply(double *i, double n, double *result)
Definition forcefield.h:1611
OpenBabel::OBForceField::_intraGroup
std::vector< OBBitVec > _intraGroup
groups for which intra-molecular interactions should be calculated
Definition forcefield.h:563
OpenBabel::OBForceField::VectorSubtract
static void VectorSubtract(double *i, double *j, double *result)
Definition forcefield.h:1572
OpenBabel::OBForceField::GetParameter
OBFFParameter * GetParameter(int a, int b, int c, int d, std::vector< OBFFParameter > &parameter)
Definition forcefield.cpp:239
OpenBabel::OBForceField::Energy
virtual double Energy(bool gradients=true)
Definition forcefield.h:913
OpenBabel::OBForceField::E_Bond
virtual double E_Bond(bool gradients=true)
Definition forcefield.h:920
OpenBabel::OBForceField::VectorClear
static void VectorClear(double *i)
Definition forcefield.h:1699
OpenBabel::OBForceField::TypeID
const char * TypeID()
Definition forcefield.h:587
OpenBabel::OBForceField::SetUpdateFrequency
void SetUpdateFrequency(int f)
Definition forcefield.h:841
OpenBabel::OBForceField::SetParameterFile
void SetParameterFile(const std::string &filename)
Definition forcefield.h:609
OpenBabel::OBForceField::SetupCalculations
virtual bool SetupCalculations()
Definition forcefield.h:659
OpenBabel::OBForceField::VectorLength
static double VectorLength(double *i)
Definition forcefield.h:1657
OpenBabel::OBForceField::_linesearch
int _linesearch
LineSearch type.
Definition forcefield.h:545
OpenBabel::OBForceField::_nsteps
int _nsteps
Used for conjugate gradients and steepest descent(Initialize and TakeNSteps).
Definition forcefield.h:542
OpenBabel::OBForceField::ClearGradients
virtual void ClearGradients()
Definition forcefield.h:507
OpenBabel::OBGridData
Store values for numeric grids such as orbitals or electrostatic potential.
Definition griddata.h:40
OpenBabel::OBMol
Molecule Class.
Definition mol.h:121
OpenBabel::OBPlugin
Base class for all types of dynamic classes discovered at runtime.
Definition plugin.h:53
OpenBabel::vector3
Represents a vector in 3-dimensional real space.
Definition vector3.h:45
OBFF_ENERGY
#define OBFF_ENERGY
all terms
Definition forcefield.h:43
OBFF_ANALYTICAL_GRADIENT
#define OBFF_ANALYTICAL_GRADIENT
use analytical gradients
Definition forcefield.h:65
MAKE_PLUGIN
#define MAKE_PLUGIN(BaseClass)
Definition plugin.h:195
mol.h
Handle molecules. Declarations of OBMol, OBAtom, OBBond, OBResidue. (the main header for Open Babel).
BUFF_SIZE
#define BUFF_SIZE
Definition mol.h:741
OpenBabel
Global namespace for all Open Babel code.
Definition alias.h:23
OpenBabel::GAS_CONSTANT
const double GAS_CONSTANT
kcal mol^-1 K^-1 (2018 CODATA recommended value)
Definition forcefield.h:68
OpenBabel::KCAL_TO_KJ
const double KCAL_TO_KJ
Definition forcefield.h:67
OpenBabel::VZero
const vector3 VZero
The zero vector: <0.0, 0.0, 0.0>.
plugin.h
Simplify 'plugin' classes to be discovered and/or loaded at runtime.
OpenBabel::LineSearchType
The type of line search to be used for optimization – simple or Newton numeric.
Definition forcefield.h:77
OpenBabel::LineSearchType::Newton2Num
@ Newton2Num
Definition forcefield.h:79
OpenBabel::LineSearchType::Simple
@ Simple
Definition forcefield.h:79