ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/group/branches/new_design/OOPSE-3.0/src/UseTheForce/ForceField.cpp
(Generate patch)

Comparing branches/new_design/OOPSE-3.0/src/UseTheForce/ForceField.cpp (file contents):
Revision 1735 by tim, Fri Nov 12 17:40:03 2004 UTC vs.
Revision 1783 by tim, Wed Nov 24 21:33:00 2004 UTC

# Line 32 | Line 32 | namespace oopse {
32    */
33    
34   #include "UseTheForce/ForceField.hpp"
35 + #include "utils/simError.h"
36   namespace oopse {
37  
38   ForceField::ForceField() : hasVariant_(false){
# Line 80 | Line 81 | void ForceField::addAtomType(const std::string &at, At
81  
82   }
83  
84 < void ForceField::addAtomType(const std::string &at, AtomType* atomType) {
84 > BondType* ForceField::getExactBondType(const std::string &at1, const std::string &at2){
85      std::vector<std::string> keys;
86 +    keys.push_back(at1);
87 +    keys.push_back(at2);    
88 +    return bondTypeCont_.find(keys);
89 + }
90 +
91 + BendType* ForceField::getExactBendType(const std::string &at1, const std::string &at2,
92 +                            const std::string &at3){
93 +    std::vector<std::string> keys;
94 +    keys.push_back(at1);
95 +    keys.push_back(at2);    
96 +    keys.push_back(at3);    
97 +    return bendTypeCont_.find(keys);
98 + }
99 +
100 + TorsionType* ForceField::getExactTorsionType(const std::string &at1, const std::string &at2,
101 +                                  const std::string &at3, const std::string &at4){
102 +    std::vector<std::string> keys;
103 +    keys.push_back(at1);
104 +    keys.push_back(at2);    
105 +    keys.push_back(at3);    
106 +    keys.push_back(at4);  
107 +    return torsionTypeCont_.find(keys);
108 + }
109 + bool ForceField::addAtomType(const std::string &at, AtomType* atomType) {
110 +    std::vector<std::string> keys;
111      keys.push_back(at);
112 <    return atomTypeCont_.add(keys);
112 >    return atomTypeCont_.add(keys, atomType);
113   }
114  
115 < void ForceField::addBondType(const std::string &at1, const std::string &at2, BondType* bondType) {
115 > bool ForceField::addBondType(const std::string &at1, const std::string &at2, BondType* bondType) {
116      std::vector<std::string> keys;
117      keys.push_back(at1);
118      keys.push_back(at2);    
119 <    return bondTypeCont_.add(keys);
119 >    return bondTypeCont_.add(keys, bondType);
120  
121   }
122  
123 < void ForceField::addBendType(const std::string &at1, const std::string &at2,
123 > bool ForceField::addBendType(const std::string &at1, const std::string &at2,
124                          const std::string &at3, BendType* bendType) {
125      std::vector<std::string> keys;
126      keys.push_back(at1);
127      keys.push_back(at2);    
128      keys.push_back(at3);    
129 <    return bendTypeCont_.add(keys);
129 >    return bendTypeCont_.add(keys, bendType);
130   }
131  
132 < void ForceField::addTorsionType(const std::string &at1, const std::string &at2,
132 > bool ForceField::addTorsionType(const std::string &at1, const std::string &at2,
133                                const std::string &at3, const std::string &at4, TorsionType* torsionType) {
134      std::vector<std::string> keys;
135      keys.push_back(at1);
136      keys.push_back(at2);    
137      keys.push_back(at3);    
138      keys.push_back(at4);    
139 <    return torsionTypeCont_.add(keys);
139 >    return torsionTypeCont_.add(keys, torsionType);
140   }
141  
142   double ForceField::getRcutFromAtomType(AtomType* at) {
143 +    /**@todo */
144 +    GenericData* data;
145 +    double rcut = 0.0;
146 +
147 +    if (at->isLennardJones()) {
148 +        data = at->getPropertyByName("LennardJones");
149 +        if (data != NULL) {
150 +            LJParamGenericData* ljData = dynamic_cast<LJParamGenericData*>(data);
151 +
152 +            if (ljData != NULL) {
153 +                LJParam ljParam = ljData->getData();
154 +
155 +                //by default use 2.5*sigma as cutoff radius
156 +                rcut = 2.5 * ljParam.sigma;
157 +                
158 +            } else {
159 +                    sprintf( painCave.errMsg,
160 +                           "Can not cast GenericData to LJParam\n");
161 +                    painCave.severity = OOPSE_ERROR;
162 +                    painCave.isFatal = 1;
163 +                    simError();          
164 +            }            
165 +        } else {
166 +            sprintf( painCave.errMsg, "Can not find Parameters for LennardJones\n");
167 +            painCave.severity = OOPSE_ERROR;
168 +            painCave.isFatal = 1;
169 +            simError();          
170 +        }
171 +    }
172 +
173 +    return rcut;    
174 + }
175 +
176 +
177 + ifstrstream* ForceField::openForceFieldFile(const std::string& filename) {
178 +    std::string forceFieldFilename(filename);
179 +    ifstrstream* ffStream = new ifstrstream();
180      
181 +    //try to open the force filed file in current directory first    
182 +    ffStream->open(forceFieldFilename.c_str());
183 +    if(!ffStream->is_open()){
184 +
185 +        forceFieldFilename = ffPath_ + "/" + forceFieldFilename;
186 +        ffStream->open( forceFieldFilename.c_str() );
187 +
188 +        //if current directory does not contain the force field file,
189 +        //try to open it in the path        
190 +        if(!ffStream->is_open()){
191 +
192 +            sprintf( painCave.errMsg,
193 +               "Error opening the force field parameter file:\n"
194 +               "\t%s\n"
195 +               "\tHave you tried setting the FORCE_PARAM_PATH environment "
196 +               "variable?\n",
197 +               forceFieldFilename.c_str() );
198 +            painCave.severity = OOPSE_ERROR;
199 +            painCave.isFatal = 1;
200 +            simError();
201 +        }
202 +    }  
203 +
204 +    return ffStream;
205 +
206   }
207  
208   } //end namespace oopse

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines