| 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 |
| 40 |
|
*/ |
| 41 |
|
|
| 42 |
|
#include "UseTheForce/EAM_FF.hpp" |
| 43 |
+ |
#include "UseTheForce/DarkSide/eam_interface.h" |
| 44 |
|
#include "UseTheForce/DarkSide/lj_interface.h" |
| 45 |
|
#include "UseTheForce/DarkSide/sticky_interface.h" |
| 46 |
|
#include "UseTheForce/ForceFieldFactory.hpp" |
| 54 |
|
#include "io/BondTypesSectionParser.hpp" |
| 55 |
|
#include "io/BendTypesSectionParser.hpp" |
| 56 |
|
#include "io/TorsionTypesSectionParser.hpp" |
| 57 |
+ |
#include "io/OptionSectionParser.hpp" |
| 58 |
|
#include "UseTheForce/ForceFieldCreator.hpp" |
| 59 |
|
#include "utils/simError.h" |
| 60 |
|
namespace oopse { |
| 61 |
|
|
| 62 |
< |
EAM_FF::EAM_FF(){ |
| 62 |
> |
EAM_FF::EAM_FF(){ |
| 63 |
|
|
| 64 |
|
//set default force field filename |
| 65 |
|
setForceFieldFileName("EAM.frc"); |
| 74 |
|
//Make sure they are added after DirectionalAtomTypesSectionParser and AtomTypesSectionParser. |
| 75 |
|
//The order of BondTypesSectionParser, BendTypesSectionParser and TorsionTypesSectionParser are |
| 76 |
|
//not important. |
| 77 |
+ |
spMan_.push_back(new OptionSectionParser(forceFieldOptions_)); |
| 78 |
|
spMan_.push_back(new DirectionalAtomTypesSectionParser()); |
| 79 |
|
spMan_.push_back(new AtomTypesSectionParser()); |
| 77 |
– |
spMan_.push_back(new LennardJonesAtomTypesSectionParser()); |
| 78 |
– |
spMan_.push_back(new ChargeAtomTypesSectionParser()); |
| 79 |
– |
spMan_.push_back(new MultipoleAtomTypesSectionParser()); |
| 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()); |
| 81 |
> |
|
| 82 |
|
|
| 83 |
< |
} |
| 83 |
> |
} |
| 84 |
|
|
| 85 |
< |
void EAM_FF::parse(const std::string& filename) { |
| 85 |
> |
void EAM_FF::parse(const std::string& filename) { |
| 86 |
|
ifstrstream* ffStream; |
| 87 |
|
ffStream = openForceFieldFile(filename); |
| 88 |
|
|
| 92 |
|
AtomType* at; |
| 93 |
|
|
| 94 |
|
for (at = atomTypeCont_.beginType(i); at != NULL; at = atomTypeCont_.nextType(i)) { |
| 95 |
< |
at->makeFortranAtomType(); |
| 95 |
> |
at->makeFortranAtomType(); |
| 96 |
|
} |
| 97 |
|
|
| 98 |
|
for (at = atomTypeCont_.beginType(i); at != NULL; at = atomTypeCont_.nextType(i)) { |
| 99 |
< |
at->complete(); |
| 99 |
> |
at->complete(); |
| 100 |
|
} |
| 101 |
|
|
| 102 |
|
delete ffStream; |
| 103 |
< |
} |
| 103 |
> |
} |
| 104 |
|
|
| 105 |
|
|
| 106 |
< |
double EAM_FF::getRcutFromAtomType(AtomType* at){ |
| 106 |
> |
double EAM_FF::getRcutFromAtomType(AtomType* at){ |
| 107 |
|
double rcut = 0.0; |
| 108 |
|
if (at->isEAM()) { |
| 109 |
< |
GenericData* data = at->getPropertyByName("EAM"); |
| 110 |
< |
if (data != NULL) { |
| 111 |
< |
EAMParamGenericData* eamData = dynamic_cast<EAMParamGenericData*>(data); |
| 109 |
> |
GenericData* data = at->getPropertyByName("EAM"); |
| 110 |
> |
if (data != NULL) { |
| 111 |
> |
EAMParamGenericData* eamData = dynamic_cast<EAMParamGenericData*>(data); |
| 112 |
|
|
| 113 |
< |
if (eamData != NULL) { |
| 113 |
> |
if (eamData != NULL) { |
| 114 |
|
|
| 115 |
< |
EAMParam& eamParam = eamData->getData(); |
| 116 |
< |
rcut = eamParam.rcut; |
| 117 |
< |
} else { |
| 118 |
< |
sprintf( painCave.errMsg, |
| 119 |
< |
"Can not cast GenericData to EAMParam\n"); |
| 120 |
< |
painCave.severity = OOPSE_ERROR; |
| 121 |
< |
painCave.isFatal = 1; |
| 122 |
< |
simError(); |
| 123 |
< |
} |
| 124 |
< |
} else { |
| 125 |
< |
sprintf( painCave.errMsg, "Can not find EAM Parameters\n"); |
| 126 |
< |
painCave.severity = OOPSE_ERROR; |
| 127 |
< |
painCave.isFatal = 1; |
| 128 |
< |
simError(); |
| 129 |
< |
} |
| 115 |
> |
EAMParam& eamParam = eamData->getData(); |
| 116 |
> |
rcut = eamParam.rcut; |
| 117 |
> |
} else { |
| 118 |
> |
sprintf( painCave.errMsg, |
| 119 |
> |
"Can not cast GenericData to EAMParam\n"); |
| 120 |
> |
painCave.severity = OOPSE_ERROR; |
| 121 |
> |
painCave.isFatal = 1; |
| 122 |
> |
simError(); |
| 123 |
> |
} |
| 124 |
> |
} else { |
| 125 |
> |
sprintf( painCave.errMsg, "Can not find EAM Parameters\n"); |
| 126 |
> |
painCave.severity = OOPSE_ERROR; |
| 127 |
> |
painCave.isFatal = 1; |
| 128 |
> |
simError(); |
| 129 |
> |
} |
| 130 |
|
} else { |
| 131 |
< |
rcut = ForceField::getRcutFromAtomType(at); |
| 131 |
> |
rcut = ForceField::getRcutFromAtomType(at); |
| 132 |
|
} |
| 133 |
|
|
| 134 |
|
return rcut; |
| 135 |
< |
} |
| 135 |
> |
} |
| 136 |
|
|
| 137 |
+ |
EAM_FF::~EAM_FF(){ |
| 138 |
+ |
// We need to clean up the fortran side so we don't have bad things happen if |
| 139 |
+ |
// we try to create a second EAM force field. |
| 140 |
+ |
destroyEAMTypes(); |
| 141 |
+ |
} |
| 142 |
|
} //end namespace oopse |