Exemplo n.º 1
0
 def test_dense_forces(self):
     orig_a = io.read('eam_crash2.poscar')
     c = TabulatedAlloyEAM(fn='Cu_mishin1.eam.alloy')
     for fac in [0.2, 0.3, 0.4, 0.5]:
         a = orig_a.copy()
         a.set_cell(fac * a.cell, scale_atoms=True)
         a.set_calculator(c)
         ffd, f0, maxdf = test_forces(a, dx=dx)
         if maxdf > tol:
             nfail += 1
             print("forces .failed.")
             print("max(df)  = %f" % maxdf)
             print("f - from potential")
             for i, f in enumerate(f0):
                 print(i, f)
             print("f - numerically")
             for i, f in enumerate(ffd):
                 print(i, f)
             print("difference between the above")
             for i, f in enumerate(f0 - ffd):
                 print(i, f)
         self.assertTrue(maxdf < tol)
Exemplo n.º 2
0
 def test_crash1(self):
     a = io.read('eam_crash1.poscar')
     a.set_calculator(TabulatedAlloyEAM(fn='Cu_mishin1.eam.alloy'))
     a.get_potential_energy()
Exemplo n.º 3
0
 def test_mask_decomposition_tabulated_alloy_eam(self):
     a = FaceCenteredCubic('Au', size=[2, 2, 2])
     c = TabulatedAlloyEAM(fn='Au-Grochola-JCP05.eam.alloy')
     a.set_calculator(c)
     self.random_mask_test(a)
Exemplo n.º 4
0
import numpy as np

from ase.constraints import UnitCellFilter
from ase.lattice.cubic import FaceCenteredCubic
from ase.optimize import FIRE
from ase.utils.eos import EquationOfState

from atomistica import TabulatedAlloyEAM

###

n = 2
a = FaceCenteredCubic('Au', size=[n, n, n])
x0 = a.cell[0, 0]/n
c = TabulatedAlloyEAM(fn='Au-Grochola-JCP05.eam.alloy')
a.set_calculator(c)

# Vary volume and fit minimum
def en(a, x):
	a.set_cell([x, x, x], scale_atoms=True)
	return a.get_potential_energy()
x = np.linspace(0.9*x0, 1.1*x0, 101)
e = [ en(a, n*_x)/(n**3) for _x in x ]
eos = EquationOfState(x**3, e)
v0, e0, B = eos.fit()

print 'lattice constant (from equation of state) =', v0**(1./3)

# Keep cell rectangular during optimization
FIRE(UnitCellFilter(a, mask=[1,1,1,0,0,0]), logfile=None).run(fmax=0.0001)
    def test_rotation(self):
        if not atomistica:
            print('Atomistica not available. Skipping test.')
            return

        for make_atoms, calc in [
                #            ( lambda a0,x :
                #              FaceCenteredCubic('He', size=[1,1,1],
                #                                latticeconstant=3.5 if a0 is None else a0,
                #                                directions=x),
                #              LJCut(epsilon=10.2, sigma=2.28, cutoff=5.0, shift=True) ),
            (lambda a0, x: FaceCenteredCubic(
                'Au', size=[1, 1, 1], latticeconstant=a0, directions=x),
             TabulatedAlloyEAM(fn='Au-Grochola-JCP05.eam.alloy')),
            (lambda a0, x: Diamond(
                'Si', size=[1, 1, 1], latticeconstant=a0, directions=x),
             Kumagai())
                #( lambda a0,x : FaceCenteredCubic('Au', size=[1,1,1],
                #                                  latticeconstant=a0, directions=x),
                #  EAM(potential='Au-Grochola-JCP05.eam.alloy') ),
        ]:

            a = make_atoms(None, [[1, 0, 0], [0, 1, 0], [0, 0, 1]])
            a.set_calculator(calc)
            FIRE(StrainFilter(a, mask=[1,1,1,0,0,0]), logfile=None) \
                .run(fmax=self.fmax)
            latticeconstant = np.mean(a.cell.diagonal())

            C6 = measure_triclinic_elastic_constants(a,
                                                     delta=self.delta,
                                                     fmax=self.fmax)
            C11, C12, C44 = Voigt_6x6_to_cubic(C6) / GPa

            el = CubicElasticModuli(C11, C12, C44)

            C_m = measure_triclinic_elastic_constants(
                a, delta=self.delta, fmax=self.fmax) / GPa
            self.assertArrayAlmostEqual(el.stiffness(), C_m, tol=0.01)

            for directions in [[[1, 0, 0], [0, 1, 0], [0, 0, 1]],
                               [[0, 1, 0], [0, 0, 1], [1, 0, 0]],
                               [[1, 1, 0], [0, 0, 1], [1, -1, 0]],
                               [[1, 1, 1], [-1, -1, 2], [1, -1, 0]]]:
                a, b, c = directions

                directions = np.array(
                    [np.array(x) / np.linalg.norm(x) for x in directions])
                a = make_atoms(latticeconstant, directions)
                a.set_calculator(calc)

                C = el.rotate(directions)
                C_check = el._rotate_explicit(directions)
                C_check2 = rotate_cubic_elastic_constants(
                    C11, C12, C44, directions)
                C_check3 = \
                    rotate_elastic_constants(cubic_to_Voigt_6x6(C11, C12, C44),
                                             directions)
                self.assertArrayAlmostEqual(C, C_check, tol=1e-6)
                self.assertArrayAlmostEqual(C, C_check2, tol=1e-6)
                self.assertArrayAlmostEqual(C, C_check3, tol=1e-6)

                C_m = measure_triclinic_elastic_constants(
                    a, delta=self.delta, fmax=self.fmax) / GPa

                self.assertArrayAlmostEqual(C, C_m, tol=1e-2)