Esempio n. 1
0
 def calculate_c(self, pot, size=(1,1,1)):
   """
   Calculate the elastic constants for the underlying crack unit cell.
   """
   if self.symbol=='Si':
     at_bulk = bulk('Si', a=self.a0, cubic=True)
   elif self.symbol=='Fe':
     at_bulk = BodyCenteredCubic(directions=[self.crack_direction, self.cleavage_plane, self.crack_front],
                              size=size, symbol='Fe', pbc=(1,1,1),
                              latticeconstant=self.a0)
   at_bulk.set_calculator(pot)
   self.cij  = pot.get_elastic_constants(at_bulk)
   print((self.cij / units.GPa).round(2))
   return
Esempio n. 2
0
 def calculate_c(self, pot, size=(1, 1, 1)):
     """
 Calculate the elastic constants for the underlying crack unit cell.
 """
     if self.symbol == 'Si':
         at_bulk = bulk('Si', a=self.a0, cubic=True)
     elif self.symbol == 'Fe':
         at_bulk = BodyCenteredCubic(directions=[
             self.crack_direction, self.cleavage_plane, self.crack_front
         ],
                                     size=size,
                                     symbol='Fe',
                                     pbc=(1, 1, 1),
                                     latticeconstant=self.a0)
     at_bulk.set_calculator(pot)
     self.cij = pot.get_elastic_constants(at_bulk)
     print((self.cij / units.GPa).round(2))
     return
    def EfccEbccCalculator(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 difference in energy between a system 
            of atoms placed in the BCC and FCC structure. """
        # The atoms objects are created using the input size and element and the energy calculator
        # is set to the EMT calculator
        # The Lattice Constant for the BCC lattice is here given so that the volume pr atom of the system is
        # held fixed for the FCC and BCC lattice, that is Vol_pr_atom_BCC = Vol_pr_atom_FCC.
        atoms1 = FaceCenteredCubic(size=(self.Size, self.Size, self.Size),
                                   symbol=self.Element)
        atoms1.set_calculator(EMT)
        # The Lattice constant which produces the same volume pr atom for an BCC crystal is calculated
        LCBcc = 1. / (2.**(1. / 3.)) * beta * PARAMETERS[
            self.Element][1] * Bohr * numpy.sqrt(2)
        atoms2 = BodyCenteredCubic(size=(self.Size, self.Size, self.Size),
                                   symbol=self.Element,
                                   latticeconstant=LCBcc)
        atoms2.set_calculator(EMT)

        # The energy difference pr atom is calculated and returned
        return atoms2.get_potential_energy() / len(
            atoms2) - atoms1.get_potential_energy() / len(atoms1)
Esempio n. 4
0
    #screw_slab_unit.add_atoms(center_cell*0.76, 6)

    screw_slab_unit.set_atoms(screw_slab_unit.Z)
    print len(screw_slab_unit)
    tb.write_control_file('ctrl.fe', screw_slab_unit)
    pot = Potential('IP LMTO_TBE', param_str="""
    <params>
      <LMTO_TBE_params n_types="2" control_file="ctrl.fe">
        <per_type_data type="1" atomic_num="26"/>
        <per_type_data type="2" atomic_num="1"/>
      </LMTO_TBE_params>
    </params>""")
#If there is an initial strain energy increment that here:
  pot.print_()
  screw_slab_unit.write('screw_unitcell.xyz')
  screw_slab_unit.set_calculator(pot)
#Elastic constants are disabled until we have tight binding operational.
  if calc_elastic_constants and dyn_type != 'LOTF':
    cij = pot.get_elastic_constants(screw_slab_unit)
    print 'ELASTIC CONSTANTS'
    print ((cij / units.GPa).round(2))
    E   = youngs_modulus(cij, y)
    nu  = poisson_ratio(cij, y, x)
    print 'Youngs Modulus: ', E/units.GPa,'Poisson Ratio: ', nu
    print 'Effective elastic modulus E: ', E/(1.-nu**2)
  print 'Loading Structure File:', '{0}.xyz'.format(input_file)
  defect = Atoms('{0}.xyz'.format(input_file))

  top    = defect.positions[:,1].max()
  bottom = defect.positions[:,1].min()
  left   = defect.positions[:,0].min()
Esempio n. 5
0
        screw_slab_unit.set_atoms(screw_slab_unit.Z)
        print len(screw_slab_unit)
        tb.write_control_file('ctrl.fe', screw_slab_unit)
        pot = Potential('IP LMTO_TBE',
                        param_str="""
    <params>
      <LMTO_TBE_params n_types="2" control_file="ctrl.fe">
        <per_type_data type="1" atomic_num="26"/>
        <per_type_data type="2" atomic_num="1"/>
      </LMTO_TBE_params>
    </params>""")
#If there is an initial strain energy increment that here:
    pot.print_()
    screw_slab_unit.write('screw_unitcell.xyz')
    screw_slab_unit.set_calculator(pot)
    #Elastic constants are disabled until we have tight binding operational.
    if calc_elastic_constants and dyn_type != 'LOTF':
        cij = pot.get_elastic_constants(screw_slab_unit)
        print 'ELASTIC CONSTANTS'
        print((cij / units.GPa).round(2))
        E = youngs_modulus(cij, y)
        nu = poisson_ratio(cij, y, x)
        print 'Youngs Modulus: ', E / units.GPa, 'Poisson Ratio: ', nu
        print 'Effective elastic modulus E: ', E / (1. - nu**2)
    print 'Loading Structure File:', '{0}.xyz'.format(input_file)
    defect = Atoms('{0}.xyz'.format(input_file))

    top = defect.positions[:, 1].max()
    bottom = defect.positions[:, 1].min()
    left = defect.positions[:, 0].min()
Esempio n. 6
0
def calc_bulk_dissolution(args):
    """Calculate the bulk dissolution energy for hydrogen
    in a tetrahedral position in bcc iron.
    Args:
      args(list): determine applied strain to unit cell.
    """
    POT_DIR = os.path.join(app.root_path, 'potentials')
    eam_pot = os.path.join(POT_DIR, 'PotBH.xml')
    r_scale = 1.00894848312
    pot = Potential(
        'IP EAM_ErcolAd do_rescale_r=T r_scale={0}'.format(r_scale),
        param_filename=eam_pot)
    alat = 2.83

    gb = BodyCenteredCubic(directions=[[1, 0, 0], [0, 1, 0], [0, 0, 1]],
                           size=(6, 6, 6),
                           symbol='Fe',
                           pbc=(1, 1, 1),
                           latticeconstant=alat)
    cell = gb.get_cell()
    print 'Fe Cell', cell

    e1 = np.array([1, 0, 0])
    e2 = np.array([0, 1, 0])
    e3 = np.array([0, 0, 1])

    if args.hydrostatic != 0.0:
        strain_tensor = np.eye(3) + args.hydrostatic * np.eye(3)
        cell = cell * strain_tensor
        gb.set_cell(cell, scale_atoms=True)
        print 'Hydrostatic strain', args.hydrostatic
        print 'strain tensor', strain_tensor
        print gb.get_cell()
    elif args.stretch != 0.0:
        strain_tensor = np.tensordot(e2, e2, axes=0)
        strain_tensor = np.eye(3) + args.stretch * strain_tensor
        cell = strain_tensor * cell
        print 'Stretch strain'
        print 'Cell:', cell
        gb.set_cell(cell, scale_atoms=True)
    elif args.shear != 0.0:
        strain_tensor = np.tensordot(e1, e2, axes=0)
        strain_tensor = np.eye(3) + args.shear * strain_tensor
        cell = strain_tensor.dot(cell)
        print 'Shear Strain', strain_tensor
        print 'Cell:', cell
        gb.set_cell(cell, scale_atoms=True)
        gb.write('sheared.xyz')
    else:
        print 'No strain applied.'

    tetra_pos = alat * np.array([0.25, 0.0, 0.5])
    h2 = aseAtoms('H2', positions=[[0, 0, 0], [0, 0, 0.7]])
    h2 = Atoms(h2)

    gb = Atoms(gb)
    gb_h = gb.copy()
    gb_h.add_atoms(tetra_pos, 1)

    #caclulators
    gb.set_calculator(pot)
    h2.set_calculator(pot)
    gb_h.set_calculator(pot)
    gb_h.write('hydrogen_bcc.xyz')

    #Calc Hydrogen molecule energy
    opt = BFGS(h2)
    opt.run(fmax=0.0001)
    E_h2 = h2.get_potential_energy()
    h2.write('h2mol.xyz')

    #strain_mask  = [1,1,1,0,0,0]
    strain_mask = [0, 0, 0, 0, 0, 0]
    ucf = UnitCellFilter(gb_h, strain_mask)

    #opt = BFGS(gb_h)
    opt = FIRE(ucf)
    opt.run(fmax=0.0001)
    E_gb = gb.get_potential_energy()
    E_gbh = gb_h.get_potential_energy()
    E_dis = E_gbh - E_gb - 0.5 * E_h2

    print 'E_gb', E_gb
    print 'E_gbh', E_gbh
    print 'H2 Formation Energy', E_h2
    print 'Dissolution Energy', E_dis
Esempio n. 7
0
# set of utility routines specific this this model/testing framework
from utilities import relax_atoms, relax_atoms_cell

# the current model
import model

a0 = 3.17 # initial guess at lattice constant, cell will be relaxed below
fmax = 0.01 # maximum force following relaxtion [eV/A]

if not hasattr(model, 'bulk_reference'):
    # set up the a
    bulk = BodyCenteredCubic(symbol='W', latticeconstant=a0)

    # specify that we will use model.calculator to compute forces, energies and stresses
    bulk.set_calculator(model.calculator)

    # use one of the routines from utilities module to relax the initial
    # unit cell and atomic positions
    bulk = relax_atoms_cell(bulk, tol=fmax, traj_file=None)
else:
    bulk = model.bulk_reference.copy()
    bulk.set_calculator(model.calculator)

a0 = bulk.cell[0,0] # get lattice constant from relaxed bulk
bulk = Diamond(symbol="Si", latticeconstant=a0, directions=[[1,-1,0],[0,0,1],[1,1,0]])
bulk.set_calculator(model.calculator)

# set up supercell
bulk *= (1, 1, 10)
# flip coord system for ASE (precon minim?)
Esempio n. 8
0
# NB: order of types must match order in control file
tb_pot = Potential('IP LMTO_TBE',
                   param_str="""
    <params>
      <LMTO_TBE_params n_types="3" control_file="ctrl.fe">
        <per_type_data type="1" atomic_num="26"/>
        <per_type_data type="2" atomic_num="6"/>
        <per_type_data type="3" atomic_num="1"/>
      </LMTO_TBE_params>
    </params>""")

print tb_pot

# compute energies and forces for a range of lattice constants
if True:
    a = np.linspace(2.5, 3.0, 5)
    e = []
    f = []
    configs = []
    for aa in a:
        atoms = BodyCenteredCubic(symbol='Fe', latticeconstant=aa)
        atoms *= [n, n, n]
        atoms.set_calculator(tb_pot)
        e.append(atoms.get_potential_energy())
        f.append(atoms.get_forces()[0, 0])
        configs.append(atoms.copy())
# print lattice constants, energies and forces
    print 'a = ', list(a)
    print 'e = ', list(e)
    print 'f = ', list(f)
Esempio n. 9
0
  gbid = '1109337334'
  or_axis = [1,1,0]
  bp      = [-1,1,12]

##########################################
##First calculate surface energetics:   ##
##########################################
  bulk = BodyCenteredCubic(directions = [[1,0,0],[0,1,0], [0,0,1]],
                           size = (1,1,1), symbol='Fe', pbc=(1,1,1),
                           latticeconstant = 2.85)

  eam_pot = './Fe_Mendelev.xml'
  gb_frac = GBFracture()
  surf_cell = gb_frac.build_surface(bp = sym_tilt_110[0][1])
  pot     = Potential('IP EAM_ErcolAd', param_filename=eam_pot)
  bulk.set_calculator(pot)
  ener_per_atom = bulk.get_potential_energy()/len(bulk)
  surf_cell.set_calculator(pot)
  surf_ener = surf_cell.get_potential_energy()
  cell  = surf_cell.get_cell()
  A     = cell[0][0]*cell[1][1]
  gamma = (surf_ener- len(surf_cell)*ener_per_atom)/A

  print '2*gamma ev/A2', gamma
  print '2*gamma J/m2',  gamma/(units.J/units.m**2)
  j_dict = {'or_axis':or_axis, 'bp':bp, 'gamma':gamma}
  with open('gbfrac.json','w') as f:
    json.dump(j_dict, f)
  out = AtomsWriter('{0}'.format('{0}_surf.xyz'.format(gbid)))
  out.write(Atoms(surf_cell))
  out.close()
Esempio n. 10
0
                       size=(4, 4, 4),
                       symbol='Fe',
                       pbc=(1, 1, 1),
                       latticeconstant=alat)

tetra_pos = alat * np.array([0.25, 0.0, 0.5])

h2 = aseAtoms('H2', positions=[[0, 0, 0], [0, 0, 0.7]])
h2 = Atoms(h2)

gb = Atoms(gb)
gb_h = gb.copy()
gb_h.add_atoms(tetra_pos, 1)

#caclulators
gb.set_calculator(pot)
h2.set_calculator(pot)
gb_h.set_calculator(pot)
gb_h.write('hydrogen_bcc.xyz')

#Calc Hydrogen molecule energy
opt = BFGS(h2)
opt.run(fmax=0.0001)
E_h2 = h2.get_potential_energy()

strain_mask = [1, 1, 1, 0, 0, 0]
ucf = UnitCellFilter(gb_h, strain_mask)

#opt = BFGS(gb_h)
opt = FIRE(ucf)
opt.run(fmax=0.0001)
Esempio n. 11
0
def gamma_surf(h_pos=np.array([1.41, 1.500, 22.48])):
    """
    :method:`gamma_surf` generates a set of directories with the upper
    half unit cell displaced along a certain distance
    along a particular lattice vector. Hydrogens can be added by
    setting vector in h_pos.

    TODO:
      h_pos should be a list of vectors and atom type for this to be more general.
    """

    vasp_exe = '/projects/SiO2_Fracture/iron/vasp.bgq'
    crack_geom = {
        'cleavage_plane': (1, 1, 0),
        'crack_front': (1, -1, 0),
        'crack_direction': (0, 0, 1)
    }

    crack_direction = crack_geom['crack_direction']
    crack_front = crack_geom['crack_front']
    cleavage_plane = crack_geom['cleavage_plane']
    fe_unit = BodyCenteredCubic(
        directions=[crack_direction, crack_front, cleavage_plane],
        size=(1, 1, 1),
        symbol='Fe',
        pbc=(1, 1, 1),
        latticeconstant=2.83)
    nunits = 8
    fe_bulk = BodyCenteredCubic(
        directions=[crack_direction, crack_front, cleavage_plane],
        size=(2, 2, nunits),
        symbol='Fe',
        pbc=(1, 1, 1),
        latticeconstant=2.83)
    fe_unit = Atoms(fe_unit)
    fe_bulk = Atoms(fe_bulk)

    ycut = 5.0 + float(nunits) / 2.0 * fe_unit.lattice[2, 2]
    fe_bulk.center(vacuum=5.0, axis=2)
    print 'lattice', fe_bulk.lattice[1, 1]
    print 'ycut', ycut

    a1 = fe_unit.lattice[0, 0]
    a2 = fe_unit.lattice[1, 1]

    POT_DIR = os.environ['POTDIR']
    eam_pot = os.path.join(POT_DIR, 'PotBH.xml')
    r_scale = 1.00894848312
    #eam_pot = os.path.join(POT_DIR, 'iron_mish.xml')
    #r_scale = 1.0129007626
    pot = Potential(
        'IP EAM_ErcolAd do_rescale_r=T r_scale={0}'.format(r_scale),
        param_filename=eam_pot)
    fe_bulk.set_calculator(pot)
    print 'Bulk Energy', fe_bulk.get_potential_energy()
    refen = fe_bulk.get_potential_energy()
    A = fe_bulk.get_volume() / fe_bulk.lattice[2, 2]

    vasp_args = dict(
        xc='PBE',
        amix=0.01,
        amin=0.001,
        bmix=0.001,
        amix_mag=0.01,
        bmix_mag=0.001,
        kpts=[8, 8, 1],
        kpar=32,
        lreal='auto',
        ibrion=2,
        nsw=40,
        nelmdl=-15,
        ispin=2,
        nelm=100,
        algo='VeryFast',
        npar=8,
        lplane=False,
        lwave=False,
        lcharg=False,
        istart=0,
        voskown=1,
        ismear=1,
        sigma=0.1,
        isym=2)  # possibly try iwavpr=12, should be faster if it works

    dir_name = 'b111shiftsym'
    #dir_name  = 'b001shiftsym'
    f = open('_patdon123{0}H1.dat'.format(dir_name), 'w')
    WRITEVASP = True
    a0 = 2.83
    for inum, ashift in enumerate(np.arange(0, 1.10, 0.10)):
        try:
            os.mkdir('{0}{1}'.format(dir_name, ashift))
        except:
            pass
        print 'Directory already exists'

        os.chdir('{0}{1}'.format(dir_name, ashift))
        fe_shift = fe_bulk.copy()
        fe_shift.set_calculator(pot)
        for at in fe_shift:
            if at.position[2] > ycut:
                #[00-1](110)
                #  at.position += ashift*np.array([-a1,0,0])
                #[1-11](110)
                at.position += 0.5 * ashift * np.array([a1, a2, 0])
    #  print >> fil1, ashift, (units.m**2/units.J)*(fe_shift.get_potential_energy()-refen)/A
        line = []
        for at in fe_shift:
            line.append(FixedLine(at.index, (0, 0, 1)))
    #Now add Hydrogen
    # fe_shift.add_atoms(np.array([0.53*a0, 0.53*a0, 21.0+a0/2]),1)
    # at relaxed position:
        fe_shift.add_atoms(h_pos, 1)
        fix_atoms_mask = [at.number == 1 for at in fe_shift]
        fixedatoms = FixAtoms(mask=fix_atoms_mask)
        fe_shift.set_constraint(line + [fixedatoms])
        opt = LBFGS(fe_shift)
        opt.run(fmax=0.1, steps=1000)
        if inum == 0:
            print 'Setting Reference Energy'
            refen = fe_shift.get_potential_energy()
        print >> f, ashift, (units.m**2 / units.J) * (
            fe_shift.get_potential_energy() - refen) / A
        fe_shift.write('feb{0}.xyz'.format(ashift))
        if WRITEVASP:
            vasp = Vasp(**vasp_args)
            vasp.initialize(fe_shift)
            write_vasp('POSCAR',
                       vasp.atoms_sorted,
                       symbol_count=vasp.symbol_count,
                       vasp5=True)
            vasp.write_incar(fe_shift)
            vasp.write_potcar()
            vasp.write_kpoints()
        os.chdir('../')
    f.close()
Esempio n. 12
0
QNA = {
    'alpha': 2.0,
    'name': 'QNA',
    'orbital_dependent': False,
    'parameters': {
        'Fe': (0.1485, 0.005)
    },
    'setup_name': 'PBE',
    'type': 'qna-gga'
}

atoms = BodyCenteredCubic(symbol='Fe', latticeconstant=2.854, pbc=(1, 1, 1))

atoms.set_initial_magnetic_moments([2, 2])

calc = GPAW(mode=PW(400),
            kpts=(3, 3, 3),
            experimental={'niter_fixdensity': 2},
            xc=QNA,
            parallel={'domain': 1},
            txt='qna_spinpol.txt')

atoms.set_calculator(calc)
atoms.get_potential_energy()
magmoms = atoms.get_magnetic_moments()

tol = 0.003
equal(2.243, magmoms[0], tol)
equal(2.243, magmoms[1], tol)