pwtools.parse.PwSCFOutputFile¶
- class pwtools.parse.PwSCFOutputFile(filename=None, use_alat=True, **kwds)[source]¶
Bases:
StructureFileParser
Parse a pw.x SCF output file (calculation=’scf’).
Some getters (_get_<attr>_raw) work for MD-like output, too. Here in the SCF case, only the first item along the time axis is returned and should only be used on calculation=’scf’ output.
SCF output files don’t have an ATOMIC_POSITIONS block. We need to parse the block below, which can be found at the top the file (cartesian, divided by alat). From that, we also get symbols:
Cartesian axes site n. atom positions (a_0 units) 1 Al tau( 1) = ( -0.0000050 0.5773532 0.0000000 ) 2 Al tau( 2) = ( 0.5000050 0.2886722 0.8000643 ) 3 N tau( 3) = ( -0.0000050 0.5773532 0.6208499 ) 4 N tau( 4) = ( 0.5000050 0.2886722 1.4209142 )
Many quantities in PWscf’s output files are always in units of the lattice vector “a” (= a_0 = celldm1 = “alat” [Bohr]), i.e. divided by that value, which is usually printed in the output in low precision:
lattice parameter (a_0) = 5.8789 a.u.
You can parse that value with
get_alat(use_alat=True)
. We do that by default:PwSCFOutputFile(filename, use_alat=True)
b/c this is what most people will expect if they just call the parser on some file. Then, we multiply all relevent quantities with dimension length with the alat value from pw.out automatically.If
use_alat=False
, we usealat=1.0
, i.e. all length quantities which are “in alat units” are returned exactly as found in the file, which is the same behavior as in all other parsers. Unit conversion happens only when we pass things to Structure / Trajectory using self.units.If you need/want to use another alat (i.e. a value with more precision), then you need to explicitly provide that value and use
use_alat=False
:>>> alat = 1.23456789 # high precision value in Bohr >>> pp = PwSCFOutputFile('pw.out', use_alat=False, units={'length': alat*Bohr/Ang}) >>> st = pp.get_struct()
use_alat=False
will prevent parsing the low precision value from ‘pw.out’. The optionunits=...
will overwritedefault_units['length'] = Bohr/Ang
, which is used to convert all PWscf length [Bohr] to [Ang] when passing things to Trajectory.In either case, all quantities with a length unit or derived from such a quantitiy, e.g.
cellcryst_constcoordscoords_fracvolume…will be correct (up to alat’s precision).
All getters return PWscf standard units (Ry, Bohr, …).
It is a special case for PWscf that a parser class may modify values parsed from a file (multiply by alat if use_alat=True, etc) before they are passed over to Structure / Trajectory b/c otherwise the numbers would be pretty useless, unless you use units explicitely. To get an object with pwtools standard units (eV, Angstrom, …), use
get_struct()
.Notes
Total force: Pwscf writes a “Total Force” after the “Forces acting on atoms” section . This value a UNnormalized RMS of the force matrix (f_ij, i=1,natoms j=1,2,3) printed. According to …/PW/forces.f90, variable “sumfor”, the “Total Force” is
sqrt(sum_ij f_ij^2)
. Usecrys.rms(self.forces)
(for PwSCFOutputFile) orcrys.rms3d(self.forces, axis=self.timeaxis)
(for PwMDOutputFile) instead.Verbose force printing: When using van der Waals (
london=.true.
) orverbosity='high'
, then more than one force block (natoms,3) is printed. In that case, we assume the first block to be the sum of all force contributions and that will end up inself.forces
. Each subsequent block is discarded fromself.forces
. However, you may useself._forces_raw
(seeself._get_forces_raw()
) to obtain all forces, which will have the shape (N*natoms). The forces blocks will be in the following order:london=.true.
verbosity='high'
verbosity='high'
+london=.true.
sum
sum
sum
vdw
non-local
non-local
ionic
ionic
local
local
core
core
Hubbard
Hubbard
SCF correction
SCF correction
vdw
Note that this order may change with QE versions, check your output file! Tested w/ QE 4.3.2 .
Methods
Like _apply_units_raw(), make sure that units are only applied once.
assert_attr
(attr)Raise AssertionError if self.<attr> is not set (is_set_attr() returns False.
assert_attr_lst
(attr_lst)assert_set_attr
(attr)Same as assert_attr(), but run try_set_attr() first.
assert_set_attr_lst
(attr_lst)check_set_attr
(attr)Run try_set_attr() and return the result of is_set_attr(), i.e. True or False.
check_set_attr_lst
(attr_lst)dump
(dump_filename[, mkdir])Write object to binary file using pickle.
get_alat
([use_alat])Lattice parameter "alat" [Bohr].
get_cell
()Start cell [Bohr].
get_cont
([auto_calc])Populate and return a Container object.
Cartesian start coords [Bohr] if self.alat in [Bohr].
get_etot
()Total enery [Ry].
Forces [Ry / Bohr].
get_return_attr
(attr_name)Call try_set_attr() are return self.<attr_name> if set.
Stress tensor [kbar].
get_struct
(**kwds)init_attr_lst
([attr_lst])Set each self.<attr> in attr_lst to None.
is_set_attr
(attr)Check if self has the attribute self.<attr> and if it is _not_ None.
is_set_attr_lst
(attr_lst)load
(dump_filename)Load pickled object.
parse
()raw_return
(attr_name)Call
try_set_attr(_<attr_name>_raw)
and return it if set, else None.raw_slice_get
(attr_name, sl, axis)Shortcut method:
set_all
([attr_lst])Call getter for each attr name in attr_lst.
set_attr_lst
(attr_lst)Set self.attr_lst and init each attr to None.
try_set_attr
(attr)If self.<attr> does not exist or is None, then invoke an appropirately named getter as if this command would be executed.
try_set_attr_lst
(attr_lst)update_units
(units)Update self.units dict from units.
Attributes