ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/group/branches/new_design/OOPSE-2.0/src/UseTheForce/ForceField.cpp
Revision: 1770
Committed: Tue Nov 23 17:53:43 2004 UTC (19 years, 7 months ago) by tim
File size: 5722 byte(s)
Log Message:
add Electrostatic AtomType Section Parser

File Contents

# User Rev Content
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.cpp
28     * @author tlin
29     * @date 11/04/2004
30     * @time 22:51am
31     * @version 1.0
32     */
33    
34 gezelter 1711 #include "UseTheForce/ForceField.hpp"
35 tim 1720 namespace oopse {
36 gezelter 1711
37 tim 1720 ForceField::ForceField() : hasVariant_(false){
38     char* tempPath;
39     tempPath = getenv("FORCE_PARAM_PATH");
40 gezelter 1711
41 tim 1720 if (tempPath == NULL) {
42     //convert a macro from compiler to a string in c++
43     STR_DEFINE(ffPath_, FRC_PATH );
44     } else {
45     ffPath_ = tempPath;
46     }
47 gezelter 1711 }
48    
49 tim 1720 AtomType* ForceField::getAtomType(const std::string &at) {
50     std::vector<std::string> keys;
51     keys.push_back(at);
52     return atomTypeCont_.find(keys);
53     }
54 gezelter 1711
55 tim 1720 BondType* ForceField::getBondType(const std::string &at1, const std::string &at2) {
56     std::vector<std::string> keys;
57     keys.push_back(at1);
58     keys.push_back(at2);
59     return bondTypeCont_.find(keys, wildCardAtomTypeName_);
60 gezelter 1711
61 tim 1720 }
62 gezelter 1711
63 tim 1720 BendType* ForceField::getBendType(const std::string &at1, const std::string &at2,
64     const std::string &at3) {
65     std::vector<std::string> keys;
66     keys.push_back(at1);
67     keys.push_back(at2);
68     keys.push_back(at3);
69     return bendTypeCont_.find(keys, wildCardAtomTypeName_);
70     }
71 gezelter 1711
72 tim 1720 TorsionType* ForceField::getTorsionType(const std::string &at1, const std::string &at2,
73     const std::string &at3, const std::string &at4) {
74     std::vector<std::string> keys;
75     keys.push_back(at1);
76     keys.push_back(at2);
77     keys.push_back(at3);
78     keys.push_back(at4);
79     return torsionTypeCont_.find(keys, wildCardAtomTypeName_);
80 gezelter 1711
81 tim 1720 }
82 gezelter 1711
83 tim 1770 BondType* getExactBondType(const std::string &at1, const std::string &at2){
84     std::vector<std::string> keys;
85     keys.push_back(at1);
86     keys.push_back(at2);
87     return bondTypeCont_.find(keys);
88     }
89    
90     BendType* getExactBendType(const std::string &at1, const std::string &at2,
91     const std::string &at3){
92     std::vector<std::string> keys;
93     keys.push_back(at1);
94     keys.push_back(at2);
95     keys.push_back(at3);
96     return bendTypeCont_.find(keys);
97     }
98    
99     TorsionType* getExactTorsionType(const std::string &at1, const std::string &at2,
100     const std::string &at3, const std::string &at4){
101     std::vector<std::string> keys;
102     keys.push_back(at1);
103     keys.push_back(at2);
104     keys.push_back(at3);
105     keys.push_back(at4);
106     return torsionTypeCont_.find(keys);
107     }
108 tim 1758 bool ForceField::addAtomType(const std::string &at, AtomType* atomType) {
109 tim 1720 std::vector<std::string> keys;
110     keys.push_back(at);
111     return atomTypeCont_.add(keys);
112     }
113 gezelter 1711
114 tim 1758 bool ForceField::addBondType(const std::string &at1, const std::string &at2, BondType* bondType) {
115 tim 1720 std::vector<std::string> keys;
116     keys.push_back(at1);
117     keys.push_back(at2);
118     return bondTypeCont_.add(keys);
119 gezelter 1711
120 tim 1720 }
121 gezelter 1711
122 tim 1758 bool ForceField::addBendType(const std::string &at1, const std::string &at2,
123 tim 1720 const std::string &at3, BendType* bendType) {
124     std::vector<std::string> keys;
125     keys.push_back(at1);
126     keys.push_back(at2);
127     keys.push_back(at3);
128     return bendTypeCont_.add(keys);
129     }
130 gezelter 1711
131 tim 1758 bool ForceField::addTorsionType(const std::string &at1, const std::string &at2,
132 tim 1720 const std::string &at3, const std::string &at4, TorsionType* torsionType) {
133     std::vector<std::string> keys;
134     keys.push_back(at1);
135     keys.push_back(at2);
136     keys.push_back(at3);
137     keys.push_back(at4);
138     return torsionTypeCont_.add(keys);
139     }
140 gezelter 1711
141 tim 1735 double ForceField::getRcutFromAtomType(AtomType* at) {
142    
143 tim 1720 }
144 gezelter 1711
145 tim 1740
146     ifstrstream* ForceField::openForceFiledFile(const std::string& filename) {
147     std::string forceFieldFilename(filename);
148     ifstrstream* ffStream = new ifstrstream();
149    
150     //try to open the force filed file in current directory first
151     ffStream.open(forceFieldFilename.c_str());
152     if(!ffStream.is_open()){
153    
154     forceFieldFilename = ffPath_ + "/" + forceFieldFilename;
155     ffStream.open( forceFieldFilename.c_str() );
156    
157     //if current directory does not contain the force field file,
158     //try to open it in the path
159     if(!ffStream.is_open()){
160    
161     sprintf( painCave.errMsg,
162     "Error opening the force field parameter file:\n"
163     "\t%s\n"
164     "\tHave you tried setting the FORCE_PARAM_PATH environment "
165     "variable?\n",
166     forceFieldFilename.c_str() );
167     painCave.severity = OOPSE_ERROR;
168     painCave.isFatal = 1;
169     simError();
170     }
171     }
172    
173     return ffStream;
174    
175     }
176    
177 tim 1720 } //end namespace oopse