1 |
tim |
1741 |
/* |
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 |
gezelter |
1490 |
|
26 |
tim |
1741 |
#include "UseTheForce/DUFF.hpp" |
27 |
gezelter |
1634 |
#include "UseTheForce/DarkSide/lj_interface.h" |
28 |
gezelter |
1490 |
|
29 |
tim |
1741 |
namespace oopse { |
30 |
gezelter |
1490 |
|
31 |
tim |
1741 |
//definition of createDUFF |
32 |
|
|
ForceField* createDUFF() { |
33 |
|
|
return new DUFF(); |
34 |
|
|
} |
35 |
gezelter |
1490 |
|
36 |
tim |
1741 |
//register createDUFF to ForceFieldCreator |
37 |
|
|
ForceFieldFactory::getInstance()->registerForceField("DUFF", createDUFF); |
38 |
gezelter |
1490 |
|
39 |
tim |
1741 |
void DUFF::parse(const std::string& filename) { |
40 |
|
|
ifstrstream* ffStream; |
41 |
|
|
ffStream = openForceFiledFile(filename); |
42 |
|
|
const int bufferSize = 65535; |
43 |
|
|
char line[bufferSize]; |
44 |
|
|
AtomType* atomType; |
45 |
|
|
std::string atomTypeName; |
46 |
gezelter |
1490 |
double mass; |
47 |
tim |
1741 |
double epsilon; |
48 |
gezelter |
1490 |
double sigma; |
49 |
tim |
1741 |
int status; |
50 |
|
|
int ident = 1; //ident begins from 1 (fortran's index begins from 1) |
51 |
|
|
int lineNo = 0; |
52 |
gezelter |
1490 |
|
53 |
tim |
1741 |
while(ffStream.getline(line, bufferSize)){ |
54 |
|
|
++lineNo; |
55 |
gezelter |
1490 |
|
56 |
tim |
1741 |
//a line begins with '#' or '!' is comment which is skipped |
57 |
|
|
if (line[0] != '#' ||line[0] != '!') { |
58 |
|
|
StringTokenizer tokenizer(line); |
59 |
|
|
|
60 |
|
|
if (tokenizer.countTokens() >= 4) { |
61 |
|
|
atomTypeName = tokenizer.nextToken(); |
62 |
tim |
1753 |
mass = tokenizer.nextTokenAsDouble(); |
63 |
|
|
epsilon = tokenizer.nextTokenAsDouble(); |
64 |
|
|
sigma = tokenizer.nextTokenAsDouble(); |
65 |
gezelter |
1490 |
|
66 |
tim |
1741 |
atomType = new AtomType(); |
67 |
|
|
atomType->setName(atomTypeName); |
68 |
|
|
atomType->setMass(mass); |
69 |
|
|
|
70 |
|
|
//by default, all of the properties in AtomTypeProperties is set to 0 |
71 |
|
|
//In Lennard-Jones Force Field, we only need to set Lennard-Jones to true |
72 |
|
|
atomType->setLennardJones(); |
73 |
gezelter |
1490 |
|
74 |
tim |
1741 |
atomType->setIdent(ident); |
75 |
|
|
atomType->addProperty(new DoubleGenericData("Epsilon", epsilon)); |
76 |
|
|
atomType->addProperty(new DoubleGenericData("Sigma", sigma)); |
77 |
|
|
atomType->complete(); |
78 |
|
|
//notify a new LJtype atom type is created |
79 |
|
|
newLJtype(&ident, &sigma, &epsilon, &status); |
80 |
gezelter |
1490 |
|
81 |
tim |
1741 |
//add atom type to AtomTypeContainer |
82 |
|
|
addAtomType(atomTypeName, atomType); |
83 |
|
|
++ident; |
84 |
|
|
|
85 |
|
|
} else { |
86 |
|
|
sprintf( painCave.errMsg, |
87 |
|
|
"Not enough tokens when parsing Lennard-Jones Force Field : %s\n" |
88 |
|
|
"in line %d : %s\n", |
89 |
|
|
filename.c_str(), lineNo, line); |
90 |
|
|
painCave.severity = OOPSE_ERROR; |
91 |
|
|
painCave.isFatal = 1; |
92 |
|
|
simError(); |
93 |
|
|
} |
94 |
gezelter |
1653 |
|
95 |
gezelter |
1634 |
} |
96 |
gezelter |
1490 |
} |
97 |
|
|
|
98 |
tim |
1741 |
delete ffStream; |
99 |
gezelter |
1490 |
} |
100 |
|
|
|
101 |
|
|
|
102 |
tim |
1741 |
void DUFF::parseAtomType(){ |
103 |
gezelter |
1490 |
} |
104 |
|
|
|
105 |
tim |
1741 |
void DUFF::parseBondType(){ |
106 |
gezelter |
1490 |
} |
107 |
|
|
|
108 |
tim |
1741 |
void DUFF::parseBendType(){ |
109 |
gezelter |
1490 |
} |
110 |
|
|
|
111 |
tim |
1741 |
void DUFF::parseTorsionType(){ |
112 |
gezelter |
1490 |
|
113 |
|
|
} |
114 |
|
|
|
115 |
tim |
1741 |
} //end namespace oopse |
116 |
gezelter |
1490 |
|