Ejemplo n.º 1
0
    def C44_Calculator(self, EMT, PARAMETERS):
        # Return 0 is used when the method is not desired to be used
        # return 0
        """ This method uses the given EMT calculator to calculate and return the value of the matrix element C44 for 
            a system of atoms of a given element type. The calculation is done by using that:
            C44 = 1 / Volume * d^2/depsilon^2 (E_system) where epsilon is the displacement in one direction of the 
            system along one axis diveded by the highth of the system. """

        # An atom object is created and the calculator attached
        atoms = FaceCenteredCubic(size=(self.Size, self.Size, self.Size),
                                  symbol=self.Element)
        atoms.set_calculator(EMT)

        # The volume of the sample is calculated
        Vol = atoms.get_volume()

        # The value of the relative displacement, epsilon, is set
        epsilon = 1. / 1000

        # The matrix used to change the unitcell by n*epsilon is initialized
        LMM = numpy.array([[1, 0, -10 * epsilon], [0, 1, 0], [0, 0, 1]])

        # The original unit cell is conserved
        OCell = atoms.get_cell()

        # The array for storing the energies is initialized
        E_calc = numpy.zeros(20)

        # The numerical value of C44 is calculated
        for i in range(20):
            # The new system cell based on the pertubation epsilon is set
            atoms.set_cell(numpy.dot(OCell, LMM), scale_atoms=True)
            # The energy of the system is calculated
            E_calc[i] = atoms.get_potential_energy()
            # The value of LMM is updated
            LMM[0, 2] += epsilon

        # A polynomial fit is made for the energy as a function of epsilon

        # The displaced axis is defined
        da = numpy.arange(-10, 10) * epsilon

        # The fit is made
        Poly = numpyfit.polyfit(da, E_calc, 2)

        # Now C44 can be estimated from this fit by the second derivative of Poly = a * x^2 + b * x + c , multiplied
        # with 1 / (2 * Volume) of system
        C44 = 2. / Vol * Poly[0]

        return C44
    # this did not work
    # maybe wrong setting of LAMMPS volume optimization for triclinic cell
    # from ase.lattice.hexagonal import HexagonalClosedPacked
    # atoms = HexagonalClosedPacked(symbol=el1,latticeconstant=(lp,c),size=(5,5,5))
    atoms = HCPO(symbol=el1, latticeconstant=(a, b, c), size=(8, 4, 4))

else:
    raise RuntimeError, 'unknown structure "' + str + '"'

atoms.set_calculator(calc)

print "el:", el1, "str:", str, "lp:", lp
if str == "hcp":
    print "catoi:", catoi

v1 = atoms.get_volume()
print "v1:", v1
n1 = atoms.get_number_of_atoms()
print "n1:", n1
v1pa = v1 / n1
print "v1pa:", v1pa

# initial
ene0 = atoms.get_potential_energy()
print "ene0:", ene0
print "ene0pa:", ene0 / atoms.get_number_of_atoms()
ene0pa = ene0 / atoms.get_number_of_atoms()

# vacancy
atoms.pop(0)
nm1 = n1 - 1
Ejemplo n.º 3
0
from vasp import Vasp
from ase.lattice.cubic import FaceCenteredCubic
import numpy as np
import matplotlib.pyplot as plt

DELTAS = np.linspace(-0.05, 0.05, 5)
calcs = []
volumes = []
for delta in DELTAS:
    atoms = FaceCenteredCubic(symbol='Al')
    cell = atoms.cell
    T = np.array([[1 + delta, 0, 0], [0, 1, 0], [0, 0, 1]])
    newcell = np.dot(cell, T)
    atoms.set_cell(newcell, scale_atoms=True)
    volumes += [atoms.get_volume()]
    calcs += [
        Vasp('bulk/Al-c11-{}'.format(delta),
             xc='pbe',
             kpts=[12, 12, 12],
             encut=350,
             atoms=atoms)
    ]
Vasp.run()
energies = [calc.potential_energy for calc in calcs]
# fit a parabola
eos = np.polyfit(DELTAS, energies, 2)
# first derivative
d_eos = np.polyder(eos)
print(np.roots(d_eos))
xfit = np.linspace(min(DELTAS), max(DELTAS))
yfit = np.polyval(eos, xfit)
Ejemplo n.º 4
0
    # this did not work
    # maybe wrong setting of LAMMPS volume optimization for triclinic cell
    # from ase.lattice.hexagonal import HexagonalClosedPacked
    # atoms = HexagonalClosedPacked(symbol=el1,latticeconstant=(lp,c),size=(5,5,5))
    atoms = HCPO(symbol=el1, latticeconstant=(a, b, c), size=(8, 4, 4))

else:
    raise RuntimeError, "unknown structure \"" + str + "\""

atoms.set_calculator(calc)

print "el:", el1, "str:", str, "lp:", lp
if str == "hcp":
    print "catoi:", catoi

v1 = atoms.get_volume()
print "v1:", v1
n1 = atoms.get_number_of_atoms()
print "n1:", n1
v1pa = v1 / n1
print "v1pa:", v1pa

# initial
ene0 = atoms.get_potential_energy()
print "ene0:", ene0
print "ene0pa:", ene0 / atoms.get_number_of_atoms()
ene0pa = ene0 / atoms.get_number_of_atoms()

# vacancy
atoms.pop(0)
nm1 = n1 - 1
Ejemplo n.º 5
0
    ReportTest("Local and global RDF are identical",
               max(abs(globalrdf - localrdf)), 0.0, 1e-6)
        
    shellpop = [12, 6, 24, 12, 24, -1]
    shell = [sqrt(i+1.0)/sqrt(2.0) for i in range(6)]
    print shell
    print shellpop
    n = 0

    dr = maxrdf/nbins

    for i in range(nbins):
        if (i+1)*dr >= shell[n] * latconst:
            if shellpop[n] == -1:
                print "Reached the end of the test data"
                break
            rho = len(atoms) / atoms.get_volume()
            expected = shellpop[n] / (4 * pi * ((i+0.5) * dr)**2 * dr * rho)
            maxerr = shellpop[n] / (8 * pi * ((i+0.5) * dr)**3 * rho)
            print "Shell", n+1, globalrdf[i]
            ReportTest(("Shell %d (%d)" % (n+1, i)), globalrdf[i],
                       expected, maxerr)
            n += 1
        else:
            ReportTest(("Between shells (%d)" % (i,)), globalrdf[i], 0, 0)


ReportTest.Summary()

Ejemplo n.º 6
0
from vasp import Vasp
from ase.lattice.cubic import FaceCenteredCubic
import numpy as np
import matplotlib.pyplot as plt
DELTAS = np.linspace(-0.05, 0.05, 5)
calcs = []
volumes = []
for delta in DELTAS:
    atoms = FaceCenteredCubic(symbol='Al')
    cell = atoms.cell
    T = np.array([[1 + delta, 0, 0],
                  [0,1, 0],
                  [0, 0, 1]])
    newcell = np.dot(cell, T)
    atoms.set_cell(newcell, scale_atoms=True)
    volumes += [atoms.get_volume()]
    calcs += [Vasp('bulk/Al-c11-{}'.format(delta),
                xc='pbe',
                kpts=[12, 12, 12],
                encut=350,
                atoms=atoms)]
Vasp.run()
energies =  [calc.potential_energy for calc in calcs]
# fit a parabola
eos = np.polyfit(DELTAS, energies, 2)
# first derivative
d_eos = np.polyder(eos)
print(np.roots(d_eos))
xfit = np.linspace(min(DELTAS), max(DELTAS))
yfit = np.polyval(eos, xfit)
plt.plot(DELTAS, energies, 'bo', xfit, yfit, 'b-')