I'm trying to follow simple example of determining the lattice constant (https://wiki.fysik.dtu.dk/ase/tutorials/eos/eos.html), but using QE instead of EMT. Here is ASE code I use:
import numpy as np
from ase.build import bulk
from ase.calculators.espresso import Espresso, EspressoProfile
from ase.io.trajectory import Trajectory
from ase.io.espresso import write_espresso_in
from ase.units import kJ
import os
pseudo_dir = '/mnt/d/PhD/DFT/SSSP_1.3.0_PBE_efficiency'
profile = EspressoProfile(
command='mpirun -n 2 /home/mateja/qe-7.3.1/bin/pw.x',
pseudo_dir=pseudo_dir
)
input_data = {
'prefix': 'Ag_lattice',
'pseudo_dir': pseudo_dir,
'outdir': '/mnt/d/PhD/DFT/LatticeConstant',
'calculation': 'scf',
'restart_mode': 'from_scratch',
'tprnfor': True,
'etot_conv_thr': 1e-5,
'forc_conv_thr': 1e-4,
'ecutwfc': 60,
'ecutrho': 480,
'input_dft': 'rpbe',
'vdw_corr': 'dft-d3',
'occupations': 'smearing',
'degauss': 0.01,
'smearing': 'gaussian',
'conv_thr': 1e-8,
'mixing_mode': 'local-TF',
'mixing_beta': 0.35,
'diagonalization': 'david',
'ion_dynamics': 'bfgs',
'bfgs_ndim': 6,
'startingwfc': 'random',
}
pseudopotentials = {
'Ag': 'Ag_ONCV_PBE-1.0.oncvpsp.upf' # Ensure this file is in the pseudo_dir
}
def run_espresso(atoms, prefix, input_pars):
calc = Espresso(profile=profile, pseudopotentials=pseudopotentials, tstress=True, tprnfor=True,input_data=input_pars, kpts=(1, 1, 1))
atoms.calc = calc
# Write the input file
input_file = f'{prefix}.in'
output_file = f'{prefix}.out'
write_espresso_in(input_file,atoms, input_pars, pseudopotentials=pseudopotentials, format='espresso-in')
return atoms.get_potential_energy()
a = 4.0
ag = bulk('Ag', 'fcc', a=a)
traj = Trajectory('Ag.traj', 'w', atoms=ag)
for x in np.linspace(0.95, 1.05, 5):
run_espresso(ag, 'Ag_lattice', input_data)
traj.write(ag)
from ase.eos import EquationOfState
from ase.io import read
from ase.units import kJ
configs = read('Ag.traj@0:5')
volumes = [ag.get_volume() for ag in configs]
energies = [ag.get_potential_energy() for ag in configs]
eos = EquationOfState(volumes, energies)
v0, e0, B = eos.fit()
print(B / kJ * 1.0e24, 'GPa')
eos.plot('Ag-eos.png',show=False)
Why are my results so off?
'vdw_corr': 'dft-d3'
) for bulk silver? Your single k-pointkpts=(1, 1, 1)
might not be sufficiently converged. $\endgroup$