# What is the best way to compute the DFT total energy and atomic forces for given atomic positions?

I am new to DFT calculation and I want to compute DFT total energy and atomic forces of an atomic configuration, given the atomic positions and lattice vectors.

I have an extended xyz with DFT energy and forces from a paper. XYZ file is pasted at the end of the question.

My goal is to do my own DFT calculation using the atomic position information and reproduce the energy and forces data. However, I haven't been able to do so.

In the paper, the authors used VASP with PBE exchange-correlation function, 500 eV energy cutoff, and 4x4x4 grid points. I don't have access to VASP, and I was trying to do the calculation using quantum espresso. With my initial attempt, the atomic forces that I got differed by about 1e-2 eV/angstrom, but the energy that I got was about -16,000 eV vs -500 in the paper/xyz file.

I don't know why my energy is off by a lot, while the forces are pretty close. Is this an expected behavior from comparing calculations using 2 different DFT software? Is there another way to compute DFT total energy and forces given xyz file?

Note: I used quantum espresso calculator in ASE to do the calculation.

### Code

from ase.io import read
from ase.calculators.espresso import Espresso

# Calcualtor
calc = Espresso(
pseudopotentials={"C": "C.pbe-n-kjpaw_psl.1.0.0.UPF"},
tstress=True,
tprnfor=True,
outdir=<outdir>,
pseudo_dir=<pseudo_dir>,
kpts=(4, 4, 4),
koffset=True,
)
atoms.calc = calc

# Compute energy and forces
energy = atoms.get_potential_energy()
print("Energy:", energy)
forces = atoms.get_forces()


### XYZ file

64
Lattice="7.10842262195238 0 0 0 7.10842262195238 0 0 0 7.10842262195238 " PBC="1 1 1" Properties=species:S:1:pos:R:3:force:R:3 Energy="-512.86187833"
C     2.515720524176340e-02   3.867550579089600e-03   7.089434672581682e+00 -5.37951000e-01  -9.43653100e-01   8.96908860e-01
C     1.776933986593727e+00   1.732049273644261e+00   2.572083207130320e-02  4.26181090e-01   1.51736004e+00   3.81343080e-01
C     7.082577532701300e+00   1.802144789342045e+00   1.769809143517475e+00  1.13683654e+00  -6.10598840e-01   7.06415680e-01
C     1.730755114222064e+00   7.103866760858615e+00   1.834766904598202e+00  5.28662040e-01   3.17688010e-01  -1.12025143e+00
C     8.721281061942280e-01   8.735364979679285e-01   8.966439895472150e-01  1.05603720e-01   2.62228850e-01   5.75211080e-01
C     2.696528798085684e+00   2.679314544279508e+00   9.295221501861438e-01 -7.81283670e-01  -5.78397410e-01  -1.85532276e+00
C     9.346490289165925e-01   2.672186644581529e+00   2.654060735574339e+00 -2.03034942e+00   1.70433750e-01  -3.59527500e-02
C     2.678101420875179e+00   9.199713446381380e-01   2.689016972481999e+00 -6.26726520e-01  -1.33007226e+00   1.56036970e-01
C     3.511187368839771e+00   7.101188022878494e+00   7.107915220793385e+00  9.31579400e-02  -4.02755650e-01   8.05187710e-01
C     5.312681026669824e+00   1.769173081861437e+00   7.067010726921535e+00  6.70675890e-01  -1.36012410e-01   1.35187542e+00
C     3.546168769563506e+00   1.802083870160192e+00   1.830411431890475e+00  8.04017590e-01  -7.92153530e-01  -1.76726650e+00
C     5.379223112984097e+00   3.912248340524160e-02   1.782229477108722e+00 -2.47505791e+00  -2.16700570e-01  -5.76459000e-03
C     4.425585354722698e+00   8.827204378245163e-01   8.970133431865501e-01  2.16665110e-01   8.11297010e-01  -2.73793900e-01
C     6.213865521165564e+00   2.672265050483028e+00   8.666035823024164e-01  2.11940450e-01  -9.71874700e-02  -3.56909090e-01
C     4.454692212824812e+00   2.667208331883838e+00   2.664322099047440e+00  1.78292390e-01   3.44728770e-01   2.32568650e-01
C     6.202805881832237e+00   9.258737522764287e-01   2.730940032231068e+00  4.33003680e-01   5.79964000e-02  -1.57874570e+00
C     3.423771754923000e-03   3.576000047014824e+00   7.096407537582318e+00  7.40474130e-01  -4.69554600e-01   5.82278100e-02
C     1.773121668458395e+00   5.291121536284495e+00   7.096664293807353e+00  5.47373550e-01   2.29641219e+00  -6.93962180e-01
C     7.061366710445481e+00   5.370766791266893e+00   1.766795669916178e+00  1.08575565e+00  -1.16270741e+00  -3.20823180e-01
C     1.783560955749675e+00   3.595632230775192e+00   1.744914310154615e+00 -1.61832200e-02  -1.34411611e+00   6.86037350e-01
C     9.147487865392240e-01   4.470236769241776e+00   8.314481673929444e-01 -1.97196630e+00  -7.49626810e-01   2.35244402e+00
C     2.602983378091007e+00   6.204381819127091e+00   9.149161188076987e-01  1.82101717e+00  -1.18240660e-01  -3.90261780e-01
C     7.917225343283958e-01   6.245417605564732e+00   2.701292578588703e+00  2.03609908e+00  -3.15842450e-01  -7.80305460e-01
C     2.658791177575270e+00   4.409512997926200e+00   2.662736565382049e+00  6.59346630e-01   2.03379123e+00  -1.16759940e+00
C     3.571911211239574e+00   3.541409467366737e+00   7.066099498225877e+00  1.32691510e-01   8.00661400e-02   1.22032686e+00
C     5.332296008047452e+00   5.301607810249293e+00   7.096567761428173e+00 -7.19261300e-01   1.61148671e+00   5.60174190e-01
C     3.599161989111380e+00   5.298915424097742e+00   1.755959945895381e+00 -1.45534256e+00   1.23807627e+00   5.26815840e-01
C     5.343400430443285e+00   3.555400122598969e+00   1.724019670536935e+00 -7.94688100e-02  -1.22034087e+00   1.68260656e+00
C     4.495938763993136e+00   4.410190288433433e+00   8.644839217613586e-01 -1.90959096e+00   6.98633670e-01  -3.14938090e-01
C     6.177803853456268e+00   6.250621184175251e+00   8.693900128852301e-01  1.68162569e+00  -6.84345710e-01   1.99048910e-01
C     4.467966552309626e+00   6.254770441542771e+00   2.656286880286244e+00 -7.57695100e-02  -1.03345062e+00  -3.54654490e-01
C     6.207880087151072e+00   4.401281444532239e+00   2.639561757040551e+00  7.66324170e-01   1.46387162e+00  -1.26064490e-01
C     7.092034222733816e+00   6.469645546521559e-02   3.611905542679158e+00 -3.69020620e-01  -1.32917779e+00  -7.38472440e-01
C     1.813401260897720e+00   1.798810015038325e+00   3.567437312210998e+00 -6.60443250e-01   1.25397500e-01  -5.29906640e-01
C     9.131195360747199e-03   1.777007203346713e+00   5.386779579481836e+00  1.49964985e+00   4.50847890e-01  -1.38667509e+00
C     1.762572342784958e+00   7.084367575685467e+00   5.258194825119071e+00 -1.44468190e-01   4.70378990e-01   2.27251762e+00
C     8.933156128238523e-01   9.138509927623180e-01   4.435922067475571e+00  2.19887730e-01   2.63211500e-01   6.47886620e-01
C     2.734726120286932e+00   2.672868982068823e+00   4.419541631642722e+00 -1.61252743e+00  -8.08281400e-02   1.02152425e+00
C     9.668444966470966e-01   2.659522421010190e+00   6.248003507545436e+00 -2.34920086e+00  -7.79319900e-02  -1.55410930e-01
C     2.621514609355990e+00   8.887661512628261e-01   6.206886542921475e+00  1.00247324e+00  -9.82742760e-01   2.23900990e-01
C     3.560229798179676e+00   1.192011389147800e-02   3.571414759003793e+00 -1.08340810e-01  -6.94958780e-01  -6.32829660e-01
C     5.303243173957251e+00   1.783785084314883e+00   3.608673698334975e+00  6.65906520e-01   1.93424360e-01  -2.00882610e-01
C     3.528356910667667e+00   1.767911834435971e+00   5.347927358304606e+00  7.39111180e-01  -2.47114860e-01  -1.04495492e+00
C     5.329030825201182e+00   7.096177437942109e+00   5.369101643268158e+00 -3.08175260e-01  -1.14381900e-02   1.84117730e-01
C     4.422761249499998e+00   8.668823746375728e-01   4.494489925294728e+00  3.83796370e-01   4.22127430e-01  -5.75045160e-01
C     6.241506267102304e+00   2.679197823980088e+00   4.509426711577681e+00 -9.90742090e-01  -1.47647882e+00  -1.25004513e+00
C     4.432864237317125e+00   2.645875244758956e+00   6.162178971863699e+00  2.14951310e-01   1.37021740e-01   2.03719183e+00
C     6.276550008692416e+00   8.743755050897671e-01   6.235059780796678e+00 -2.36728919e+00   4.92518030e-01  -1.75193300e-01
C     7.065680456712427e+00   3.515117189201012e+00   3.569630900347304e+00  2.01679955e+00   6.47574810e-01  -7.38426790e-01
C     1.744524484258135e+00   5.323755096101070e+00   3.489180474334740e+00 -2.31814270e-01  -5.78952010e-01   2.30748316e+00
C     7.087238738665912e+00   5.312598853304337e+00   5.367801939276317e+00  8.84590350e-01   6.63457880e-01  -2.04867967e+00
C     1.836661512479110e+00   3.526170004448624e+00   5.351513557516396e+00 -1.23618594e+00   5.61918680e-01  -1.49124744e+00
C     8.644019616485500e-01   4.381350493769153e+00   4.431205771235654e+00  6.54489790e-01   1.65426557e+00   5.88371370e-01
C     2.638706329462460e+00   6.199561100158887e+00   4.412298788750978e+00  5.65976410e-01   3.85331420e-01  -6.55854390e-01
C     8.855542105019791e-01   6.193752239362274e+00   6.199043180486793e+00  4.21980700e-01   3.69641240e-01   2.30177540e-01
C     2.676275196019875e+00   4.452567718556373e+00   6.202611111052449e+00  5.14470800e-01  -6.82406950e-01  -3.64222200e-02
C     3.579314420145626e+00   3.572309993748555e+00   3.522390171804665e+00  1.20915900e-02  -5.19302820e-01   8.08118950e-01
C     5.377902368061301e+00   5.343446208684958e+00   3.488438141760533e+00 -1.17684527e+00   1.56643050e-01   2.46875405e+00
C     3.545122765174973e+00   5.343271341488506e+00   5.291750347349461e+00  3.51595720e-01  -8.43737200e-01   5.14030800e-01
C     5.342069378307690e+00   3.526753748114178e+00   5.351913690625676e+00 -3.28223650e-01   2.01570343e+00  -1.31587457e+00
C     4.480059756291901e+00   4.450995690893960e+00   4.393124174154658e+00 -6.06505570e-01   2.54363480e-01   8.42964100e-01
C     6.221970331384210e+00   6.256644790419212e+00   4.501010623532506e+00  3.77290300e-02  -1.34160519e+00  -1.84268948e+00
C     4.403452996558423e+00   6.178451075335819e+00   6.250501549422556e+00  6.40125260e-01   1.35140560e+00  -1.06078985e+00
C     6.211810831607253e+00   4.482924592776214e+00   6.216467417097163e+00  8.36191500e-02  -2.43405957e+00   4.62511060e-01

• +1 but please put your script in a code block. Most people will not click on your link, since we don't know whether or not it leads to a dangerous website. Apr 28 at 1:16
• It is possible that you can get different values for absolute energies depending on the software that you use. That's why relative energies are important. Apr 28 at 2:33
• @HemanthHaridas Thanks. How is relative energy different conceptually? Sorry, I'm new to this. And can we extract that value from QE output file? Apr 28 at 4:14
• Lets say that you are comparing two structures: say graphene and hexagonal boron nitride. What you can do is optimize the geometries for both these at same level of theory, and then extract the energies. Now you can find the energy of one material relative to the other by taking the difference in their energies. Apr 28 at 4:45
• @YonatanKurniawan Please do not add google drive links. Reasons for this are listed here: mattermodeling.meta.stackexchange.com/questions/393/…. Instead paste the content of your file inline, inside a code block using a ''' ''' .You can also find instructions on how to handle files with more than 30000 characters in the link. Apr 28 at 7:29