Exemple #1
0
def relax_structure(system,
                    potential,
                    potential_filename=None,
                    relax_positions=True,
                    relax_cell=True):
    """
    Run a geometry optimisation on the structure to find the energy minimum.

    Parameters
    ----------
    system : ase.Atoms
        A system of atoms to run the minimisation on. The structure is
        altered in-place.
    potential : Potential or str
        A quippy Potential object with the desired potential, or a
        potential_str to initialise a new potential.

    Returns
    -------
    minimised_structure : Atoms
        The geometry optimised structure.
    """
    info("Inside minimiser.")

    qsystem = Atoms(system)

    if not isinstance(potential, Potential):
        if potential_filename:
            potential = Potential(potential, param_filename=potential_filename)
        else:
            potential = Potential(potential)
    qsystem.set_calculator(potential)

    minimiser = Minim(qsystem,
                      relax_positions=relax_positions,
                      relax_cell=relax_cell)

    with Capturing(debug_on_exit=True):
        minimiser.run()

    system.set_cell(qsystem.cell)
    system.set_positions(qsystem.positions)
    system.energy = qsystem.get_potential_energy()

    info("Minimiser done.")

    return system
Exemple #2
0
def h2_formation_energy(pot):
    """
    Given a potential calculate the H2 formation energy and
    equilibrium bond spacing.

    Args:
      pot(:quippy:class:`Potential`) potential object.

    Returns:
      float: Hydrogen molecule formation energy.
    """
    h2 = aseAtoms('H2', positions=[[0, 0, 0], [0, 0, 0.7]])
    h2 = Atoms(h2)
    h2.set_calculator(pot)
    opt = BFGS(h2)
    opt.run(fmax=0.0001)
    E_h2 = h2.get_potential_energy()
    return E_h2
Exemple #3
0
                         block=block,
                         corner=corner,
                         shape=shape,
                         exe    = vasp,
                         ediffg = -0.05,
                         nelmin = 6,
                         nelmdl = -15,
                         kpar   = 32,
                         parmode='cobalt',
                         xc='PBE',
                         lreal=False, ibrion=13, nsw=40,
                         algo='VeryFast', npar=8, 
                         lplane=False, lwave=False, lcharg=False, nsim=1,
                         voskown=1, ismear=1, sigma=0.01, iwavpr=11, isym=2, nelm=100)

sock_calc = SocketCalculator(vasp_client, ip=ip, bgq=True)

bulk.set_calculator(sock_calc)
opt = LBFGS(bulk)
opt.run(fmax=0.05, steps=100)

sock_e = bulk.get_potential_energy()
sock_f = bulk.get_forces()
sock_s = bulk.get_stress()

print 'energy', sock_e
print 'forces', sock_f
print 'stress', sock_s

sock_calc.shutdown()
Exemple #4
0
                         ibrion=13,
                         nsw=40,
                         algo='VeryFast',
                         npar=8,
                         lplane=False,
                         lwave=False,
                         lcharg=False,
                         nsim=1,
                         voskown=1,
                         ismear=1,
                         sigma=0.01,
                         iwavpr=11,
                         isym=2,
                         nelm=100)

sock_calc = SocketCalculator(vasp_client, ip=ip, bgq=True)

bulk.set_calculator(sock_calc)
opt = LBFGS(bulk)
opt.run(fmax=0.05, steps=100)

sock_e = bulk.get_potential_energy()
sock_f = bulk.get_forces()
sock_s = bulk.get_stress()

print 'energy', sock_e
print 'forces', sock_f
print 'stress', sock_s

sock_calc.shutdown()
Exemple #5
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
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)
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