pwtools.parse.LammpsTextMDOutputFile¶
- class pwtools.parse.LammpsTextMDOutputFile(filename='log.lammps', order=None, **kwds)[source]¶
Bases:
TrajectoryFileParser
Parse LAMMPS text output.
We parse the default
log.lammps
file (filename) withthermo
output and, if present, a custom dump filelmp.out.dump
created by something likedump 2 all custom 1 lmp.out.dump ...
Tested with MD and structure optimization (minimize
).- Currently hardcoded file names:
- dumpfilename =
basedir/lmp.out.dump
symbolsfilename =basedir/lmp.struct.symbols
where basedir is the dir where filename (i.e.
log.lammps
) lives.default_units are for lammps metal units.
Examples
Example lammps input:
clear units metal boundary p p p atom_style atomic read_data lmp.struct ### interactions pair_style tersoff pair_coeff * * AlN.tersoff Al N ### IO dump dump_txt all custom 1 lmp.out.dump id type xsu ysu zsu xu yu zu fx fy fz vx vy vz dump dump_dcd all dcd 1 lmp.out.dcd ##dump dump_xyz all xyz 1 lmp.out.xyz ##dump_modify dump_xyz element Al N dump_modify dump_txt sort id dump_modify dump_dcd sort id unwrap yes thermo_style custom step temp vol cella cellb cellc cellalpha cellbeta cellgamma & ke pe etotal & press pxx pyy pzz pxy pxz pyz cpu thermo_modify flush yes thermo 1 ### init velocity all create 300.0 123 rot yes dist gaussian ### run fix fix_npt all npt temp 1000 1000 0.01 tri 0 0 0.3 tchain 4 pchain 4 & mtk yes scaleyz no scalexz no scalexy no flip no timestep 2.5e-3 run 1000
Notes
columns in filename and dumpfilename: We automagically extract the “header” (e.g. “Step Temp Volume Cella …” in filename or “ITEM: ATOMS id type xsu ysu zsu fx fy fz vx vy vz” in dumpfilename) and map data to these symbols. See _thermo_dct and _dump_dct. Currently, “xsu ysu zsu” is parsed to get coords_frac. “xu yu zu” is parsed to get coords. Wrapped coordinates (e.g. “xs ys zs” and “x y z”) are ignored.
multiple runs from one input script (i.e. 2 or more
run
commands): it seems that the last step of the preceeding run is printed again by the new run bythermo_style
, which results in more nstep in filename as there really are in dumpfilename. We parse all important stuff (coords, cell, velocity) from dumpfilename, but temperature and stress etc. is from filename. Watch out when plotting.cell: We parse cell from “ITEM: BOX BOUNDS” in dumpfilename and the cell is always [[x,0,0],[xy,y,0],[xz,yz,z]], i.e. it is aligned in the same way in each timestep.
atom symbols: First we try to read symbolsfilename, which may have been written by
pwtools.io.write_lammps()
. If that is not found, we try to use thetype
column in dumpfilename together with a type number -> atom symbol mapping either from the order input keyword or adump_modify ... element
line in filename if found.
- __init__(filename='log.lammps', order=None, **kwds)[source]¶
- Parameters:
filename (str) – Text output file, where
thermo_style [custom]
output is written to. The lammps default islog.lammps
.order (dict, optional) – See
pwtools.crys.Structure.get_order()
. Mapping of atom symbols totype
in lammps, i.e. {‘Al’: 1, ‘N’: 2}. If None then we try to usedump_modify ... element
if present in filename, where lammps echos the input script. symbols is build from thetype
column in dumpfilename.
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_cell
()get_cont
([auto_calc])Populate and return a Container object.
get_ekin
()get_etot
()Potetntial energy PotEng [eV].
get_return_attr
(attr_name)Call try_set_attr() are return self.<attr_name> if set.
get_struct
(**kwds)get_traj
(**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