Skip to content

Commit

Permalink
lammps.py errors (#4458)
Browse files Browse the repository at this point in the history
* contributes to #3925
* fix lammps.py doctest errors
  • Loading branch information
nataliyah123 authored Apr 1, 2024
1 parent 6ec838b commit 73acc9b
Showing 1 changed file with 20 additions and 9 deletions.
29 changes: 20 additions & 9 deletions package/MDAnalysis/coordinates/LAMMPS.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,22 +66,33 @@
:class:`~MDAnalysis.topology.LAMMPSParser.DATAParser`) together with a
LAMMPS DCD with "*real*" provide the keyword *format="LAMMPS*"::
>>> u = MDAnalysis.Universe("lammps.data", "lammps_real.dcd", format="LAMMPS")
>>> import MDAnalysis
>>> from MDAnalysis.tests.datafiles import LAMMPSdata2, LAMMPSdcd2
>>> u = MDAnalysis.Universe(LAMMPSdata2, LAMMPSdcd2, format="LAMMPS")
If the trajectory uses *units nano* then use ::
If the trajectory uses *units nano* then use
>>> u = MDAnalysis.Universe("lammps.data", "lammps_nano.dcd", format="LAMMPS",
>>> import MDAnalysis
>>> from MDAnalysis.tests.datafiles import LAMMPSdata2, LAMMPSdcd2
>>> u = MDAnalysis.Universe(LAMMPSdata2, LAMMPSdcd2, format="LAMMPS",
... lengthunit="nm", timeunit="ns")
To scan through a trajectory to find a desirable frame and write to a LAMMPS
data file,
>>> for ts in u.trajectory:
... # analyze frame
... if take_this_frame == True:
... with mda.Writer('frame.data') as W:
... W.write(u.atoms)
... break
>>> import MDAnalysis
>>> from MDAnalysis.tests.datafiles import LAMMPSdata2, LAMMPSdcd2
>>> u = MDAnalysis.Universe(LAMMPSdata2, LAMMPSdcd2, format="LAMMPS",
... lengthunit="nm", timeunit="ns")
>>> take_this_frame = False
>>> for ts in u.trajectory:
... # analyze frame
... if ts.frame == 4:
... take_this_frame = True
... if take_this_frame == True:
... with MDAnalysis.Writer('frame.data') as W:
... W.write(u.atoms)
... break
Note
----
Expand Down

0 comments on commit 73acc9b

Please sign in to comment.