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

Comparing branches/new_design/OOPSE-2.0/src/UseTheForce/ForceField.cpp (file contents):
Revision 1782 by tim, Tue Nov 23 17:53:43 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 | BondType* getExactBondType(const std::string &at1, con
81  
82   }
83  
84 < BondType* getExactBondType(const std::string &at1, const std::string &at2){
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* getExactBendType(const std::string &at1, const std::string &at2,
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);
# Line 96 | Line 97 | TorsionType* getExactTorsionType(const std::string &at
97      return bendTypeCont_.find(keys);
98   }
99  
100 < TorsionType* getExactTorsionType(const std::string &at1, const std::string &at2,
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);
# Line 108 | Line 109 | bool ForceField::addAtomType(const std::string &at, At
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   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  
# Line 125 | Line 126 | bool ForceField::addBendType(const std::string &at1, c
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   bool ForceField::addTorsionType(const std::string &at1, const std::string &at2,
# Line 135 | Line 136 | bool ForceField::addTorsionType(const std::string &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 <    
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::openForceFiledFile(const std::string& filename) {
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()){
182 >    ffStream->open(forceFieldFilename.c_str());
183 >    if(!ffStream->is_open()){
184  
185          forceFieldFilename = ffPath_ + "/" + forceFieldFilename;
186 <        ffStream.open( forceFieldFilename.c_str() );
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()){
190 >        if(!ffStream->is_open()){
191  
192              sprintf( painCave.errMsg,
193                 "Error opening the force field parameter file:\n"

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines