Skip to content

Commit 9cb448a

Browse files
andyclaude
andcommitted
GROMACS: emit the pressure that was already being parsed
gromacs.energy reads every term in the energies block into %term and then emitted only the energy, so "Pressure (bar)" -- which GROMACS prints in the same block, on the same line as Total Energy and Temperature -- was parsed and thrown away. Emitted from the existing [TE][TEVEC] entry rather than a new one. The marker line is byte-identical, and two .desc entries sharing a Begin leave one of them permanently starved (PDMatchBegin returns only the first match) -- the same reason TE and TEVEC already share this entry. Units are Bar, which is what GROMACS labels the column and what PressureConverter knows. That is not cosmetic: convertTo() throws on an unrecognised unit. Scalar only, deliberately. A per-step pressure would have to be a PropTSVector<Geometry Step>, and GeomTracePropertyPanel plots any of those against GEOMTRACE, which GROMACS has no producer for. A minimisation prints no pressure column at all, so the emission is guarded and water_em legitimately has none. The PRESSURE property itself came in with the Quantum ESPRESSO stress work; this is its second consumer. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01EFMUNbw2UpRPmgsqviAowb
1 parent 4f470e6 commit 9cb448a

5 files changed

Lines changed: 82 additions & 6 deletions

File tree

‎scripts/parsers/gromacs.desc‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@
5555
# apart. Parsed as a step it would put a final point on every
5656
# energy-vs-step plot whose value is an AVERAGE OVER THE RUN, and would
5757
# leave the scalar TE holding that average rather than the last step.
58-
[TE][TEVEC]
58+
[TE][TEVEC][PRESSURE]
5959
Script=gromacs.energy
6060
Begin=^\s*Energies \(kJ/mol\)
6161
Frequency=all

‎scripts/parsers/gromacs.energy‎

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -186,4 +186,29 @@ foreach my $k ("TE", "TEVEC") {
186186
print "units:\nkJoule/Mole\n";
187187
print "END\n";
188188
}
189+
190+
# Pressure comes out of the SAME block, already parsed into %term above,
191+
# and is emitted from this one entry rather than a second .desc entry --
192+
# the marker line is identical, and two entries sharing a Begin would
193+
# leave one of them permanently starved (PDMatchBegin returns only the
194+
# first match).
195+
#
196+
# GROMACS labels the column "Pressure (bar)", and bar is a unit
197+
# PressureConverter knows. That matters: convertTo() THROWS on a unit
198+
# it does not have, so an invented label would be an exception rather
199+
# than a cosmetic wart.
200+
#
201+
# Scalar only, deliberately. A per-step pressure would have to be a
202+
# PropTSVector<Geometry Step>, and GeomTracePropertyPanel plots any of
203+
# those against GEOMTRACE -- which GROMACS has no producer for, so the
204+
# trace would be unplottable at best and out of bounds at worst (the
205+
# len(TEVEC) <= len(GEOMTRACE) rule in CLAUDE.md). A minimisation run
206+
# prints no pressure at all, hence the defined() guard.
207+
if (defined($term{"Pressure (bar)"})) {
208+
print "key: PRESSURE\n";
209+
print "size:\n1\n";
210+
print "values:\n" . $term{"Pressure (bar)"} . "\n";
211+
print "units:\nBar\n";
212+
print "END\n";
213+
}
189214
exit(0);

‎tests/parsers/cases.py‎

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1133,7 +1133,10 @@
11331133
fixture='gromacs/water_em.log',
11341134
parse_args=('.', 'Energy', 'MD', 'OPLS', '0'),
11351135
expect={
1136-
'TE][TEVEC': dict(blocks=5, keys={
1136+
# A minimisation prints no pressure column at all, so
1137+
# PRESSURE is absent here by design -- the parser guards on
1138+
# the term being present rather than emitting an empty one.
1139+
'TE][TEVEC][PRESSURE': dict(blocks=5, keys={
11371140
'TE': {'values': '-8.19803e+03', 'units': 'kJoule/Mole'},
11381141
'TEVEC': {'units': 'kJoule/Mole'}}),
11391142
},
@@ -1163,9 +1166,13 @@
11631166
# [NULL] suppressor ever stops swallowing it, TE lands on
11641167
# the run average and this fails loudly instead of quietly
11651168
# reporting a plausible wrong number.
1166-
'TE][TEVEC': dict(blocks=6, keys={
1169+
'TE][TEVEC][PRESSURE': dict(blocks=6, keys={
11671170
'TE': {'values': '-7.11568e+03', 'units': 'kJoule/Mole'},
1168-
'TEVEC': {'units': 'kJoule/Mole'}}),
1171+
'TEVEC': {'units': 'kJoule/Mole'},
1172+
# Same argument as TE: the LAST STEP's pressure, not the
1173+
# averages block's. Units must be one PressureConverter
1174+
# knows -- it throws on anything else.
1175+
'PRESSURE': {'values': '-2.13868e+03', 'units': 'Bar'}}),
11691176
},
11701177
),
11711178
dict(

‎tests/parsers/expected/gromacs-water-em.txt‎

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ desc: gromacs.desc
44
fixture: gromacs/water_em.log (472 lines)
55
args: '.' 'Energy' 'MD' 'OPLS' '0'
66

7-
[TE][TEVEC] Script=gromacs.energy Freq=all Skip=0 Lines=-
7+
[TE][TEVEC][PRESSURE] Script=gromacs.energy Freq=all Skip=0 Lines=-
88
Begin=^\s*Energies \(kJ/mol\)
99
End=^\s*$
1010
begins=5 delivered=5 buffered_away=0
@@ -17,6 +17,10 @@ args: '.' 'Energy' 'MD' 'OPLS' '0'
1717
size: 1
1818
values: -1.99051e+03
1919
units: kJoule/Mole
20+
key: PRESSURE
21+
size: 1
22+
values: 4.93577e+04
23+
units: Bar
2024
block 2: begin-line=435 fed=4 rc=0 first-fed=' Energies (kJ/mol)'
2125
key: TE
2226
size: 1
@@ -26,6 +30,10 @@ args: '.' 'Energy' 'MD' 'OPLS' '0'
2630
size: 1
2731
values: -5.73156e+03
2832
units: kJoule/Mole
33+
key: PRESSURE
34+
size: 1
35+
values: 1.72969e+04
36+
units: Bar
2937
block 3: begin-line=442 fed=4 rc=0 first-fed=' Energies (kJ/mol)'
3038
key: TE
3139
size: 1
@@ -35,6 +43,10 @@ args: '.' 'Energy' 'MD' 'OPLS' '0'
3543
size: 1
3644
values: -7.16623e+03
3745
units: kJoule/Mole
46+
key: PRESSURE
47+
size: 1
48+
values: 5.66364e+03
49+
units: Bar
3850
block 4: begin-line=449 fed=4 rc=0 first-fed=' Energies (kJ/mol)'
3951
key: TE
4052
size: 1
@@ -44,6 +56,10 @@ args: '.' 'Energy' 'MD' 'OPLS' '0'
4456
size: 1
4557
values: -7.67943e+03
4658
units: kJoule/Mole
59+
key: PRESSURE
60+
size: 1
61+
values: 1.82489e+03
62+
units: Bar
4763
block 5: begin-line=456 fed=4 rc=0 first-fed=' Energies (kJ/mol)'
4864
key: TE
4965
size: 1
@@ -53,4 +69,8 @@ args: '.' 'Energy' 'MD' 'OPLS' '0'
5369
size: 1
5470
values: -8.19803e+03
5571
units: kJoule/Mole
72+
key: PRESSURE
73+
size: 1
74+
values: -1.66600e+03
75+
units: Bar
5676

‎tests/parsers/expected/gromacs-water-md.txt‎

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ desc: gromacs.desc
44
fixture: gromacs/water_md.log (612 lines)
55
args: '.' 'Dynamics' 'MD' 'OPLS' '0'
66

7-
[TE][TEVEC] Script=gromacs.energy Freq=all Skip=0 Lines=-
7+
[TE][TEVEC][PRESSURE] Script=gromacs.energy Freq=all Skip=0 Lines=-
88
Begin=^\s*Energies \(kJ/mol\)
99
End=^\s*$
1010
begins=6 delivered=6 buffered_away=0
@@ -17,6 +17,10 @@ args: '.' 'Dynamics' 'MD' 'OPLS' '0'
1717
size: 1
1818
values: -8.18669e+03
1919
units: kJoule/Mole
20+
key: PRESSURE
21+
size: 1
22+
values: -1.63353e+03
23+
units: Bar
2024
block 2: begin-line=468 fed=6 rc=0 first-fed=' Energies (kJ/mol)'
2125
key: TE
2226
size: 1
@@ -26,6 +30,10 @@ args: '.' 'Dynamics' 'MD' 'OPLS' '0'
2630
size: 1
2731
values: -7.33732e+03
2832
units: kJoule/Mole
33+
key: PRESSURE
34+
size: 1
35+
values: -2.89873e+03
36+
units: Bar
2937
block 3: begin-line=477 fed=6 rc=0 first-fed=' Energies (kJ/mol)'
3038
key: TE
3139
size: 1
@@ -35,6 +43,10 @@ args: '.' 'Dynamics' 'MD' 'OPLS' '0'
3543
size: 1
3644
values: -7.19592e+03
3745
units: kJoule/Mole
46+
key: PRESSURE
47+
size: 1
48+
values: -1.50656e+03
49+
units: Bar
3850
block 4: begin-line=486 fed=6 rc=0 first-fed=' Energies (kJ/mol)'
3951
key: TE
4052
size: 1
@@ -44,6 +56,10 @@ args: '.' 'Dynamics' 'MD' 'OPLS' '0'
4456
size: 1
4557
values: -7.14458e+03
4658
units: kJoule/Mole
59+
key: PRESSURE
60+
size: 1
61+
values: -2.07738e+03
62+
units: Bar
4763
block 5: begin-line=495 fed=6 rc=0 first-fed=' Energies (kJ/mol)'
4864
key: TE
4965
size: 1
@@ -53,6 +69,10 @@ args: '.' 'Dynamics' 'MD' 'OPLS' '0'
5369
size: 1
5470
values: -7.18100e+03
5571
units: kJoule/Mole
72+
key: PRESSURE
73+
size: 1
74+
values: -2.89189e+03
75+
units: Bar
5676
block 6: begin-line=507 fed=6 rc=0 first-fed=' Energies (kJ/mol)'
5777
key: TE
5878
size: 1
@@ -62,6 +82,10 @@ args: '.' 'Dynamics' 'MD' 'OPLS' '0'
6282
size: 1
6383
values: -7.11568e+03
6484
units: kJoule/Mole
85+
key: PRESSURE
86+
size: 1
87+
values: -2.13868e+03
88+
units: Bar
6589

6690
[NULL] Script=gromacs.null Freq=last Skip=0 Lines=-
6791
Begin=A V E R A G E S

0 commit comments

Comments
 (0)