~ubuntu-branches/ubuntu/hardy/openbabel/hardy

« back to all changes in this revision

Viewing changes to src/forcefields/forcefieldghemical.h

  • Committer: Bazaar Package Importer
  • Author(s): Jonathan Riddell
  • Date: 2007-08-06 17:28:40 UTC
  • mfrom: (1.1.4 upstream)
  • Revision ID: james.westby@ubuntu.com-20070806172840-22hoqb3ve230qav1
Tags: 2.1.1-0ubuntu1
* New upstream release
* New so version 2

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/**********************************************************************
 
2
forcefieldghemical.h - Ghemical force field.
 
3
 
 
4
Copyright (C) 2006 by Tim Vandermeersch <tim.vandermeersch@gmail.com>
 
5
 
 
6
This file is part of the Open Babel project.
 
7
For more information, see <http://openbabel.sourceforge.net/>
 
8
 
 
9
This program is free software; you can redistribute it and/or modify
 
10
it under the terms of the GNU General Public License as published by
 
11
the Free Software Foundation version 2 of the License.
 
12
 
 
13
This program is distributed in the hope that it will be useful,
 
14
but WITHOUT ANY WARRANTY; without even the implied warranty of
 
15
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
16
GNU General Public License for more details.
 
17
***********************************************************************/
 
18
 
 
19
#include <vector>
 
20
#include <string>
 
21
#include <map>
 
22
 
 
23
#include <openbabel/forcefield.h>
 
24
#include <openbabel/base.h>
 
25
#include <openbabel/mol.h>
 
26
 
 
27
namespace OpenBabel
 
28
{
 
29
  class OBFFBondCalculationGhemical : public OBFFCalculation
 
30
  {
 
31
    public:
 
32
      double kb, r0, rab, delta;
 
33
      int bt; // bondtype
 
34
      
 
35
      void Compute(bool gradients = true);
 
36
  };
 
37
  
 
38
  class OBFFAngleCalculationGhemical : public OBFFCalculation
 
39
  {
 
40
    public:
 
41
      double ka, theta0, theta, delta;
 
42
      
 
43
      void Compute(bool gradients = true);
 
44
  };
 
45
  
 
46
  class OBFFTorsionCalculationGhemical : public OBFFCalculation
 
47
  {
 
48
    public:
 
49
      double V, s, n, tor;
 
50
      double k1, k2, k3;
 
51
      int tt; //torsiontype
 
52
      
 
53
      void Compute(bool gradients = true);
 
54
  };
 
55
 
 
56
  class OBFFVDWCalculationGhemical : public OBFFCalculation
 
57
  {
 
58
    public:
 
59
      double ka, Ra, kb, Rb, kab, rab;
 
60
      bool is14, samering;
 
61
 
 
62
      void Compute(bool gradients = true);
 
63
  };
 
64
 
 
65
  class OBFFElectrostaticCalculationGhemical : public OBFFCalculation
 
66
  {
 
67
    public:
 
68
      double qq, rab;
 
69
      
 
70
      void Compute(bool gradients = true);
 
71
  };
 
72
 
 
73
  // Class OBForceFieldGhemical
 
74
  // class introduction in forcefieldghemical.cpp
 
75
  class OBAPI OBForceFieldGhemical: public OBForceField
 
76
  {
 
77
    protected:
 
78
      //!  Parses the parameter file
 
79
      bool ParseParamFile();
 
80
      //!  Sets atomtypes to Ghemical types in _mol
 
81
      bool SetGhemicalTypes();
 
82
      //!  Sets partial charges to Ghemical charges in _mol
 
83
      bool SetGhemicalCharges();
 
84
      //! fill OBFFXXXCalculation vectors
 
85
      bool SetupCalculations();
 
86
      //! Same as OBForceField::GetParameter, but takes (bond/angle/torsion) type in account.
 
87
      OBFFParameter* GetParameterGhemical(int type, const char* a, const char* b, const char* c, const char* d, std::vector<OBFFParameter> &parameter);
 
88
      //! Returns the negative gradient (force) on atom a
 
89
      vector3 GetGradient(OBAtom *a, int terms = OBFF_ENERGY);
 
90
      
 
91
      // OBFFParameter vectors to contain the parameters
 
92
      std::vector<OBFFParameter> _ffbondparams; 
 
93
      std::vector<OBFFParameter> _ffangleparams; 
 
94
      std::vector<OBFFParameter> _fftorsionparams; 
 
95
      std::vector<OBFFParameter> _ffvdwparams;
 
96
      std::vector<OBFFParameter> _ffchargeparams;
 
97
 
 
98
      // OBFFXXXCalculationYYY vectors to contain the calculations
 
99
      std::vector<OBFFBondCalculationGhemical>          _bondcalculations;
 
100
      std::vector<OBFFAngleCalculationGhemical>         _anglecalculations;
 
101
      std::vector<OBFFTorsionCalculationGhemical>       _torsioncalculations;
 
102
      std::vector<OBFFVDWCalculationGhemical>           _vdwcalculations;
 
103
      std::vector<OBFFElectrostaticCalculationGhemical> _electrostaticcalculations;
 
104
 
 
105
    public:
 
106
      //! Constructor
 
107
      OBForceFieldGhemical(std::string ID, bool IsDefault=true) : OBForceField(ID, IsDefault)
 
108
      {
 
109
        ParseParamFile();
 
110
      }
 
111
      
 
112
      //! Destructor
 
113
      virtual ~OBForceFieldGhemical();
 
114
      
 
115
      //! Assignment
 
116
      OBForceFieldGhemical &operator = (OBForceFieldGhemical &);
 
117
      
 
118
      //! Get the description for this force field
 
119
      std::string Description() 
 
120
      { 
 
121
        return "Ghemical force field.";
 
122
      }
 
123
      
 
124
      //! Get the unit in wich the energy is expressed
 
125
      std::string GetUnit() 
 
126
      { 
 
127
        return std::string("kJ/mol"); 
 
128
      }
 
129
 
 
130
      //! Setup
 
131
      bool Setup(OBMol &mol);
 
132
      
 
133
      //! Returns total energy
 
134
      double Energy(bool gradients = true);
 
135
     //! Returns the bond stretching energy
 
136
      double E_Bond(bool gradients = true);
 
137
      //! Returns the angle bending energy
 
138
      double E_Angle(bool gradients = true);
 
139
      //! Returns the torsional energy
 
140
      double E_Torsion(bool gradients = true);
 
141
      //! Returns energy due to Van der Waals interactions
 
142
      double E_VDW(bool gradients = true);
 
143
      //! Returns energy due to electrostatic interactions
 
144
      double E_Electrostatic(bool gradients = true);
 
145
      
 
146
      //! Compare and print the numerical and analytical gradients
 
147
      bool ValidateGradients();
 
148
 
 
149
  }; // class OBForceFieldGhemical
 
150
 
 
151
}// namespace OpenBabel
 
152
 
 
153
//! \file forcefieldghemical.h
 
154
//! \brief Ghemical force field
 
155