36 |
|
* [1] Meineke, et al., J. Comp. Chem. 26, 252-271 (2005). |
37 |
|
* [2] Fennell & Gezelter, J. Chem. Phys. 124, 234104 (2006). |
38 |
|
* [3] Sun, Lin & Gezelter, J. Chem. Phys. 128, 24107 (2008). |
39 |
< |
* [4] Vardeman & Gezelter, in progress (2009). |
39 |
> |
* [4] Kuang & Gezelter, J. Chem. Phys. 133, 164101 (2010). |
40 |
> |
* [5] Vardeman, Stocker & Gezelter, J. Chem. Theory Comput. 7, 834 (2011). |
41 |
|
*/ |
42 |
|
|
43 |
|
#include <stdio.h> |
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()) { |
61 |
< |
sprintf( painCave.errMsg, |
62 |
< |
"EAM::getEAMParam was passed an atomType (%s) that does not\n" |
63 |
< |
"\tappear to be an embedded atom method (EAM) atom.\n", |
64 |
< |
atomType->getName().c_str()); |
65 |
< |
painCave.severity = OPENMD_ERROR; |
66 |
< |
painCave.isFatal = 1; |
67 |
< |
simError(); |
68 |
< |
} |
69 |
< |
|
70 |
< |
GenericData* data = atomType->getPropertyByName("EAM"); |
71 |
< |
if (data == NULL) { |
72 |
< |
sprintf( painCave.errMsg, "EAM::getEAMParam could not find EAM\n" |
73 |
< |
"\tparameters for atomType %s.\n", |
74 |
< |
atomType->getName().c_str()); |
75 |
< |
painCave.severity = OPENMD_ERROR; |
76 |
< |
painCave.isFatal = 1; |
77 |
< |
simError(); |
78 |
< |
} |
79 |
< |
|
80 |
< |
EAMParamGenericData* eamData = dynamic_cast<EAMParamGenericData*>(data); |
81 |
< |
if (eamData == NULL) { |
82 |
< |
sprintf( painCave.errMsg, |
83 |
< |
"EAM::getEAMParam could not convert GenericData to EAMParam for\n" |
84 |
< |
"\tatom type %s\n", atomType->getName().c_str()); |
85 |
< |
painCave.severity = OPENMD_ERROR; |
86 |
< |
painCave.isFatal = 1; |
87 |
< |
simError(); |
88 |
< |
} |
89 |
< |
|
90 |
< |
return eamData->getData(); |
91 |
< |
} |
92 |
< |
|
93 |
< |
CubicSpline* EAM::getZ(AtomType* atomType) { |
94 |
< |
EAMParam eamParam = getEAMParam(atomType); |
95 |
< |
int nr = eamParam.nr; |
96 |
< |
RealType dr = eamParam.dr; |
97 |
< |
vector<RealType> rvals; |
98 |
< |
|
99 |
< |
for (int i = 0; i < nr; i++) rvals.push_back(RealType(i) * dr); |
100 |
< |
|
101 |
< |
CubicSpline* cs = new CubicSpline(); |
102 |
< |
cs->addPoints(rvals, eamParam.Z); |
103 |
< |
return cs; |
104 |
< |
} |
105 |
< |
|
106 |
< |
RealType EAM::getRcut(AtomType* atomType) { |
107 |
< |
EAMParam eamParam = getEAMParam(atomType); |
108 |
< |
return eamParam.rcut; |
109 |
< |
} |
110 |
< |
|
111 |
< |
CubicSpline* EAM::getRho(AtomType* atomType) { |
112 |
< |
EAMParam eamParam = getEAMParam(atomType); |
113 |
< |
int nr = eamParam.nr; |
114 |
< |
RealType dr = eamParam.dr; |
115 |
< |
vector<RealType> rvals; |
116 |
< |
|
117 |
< |
for (int i = 0; i < nr; i++) rvals.push_back(RealType(i) * dr); |
118 |
< |
|
119 |
< |
CubicSpline* cs = new CubicSpline(); |
120 |
< |
cs->addPoints(rvals, eamParam.rho); |
121 |
< |
return cs; |
122 |
< |
} |
123 |
< |
|
124 |
< |
CubicSpline* EAM::getF(AtomType* atomType) { |
125 |
< |
EAMParam eamParam = getEAMParam(atomType); |
126 |
< |
int nrho = eamParam.nrho; |
127 |
< |
RealType drho = eamParam.drho; |
128 |
< |
vector<RealType> rhovals; |
129 |
< |
vector<RealType> scaledF; |
130 |
< |
|
131 |
< |
for (int i = 0; i < nrho; i++) { |
132 |
< |
rhovals.push_back(RealType(i) * drho); |
133 |
< |
scaledF.push_back( eamParam.F[i] * 23.06054 ); |
134 |
< |
} |
135 |
< |
|
136 |
< |
CubicSpline* cs = new CubicSpline(); |
137 |
< |
cs->addPoints(rhovals, scaledF); |
138 |
< |
return cs; |
139 |
< |
} |
140 |
< |
|
141 |
< |
CubicSpline* EAM::getPhi(AtomType* atomType1, AtomType* atomType2) { |
142 |
< |
EAMParam eamParam1 = getEAMParam(atomType1); |
143 |
< |
EAMParam eamParam2 = getEAMParam(atomType2); |
144 |
< |
CubicSpline* z1 = getZ(atomType1); |
145 |
< |
CubicSpline* z2 = getZ(atomType2); |
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 |
|
|
63 |
|
// make the r grid: |
64 |
|
|
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; |
281 |
– |
|
282 |
– |
eamAtomData.rho = getRho(atomType); |
283 |
– |
eamAtomData.F = getF(atomType); |
284 |
– |
eamAtomData.Z = getZ(atomType); |
285 |
– |
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: |
288 |
– |
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(); |