calc_opt = EMT() calc_sp = calc_opt # # ------------------------ bulk --------------------------- # if alloy: bulk = make_bulk(element1, element2=element2, comp1=comp1, repeat=repeat_bulk) else: bulk = make_bulk(element, repeat=repeat_bulk) ## lattice optimization lattice, a0 = lattice_info_guess(bulk) # optimize_lattice_constant(bulk, lattice=lattice, a0=a0, xc=xc, encut=encut, ediff=ediff, ediffg=ediff*0.1, npar=npar, nsim=nsim) bulk.set_calculator(calc_bulk_sp) e_bulk = bulk.get_potential_energy() e_form = 0.0 if alloy and calc_formation_energy: nat = 0 e_bulk_component = 0.0 for ielem in [element1, element2]: tmpbulk = make_bulk(ielem, repeat=2) optimize_lattice_constant(tmpbulk, lattice=lattice, a0=a0, xc=xc, encut=encut, ediff=ediff, ediffg=ediff, npar=npar, nsim=nsim) # # bulk energy for formation energy --- same with alloy surface calculator # # single point
from ase.build import bulk from gpaw import GPAW, PW, FermiDirac calc = GPAW(mode=PW(600), xc='PBE', occupations=FermiDirac(0.01), kpts=(32, 32, 16), symmetry='off', parallel={ 'band': 1, 'domain': 1 }, txt='gs_Co.txt') bulk = bulk('Co', 'hcp') bulk.set_initial_magnetic_moments([1.0, 1.0]) bulk.set_calculator(calc) bulk.get_potential_energy() calc.write('gs_Co.gpw', mode='all')
def optimize_lattice_constant(bulk, lattice="fcc", a0=4.0, xc="PBEsol", encut=400, ediff=1.0e-5, ediffg=1.0e-6, npar=1, nsim=1): """ function to do bulk optimization """ from ase import Atoms from ase.calculators.vasp import Vasp import os, shutil # # directry things # cudir = os.getcwd() workdir = os.path.join(cudir, "lattice_opt") os.makedirs(workdir) os.chdir(workdir) os.system("mkdir work_bulk") # # compuational condition for Vasp # prec = "normal" potim = 0.1 nelmin = 5 kpts = [3, 3, 3] gamma = True nsw = 200 isif = 6 # or 6---freezing ions xc = xc.lower() if xc == "pbe" or xc == "pbesol" or xc == "rpbe": pp = "pbe" elif xc == "pw91": pp = "pw91" elif xc == "lda": pp = "lda" else: print("xc error") calc = Vasp(prec=prec, xc=xc, pp=pp, ispin=1, ismear=1, sigma=0.2, isif=isif, nelmin=nelmin, encut=encut, ibrion=2, nsw=nsw, potim=potim, ediff=ediff, ediffg=ediffg, kpts=kpts, gamma=gamma, isym=0, npar=npar, nsim=nsim, lreal=False) bulk.set_calculator(calc) bulk.get_potential_energy() cell = bulk.cell # optimized cell size os.chdir(cudir) shutil.rmtree(workdir)