Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
was created with an independent implementation. This is not
a very strong test, but should capture some regressions.
References
----------
[1] G. Bonny, R.C. Pasianot, N. Castin, and L. Malerba (2009),
"Ternary Fe-Cu-Ni many-body potential to model reactor
pressure vessel steels: First validation by simulated
thermal annealing", Philosophical Magazine, 89(34-36),
3531-3546. DOI: 10.1080/14786430903299824.
[2] https://www.ctcms.nist.gov/potentials/Download/2009--Bonny-G-Pasianot-R-C-Castin-N-Malerba-L--Fe-Cu-Ni/1/FeCuNi.eam.alloy
"""
input_table = "FeCuNi.eam.alloy"
reference_table = "FeCuNi_reference_A-atom_Fe33Cu33Ni33.eam.alloy"
concentrations = np.array((1.0 / 3.0, 1.0 / 3.0, 1.0 / 3.0))
source, parameters, F, f, rep = io.read_eam(input_table)
(new_parameters, new_F, new_f, new_rep) = average_atom.average_potential(
concentrations, parameters, F, f, rep
)
ref_source, ref_parameters, ref_F, ref_f, ref_rep = io.read_eam(reference_table)
diff_F = np.linalg.norm(ref_F - new_F)
diff_f = np.linalg.norm(ref_f - new_f)
diff_rep = np.linalg.norm(ref_rep - new_rep)
print(diff_F, diff_f, diff_rep)
self.assertTrue(diff_F < self.tol)
self.assertTrue(diff_f < self.tol)
self.assertTrue(diff_rep < self.tol)
References
----------
[1] G.P. Purja Pun, and Y. Mishin (2009), "Development of an
interatomic potential for the Ni-Al system", Philosophical
Magazine, 89(34-36), 3245-3267. DOI: 10.1080/14786430903258184.
[2] https://www.ctcms.nist.gov/potentials/Download/2009--Purja-Pun-G-P-Mishin-Y--Ni-Al/2/Mishin-Ni-Al-2009.eam.alloy
"""
input_table = "Mishin-Ni-Al-2009.eam.alloy"
reference_table = "Mishin-Ni-Al-2009_reference_A-atom_Ni85Al15.eam.alloy"
concentrations = np.array((0.85, 0.15))
source, parameters, F, f, rep = io.read_eam(input_table)
(new_parameters, new_F, new_f, new_rep) = average_atom.average_potential(
concentrations, parameters, F, f, rep
)
ref_source, ref_parameters, ref_F, ref_f, ref_rep = io.read_eam(reference_table)
diff_F = np.linalg.norm(ref_F - new_F)
diff_f = np.linalg.norm(ref_f - new_f)
diff_rep = np.linalg.norm(ref_rep - new_rep)
print(diff_F, diff_f, diff_rep)
self.assertTrue(diff_F < self.tol)
self.assertTrue(diff_f < self.tol)
self.assertTrue(diff_rep < self.tol)
the NIST database [2]_. The generated The generated A-atom
potential is compared to a reference A-atom potential, which
was created with an independent implementation. This is not
a very strong test, but should capture some regressions.
References
----------
[1] G.P. Purja Pun, and Y. Mishin (2009), "Development of an
interatomic potential for the Ni-Al system", Philosophical
Magazine, 89(34-36), 3245-3267. DOI: 10.1080/14786430903258184.
[2] https://www.ctcms.nist.gov/potentials/Download/2009--Purja-Pun-G-P-Mishin-Y--Ni-Al/2/Mishin-Ni-Al-2009.eam.alloy
"""
input_table = "Mishin-Ni-Al-2009.eam.alloy"
reference_table = "Mishin-Ni-Al-2009_reference_A-atom_Ni85Al15.eam.alloy"
concentrations = np.array((0.85, 0.15))
source, parameters, F, f, rep = io.read_eam(input_table)
(new_parameters, new_F, new_f, new_rep) = average_atom.average_potential(
concentrations, parameters, F, f, rep
)
ref_source, ref_parameters, ref_F, ref_f, ref_rep = io.read_eam(reference_table)
diff_F = np.linalg.norm(ref_F - new_F)
diff_f = np.linalg.norm(ref_f - new_f)
diff_rep = np.linalg.norm(ref_rep - new_rep)
print(diff_F, diff_f, diff_rep)
self.assertTrue(diff_F < self.tol)
self.assertTrue(diff_f < self.tol)
self.assertTrue(diff_rep < self.tol)
----------
[1] G. Bonny, R.C. Pasianot, N. Castin, and L. Malerba (2009),
"Ternary Fe-Cu-Ni many-body potential to model reactor
pressure vessel steels: First validation by simulated
thermal annealing", Philosophical Magazine, 89(34-36),
3531-3546. DOI: 10.1080/14786430903299824.
[2] https://www.ctcms.nist.gov/potentials/Download/2009--Bonny-G-Pasianot-R-C-Castin-N-Malerba-L--Fe-Cu-Ni/1/FeCuNi.eam.alloy
"""
input_table = "FeCuNi.eam.alloy"
reference_table = "FeCuNi_reference_A-atom_Fe33Cu33Ni33.eam.alloy"
concentrations = np.array((1.0 / 3.0, 1.0 / 3.0, 1.0 / 3.0))
source, parameters, F, f, rep = io.read_eam(input_table)
(new_parameters, new_F, new_f, new_rep) = average_atom.average_potential(
concentrations, parameters, F, f, rep
)
ref_source, ref_parameters, ref_F, ref_f, ref_rep = io.read_eam(reference_table)
diff_F = np.linalg.norm(ref_F - new_F)
diff_f = np.linalg.norm(ref_f - new_f)
diff_rep = np.linalg.norm(ref_rep - new_rep)
print(diff_F, diff_f, diff_rep)
self.assertTrue(diff_F < self.tol)
self.assertTrue(diff_f < self.tol)
self.assertTrue(diff_rep < self.tol)
def test_eam_read_write(self):
source,parameters,F,f,rep = read_eam("Au_u3.eam")
write_eam(source,parameters,F,f,rep,"Au_u3_copy.eam")
source1,parameters1,F1,f1,rep1 = read_eam("Au_u3_copy.eam")
os.remove("Au_u3_copy.eam")
for i,p in enumerate(parameters):
try:
diff = p - parameters1[i]
except:
diff = None
if diff is None:
self.assertTrue(p == parameters1[i])
else:
self.assertTrue(diff < self.tol)
self.assertTrue((F == F1).all())
self.assertTrue((f == f1).all())
self.assertTrue((rep == rep1).all())
def test_eam_read_write(self):
source,parameters,F,f,rep = read_eam("Au_u3.eam")
write_eam(source,parameters,F,f,rep,"Au_u3_copy.eam")
source1,parameters1,F1,f1,rep1 = read_eam("Au_u3_copy.eam")
os.remove("Au_u3_copy.eam")
for i,p in enumerate(parameters):
try:
diff = p - parameters1[i]
except:
diff = None
if diff is None:
self.assertTrue(p == parameters1[i])
else:
self.assertTrue(diff < self.tol)
self.assertTrue((F == F1).all())
self.assertTrue((f == f1).all())
self.assertTrue((rep == rep1).all())
def __init__(self, fn=None, atomic_numbers=None, F=None, f=None, rep=None,
cutoff=None, kind='eam/alloy'):
Calculator.__init__(self)
if fn is not None:
source, parameters, F, f, rep = read_eam(fn, kind=kind)
self._db_atomic_numbers = parameters.atomic_numbers
self._db_cutoff = parameters.cutoff
dr = parameters.distance_grid_spacing
dF = parameters.density_grid_spacing
# Create spline interpolation
self.F = _make_splines(dF, F)
self.f = _make_splines(dr, f)
self.rep = _make_splines(dr, rep)
else:
self._db_atomic_numbers = atomic_numbers
self.F = F
self.f = f
self.rep = rep
self._db_cutoff = cutoff