45#include "types/EAMAdapter.hpp"
51#include "utils/CaseConversion.hpp"
52#include "utils/simError.h"
56 bool EAMAdapter::isEAM() {
return at_->
hasProperty(EAMtypeID); }
58 EAMParameters EAMAdapter::getEAMParam() {
60 snprintf(painCave.errMsg, MAX_SIM_ERROR_MSG_LENGTH,
61 "EAMAdapter::getEAMParam was passed an atomType (%s)\n"
62 "\tthat does not appear to be an EAM atom.\n",
63 at_->getName().c_str());
64 painCave.severity = OPENMD_ERROR;
70 if (data ==
nullptr) {
71 snprintf(painCave.errMsg, MAX_SIM_ERROR_MSG_LENGTH,
72 "EAMAdapter::getEAMParam could not find EAM\n"
73 "\tparameters for atomType %s.\n",
74 at_->getName().c_str());
75 painCave.severity = OPENMD_ERROR;
80 std::shared_ptr<EAMData> eamData = std::dynamic_pointer_cast<EAMData>(data);
81 if (eamData ==
nullptr) {
82 snprintf(painCave.errMsg, MAX_SIM_ERROR_MSG_LENGTH,
83 "EAMAdapter::getEAMParam could not convert\n"
84 "\tGenericData to EAMData for atom type %s\n",
85 at_->getName().c_str());
86 painCave.severity = OPENMD_ERROR;
91 return eamData->getData();
94 FuncflParameters EAMAdapter::getFuncflParam() {
96 snprintf(painCave.errMsg, MAX_SIM_ERROR_MSG_LENGTH,
97 "EAMAdapter::getFuncflParam was passed an atomType (%s)\n"
98 "\tthat does not appear to be an EAM atom.\n",
99 at_->getName().c_str());
100 painCave.severity = OPENMD_ERROR;
101 painCave.isFatal = 1;
106 if (data ==
nullptr) {
107 snprintf(painCave.errMsg, MAX_SIM_ERROR_MSG_LENGTH,
108 "EAMAdapter::getFuncflParam could not find Funcfl\n"
109 "\tparameters for atomType %s.\n",
110 at_->getName().c_str());
111 painCave.severity = OPENMD_ERROR;
112 painCave.isFatal = 1;
116 std::shared_ptr<FuncflData> funcflData =
117 std::dynamic_pointer_cast<FuncflData>(data);
118 if (funcflData ==
nullptr) {
119 snprintf(painCave.errMsg, MAX_SIM_ERROR_MSG_LENGTH,
120 "EAMAdapter::getFuncflParam could not convert\n"
121 "\tGenericData to FuncflData for atom type %s\n",
122 at_->getName().c_str());
123 painCave.severity = OPENMD_ERROR;
124 painCave.isFatal = 1;
128 return funcflData->getData();
131 ZhouParameters EAMAdapter::getZhouParam() {
133 snprintf(painCave.errMsg, MAX_SIM_ERROR_MSG_LENGTH,
134 "EAMAdapter::getZhouParam was passed an atomType (%s)\n"
135 "\tthat does not appear to be an EAM atom.\n",
136 at_->getName().c_str());
137 painCave.severity = OPENMD_ERROR;
138 painCave.isFatal = 1;
143 if (data ==
nullptr) {
144 snprintf(painCave.errMsg, MAX_SIM_ERROR_MSG_LENGTH,
145 "EAMAdapter::getZhouParam could not find Zhou\n"
146 "\tparameters for atomType %s.\n",
147 at_->getName().c_str());
148 painCave.severity = OPENMD_ERROR;
149 painCave.isFatal = 1;
153 std::shared_ptr<ZhouData> zhouData =
154 std::dynamic_pointer_cast<ZhouData>(data);
155 if (zhouData ==
nullptr) {
156 snprintf(painCave.errMsg, MAX_SIM_ERROR_MSG_LENGTH,
157 "EAMAdapter::getZhouParam could not convert\n"
158 "\tGenericData to ZhouData for atom type %s\n",
159 at_->getName().c_str());
160 painCave.severity = OPENMD_ERROR;
161 painCave.isFatal = 1;
165 return zhouData->getData();
168 EAMType EAMAdapter::getEAMType() {
169 EAMParameters eamParam = getEAMParam();
170 return eamParam.eamType;
173 std::string EAMAdapter::getLatticeType() {
174 EAMParameters eamParam = getEAMParam();
175 return eamParam.latticeType;
178 RealType EAMAdapter::getLatticeConstant() {
179 EAMParameters eamParam = getEAMParam();
180 return eamParam.latticeConstant;
183 CubicSplinePtr EAMAdapter::getZSpline() {
184 FuncflParameters funcflParam = getFuncflParam();
185 int nr = funcflParam.nr;
186 RealType dr = funcflParam.dr;
187 std::vector<RealType> rvals;
189 for (
int i = 0; i < nr; i++)
190 rvals.push_back(RealType(i) * dr);
192 CubicSplinePtr cs {std::make_shared<CubicSpline>()};
193 cs->addPoints(rvals, funcflParam.Z);
197 CubicSplinePtr EAMAdapter::getRhoSpline() {
198 FuncflParameters funcflParam = getFuncflParam();
199 int nr = funcflParam.nr;
200 RealType dr = funcflParam.dr;
201 std::vector<RealType> rvals;
203 for (
int i = 0; i < nr; i++)
204 rvals.push_back(RealType(i) * dr);
206 CubicSplinePtr cs {std::make_shared<CubicSpline>()};
207 cs->addPoints(rvals, funcflParam.rho);
211 CubicSplinePtr EAMAdapter::getFSpline() {
212 FuncflParameters funcflParam = getFuncflParam();
213 int nrho = funcflParam.nrho;
214 RealType drho = funcflParam.drho;
215 std::vector<RealType> rhovals;
217 for (
int i = 0; i < nrho; i++) {
218 rhovals.push_back(RealType(i) * drho);
221 CubicSplinePtr cs {std::make_shared<CubicSpline>()};
222 cs->addPoints(rhovals, funcflParam.F);
226 void EAMAdapter::makeFuncfl(RealType latticeConstant, std::string latticeType,
227 int nrho, RealType drho,
int nr, RealType dr,
228 RealType rcut, vector<RealType> Z,
229 vector<RealType> rho, vector<RealType> F) {
235 EAMParameters eamParam {};
236 FuncflParameters funcflParam {};
238 eamParam.eamType = eamFuncfl;
239 eamParam.latticeConstant = latticeConstant;
240 eamParam.latticeType = latticeType;
242 funcflParam.nrho = nrho;
243 funcflParam.drho = drho;
246 funcflParam.rcut = rcut;
248 funcflParam.rho = rho;
251 at_->
addProperty(std::make_shared<EAMData>(EAMtypeID, eamParam));
252 at_->
addProperty(std::make_shared<FuncflData>(FuncflTypeID, funcflParam));
255 void EAMAdapter::makeZhou2001(std::string latticeType, RealType re,
256 RealType fe, RealType rhoe, RealType alpha,
257 RealType beta, RealType A, RealType B,
258 RealType kappa, RealType lambda,
259 std::vector<RealType> Fn,
260 std::vector<RealType> F, RealType eta,
267 EAMParameters eamParam {};
268 ZhouParameters zhouParam {};
270 eamParam.eamType = eamZhou2001;
272 toUpper(latticeType);
273 eamParam.latticeType = latticeType;
275 if (latticeType ==
"HCP")
276 eamParam.latticeConstant = re;
277 else if (latticeType ==
"BCC")
278 eamParam.latticeConstant = 2.0 * re / sqrt(3.0);
280 eamParam.latticeConstant = 2.0 * re / sqrt(2.0);
284 zhouParam.rhoe = rhoe;
285 zhouParam.alpha = alpha;
286 zhouParam.beta = beta;
289 zhouParam.kappa = kappa;
290 zhouParam.lambda = lambda;
296 at_->
addProperty(std::make_shared<EAMData>(EAMtypeID, eamParam));
297 at_->
addProperty(std::make_shared<ZhouData>(ZhouTypeID, zhouParam));
300 void EAMAdapter::makeZhou2004(std::string latticeType, RealType re,
301 RealType fe, RealType rhoe, RealType rhos,
302 RealType alpha, RealType beta, RealType A,
303 RealType B, RealType kappa, RealType lambda,
304 std::vector<RealType> Fn,
305 std::vector<RealType> F, RealType eta,
306 RealType Fe, RealType rhol, RealType rhoh) {
312 EAMParameters eamParam {};
313 ZhouParameters zhouParam {};
315 eamParam.eamType = eamZhou2004;
317 toUpper(latticeType);
318 eamParam.latticeType = latticeType;
320 if (latticeType ==
"HCP")
321 eamParam.latticeConstant = re;
322 else if (latticeType ==
"BCC")
323 eamParam.latticeConstant = 2.0 * re / sqrt(3.0);
325 eamParam.latticeConstant = 2.0 * re / sqrt(2.0);
329 zhouParam.rhoe = rhoe;
330 zhouParam.alpha = alpha;
331 zhouParam.beta = beta;
334 zhouParam.kappa = kappa;
335 zhouParam.lambda = lambda;
340 zhouParam.rhos = rhos;
341 zhouParam.rhol = rhol;
342 zhouParam.rhoh = rhoh;
344 at_->
addProperty(std::make_shared<EAMData>(EAMtypeID, eamParam));
345 at_->
addProperty(std::make_shared<ZhouData>(ZhouTypeID, zhouParam));
348 void EAMAdapter::makeZhou2005(std::string latticeType, RealType re,
349 RealType fe, RealType rhoe, RealType rhos,
350 RealType alpha, RealType beta, RealType A,
351 RealType B, RealType kappa, RealType lambda,
352 std::vector<RealType> Fn,
353 std::vector<RealType> F, RealType F3plus,
354 RealType F3minus, RealType eta, RealType Fe) {
360 EAMParameters eamParam {};
361 ZhouParameters zhouParam {};
363 eamParam.eamType = eamZhou2005;
365 toUpper(latticeType);
366 eamParam.latticeType = latticeType;
368 if (latticeType ==
"HCP")
369 eamParam.latticeConstant = re;
370 else if (latticeType ==
"BCC")
371 eamParam.latticeConstant = 2.0 * re / sqrt(3.0);
373 eamParam.latticeConstant = 2.0 * re / sqrt(2.0);
377 zhouParam.rhoe = rhoe;
378 zhouParam.alpha = alpha;
379 zhouParam.beta = beta;
382 zhouParam.kappa = kappa;
383 zhouParam.lambda = lambda;
386 zhouParam.F3plus = F3plus;
387 zhouParam.F3minus = F3minus;
390 zhouParam.rhos = rhos;
392 at_->
addProperty(std::make_shared<EAMData>(EAMtypeID, eamParam));
393 at_->
addProperty(std::make_shared<ZhouData>(ZhouTypeID, zhouParam));
396 void EAMAdapter::makeZhou2005Oxygen(RealType re, RealType fe, RealType alpha,
397 RealType beta, RealType A, RealType B,
398 RealType kappa, RealType lambda,
399 RealType gamma, RealType nu,
400 std::vector<RealType> OrhoLimits,
401 std::vector<RealType> OrhoE,
402 std::vector<std::vector<RealType>> OF) {
408 EAMParameters eamParam {};
409 ZhouParameters zhouParam {};
411 eamParam.eamType = eamZhou2005Oxygen;
413 eamParam.latticeConstant = re;
417 zhouParam.alpha = alpha;
418 zhouParam.beta = beta;
421 zhouParam.kappa = kappa;
422 zhouParam.lambda = lambda;
423 zhouParam.gamma = gamma;
425 zhouParam.OrhoLimits = OrhoLimits;
426 zhouParam.OrhoE = OrhoE;
429 at_->
addProperty(std::make_shared<EAMData>(EAMtypeID, eamParam));
430 at_->
addProperty(std::make_shared<ZhouData>(ZhouTypeID, zhouParam));
433 void EAMAdapter::makeZhouRose(RealType re, RealType fe, RealType rhoe,
434 RealType alpha, RealType beta, RealType A,
435 RealType B, RealType kappa, RealType lambda,
442 EAMParameters eamParam {};
443 ZhouParameters zhouParam {};
445 eamParam.eamType = eamZhouRose;
446 eamParam.latticeConstant = re;
449 zhouParam.rhoe = rhoe;
450 zhouParam.alpha = alpha;
451 zhouParam.beta = beta;
454 zhouParam.kappa = kappa;
455 zhouParam.lambda = lambda;
458 at_->
addProperty(std::make_shared<EAMData>(EAMtypeID, eamParam));
459 at_->
addProperty(std::make_shared<ZhouData>(ZhouTypeID, zhouParam));
462 void EAMAdapter::makeOxygenFuncfl(RealType re, RealType fe, RealType alpha,
463 RealType beta, RealType A, RealType B,
464 RealType kappa, RealType lambda,
465 RealType drho, RealType nrho,
466 std::vector<RealType> F) {
473 EAMParameters eamParam {};
474 FuncflParameters funcflParam {};
475 ZhouParameters zhouParam {};
477 eamParam.eamType = eamOxygenFuncfl;
478 eamParam.latticeConstant = re;
481 zhouParam.alpha = alpha;
482 zhouParam.beta = beta;
485 zhouParam.kappa = kappa;
486 zhouParam.lambda = lambda;
489 funcflParam.drho = drho;
490 funcflParam.nrho = nrho;
492 at_->
addProperty(std::make_shared<EAMData>(EAMtypeID, eamParam));
493 at_->
addProperty(std::make_shared<ZhouData>(ZhouTypeID, zhouParam));
494 at_->
addProperty(std::make_shared<FuncflData>(FuncflTypeID, funcflParam));
497 int EAMAdapter::getNrho() {
498 FuncflParameters funcflParam = getFuncflParam();
499 return funcflParam.nrho;
502 RealType EAMAdapter::getDrho() {
503 FuncflParameters funcflParam = getFuncflParam();
504 return funcflParam.drho;
507 int EAMAdapter::getNr() {
508 FuncflParameters funcflParam = getFuncflParam();
509 return funcflParam.nr;
512 RealType EAMAdapter::getDr() {
513 FuncflParameters funcflParam = getFuncflParam();
514 return funcflParam.dr;
517 RealType EAMAdapter::getRcut() {
518 FuncflParameters funcflParam = getFuncflParam();
519 return funcflParam.rcut;
522 RealType EAMAdapter::getRe() {
523 ZhouParameters zhouParam = getZhouParam();
526 RealType EAMAdapter::get_fe() {
527 ZhouParameters zhouParam = getZhouParam();
530 RealType EAMAdapter::getRhoe() {
531 ZhouParameters zhouParam = getZhouParam();
532 return zhouParam.rhoe;
534 RealType EAMAdapter::getAlpha() {
535 ZhouParameters zhouParam = getZhouParam();
536 return zhouParam.alpha;
538 RealType EAMAdapter::getBeta() {
539 ZhouParameters zhouParam = getZhouParam();
540 return zhouParam.beta;
542 RealType EAMAdapter::getA() {
543 ZhouParameters zhouParam = getZhouParam();
546 RealType EAMAdapter::getB() {
547 ZhouParameters zhouParam = getZhouParam();
550 RealType EAMAdapter::getKappa() {
551 ZhouParameters zhouParam = getZhouParam();
552 return zhouParam.kappa;
554 RealType EAMAdapter::getLambda() {
555 ZhouParameters zhouParam = getZhouParam();
556 return zhouParam.lambda;
558 RealType EAMAdapter::getGamma() {
559 ZhouParameters zhouParam = getZhouParam();
560 return zhouParam.gamma;
562 RealType EAMAdapter::getNu() {
563 ZhouParameters zhouParam = getZhouParam();
566 std::vector<RealType> EAMAdapter::getFn() {
567 ZhouParameters zhouParam = getZhouParam();
570 std::vector<RealType> EAMAdapter::getF() {
571 ZhouParameters zhouParam = getZhouParam();
574 RealType EAMAdapter::getF3plus() {
575 ZhouParameters zhouParam = getZhouParam();
576 return zhouParam.F3plus;
578 RealType EAMAdapter::getF3minus() {
579 ZhouParameters zhouParam = getZhouParam();
580 return zhouParam.F3minus;
583 RealType EAMAdapter::getEta() {
584 ZhouParameters zhouParam = getZhouParam();
585 return zhouParam.eta;
588 RealType EAMAdapter::getFe() {
589 ZhouParameters zhouParam = getZhouParam();
593 RealType EAMAdapter::getRhos() {
594 ZhouParameters zhouParam = getZhouParam();
595 return zhouParam.rhos;
598 RealType EAMAdapter::getRhol() {
599 ZhouParameters zhouParam = getZhouParam();
600 return zhouParam.rhol;
603 RealType EAMAdapter::getRhoh() {
604 ZhouParameters zhouParam = getZhouParam();
605 return zhouParam.rhoh;
608 std::vector<RealType> EAMAdapter::getOrhoLimits() {
609 ZhouParameters zhouParam = getZhouParam();
610 return zhouParam.OrhoLimits;
612 std::vector<RealType> EAMAdapter::getOrhoE() {
613 ZhouParameters zhouParam = getZhouParam();
614 return zhouParam.OrhoE;
617 std::vector<std::vector<RealType>> EAMAdapter::getOF() {
618 ZhouParameters zhouParam = getZhouParam();
621 RealType EAMAdapter::getF0() {
622 ZhouParameters zhouParam = getZhouParam();
std::shared_ptr< GenericData > getPropertyByName(const string &propName)
Returns property.
void removeProperty(const string &propName)
Removes property from PropertyMap by name.
bool hasProperty(const string &propName)
Checks if property is in this PropertyMap.
void addProperty(std::shared_ptr< GenericData > genData)
Adds property into property map.
This basic Periodic Table class was originally taken from the data.cpp file in OpenBabel.