| 54 |
|
EAM::EAM() : name_("EAM"), initialized_(false), forceField_(NULL), |
| 55 |
|
mixMeth_(eamJohnson), eamRcut_(0.0), haveCutoffRadius_(false) {} |
| 56 |
|
|
| 57 |
< |
EAMParam EAM::getEAMParam(AtomType* atomType) { |
| 58 |
< |
|
| 59 |
< |
// Do sanity checking on the AtomType we were passed before |
| 60 |
< |
// building any data structures: |
| 61 |
< |
if (!atomType->isEAM()) { |
| 62 |
< |
sprintf( painCave.errMsg, |
| 63 |
< |
"EAM::getEAMParam was passed an atomType (%s) that does not\n" |
| 64 |
< |
"\tappear to be an embedded atom method (EAM) atom.\n", |
| 65 |
< |
atomType->getName().c_str()); |
| 66 |
< |
painCave.severity = OPENMD_ERROR; |
| 67 |
< |
painCave.isFatal = 1; |
| 68 |
< |
simError(); |
| 69 |
< |
} |
| 70 |
< |
|
| 71 |
< |
GenericData* data = atomType->getPropertyByName("EAM"); |
| 72 |
< |
if (data == NULL) { |
| 73 |
< |
sprintf( painCave.errMsg, "EAM::getEAMParam could not find EAM\n" |
| 74 |
< |
"\tparameters for atomType %s.\n", |
| 75 |
< |
atomType->getName().c_str()); |
| 76 |
< |
painCave.severity = OPENMD_ERROR; |
| 77 |
< |
painCave.isFatal = 1; |
| 78 |
< |
simError(); |
| 79 |
< |
} |
| 80 |
< |
|
| 81 |
< |
EAMParamGenericData* eamData = dynamic_cast<EAMParamGenericData*>(data); |
| 82 |
< |
if (eamData == NULL) { |
| 83 |
< |
sprintf( painCave.errMsg, |
| 84 |
< |
"EAM::getEAMParam could not convert GenericData to EAMParam for\n" |
| 85 |
< |
"\tatom type %s\n", atomType->getName().c_str()); |
| 86 |
< |
painCave.severity = OPENMD_ERROR; |
| 87 |
< |
painCave.isFatal = 1; |
| 88 |
< |
simError(); |
| 89 |
< |
} |
| 90 |
< |
|
| 91 |
< |
return eamData->getData(); |
| 92 |
< |
} |
| 93 |
< |
|
| 94 |
< |
CubicSpline* EAM::getZ(AtomType* atomType) { |
| 95 |
< |
EAMParam eamParam = getEAMParam(atomType); |
| 96 |
< |
int nr = eamParam.nr; |
| 97 |
< |
RealType dr = eamParam.dr; |
| 98 |
< |
vector<RealType> rvals; |
| 99 |
< |
|
| 100 |
< |
for (int i = 0; i < nr; i++) rvals.push_back(RealType(i) * dr); |
| 101 |
< |
|
| 102 |
< |
CubicSpline* cs = new CubicSpline(); |
| 103 |
< |
cs->addPoints(rvals, eamParam.Z); |
| 104 |
< |
return cs; |
| 105 |
< |
} |
| 106 |
< |
|
| 107 |
< |
RealType EAM::getRcut(AtomType* atomType) { |
| 108 |
< |
EAMParam eamParam = getEAMParam(atomType); |
| 109 |
< |
return eamParam.rcut; |
| 110 |
< |
} |
| 111 |
< |
|
| 112 |
< |
CubicSpline* EAM::getRho(AtomType* atomType) { |
| 113 |
< |
EAMParam eamParam = getEAMParam(atomType); |
| 114 |
< |
int nr = eamParam.nr; |
| 115 |
< |
RealType dr = eamParam.dr; |
| 116 |
< |
vector<RealType> rvals; |
| 117 |
< |
|
| 118 |
< |
for (int i = 0; i < nr; i++) rvals.push_back(RealType(i) * dr); |
| 119 |
< |
|
| 120 |
< |
CubicSpline* cs = new CubicSpline(); |
| 121 |
< |
cs->addPoints(rvals, eamParam.rho); |
| 122 |
< |
return cs; |
| 123 |
< |
} |
| 57 |
> |
CubicSpline* EAM::getPhi(AtomType* atomType1, AtomType* atomType2) { |
| 58 |
> |
EAMAdapter ea1 = EAMAdapter(atomType1); |
| 59 |
> |
EAMAdapter ea2 = EAMAdapter(atomType2); |
| 60 |
> |
CubicSpline* z1 = ea1.getZ(); |
| 61 |
> |
CubicSpline* z2 = ea2.getZ(); |
| 62 |
|
|
| 125 |
– |
CubicSpline* EAM::getF(AtomType* atomType) { |
| 126 |
– |
EAMParam eamParam = getEAMParam(atomType); |
| 127 |
– |
int nrho = eamParam.nrho; |
| 128 |
– |
RealType drho = eamParam.drho; |
| 129 |
– |
vector<RealType> rhovals; |
| 130 |
– |
vector<RealType> scaledF; |
| 131 |
– |
|
| 132 |
– |
for (int i = 0; i < nrho; i++) { |
| 133 |
– |
rhovals.push_back(RealType(i) * drho); |
| 134 |
– |
scaledF.push_back( eamParam.F[i] * 23.06054 ); |
| 135 |
– |
} |
| 136 |
– |
|
| 137 |
– |
CubicSpline* cs = new CubicSpline(); |
| 138 |
– |
cs->addPoints(rhovals, scaledF); |
| 139 |
– |
return cs; |
| 140 |
– |
} |
| 141 |
– |
|
| 142 |
– |
CubicSpline* EAM::getPhi(AtomType* atomType1, AtomType* atomType2) { |
| 143 |
– |
EAMParam eamParam1 = getEAMParam(atomType1); |
| 144 |
– |
EAMParam eamParam2 = getEAMParam(atomType2); |
| 145 |
– |
CubicSpline* z1 = getZ(atomType1); |
| 146 |
– |
CubicSpline* z2 = getZ(atomType2); |
| 147 |
– |
|
| 63 |
|
// make the r grid: |
| 64 |
|
|
| 65 |
|
|
| 66 |
|
// we need phi out to the largest value we'll encounter in the radial space; |
| 67 |
|
|
| 68 |
|
RealType rmax = 0.0; |
| 69 |
< |
rmax = max(rmax, eamParam1.rcut); |
| 70 |
< |
rmax = max(rmax, eamParam1.nr * eamParam1.dr); |
| 69 |
> |
rmax = max(rmax, ea1.getRcut()); |
| 70 |
> |
rmax = max(rmax, ea1.getNr() * ea1.getDr()); |
| 71 |
|
|
| 72 |
< |
rmax = max(rmax, eamParam2.rcut); |
| 73 |
< |
rmax = max(rmax, eamParam2.nr * eamParam2.dr); |
| 72 |
> |
rmax = max(rmax, ea2.getRcut()); |
| 73 |
> |
rmax = max(rmax, ea2.getNr() * ea2.getDr()); |
| 74 |
|
|
| 75 |
|
// use the smallest dr (finest grid) to build our grid: |
| 76 |
|
|
| 77 |
< |
RealType dr = min(eamParam1.dr, eamParam2.dr); |
| 77 |
> |
RealType dr = min(ea1.getDr(), ea2.getDr()); |
| 78 |
|
|
| 79 |
|
int nr = int(rmax/dr + 0.5); |
| 80 |
|
|
| 98 |
|
// means that our phi grid goes out beyond the cutoff of the |
| 99 |
|
// pair potential |
| 100 |
|
|
| 101 |
< |
zi = r <= eamParam1.rcut ? z1->getValueAt(r) : 0.0; |
| 102 |
< |
zj = r <= eamParam2.rcut ? z2->getValueAt(r) : 0.0; |
| 101 |
> |
zi = r <= ea1.getRcut() ? z1->getValueAt(r) : 0.0; |
| 102 |
> |
zj = r <= ea2.getRcut() ? z2->getValueAt(r) : 0.0; |
| 103 |
|
|
| 104 |
|
phi = 331.999296 * (zi * zj) / r; |
| 105 |
|
|
| 193 |
|
|
| 194 |
|
void EAM::addType(AtomType* atomType){ |
| 195 |
|
|
| 196 |
+ |
EAMAdapter ea = EAMAdapter(atomType); |
| 197 |
|
EAMAtomData eamAtomData; |
| 282 |
– |
|
| 283 |
– |
eamAtomData.rho = getRho(atomType); |
| 284 |
– |
eamAtomData.F = getF(atomType); |
| 285 |
– |
eamAtomData.Z = getZ(atomType); |
| 286 |
– |
eamAtomData.rcut = getRcut(atomType); |
| 198 |
|
|
| 199 |
+ |
eamAtomData.rho = ea.getRho(); |
| 200 |
+ |
eamAtomData.F = ea.getF(); |
| 201 |
+ |
eamAtomData.Z = ea.getZ(); |
| 202 |
+ |
eamAtomData.rcut = ea.getRcut(); |
| 203 |
+ |
|
| 204 |
|
// add it to the map: |
| 289 |
– |
AtomTypeProperties atp = atomType->getATP(); |
| 205 |
|
|
| 206 |
|
pair<map<int,AtomType*>::iterator,bool> ret; |
| 207 |
< |
ret = EAMlist.insert( pair<int, AtomType*>(atp.ident, atomType) ); |
| 207 |
> |
ret = EAMlist.insert( pair<int, AtomType*>(atomType->getIdent(), atomType) ); |
| 208 |
|
if (ret.second == false) { |
| 209 |
|
sprintf( painCave.errMsg, |
| 210 |
|
"EAM already had a previous entry with ident %d\n", |
| 211 |
< |
atp.ident); |
| 211 |
> |
atomType->getIdent()); |
| 212 |
|
painCave.severity = OPENMD_INFO; |
| 213 |
|
painCave.isFatal = 0; |
| 214 |
|
simError(); |