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 |
|
43 |
#include "utils/Tuple.hpp" |
44 |
#include "types/ShapeAtomType.hpp" |
45 |
#include "io/basic_ifstrstream.hpp" |
46 |
#include "utils/TypeContainer.hpp" |
47 |
|
48 |
namespace oopse { |
49 |
|
50 |
/** |
51 |
* @class ForceFiled ForceField.hpp ''UseTheForce/ForceField.hpp" |
52 |
* @brief |
53 |
*/ |
54 |
class ForceField{ |
55 |
|
56 |
public: |
57 |
|
58 |
ForceField(); |
59 |
|
60 |
virtual ~ForceFields(){} |
61 |
|
62 |
void setVariant(const std::string &variant) { |
63 |
hasVariant_ = true; |
64 |
variant_ = variant; |
65 |
} |
66 |
|
67 |
virtual void parse(const std::string& filename) = 0; |
68 |
|
69 |
AtomType* getAtomType(const std::string &at); |
70 |
BondType* getBondType(const std::string &at1, const std::string &at2); |
71 |
BendType* getBendType(const std::string &at1, const std::string &at2, |
72 |
const std::string &at3); |
73 |
TorsionType* getTorsionType(const std::string &at1, const std::string &at2, |
74 |
const std::string &at3, const std::string &at4); |
75 |
|
76 |
//avoid make virtual function public |
77 |
//Herb Sutter and Andrei Alexandrescu, C++ coding Standards, Addision-Wesley |
78 |
virtual double getRcutFromAtomType(AtomType* at); |
79 |
|
80 |
std::string getWildCard() { |
81 |
return wildCardAtomTypeName_; |
82 |
} |
83 |
|
84 |
void setWildCard(const std::string& wildCard) { |
85 |
wildCardAtomTypeName_ = wildCard; |
86 |
} |
87 |
|
88 |
protected: |
89 |
|
90 |
void addAtomType(const std::string &at, AtomType* atomType); |
91 |
void addBondType(const std::string &at1, const std::string &at2, BondType* bondType); |
92 |
void addBendType(const std::string &at1, const std::string &at2, |
93 |
const std::string &at3, BendType* bendType); |
94 |
void addTorsionType(const std::string &at1, const std::string &at2, |
95 |
const std::string &at3, const std::string &at4, TorsionType* torsionType); |
96 |
|
97 |
ifstrstream* openForceFieldFile(const std::string& filename); |
98 |
private: |
99 |
std::string ffPath_; |
100 |
bool hasVariant_; |
101 |
std::string variant_; |
102 |
|
103 |
std::string wildCardAtomTypeName_; |
104 |
|
105 |
typedef TypeContainer<AtomType, 1> AtomTypeContainer; |
106 |
typedef TypeContainer<BondType, 2> BondTypeContainer; |
107 |
typedef TypeContainer<BendType, 3> BendTypeContainer; |
108 |
typedef TypeContainer<TorsionType, 4> TorsionTypeContainer; |
109 |
|
110 |
AtomTypeContainer atomTypeCont_; |
111 |
BondTypeContainer bondTypeCont_; |
112 |
BendTypeContainer bendTypeCont_; |
113 |
TorsionTypeContainer torsionTypeCont_; |
114 |
}; |
115 |
|
116 |
typedef GenericFactory<ForceField> ForceFieldFactory; |
117 |
|
118 |
}//end namespace oopse |
119 |
#endif |
120 |
|