Skip to content

Commit

Permalink
the parser works when using many thermo_style (#166)
Browse files Browse the repository at this point in the history
* the parser works when using many thermo_style

before the parser was adding all the data in the same array, and parsing
the numbers with the last headers found messing up if many headers and
data columns were present in the output file.
Now, if many header are present, the old data is forgotten as soon as a
new Step ... header is found, and only the last one will be parsed in
the output. This allows to parse output from LammpsRawCalculation
with different thermo_style without errors, as the one found in
https://docs.lammps.org/compute_heat_flux.html#example-input-file

added test

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

---------

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Co-authored-by: Jonathan Chico <37243453+JPchico@users.noreply.github.com>
  • Loading branch information
3 people authored Nov 18, 2024
1 parent 499a6c5 commit 0bce91d
Show file tree
Hide file tree
Showing 4 changed files with 183 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/aiida_lammps/parsers/parse_raw/lammps_output.py
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,8 @@ def parse_outputfile(
)

if line.startswith("Step"):
_data = []
end_found = False
header_line_position = index
header_line = [
re.sub("[^a-zA-Z0-9_]", "__", entry) for entry in line.split()
Expand Down
147 changes: 147 additions & 0 deletions tests/parsers/fixtures/raw/thermo_style/lammps.out
Original file line number Diff line number Diff line change
@@ -0,0 +1,147 @@
LAMMPS (29 Aug 2024 - Update 1)
OMP_NUM_THREADS environment is not set. Defaulting to 1 thread. (src/comm.cpp:98)
using 1 OpenMP thread(s) per MPI task
Lattice spacing in x,y,z = 5.376 5.376 5.376
Created orthogonal box = (0 0 0) to (21.504 21.504 21.504)
1 by 1 by 1 MPI processor grid
Created 256 atoms
using lattice units in orthogonal box = (0 0 0) to (21.504 21.504 21.504)
create_atoms CPU = 0.000 seconds
Generated 0 of 0 mixed pair_coeff terms from geometric mixing rule
Neighbor list info ...
update: every = 1 steps, delay = 0 steps, check = yes
max neighbors/atom: 2000, page size: 100000
master list distance cutoff = 15
ghost atom cutoff = 15
binsize = 7.5, bins = 3 3 3
1 neighbor lists, perpetual/occasional/extra = 1 0 0
(1) pair lj/cut, perpetual
attributes: half, newton on
pair build: half/bin/atomonly/newton
stencil: half/bin/3d
bin: standard
Setting up Verlet run ...
Unit style : real
Current step : 0
Time step : 4
Per MPI rank memory allocation (min/avg/max) = 3.219 | 3.219 | 3.219 Mbytes
Step Temp E_pair E_mol TotEng Press
0 70 -505.75228 0 -452.54482 -1289.8945
2000 74.682256 -457.63699 0 -400.87052 547.1463
4000 73.36116 -460.69876 0 -404.93646 431.33436
6000 67.978895 -453.88308 0 -402.21187 653.83993
8000 64.247137 -462.836 0 -414.00133 329.70822
Loop time of 3.65187 on 1 procs for 8000 steps with 256 atoms

Performance: 757.092 ns/day, 0.032 hours/ns, 2190.659 timesteps/s, 560.809 katom-step/s
98.0% CPU use with 1 MPI tasks x 1 OpenMP threads

MPI task timing breakdown:
Section | min time | avg time | max time |%varavg| %total
---------------------------------------------------------------
Pair | 3.36 | 3.36 | 3.36 | 0.0 | 92.01
Neigh | 0.1196 | 0.1196 | 0.1196 | 0.0 | 3.27
Comm | 0.091569 | 0.091569 | 0.091569 | 0.0 | 2.51
Output | 0.00010239 | 0.00010239 | 0.00010239 | 0.0 | 0.00
Modify | 0.043827 | 0.043827 | 0.043827 | 0.0 | 1.20
Other | | 0.03682 | | | 1.01

Nlocal: 256 ave 256 max 256 min
Histogram: 1 0 0 0 0 0 0 0 0 0
Nghost: 3173 ave 3173 max 3173 min
Histogram: 1 0 0 0 0 0 0 0 0 0
Neighs: 46468 ave 46468 max 46468 min
Histogram: 1 0 0 0 0 0 0 0 0 0

Total # of neighbors = 46468
Ave neighs/atom = 181.51562
Neighbor list builds = 116
Dangerous builds = 0
Generated 0 of 0 mixed pair_coeff terms from geometric mixing rule
Setting up Verlet run ...
Unit style : real
Current step : 0
Time step : 4
Per MPI rank memory allocation (min/avg/max) = 5.096 | 5.096 | 5.096 Mbytes
Step Temp v_Jx v_Jy v_Jz v_k11 v_k22 v_k33
0 64.247137 -1.8079942e-06 -8.7890766e-07 -8.457266e-07 0.0046430011 0.0010972136 0.0010159321
2000 61.525894 -2.1598221e-06 1.0240044e-06 1.9775571e-06 0.085351069 0.57508192 0.17631439
4000 63.72472 2.2409554e-06 -1.6104003e-06 6.5006041e-08 0.058053309 0.17470542 0.2134226
6000 64.544354 3.9665371e-06 2.7743094e-07 -1.3962294e-06 0.48489461 0.12364319 0.10073154
8000 65.8238 1.3884442e-07 -2.2290428e-06 6.1578573e-06 0.57368765 0.30293599 0.094771849
10000 61.90025 2.0628691e-08 -3.8429267e-06 -1.3669631e-07 0.44428628 0.28608541 0.065179307
12000 64.617723 1.7775555e-06 -7.5167728e-06 1.5244731e-06 0.40535052 0.42200227 0.094071588
14000 62.062981 5.8507965e-06 -8.2314658e-07 1.9386634e-07 0.40465712 0.60088211 0.16315905
16000 63.974837 -1.0745593e-06 -2.848019e-06 -7.2257276e-07 0.38002527 0.50959436 0.14997039
18000 62.366711 1.6218743e-06 -1.7189792e-06 2.6231651e-06 0.37335212 0.44943645 0.1818345
20000 63.35814 -1.8347676e-07 6.2252326e-07 1.1084105e-06 0.34894157 0.40034091 0.15528223
22000 69.342878 1.423516e-06 -2.2446676e-06 3.6250541e-06 0.34858894 0.3773924 0.17947248
24000 58.501486 -2.5080979e-06 -8.3621623e-07 -1.4212996e-06 0.31032444 0.37896275 0.17537428
26000 62.763231 1.9173142e-07 1.7557205e-06 -3.3271006e-07 0.31493569 0.35130261 0.12796826
28000 63.43571 -2.306012e-06 -9.1269595e-07 4.041346e-07 0.29342946 0.32234586 0.14031226
30000 64.672878 3.9564769e-06 3.1243623e-06 -8.7420521e-07 0.2723538 0.33779975 0.19755617
32000 66.158501 1.880267e-06 -2.0937431e-06 -6.1682203e-07 0.25070333 0.32797017 0.19945131
34000 67.46263 -1.0614188e-06 8.222906e-08 2.9876766e-06 0.27905678 0.31010677 0.17831269
36000 62.10909 -2.8469855e-06 -4.6502305e-06 1.1223538e-06 0.27268614 0.30170783 0.16163906
38000 68.223927 -4.5540226e-06 1.548782e-07 1.4079104e-06 0.25342992 0.28814925 0.1572844
40000 60.71867 -1.8838187e-06 -9.5928082e-07 3.2171931e-06 0.23445129 0.2797954 0.18269736
42000 63.322401 -3.7530825e-07 2.4923075e-06 -2.938255e-06 0.2223093 0.26328744 0.21723599
44000 61.983322 1.3970281e-06 -4.5642174e-08 2.3503367e-07 0.21461737 0.25278444 0.23425212
46000 62.867579 -4.5015621e-06 -2.7157351e-06 2.2098371e-06 0.20562955 0.24675866 0.30204928
48000 67.355454 -2.4491652e-06 1.2453223e-06 -2.1320399e-07 0.22129212 0.23828696 0.30327962
50000 60.895587 2.1804066e-06 3.2693656e-07 1.23064e-06 0.21765599 0.23327483 0.27418783
52000 63.87045 1.3170449e-06 2.3010037e-06 1.5758504e-06 0.26890127 0.25011837 0.26157802
54000 63.642782 1.3862033e-07 1.8111635e-06 6.4693025e-07 0.26838091 0.29179343 0.25716217
56000 62.000213 5.6818896e-07 -5.4689229e-07 1.3046324e-06 0.27030927 0.29637661 0.25795301
58000 66.633073 3.0132965e-06 7.1862822e-07 -7.9702673e-08 0.2619932 0.28474913 0.24514888
60000 61.932864 6.7789186e-06 -1.7228147e-06 2.9651378e-06 0.25476542 0.27105789 0.24344415
62000 67.730639 -4.8479584e-07 -2.6325008e-06 -2.0428717e-06 0.24458967 0.26203962 0.23648301
64000 61.144379 -1.1273114e-06 -9.9286044e-07 1.8248023e-06 0.23367492 0.29444383 0.24852866
66000 62.210646 -2.1319529e-06 -2.2198766e-06 -1.5480782e-06 0.22485215 0.29804936 0.24678006
68000 62.381233 -2.8568977e-06 -1.7579616e-06 2.8269342e-06 0.2163173 0.29064131 0.23681681
70000 63.061911 -5.9148019e-07 5.6632907e-07 2.5460687e-06 0.21130195 0.2872965 0.24396951
72000 65.799805 -2.5912563e-07 3.2049528e-06 -6.0646022e-07 0.21059792 0.27197304 0.23379899
74000 66.314917 3.0989796e-06 2.5407123e-06 9.1727192e-07 0.22099481 0.26486809 0.25857014
76000 59.378433 -3.5453259e-06 -3.0209319e-06 3.1232621e-06 0.21583578 0.26188808 0.26488965
78000 61.604179 6.2627304e-08 2.9554163e-06 5.5230142e-06 0.22471699 0.2488775 0.25364298
80000 58.837728 -4.1814589e-06 -2.0533193e-06 1.8953793e-06 0.24829924 0.24093423 0.24998458
82000 62.15903 -1.9418324e-06 2.4310144e-06 2.6541324e-06 0.26576646 0.23570854 0.24046833
84000 64.714896 -6.2887387e-06 -5.8555453e-07 3.6509298e-06 0.26615445 0.23668873 0.23401392
86000 61.031618 -2.0497528e-07 3.0562669e-06 2.7240488e-06 0.27110318 0.23271246 0.2290402
88000 63.341113 1.9386269e-06 -5.0463508e-07 7.0518402e-07 0.27944331 0.23766011 0.27765394
90000 62.853688 2.8472732e-06 2.1997331e-06 -1.2000712e-06 0.27096182 0.25218938 0.27813078
92000 62.883809 3.5212323e-07 -3.0337211e-06 -1.3839795e-06 0.26153682 0.25692921 0.30104626
94000 61.765562 -2.7175472e-06 1.5353385e-06 1.4675356e-06 0.26512315 0.25522882 0.28668193
96000 61.747073 9.6732172e-07 1.5750852e-07 -8.672387e-07 0.26879919 0.25234201 0.28455876
98000 61.103977 -1.6708854e-06 5.1839447e-06 1.5492511e-09 0.27614829 0.25507382 0.2838748
100000 65.563661 3.4048861e-06 -4.7928087e-08 -1.4188391e-06 0.26142703 0.24653363 0.28040529
Loop time of 50.5402 on 1 procs for 100000 steps with 256 atoms

Performance: 683.813 ns/day, 0.035 hours/ns, 1978.624 timesteps/s, 506.528 katom-step/s
97.8% CPU use with 1 MPI tasks x 1 OpenMP threads

MPI task timing breakdown:
Section | min time | avg time | max time |%varavg| %total
---------------------------------------------------------------
Pair | 46.569 | 46.569 | 46.569 | 0.0 | 92.14
Neigh | 1.3368 | 1.3368 | 1.3368 | 0.0 | 2.65
Comm | 1.1412 | 1.1412 | 1.1412 | 0.0 | 2.26
Output | 0.1926 | 0.1926 | 0.1926 | 0.0 | 0.38
Modify | 0.82607 | 0.82607 | 0.82607 | 0.0 | 1.63
Other | | 0.4748 | | | 0.94

Nlocal: 256 ave 256 max 256 min
Histogram: 1 0 0 0 0 0 0 0 0 0
Nghost: 3173 ave 3173 max 3173 min
Histogram: 1 0 0 0 0 0 0 0 0 0
Neighs: 46456 ave 46456 max 46456 min
Histogram: 1 0 0 0 0 0 0 0 0 0

Total # of neighbors = 46456
Ave neighs/atom = 181.46875
Neighbor list builds = 1302
Dangerous builds = 0
average conductivity: 0.262788650407571[W/mK] @ 70 K, 0.0257443666020476 /A\^3
System init for write_data ...
Generated 0 of 0 mixed pair_coeff terms from geometric mixing rule
Total wall time: 0:00:54
17 changes: 17 additions & 0 deletions tests/parsers/test_raw.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,23 @@ def test_default(generate_calc_job_node, data_regression, fixture_localhost):
data_regression.check({"results": results["results"].get_dict()})


def test_double_thermo_style(
generate_calc_job_node, data_regression, fixture_localhost
):
"""Test parsing a double thermo_style output case."""
node = generate_calc_job_node(
computer=fixture_localhost,
entry_point_name="lammps.raw",
test_name="parsers/fixtures/raw/thermo_style",
)
parser = ParserFactory("lammps.raw")
results, calcfunction = parser.parse_from_node(node, store_provenance=False)

assert calcfunction.is_finished, calcfunction.exception
assert calcfunction.is_finished_ok, calcfunction.exit_message
data_regression.check({"results": results["results"].get_dict()})


def test_alt_timing_info(generate_calc_job_node, data_regression, fixture_localhost):
"""Test parsing an alt output case."""
node = generate_calc_job_node(
Expand Down
17 changes: 17 additions & 0 deletions tests/parsers/test_raw/test_double_thermo_style.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
results:
compute_variables:
bin: standard
bins:
- 3
- 3
- 3
binsize: 7.5
errors: []
ghost_atom_cutoff: 15
master_list_distance_cutoff: 15
max_neighbors_atom: 2000
steps_per_second: 2190.659
total_wall_time: 0:00:54
total_wall_time_seconds: 54
units_style: real
warnings: []

0 comments on commit 0bce91d

Please sign in to comment.