Repository navigation
Add support for dihedral potentials - #157
Open
rajkumarrb wants to merge 4 commits into
Open
rajkumarrb wants to merge 4 commits into
rajkumarrb wants to merge 4 commits into
Conversation
Completes the last unchecked task of pyMBE-dev#143 (angles were merged in pyMBE-dev#150; dihedrals are the remaining bonded-potential scope). The motivating case is Martini 2.1 peptide backbone dihedrals. New: - DihedralTemplate / DihedralInstance in pyMBE/storage. The template holds a list of terms, so GROMACS-style stacked multiplicities on the same quadruplet register as one Dihedral object per term. - pmb.define_dihedral_potential / define_default_dihedral_potential / create_dihedral_potential / get_dihedral_template. - _generate_dihedrals_for_entity and a gen_dihedral kwarg on create_residue / create_molecule / create_hydrogel, mirroring gen_angle. - espresso_engine _add_dihedral / _get_dihedral_instance / _create_dihedral_instance, wired into add_instances_to_engine. - storage manager + io: register / update / delete / templates-df / save / load branches for the dihedral type. - testsuite/dihedral_tests.py, samples/setup_dihedral_potential.py. The canonical template key is invariant under full reversal of the quadruplet. The "periodic" type maps onto the ESPResSo Dihedral bond V(phi) = k*[1 - cos(n*phi - phi_0)]; "tabulated" is reserved but raises NotImplementedError. GROMACS proper dihedral type 1, V(phi) = k*[1 + cos(n*phi - phi_s)], is recovered with phi_0 = phi_s + pi (documented in the docstrings and the sample, not applied implicitly).
add_instances_to_engine now performs a fifth _find_instance_ids_by_attribute call for pmb_type='dihedral', mirroring the bond and angle blocks. The pre-existing test_espresso_engine_add_instances_id_collision mocked that method with a four-element side_effect list, so the dihedral lookup raised StopIteration. Add the missing entry.
…chment Dihedral parameters (k, phi_s, mult) now follow the IUPAC/GROMACS type 1 convention, V(phi) = k*[1 + cos(n*phi - phi_s)] with phi = 0 at the cis conformation. The ESPResSo engine converts them internally to the ESPResSo Dihedral form (phase = -(phi_s + pi)) and documents the conversion. Attach the ESPResSo Dihedral bond to the second particle of the quadruplet, as required by ESPResSo, instead of the first one, which made ESPResSo evaluate a different torsion. Add tests that compare energies and forces set up in ESPResSo with the analytical expression: energy and forces vs. finite differences, momentum conservation, NVE energy conservation, relaxation to the minimum, GROMACS type 1 parameters, reversed quadruplets, periodic boundaries, and generation of dihedrals for residues, molecules and hydrogels.
3 tasks done
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Adds the dihedral (torsion) potentials part of #143 (bonds and angles #150 are already in).
Follows the discussion in #143 and the pyMBE-dev meeting of 14.09.2026.
What it adds
DihedralTemplate/DihedralInstanceinpyMBE/storage, mirroring the angle types. A template holds a list of terms, so GROMACS-style stacked multiplicities on the same quadruplet are supported. The template name is invariant under full reversal (A-B-C-D == D-C-B-A).define_dihedral_potential,define_default_dihedral_potential,create_dihedral_potential,get_dihedral_template.gen_dihedralargument increate_residue,create_moleculeandcreate_hydrogel, following thegen_anglepattern. In hydrogels, only dihedrals internal to the chains are generated; dihedrals involving crosslinker nodes are not.testsuite/dihedral_tests.py), sample script (samples/setup_dihedral_potential.py) and CHANGELOG entries.Convention
As agreed in #143, the API uses the IUPAC/GROMACS convention (phi = 0 at cis). Users pass the parameters of the GROMACS proper dihedral type 1,
V(phi) = k*[1 + cos(n*phi - phi_s)], ask,phi_sandmult. The ESPResSo-specific conversion is done inside the ESPResSo engine (phase = -(phi_s + pi)) and is documented in_create_dihedral_instance.The ESPResSo
Dihedralbond is attached to the second particle of the quadruplet, as in the ESPResSo documentation.Testing
Besides checking that the right ESPResSo objects are created, the tests compare the dihedral set up in ESPResSo with independent numpy references:
The force tests use geometries away from the angles affected by espressomd/espresso#5401 (phi = 0 and pi).
make tests(36/36),make pylintandmake docspassed locally with ESPResSo 5.0.1. The nested-residue and hydrogel generation tests were added after that run;dihedral_tests.pypasses 27/27 and pylint is clean.Not included
"tabulated"raisesNotImplementedError)..itpfile, which can be a follow-up._generate_hydrogel_crosslinker_angles).Questions for reviewers
phi_san acceptable name for the parameter key (instead ofphi_0as in the angle potentials)?gen_dihedral=Trueskips quadruplets without a matching template silently, asgen_angledoes. Should it log a warning instead? Should hydrogel crosslinker dihedrals follow the same all-or-nothing rule as the crosslinker angles?