iphasimulator.simulation_gromacs_runner
=======================================
.. py:module:: iphasimulator.simulation_gromacs_runner
.. autoapi-nested-parse::
Generate GROMACS run folders and command templates.
Attributes
----------
.. autoapisummary::
iphasimulator.simulation_gromacs_runner.GROMACS_POLYMER_MDP_TEMPLATE_NAMES
iphasimulator.simulation_gromacs_runner.GROMACS_CHARMM_GUI_MEMBRANE_MDP_TEMPLATE_NAMES
iphasimulator.simulation_gromacs_runner.GROMACS_MDP_TEMPLATE_NAMES
iphasimulator.simulation_gromacs_runner.GROMACS_ALL_MDP_TEMPLATE_NAMES
iphasimulator.simulation_gromacs_runner.GROMACS_WORKFLOW_MDP_TEMPLATE_NAMES
iphasimulator.simulation_gromacs_runner.INCLUDE_PATTERN
iphasimulator.simulation_gromacs_runner.LOCAL_MINIMIZATION_REQUIRED_FILENAMES
iphasimulator.simulation_gromacs_runner.MDP_CUTOFF_KEYS
iphasimulator.simulation_gromacs_runner.WATER_MOLECULE_NAMES
iphasimulator.simulation_gromacs_runner.CATION_MOLECULE_NAMES
iphasimulator.simulation_gromacs_runner.ANION_MOLECULE_NAMES
iphasimulator.simulation_gromacs_runner.GROMACS_SOLVATION_TEMPLATE_DIR
iphasimulator.simulation_gromacs_runner.GROMACS_SOLVATION_TEMPLATE_NAMES
iphasimulator.simulation_gromacs_runner.GROMACS_SOLVATION_TOPOLOGY_INCLUDE_NAMES
iphasimulator.simulation_gromacs_runner.MINIM_MDP
iphasimulator.simulation_gromacs_runner.NVT_MDP
iphasimulator.simulation_gromacs_runner.NPT_MDP
iphasimulator.simulation_gromacs_runner.PRODUCTION_MDP
iphasimulator.simulation_gromacs_runner.GROMACS_WORKFLOW_HPC_STEPS
Classes
-------
.. autoapisummary::
iphasimulator.simulation_gromacs_runner.GromacsRunFiles
iphasimulator.simulation_gromacs_runner.GromacsPreparedRunFolder
iphasimulator.simulation_gromacs_runner.GromacsTopologyValidation
iphasimulator.simulation_gromacs_runner.GromacsLocalMinimizationCheck
iphasimulator.simulation_gromacs_runner.GromacsBoxValidation
iphasimulator.simulation_gromacs_runner.GromacsSolvationFiles
iphasimulator.simulation_gromacs_runner.GromacsSolvatedTopologyValidation
iphasimulator.simulation_gromacs_runner.GromacsGromppValidation
iphasimulator.simulation_gromacs_runner.GromacsCoordinateTopologyValidation
Functions
---------
.. autoapisummary::
iphasimulator.simulation_gromacs_runner.write_gromacs_run_files
iphasimulator.simulation_gromacs_runner.create_gromacs_simulation_box
iphasimulator.simulation_gromacs_runner.validate_gromacs_box_against_mdp
iphasimulator.simulation_gromacs_runner.count_gro_atoms
iphasimulator.simulation_gromacs_runner.validate_gromacs_coordinate_topology_counts
iphasimulator.simulation_gromacs_runner.write_gromacs_solvation_files
iphasimulator.simulation_gromacs_runner.validate_gromacs_solvated_topology
iphasimulator.simulation_gromacs_runner.validate_gromacs_solvation_grompp
iphasimulator.simulation_gromacs_runner.validate_gromacs_run_folder
iphasimulator.simulation_gromacs_runner.check_gromacs_minimization_inputs
iphasimulator.simulation_gromacs_runner.run_gromacs_local_minimization
iphasimulator.simulation_gromacs_runner.prepare_gromacs_run_folder
Module Contents
---------------
.. py:class:: GromacsRunFiles
Files generated for a staged GROMACS run.
.. py:attribute:: output_dir
:type: pathlib.Path
.. py:attribute:: minim_mdp_path
:type: pathlib.Path
.. py:attribute:: nvt_mdp_path
:type: pathlib.Path
.. py:attribute:: npt_mdp_path
:type: pathlib.Path
.. py:attribute:: production_mdp_path
:type: pathlib.Path
.. py:attribute:: run_script_path
:type: pathlib.Path
.. py:class:: GromacsPreparedRunFolder
Files generated for a GROMACS run folder.
.. py:attribute:: output_dir
:type: pathlib.Path
.. py:attribute:: workflow_type
:type: str
.. py:attribute:: dry_polymer_dir
:type: pathlib.Path
.. py:attribute:: solvated_polymer_dir
:type: pathlib.Path
.. py:attribute:: charmm_gui_membrane_dir
:type: pathlib.Path
.. py:attribute:: step5_input_gro_path
:type: pathlib.Path
.. py:attribute:: topol_top_path
:type: pathlib.Path
.. py:attribute:: index_ndx_path
:type: pathlib.Path
.. py:attribute:: mdp_paths
:type: tuple[pathlib.Path, ...]
.. py:attribute:: local_script_path
:type: pathlib.Path
.. py:attribute:: hpc_script_path
:type: pathlib.Path
.. py:attribute:: charmm_gui_membrane_hpc_script_path
:type: pathlib.Path
.. py:class:: GromacsTopologyValidation
Validation result for GROMACS topology include files.
.. py:attribute:: topol_top_path
:type: pathlib.Path
.. py:attribute:: is_standalone
:type: bool
.. py:attribute:: included_files
:type: tuple[pathlib.Path, ...]
.. py:attribute:: missing_files
:type: tuple[pathlib.Path, ...]
.. py:property:: valid
:type: bool
.. py:class:: GromacsLocalMinimizationCheck
Files and command needed to run local GROMACS minimisation.
.. py:attribute:: output_dir
:type: pathlib.Path
.. py:attribute:: required_files
:type: tuple[pathlib.Path, ...]
.. py:attribute:: missing_files
:type: tuple[pathlib.Path, ...]
.. py:attribute:: command
:type: tuple[str, ...]
.. py:property:: ready
:type: bool
.. py:property:: command_text
:type: str
.. py:class:: GromacsBoxValidation
Box-size validation against GROMACS nonbonded cutoffs.
.. py:attribute:: gro_path
:type: pathlib.Path
.. py:attribute:: mdp_path
:type: pathlib.Path
.. py:attribute:: box_vectors_nm
:type: tuple[float, ...]
.. py:attribute:: shortest_box_vector_nm
:type: float
.. py:attribute:: cutoffs_nm
:type: dict[str, float]
.. py:property:: max_cutoff_nm
:type: float | None
.. py:property:: valid
:type: bool
.. py:class:: GromacsSolvationFiles
Files generated for the standard GROMACS solvate/genion workflow.
.. py:attribute:: output_dir
:type: pathlib.Path
.. py:attribute:: ions_mdp_path
:type: pathlib.Path
.. py:attribute:: solvation_itp_paths
:type: tuple[pathlib.Path, ...]
.. py:attribute:: solvent_itp_path
:type: pathlib.Path
.. py:attribute:: cation_itp_path
:type: pathlib.Path
.. py:attribute:: anion_itp_path
:type: pathlib.Path
.. py:attribute:: solvate_script_path
:type: pathlib.Path
.. py:attribute:: local_script_path
:type: pathlib.Path
.. py:attribute:: hpc_script_path
:type: pathlib.Path
.. py:attribute:: charmm_gui_membrane_hpc_script_path
:type: pathlib.Path
.. py:property:: tip3p_ions_itp_path
:type: pathlib.Path
Backward-compatible alias for older callers.
.. py:class:: GromacsSolvatedTopologyValidation
Water and ion molecule counts parsed from a GROMACS topology.
.. py:attribute:: topol_top_path
:type: pathlib.Path
.. py:attribute:: molecule_counts
:type: dict[str, int]
.. py:attribute:: water_count
:type: int
.. py:attribute:: cation_count
:type: int
.. py:attribute:: anion_count
:type: int
.. py:property:: sodium_count
:type: int
Backward-compatible alias; may include POT/K in newer workflows.
.. py:property:: chloride_count
:type: int
Backward-compatible alias for anion count.
.. py:property:: has_water
:type: bool
.. py:property:: has_ions
:type: bool
.. py:class:: GromacsGromppValidation
Result of a lightweight GROMACS ``grompp`` validation command.
.. py:attribute:: command
:type: tuple[str, ...]
.. py:attribute:: returncode
:type: int
.. py:attribute:: stdout
:type: str
.. py:attribute:: stderr
:type: str
.. py:property:: ok
:type: bool
.. py:class:: GromacsCoordinateTopologyValidation
Atom-count comparison between a GRO coordinate file and topology.
.. py:attribute:: gro_path
:type: pathlib.Path
.. py:attribute:: topol_top_path
:type: pathlib.Path
.. py:attribute:: coordinate_atom_count
:type: int
.. py:attribute:: molecule_counts
:type: dict[str, int]
.. py:attribute:: molecule_atom_counts
:type: dict[str, int]
.. py:attribute:: expected_atom_count
:type: int | None
.. py:property:: can_compare
:type: bool
.. py:property:: valid
:type: bool
.. py:data:: GROMACS_POLYMER_MDP_TEMPLATE_NAMES
:value: ('step6.0_minimization.mdp', 'step6.1_nvt.mdp', 'step6.2_npt.mdp', 'step7_production.mdp')
.. py:data:: GROMACS_CHARMM_GUI_MEMBRANE_MDP_TEMPLATE_NAMES
:value: ('step6.0_minimization.mdp', 'step6.1_equilibration.mdp', 'step6.2_equilibration.mdp',...
.. py:data:: GROMACS_MDP_TEMPLATE_NAMES
:value: ('step6.0_minimization.mdp', 'step6.1_nvt.mdp', 'step6.2_npt.mdp', 'step7_production.mdp')
.. py:data:: GROMACS_ALL_MDP_TEMPLATE_NAMES
:value: ('step6.0_minimization.mdp', 'step6.1_nvt.mdp', 'step6.2_npt.mdp', 'step7_production.mdp',...
.. py:data:: GROMACS_WORKFLOW_MDP_TEMPLATE_NAMES
.. py:data:: INCLUDE_PATTERN
.. py:data:: LOCAL_MINIMIZATION_REQUIRED_FILENAMES
:value: ('step5_input.gro', 'topol.top', 'index.ndx', 'step6.0_minimization.mdp', 'run_step6_local.sh')
.. py:data:: MDP_CUTOFF_KEYS
:value: ('rlist', 'rcoulomb', 'rvdw')
.. py:data:: WATER_MOLECULE_NAMES
:value: ('SOL', 'WAT', 'TIP3', 'TIP3P', 'HOH')
.. py:data:: CATION_MOLECULE_NAMES
:value: ('SOD', 'NA', 'NA+', 'POT', 'K', 'K+')
.. py:data:: ANION_MOLECULE_NAMES
:value: ('CLA', 'CL', 'CL-')
.. py:data:: GROMACS_SOLVATION_TEMPLATE_DIR
:value: 'data/gromacs_solvation'
.. py:data:: GROMACS_SOLVATION_TEMPLATE_NAMES
:value: ('ions.mdp', 'tip3_ions_atomtypes.itp', 'TIP3_SOL.itp', 'TIP3.itp', 'SOD.itp', 'POT.itp', 'CLA.itp')
.. py:data:: GROMACS_SOLVATION_TOPOLOGY_INCLUDE_NAMES
:value: ('tip3_ions_atomtypes.itp', 'TIP3_SOL.itp', 'SOD.itp', 'CLA.itp')
.. py:data:: MINIM_MDP
:value: Multiline-String
.. raw:: html
Show Value
.. code-block:: python
"""; Energy minimisation
integrator = steep
emtol = 1000.0
emstep = 0.01
nsteps = 5000
cutoff-scheme = Verlet
coulombtype = PME
rcoulomb = 1.0
rvdw = 1.0
pbc = xyz
"""
.. raw:: html
.. py:data:: NVT_MDP
:value: Multiline-String
.. raw:: html
Show Value
.. code-block:: python
"""; NVT equilibration
integrator = md
nsteps = 50000
dt = 0.002
continuation = no
constraint_algorithm = lincs
constraints = h-bonds
cutoff-scheme = Verlet
coulombtype = PME
rcoulomb = 1.0
rvdw = 1.0
tcoupl = V-rescale
tc-grps = System
tau_t = 1.0
ref_t = 300
pcoupl = no
pbc = xyz
gen_vel = yes
gen_temp = 300
gen_seed = -1
"""
.. raw:: html
.. py:data:: NPT_MDP
:value: Multiline-String
.. raw:: html
Show Value
.. code-block:: python
"""; NPT equilibration
integrator = md
nsteps = 50000
dt = 0.002
continuation = yes
constraint_algorithm = lincs
constraints = h-bonds
cutoff-scheme = Verlet
coulombtype = PME
rcoulomb = 1.0
rvdw = 1.0
tcoupl = V-rescale
tc-grps = System
tau_t = 1.0
ref_t = 300
pcoupl = C-rescale
pcoupltype = isotropic
tau_p = 5.0
ref_p = 1.0
compressibility = 4.5e-5
pbc = xyz
gen_vel = no
"""
.. raw:: html
.. py:data:: PRODUCTION_MDP
:value: Multiline-String
.. raw:: html
Show Value
.. code-block:: python
"""; Production MD
integrator = md
nsteps = 500000
dt = 0.002
continuation = yes
constraint_algorithm = lincs
constraints = h-bonds
cutoff-scheme = Verlet
coulombtype = PME
rcoulomb = 1.0
rvdw = 1.0
tcoupl = V-rescale
tc-grps = System
tau_t = 1.0
ref_t = 300
pcoupl = C-rescale
pcoupltype = isotropic
tau_p = 5.0
ref_p = 1.0
compressibility = 4.5e-5
pbc = xyz
gen_vel = no
nstxout-compressed = 1000
nstenergy = 1000
nstlog = 1000
"""
.. raw:: html
.. py:function:: write_gromacs_run_files(output_dir: str | pathlib.Path, system_name: str = 'system') -> GromacsRunFiles
Write basic GROMACS ``mdp`` files and a staged run script.
.. py:function:: create_gromacs_simulation_box(input_gro: str | pathlib.Path, output_gro: str | pathlib.Path, *, padding_nm: float = 3.0, box_type: str = 'cubic', gmx_command: str = 'gmx', runner=subprocess.run) -> pathlib.Path
Create a centered GROMACS simulation box with ``gmx editconf``.
.. py:function:: validate_gromacs_box_against_mdp(gro_file: str | pathlib.Path, mdp_file: str | pathlib.Path) -> GromacsBoxValidation
Warn when a GRO box is too small for the MDP nonbonded cutoffs.
.. py:data:: GROMACS_WORKFLOW_HPC_STEPS
.. py:function:: count_gro_atoms(gro_path: str | pathlib.Path) -> int
Read the atom count from the second line of a GROMACS ``.gro`` file.
.. py:function:: validate_gromacs_coordinate_topology_counts(output_dir: str | pathlib.Path, *, coordinate_name: str = 'step5_input.gro', topology_name: str = 'topol.top') -> GromacsCoordinateTopologyValidation
Compare final coordinate atoms with topology molecule atom counts.
.. py:function:: write_gromacs_solvation_files(output_dir: str | pathlib.Path, *, workflow_type: str = 'polymer', box_padding_nm: float = 1.2, ion_concentration_molar: float = 0.15, clean: bool = False, overwrite: bool = False) -> GromacsSolvationFiles
Write files for the standard GROMACS solvate/genion workflow.
This keeps the polymer GAFF2 topology unchanged and only adds the simulation
environment: box, TIP3P-compatible water from GROMACS, and neutralising NaCl ions.
.. py:function:: validate_gromacs_solvated_topology(output_dir: str | pathlib.Path, *, topology_name: str = 'topol.top') -> GromacsSolvatedTopologyValidation
Validate that topology molecule counts include solvent and ions.
.. py:function:: validate_gromacs_solvation_grompp(output_dir: str | pathlib.Path, *, gmx_command: str = 'gmx', runner=subprocess.run) -> tuple[GromacsGromppValidation, GromacsGromppValidation]
Run the two ``grompp`` checks required by the solvation workflow.
.. py:function:: validate_gromacs_run_folder(output_dir: str | pathlib.Path, *, topology_name: str = 'topol.top') -> GromacsTopologyValidation
Validate external include files referenced by a GROMACS topology.
ParmEd GAFF2 conversion often writes a standalone topology with all molecule
definitions in ``topol.top``. In that case there are no ``#include`` lines
and no ``toppar`` directory is required.
.. py:function:: check_gromacs_minimization_inputs(output_dir: str | pathlib.Path) -> GromacsLocalMinimizationCheck
Check the files needed before running local GROMACS minimisation.
.. py:function:: run_gromacs_local_minimization(output_dir: str | pathlib.Path, *, runner=subprocess.run) -> subprocess.CompletedProcess
Run the local minimisation script from inside the GROMACS folder.
.. py:function:: prepare_gromacs_run_folder(prmtop_file: str | pathlib.Path, inpcrd_file: str | pathlib.Path, output_dir: str | pathlib.Path, system_name: str, *, workflow_type: str = 'polymer', index_file: str | pathlib.Path | None = None, gmx_command: str = 'gmx', runner=subprocess.run) -> GromacsPreparedRunFolder
Prepare self-contained GROMACS workflow folders from AMBER files.
``output_dir`` is the system-level ``gromacs`` directory. This function
writes independent ``dry_polymer``, ``solvated_polymer`` and
``charmm_gui_membrane`` subdirectories so one workflow cannot overwrite
another workflow's inputs or outputs.