1 |
tim |
1720 |
/* |
2 |
|
|
* Copyright (C) 2000-2004 Object Oriented Parallel Simulation Engine (OOPSE) project |
3 |
|
|
* |
4 |
|
|
* Contact: oopse@oopse.org |
5 |
|
|
* |
6 |
|
|
* This program is free software; you can redistribute it and/or |
7 |
|
|
* modify it under the terms of the GNU Lesser General Public License |
8 |
|
|
* as published by the Free Software Foundation; either version 2.1 |
9 |
|
|
* of the License, or (at your option) any later version. |
10 |
|
|
* All we ask is that proper credit is given for our work, which includes |
11 |
|
|
* - but is not limited to - adding the above copyright notice to the beginning |
12 |
|
|
* of your source code files, and to any copyright notice that you may distribute |
13 |
|
|
* with programs based on this work. |
14 |
|
|
* |
15 |
|
|
* This program is distributed in the hope that it will be useful, |
16 |
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
17 |
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
18 |
|
|
* GNU Lesser General Public License for more details. |
19 |
|
|
* |
20 |
|
|
* You should have received a copy of the GNU Lesser General Public License |
21 |
|
|
* along with this program; if not, write to the Free Software |
22 |
|
|
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
23 |
|
|
* |
24 |
|
|
*/ |
25 |
|
|
|
26 |
|
|
/** |
27 |
|
|
* @file ForceField.hpp |
28 |
|
|
* @author tlin |
29 |
|
|
* @date 11/04/2004 |
30 |
|
|
* @time 22:51am |
31 |
|
|
* @version 1.0 |
32 |
|
|
*/ |
33 |
|
|
|
34 |
gezelter |
1711 |
#ifndef USETHEFORCE_FORCEFIELD_HPP |
35 |
|
|
#define USETHEFORCE_FORCEFIELD_HPP |
36 |
|
|
|
37 |
|
|
#define MK_STR(s) # s |
38 |
|
|
#define STR_DEFINE(t, s) t = MK_STR(s) |
39 |
|
|
|
40 |
tim |
1740 |
#include <string> |
41 |
tim |
1783 |
#include <utility> |
42 |
gezelter |
1711 |
|
43 |
|
|
#include "io/basic_ifstrstream.hpp" |
44 |
tim |
1720 |
#include "utils/TypeContainer.hpp" |
45 |
tim |
1758 |
#include "types/AtomType.hpp" |
46 |
|
|
#include "types/BondType.hpp" |
47 |
|
|
#include "types/BendType.hpp" |
48 |
|
|
#include "types/TorsionType.hpp" |
49 |
gezelter |
1711 |
|
50 |
tim |
1720 |
namespace oopse { |
51 |
gezelter |
1711 |
|
52 |
tim |
1720 |
/** |
53 |
tim |
1783 |
* @class ForceField ForceField.hpp ''UseTheForce/ForceField.hpp" |
54 |
tim |
1720 |
* @brief |
55 |
|
|
*/ |
56 |
gezelter |
1711 |
class ForceField{ |
57 |
|
|
|
58 |
tim |
1720 |
public: |
59 |
gezelter |
1711 |
|
60 |
tim |
1783 |
typedef TypeContainer<AtomType, 1> AtomTypeContainer; |
61 |
|
|
typedef TypeContainer<BondType, 2> BondTypeContainer; |
62 |
|
|
typedef TypeContainer<BendType, 3> BendTypeContainer; |
63 |
|
|
typedef TypeContainer<TorsionType, 4> TorsionTypeContainer; |
64 |
|
|
|
65 |
tim |
1720 |
ForceField(); |
66 |
gezelter |
1711 |
|
67 |
tim |
1783 |
virtual ~ForceField(){} |
68 |
gezelter |
1711 |
|
69 |
tim |
1720 |
void setVariant(const std::string &variant) { |
70 |
|
|
hasVariant_ = true; |
71 |
|
|
variant_ = variant; |
72 |
|
|
} |
73 |
tim |
1740 |
|
74 |
|
|
virtual void parse(const std::string& filename) = 0; |
75 |
gezelter |
1711 |
|
76 |
tim |
1720 |
AtomType* getAtomType(const std::string &at); |
77 |
|
|
BondType* getBondType(const std::string &at1, const std::string &at2); |
78 |
|
|
BendType* getBendType(const std::string &at1, const std::string &at2, |
79 |
|
|
const std::string &at3); |
80 |
|
|
TorsionType* getTorsionType(const std::string &at1, const std::string &at2, |
81 |
|
|
const std::string &at3, const std::string &at4); |
82 |
gezelter |
1711 |
|
83 |
tim |
1770 |
BondType* getExactBondType(const std::string &at1, const std::string &at2); |
84 |
|
|
BendType* getExactBendType(const std::string &at1, const std::string &at2, |
85 |
|
|
const std::string &at3); |
86 |
|
|
TorsionType* getExactTorsionType(const std::string &at1, const std::string &at2, |
87 |
|
|
const std::string &at3, const std::string &at4); |
88 |
|
|
|
89 |
|
|
|
90 |
tim |
1740 |
//avoid make virtual function public |
91 |
|
|
//Herb Sutter and Andrei Alexandrescu, C++ coding Standards, Addision-Wesley |
92 |
tim |
1735 |
virtual double getRcutFromAtomType(AtomType* at); |
93 |
tim |
1720 |
|
94 |
|
|
std::string getWildCard() { |
95 |
|
|
return wildCardAtomTypeName_; |
96 |
|
|
} |
97 |
|
|
|
98 |
|
|
void setWildCard(const std::string& wildCard) { |
99 |
|
|
wildCardAtomTypeName_ = wildCard; |
100 |
|
|
} |
101 |
|
|
|
102 |
|
|
protected: |
103 |
|
|
|
104 |
tim |
1758 |
bool addAtomType(const std::string &at, AtomType* atomType); |
105 |
|
|
bool addBondType(const std::string &at1, const std::string &at2, BondType* bondType); |
106 |
|
|
bool addBendType(const std::string &at1, const std::string &at2, |
107 |
tim |
1720 |
const std::string &at3, BendType* bendType); |
108 |
tim |
1758 |
bool addTorsionType(const std::string &at1, const std::string &at2, |
109 |
tim |
1720 |
const std::string &at3, const std::string &at4, TorsionType* torsionType); |
110 |
|
|
|
111 |
tim |
1740 |
ifstrstream* openForceFieldFile(const std::string& filename); |
112 |
tim |
1760 |
|
113 |
|
|
unsigned int getNAtomType() { |
114 |
|
|
return atomTypeCont_.size(); |
115 |
|
|
} |
116 |
|
|
|
117 |
tim |
1783 |
protected: |
118 |
|
|
|
119 |
|
|
AtomTypeContainer atomTypeCont_; |
120 |
|
|
BondTypeContainer bondTypeCont_; |
121 |
|
|
BendTypeContainer bendTypeCont_; |
122 |
|
|
TorsionTypeContainer torsionTypeCont_; |
123 |
|
|
|
124 |
tim |
1720 |
private: |
125 |
|
|
std::string ffPath_; |
126 |
|
|
bool hasVariant_; |
127 |
|
|
std::string variant_; |
128 |
|
|
|
129 |
|
|
std::string wildCardAtomTypeName_; |
130 |
|
|
|
131 |
gezelter |
1711 |
}; |
132 |
|
|
|
133 |
tim |
1720 |
|
134 |
|
|
}//end namespace oopse |
135 |
gezelter |
1711 |
#endif |
136 |
|
|
|