ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/OpenMD/branches/heatflux/src/UseTheForce/EAM_FF.cpp
(Generate patch)

Comparing trunk/src/UseTheForce/EAM_FF.cpp (file contents):
Revision 366 by gezelter, Fri Feb 18 15:58:22 2005 UTC vs.
Revision 1280 by gezelter, Wed Jul 16 02:07:09 2008 UTC

# Line 1 | Line 1
1 < /*
1 > /*
2   * Copyright (c) 2005 The University of Notre Dame. All Rights Reserved.
3   *
4   * The University of Notre Dame grants you ("Licensee") a
# Line 40 | Line 40
40   */
41  
42   #include "UseTheForce/EAM_FF.hpp"
43 + #include "UseTheForce/DarkSide/eam_interface.h"
44   #include "UseTheForce/DarkSide/lj_interface.h"
44 #include "UseTheForce/DarkSide/charge_interface.h"
45 #include "UseTheForce/DarkSide/dipole_interface.h"
45   #include "UseTheForce/DarkSide/sticky_interface.h"
46   #include "UseTheForce/ForceFieldFactory.hpp"
47   #include "io/DirectionalAtomTypesSectionParser.hpp"
48 + #include "io/BaseAtomTypesSectionParser.hpp"
49   #include "io/AtomTypesSectionParser.hpp"
50   #include "io/LennardJonesAtomTypesSectionParser.hpp"
51 < #include "io/ElectrostaticAtomTypesSectionParser.hpp"
51 > #include "io/ChargeAtomTypesSectionParser.hpp"
52 > #include "io/MultipoleAtomTypesSectionParser.hpp"
53   #include "io/EAMAtomTypesSectionParser.hpp"
54   #include "io/StickyAtomTypesSectionParser.hpp"
55   #include "io/BondTypesSectionParser.hpp"
56   #include "io/BendTypesSectionParser.hpp"
57   #include "io/TorsionTypesSectionParser.hpp"
58 + #include "io/OptionSectionParser.hpp"
59   #include "UseTheForce/ForceFieldCreator.hpp"
60   #include "utils/simError.h"
61   namespace oopse {
62      
63 < EAM_FF::EAM_FF(){
63 >  EAM_FF::EAM_FF(){
64  
65      //set default force field filename
66      setForceFieldFileName("EAM.frc");
67  
68      //the order of adding section parsers are important
69 +    //OptionSectionParser must come first to set options for other parsers
70      //DirectionalAtomTypesSectionParser should be added before AtomTypesSectionParser Since
71      //These two section parsers will actually create "real" AtomTypes (AtomTypesSectionParser will create
72      //AtomType and DirectionalAtomTypesSectionParser will creat DirectionalAtomType which is a subclass
# Line 73 | Line 76 | EAM_FF::EAM_FF(){
76      //Make sure they are added after DirectionalAtomTypesSectionParser and AtomTypesSectionParser.
77      //The order of BondTypesSectionParser, BendTypesSectionParser and TorsionTypesSectionParser are
78      //not important.
79 <    spMan_.push_back(new DirectionalAtomTypesSectionParser());
79 >    spMan_.push_back(new OptionSectionParser(forceFieldOptions_));
80 >    spMan_.push_back(new BaseAtomTypesSectionParser());
81      spMan_.push_back(new AtomTypesSectionParser());
82 <    spMan_.push_back(new LennardJonesAtomTypesSectionParser());
83 <    spMan_.push_back(new ElectrostaticAtomTypesSectionParser());
80 <    spMan_.push_back(new EAMAtomTypesSectionParser());
81 <    spMan_.push_back(new StickyAtomTypesSectionParser());
82 <    spMan_.push_back(new BondTypesSectionParser());
83 <    spMan_.push_back(new BendTypesSectionParser());
84 <    spMan_.push_back(new TorsionTypesSectionParser());
82 >    spMan_.push_back(new EAMAtomTypesSectionParser(forceFieldOptions_));
83 >
84      
85 < }
85 >  }
86  
87 < void EAM_FF::parse(const std::string& filename) {
87 >  void EAM_FF::parse(const std::string& filename) {
88      ifstrstream* ffStream;
89      ffStream = openForceFieldFile(filename);
90  
# Line 95 | Line 94 | void EAM_FF::parse(const std::string& filename) {
94      AtomType* at;
95  
96      for (at = atomTypeCont_.beginType(i); at != NULL; at = atomTypeCont_.nextType(i)) {
97 <        at->makeFortranAtomType();
97 >      // useBase sets the responsibilities, and these have to be done
98 >      // after the atomTypes and Base types have all been scanned:
99 >
100 >      std::vector<AtomType*> ayb = at->allYourBase();      
101 >      if (ayb.size() > 1) {
102 >        for (int j = ayb.size()-1; j > 0; j--) {
103 >          
104 >          ayb[j-1]->useBase(ayb[j]);
105 >
106 >        }
107 >      }
108 >      at->makeFortranAtomType();
109      }
110  
111      for (at = atomTypeCont_.beginType(i); at != NULL; at = atomTypeCont_.nextType(i)) {
112 <        at->complete();
112 >      at->complete();
113      }
104    
105 }
114  
115 +    delete ffStream;
116 +  }
117  
118 < double EAM_FF::getRcutFromAtomType(AtomType* at){
119 <    double rcut = 0.0;    
118 >
119 >  RealType EAM_FF::getRcutFromAtomType(AtomType* at){
120 >    RealType rcut = 0.0;    
121      if (at->isEAM()) {
122 <        GenericData* data = at->getPropertyByName("EAM");
123 <        if (data != NULL) {
124 <            EAMParamGenericData* eamData = dynamic_cast<EAMParamGenericData*>(data);
122 >      GenericData* data = at->getPropertyByName("EAM");
123 >      if (data != NULL) {
124 >        EAMParamGenericData* eamData = dynamic_cast<EAMParamGenericData*>(data);
125  
126 <            if (eamData != NULL) {
126 >        if (eamData != NULL) {
127  
128 <                EAMParam& eamParam = eamData->getData();
129 <                rcut =  eamParam.rcut;
130 <            } else {
131 <                    sprintf( painCave.errMsg,
132 <                           "Can not cast GenericData to EAMParam\n");
133 <                    painCave.severity = OOPSE_ERROR;
134 <                    painCave.isFatal = 1;
135 <                    simError();          
136 <            }
137 <        } else {
138 <            sprintf( painCave.errMsg, "Can not find EAM Parameters\n");
139 <            painCave.severity = OOPSE_ERROR;
140 <            painCave.isFatal = 1;
141 <            simError();          
142 <        }
128 >          EAMParam& eamParam = eamData->getData();
129 >          rcut =  eamParam.rcut;
130 >        } else {
131 >          sprintf( painCave.errMsg,
132 >                   "Can not cast GenericData to EAMParam\n");
133 >          painCave.severity = OOPSE_ERROR;
134 >          painCave.isFatal = 1;
135 >          simError();          
136 >        }
137 >      } else {
138 >        sprintf( painCave.errMsg, "Can not find EAM Parameters\n");
139 >        painCave.severity = OOPSE_ERROR;
140 >        painCave.isFatal = 1;
141 >        simError();          
142 >      }
143      }    else {
144 <        rcut = ForceField::getRcutFromAtomType(at);
144 >      rcut = ForceField::getRcutFromAtomType(at);
145      }
146    
147      return rcut;    
148 < }
148 >  }
149  
150 +  EAM_FF::~EAM_FF(){
151 +    // We need to clean up the fortran side so we don't have bad things happen if
152 +    // we try to create a second EAM force field.
153 +    destroyEAMTypes();
154 +  }
155   } //end namespace oopse

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines