1 |
+ |
/* |
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 |
|
#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 |
+ |
#include <string> |
41 |
|
#include <utilities> |
42 |
|
|
9 |
– |
#include "utils/Tuple.hpp" |
10 |
– |
#include "types/ShapeAtomType.hpp" |
43 |
|
#include "io/basic_ifstrstream.hpp" |
44 |
+ |
#include "utils/TypeContainer.hpp" |
45 |
+ |
#include "types/AtomType.hpp" |
46 |
+ |
#include "types/BondType.hpp" |
47 |
+ |
#include "types/BendType.hpp" |
48 |
+ |
#include "types/TorsionType.hpp" |
49 |
|
|
50 |
< |
using namespace std; |
14 |
< |
using namespace oopse; |
50 |
> |
namespace oopse { |
51 |
|
|
52 |
+ |
/** |
53 |
+ |
* @class ForceFiled ForceField.hpp ''UseTheForce/ForceField.hpp" |
54 |
+ |
* @brief |
55 |
+ |
*/ |
56 |
|
class ForceField{ |
57 |
|
|
58 |
< |
public: |
58 |
> |
public: |
59 |
|
|
60 |
< |
ForceField(){ |
21 |
< |
hasVariant=false; |
22 |
< |
ffPath = getenv("FORCE_PARAM_PATH"); |
23 |
< |
if( ffPath.empty() ) { |
24 |
< |
STR_DEFINE(ffPath, FRC_PATH ); |
25 |
< |
} |
26 |
< |
} |
60 |
> |
ForceField(); |
61 |
|
|
62 |
< |
virtual ~ForceFields(){} |
62 |
> |
virtual ~ForceFields(){} |
63 |
|
|
64 |
< |
void setVariant(const string &variant) { hasVariant = true; theVariant = variant; } |
65 |
< |
virtual void readParams( void ) = 0; |
66 |
< |
|
67 |
< |
AtomType* getMatchingAtomType(const string &at); |
68 |
< |
BondType* getMatchingBondType(const string &at1, const string &at2); |
69 |
< |
BendType* getMatchingBendType(const string &at1, const string &at2, |
36 |
< |
const string &at3); |
37 |
< |
TorsionType* getMatchingTorsionType(const string &at1, const string &at2, |
38 |
< |
const string &at3, const string &at4); |
64 |
> |
void setVariant(const std::string &variant) { |
65 |
> |
hasVariant_ = true; |
66 |
> |
variant_ = variant; |
67 |
> |
} |
68 |
> |
|
69 |
> |
virtual void parse(const std::string& filename) = 0; |
70 |
|
|
71 |
< |
double getRcutForAtomType(AtomType* at); |
72 |
< |
|
73 |
< |
protected: |
74 |
< |
|
75 |
< |
string ffPath; |
76 |
< |
ifstrstream forceFile; |
46 |
< |
bool hasVariant; |
47 |
< |
string variant; |
48 |
< |
map<string, AtomType*> atomTypeMap; |
49 |
< |
map<pair<string,string>, BondType*> bondTypeMap; |
50 |
< |
map<tuple3<string,string,string>, BendType*> bendTypeMap; |
51 |
< |
map<tuple4<string,string,string,string>, TorsionType*> torsionTypeMap; |
52 |
< |
string wildCardAtomTypeName; |
71 |
> |
AtomType* getAtomType(const std::string &at); |
72 |
> |
BondType* getBondType(const std::string &at1, const std::string &at2); |
73 |
> |
BendType* getBendType(const std::string &at1, const std::string &at2, |
74 |
> |
const std::string &at3); |
75 |
> |
TorsionType* getTorsionType(const std::string &at1, const std::string &at2, |
76 |
> |
const std::string &at3, const std::string &at4); |
77 |
|
|
78 |
< |
}; |
78 |
> |
//avoid make virtual function public |
79 |
> |
//Herb Sutter and Andrei Alexandrescu, C++ coding Standards, Addision-Wesley |
80 |
> |
virtual double getRcutFromAtomType(AtomType* at); |
81 |
|
|
82 |
+ |
std::string getWildCard() { |
83 |
+ |
return wildCardAtomTypeName_; |
84 |
+ |
} |
85 |
|
|
86 |
+ |
void setWildCard(const std::string& wildCard) { |
87 |
+ |
wildCardAtomTypeName_ = wildCard; |
88 |
+ |
} |
89 |
+ |
|
90 |
+ |
protected: |
91 |
+ |
|
92 |
+ |
bool addAtomType(const std::string &at, AtomType* atomType); |
93 |
+ |
bool addBondType(const std::string &at1, const std::string &at2, BondType* bondType); |
94 |
+ |
bool addBendType(const std::string &at1, const std::string &at2, |
95 |
+ |
const std::string &at3, BendType* bendType); |
96 |
+ |
bool addTorsionType(const std::string &at1, const std::string &at2, |
97 |
+ |
const std::string &at3, const std::string &at4, TorsionType* torsionType); |
98 |
+ |
|
99 |
+ |
ifstrstream* openForceFieldFile(const std::string& filename); |
100 |
+ |
|
101 |
+ |
unsigned int getNAtomType() { |
102 |
+ |
return atomTypeCont_.size(); |
103 |
+ |
} |
104 |
+ |
|
105 |
+ |
private: |
106 |
+ |
std::string ffPath_; |
107 |
+ |
bool hasVariant_; |
108 |
+ |
std::string variant_; |
109 |
+ |
|
110 |
+ |
std::string wildCardAtomTypeName_; |
111 |
+ |
|
112 |
+ |
typedef TypeContainer<AtomType, 1> AtomTypeContainer; |
113 |
+ |
typedef TypeContainer<BondType, 2> BondTypeContainer; |
114 |
+ |
typedef TypeContainer<BendType, 3> BendTypeContainer; |
115 |
+ |
typedef TypeContainer<TorsionType, 4> TorsionTypeContainer; |
116 |
+ |
|
117 |
+ |
AtomTypeContainer atomTypeCont_; |
118 |
+ |
BondTypeContainer bondTypeCont_; |
119 |
+ |
BendTypeContainer bendTypeCont_; |
120 |
+ |
TorsionTypeContainer torsionTypeCont_; |
121 |
+ |
}; |
122 |
+ |
|
123 |
+ |
|
124 |
+ |
}//end namespace oopse |
125 |
|
#endif |
126 |
|
|