Skip to content

Report GROMACS Per. Imp. Dih. energy contribution#404

Merged
ctk3b merged 1 commit intoshirtsgroup:masterfrom
jotelha:2026-01-20-improper-periodic-dihedral-energy-reporting
Jan 20, 2026
Merged

Report GROMACS Per. Imp. Dih. energy contribution#404
ctk3b merged 1 commit intoshirtsgroup:masterfrom
jotelha:2026-01-20-improper-periodic-dihedral-energy-reporting

Conversation

@jotelha
Copy link
Contributor

@jotelha jotelha commented Jan 20, 2026

The GROMACS dihedral type 4 (periodic improper dihedral, see table in https://manual.gromacs.org/documentation/2024.2/reference-manual/topologies/topology-file-formats.html and https://manual.gromacs.org/documentation/current/reference-manual/functions/bonded-interactions.html#improper-dihedrals-periodic-type) produces its own energy contribution named "Per. Imp. Dih." in the energy.xvg. The single line added in this PR would evaluate this contribution, but likely override the other "Improper Dih." energy contribution. What would be the desired way of reporting this energy contribution?

A standard InterMol GROMAC -> LAMMPS conversion energy report would look like this

Energy group summary
=======================================================================
                type     input(gromacs)   output (lammps)     diff (lammps)
-----------------------------------------------------------------------
Not comparable energies: are likely not to be the same
-----------------------------------------------------------------------
        coulomb (LR)       452.62161255        0.00000000     -452.62161255
        coulomb (SR)     -9485.61523438        0.00000000     9485.61523438
       coulomb total     -2830.31246948    13796.20026400    16626.51273348
          coulomb-14      6202.68115234        0.00000000    -6202.68115234
              proper      5090.43310547     5887.73274960      797.29964413
            vdw (LR)      -106.85102081     -107.06120453       -0.21018372
            vdw (SR)     -1337.50134277        0.00000000     1337.50134277
           vdw total      3378.27410126     3270.99533523     -107.27876603
              vdw-14      4822.62646484        0.00000000    -4822.62646484
-----------------------------------------------------------------------
Comparable energy terms: these should be very close
-----------------------------------------------------------------------
               angle      7595.20751953     7595.20683200       -0.00068753
                bond      1527.76965332     1527.77216104        0.00250772
              bonded     14213.41027832    15010.71174264      797.30146432
            dihedral      5090.43310547     5887.73274960      797.29964413
           nonbonded       547.96163177      548.64080720        0.67917543
           potential     15558.67675781    15559.35250800        0.67575019

---------------- Total Potential Energy Comparison --------------------
Input gromacs potential energy:         15558.67675781
Difference in potential energy from gromacs=>lammps conversion:         0.67575019
=======================================================================

while the report with this additional line looks like this,

=======================================================================
                type     input(gromacs)   output (lammps)     diff (lammps)
-----------------------------------------------------------------------
Not comparable energies: are likely not to be the same
-----------------------------------------------------------------------
        coulomb (LR)       452.62170410        0.00000000     -452.62170410
        coulomb (SR)     -9485.61523438        0.00000000     9485.61523438
       coulomb total     -2830.31237793    13796.20026400    16626.51264193
          coulomb-14      6202.68115234        0.00000000    -6202.68115234
            improper       797.30468750        0.00000000     -797.30468750
              proper      5090.43310547     5887.73274960      797.29964413
            vdw (LR)      -106.85102081     -107.06120453       -0.21018372
            vdw (SR)     -1337.50134277        0.00000000     1337.50134277
           vdw total      3378.27410126     3270.99533523     -107.27876603
              vdw-14      4822.62646484        0.00000000    -4822.62646484
-----------------------------------------------------------------------
Comparable energy terms: these should be very close
-----------------------------------------------------------------------
               angle      7595.20751953     7595.20683200       -0.00068753
                bond      1527.76965332     1527.77216104        0.00250772
              bonded     15010.71496582    15010.71174264       -0.00322318
            dihedral      5887.73779297     5887.73274960       -0.00504337
           nonbonded       547.96172333      548.64080720        0.67908387
           potential     15558.67675781    15559.35250800        0.67575019

---------------- Total Potential Energy Comparison --------------------
Input gromacs potential energy:         15558.67675781
Difference in potential energy from gromacs=>lammps conversion:         0.67575019
=======================================================================

You see that the GROMACS proper + improper contributions now add up to the LAMMPS proper dihedral contribution. This is expected as InterMol converts GROMACS type 4 periodic improper dihedrals to LAMMPS multi/nharmonic proper dihedrals.

Copy link
Member

@ctk3b ctk3b left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This makes sense to me! Thanks for the contribution

@ctk3b ctk3b merged commit e53e633 into shirtsgroup:master Jan 20, 2026
0 of 5 checks passed
@jotelha
Copy link
Contributor Author

jotelha commented Jan 22, 2026

Thank you for merging so quickly. However, I am worried that the newly added line

'Per. Imp. Dih.': ['dihedral', 'improper'],
overrides the preceding line
'Improper Dih.': ['dihedral', 'improper'],
.

I think it would be better to either introduce a mechanism to add both GROMACS-reported contributions Improper Dih. and Per. Imp. Dih. up and show them lumped together in the InterMol report under improper, or introduce the destinction between improper and periodic improper on the InterMol side as well. Latter would mean changing the added line from

'Per. Imp. Dih.': ['dihedral', 'improper'],

to

'Per. Imp. Dih.': ['dihedral', 'periodic improper'],

and then go through the code and modify reporting logic where necessary.

What would be your preferred way?

@ctk3b
Copy link
Member

ctk3b commented Jan 22, 2026

Ah apologies for missing this. You're absolutely right. Reverted for the time being: #405

My preference would be to not introduce new categories, i.e. lumping them both into improper

I won't have time to implement this but happy to review a PR if you do!

@jotelha
Copy link
Contributor Author

jotelha commented Jan 28, 2026

Looking at the energy summing logic in

for key, energy in energy_dict.items():
canonical_key = canonical_keys.get(key)
if canonical_key is None:
continue
elif not isinstance(canonical_key, string_types):
for k in canonical_key:
normalized[k] += energy.in_units_of(units.kilojoules_per_mole)
else:
normalized[canonical_key] += energy.in_units_of(units.kilojoules_per_mole)

I realize InterMol already does the lumping together of energy terms with the same canonical label. I wasn't aware of that, my apologies. The same already happens for other energy contributions, e.g.

'Proper Dih.': ['dihedral', 'proper'],
'Ryckaert-Bell.': ['dihedral', 'proper'],

Hence, I think the initially added single line is fine. If you agree, please revert the revert.

Thank you.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants