-
Notifications
You must be signed in to change notification settings - Fork 647
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
DL_POLY HISTORY may contain cells even for non-periodic simulations #3312
Changes from 8 commits
dc37815
92f12d8
d1f3d1d
6c21217
82b1ba4
b07d6c1
833e9ab
9889101
f9dccaf
d9bb454
e4b2a45
69c08cf
656848c
abe62d7
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -129,16 +129,14 @@ def parse(self, **kwargs): | |
with openany(self.filename) as inf: | ||
inf.readline() | ||
levcfg, imcon, megatm = np.int64(inf.readline().split()[:3]) | ||
inf.readline() | ||
if not imcon == 0: | ||
inf.readline() | ||
inf.readline() | ||
inf.readline() | ||
|
||
names = [] | ||
ids = [] | ||
|
||
line = inf.readline() | ||
while not len(line.split()) == 5: | ||
line = inf.readline() | ||
Comment on lines
+137
to
+138
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think this has the ability to infinitely loop if a (non HISTORY) file never has 5 tokens on a line. I think once we reach end-of-file There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It now raises EOFError, thanks! |
||
|
||
while line and not line.startswith('timestep'): | ||
name = line[:8].strip() | ||
names.append(name) | ||
|
@@ -169,7 +167,7 @@ def parse(self, **kwargs): | |
|
||
atomtypes = guessers.guess_types(names) | ||
masses = guessers.guess_masses(atomtypes) | ||
|
||
attrs = [ | ||
Atomnames(names), | ||
Atomids(ids), | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The reason for
self._n_frames
was to cache the number of frames so it's only calculated once. This needs to be added back in.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actually, a question about the expected behaviour if a wrong HISTORY file is passed. DL_POLY HISTORY files have the
n_frames
added to the header line on top, so from the test filesDLP_HISTORY_minimal
:it can be parsed as:
trajectory key:
0
- only coordinates savedimcom:
0
- non periodicn_atoms:
3
- three atomsn_frames:
3
- three framesn_records:
2606
- number of records (typically lines, wrong here).The
HistoryReader()
takesn_atoms
from there. I also made it taken_frames
from there, but it might be that someone just truncated the trajectory file and the information might be wrong. Should we instead just go through the file updating the number of frames as it reads? That is:n_frames = len(offsets)
.I think it might be more bullet proof, as I can totally imagine when someone would remove some last/first 50 frames without updating a header, but not touch the number of atoms at all.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Re caching, I don't think the
HistoryReader()
was doing that but it makes sense to add, thanks!