iphasimulator.simulation_gromacs_runner

Generate GROMACS run folders and command templates.

Attributes

GROMACS_POLYMER_MDP_TEMPLATE_NAMES

GROMACS_CHARMM_GUI_MEMBRANE_MDP_TEMPLATE_NAMES

GROMACS_MDP_TEMPLATE_NAMES

GROMACS_ALL_MDP_TEMPLATE_NAMES

GROMACS_WORKFLOW_MDP_TEMPLATE_NAMES

INCLUDE_PATTERN

LOCAL_MINIMIZATION_REQUIRED_FILENAMES

MDP_CUTOFF_KEYS

WATER_MOLECULE_NAMES

CATION_MOLECULE_NAMES

ANION_MOLECULE_NAMES

GROMACS_SOLVATION_TEMPLATE_DIR

GROMACS_SOLVATION_TEMPLATE_NAMES

GROMACS_SOLVATION_TOPOLOGY_INCLUDE_NAMES

MINIM_MDP

NVT_MDP

NPT_MDP

PRODUCTION_MDP

GROMACS_WORKFLOW_HPC_STEPS

Classes

GromacsRunFiles

Files generated for a staged GROMACS run.

GromacsPreparedRunFolder

Files generated for a GROMACS run folder.

GromacsTopologyValidation

Validation result for GROMACS topology include files.

GromacsLocalMinimizationCheck

Files and command needed to run local GROMACS minimisation.

GromacsBoxValidation

Box-size validation against GROMACS nonbonded cutoffs.

GromacsSolvationFiles

Files generated for the standard GROMACS solvate/genion workflow.

GromacsSolvatedTopologyValidation

Water and ion molecule counts parsed from a GROMACS topology.

GromacsGromppValidation

Result of a lightweight GROMACS grompp validation command.

GromacsCoordinateTopologyValidation

Atom-count comparison between a GRO coordinate file and topology.

Functions

write_gromacs_run_files(→ GromacsRunFiles)

Write basic GROMACS mdp files and a staged run script.

create_gromacs_simulation_box(→ pathlib.Path)

Create a centered GROMACS simulation box with gmx editconf.

validate_gromacs_box_against_mdp(→ GromacsBoxValidation)

Warn when a GRO box is too small for the MDP nonbonded cutoffs.

count_gro_atoms(→ int)

Read the atom count from the second line of a GROMACS .gro file.

validate_gromacs_coordinate_topology_counts(...)

Compare final coordinate atoms with topology molecule atom counts.

write_gromacs_solvation_files(→ GromacsSolvationFiles)

Write files for the standard GROMACS solvate/genion workflow.

validate_gromacs_solvated_topology(...)

Validate that topology molecule counts include solvent and ions.

validate_gromacs_solvation_grompp(...)

Run the two grompp checks required by the solvation workflow.

validate_gromacs_run_folder(→ GromacsTopologyValidation)

Validate external include files referenced by a GROMACS topology.

check_gromacs_minimization_inputs(...)

Check the files needed before running local GROMACS minimisation.

run_gromacs_local_minimization(...)

Run the local minimisation script from inside the GROMACS folder.

prepare_gromacs_run_folder(→ GromacsPreparedRunFolder)

Prepare self-contained GROMACS workflow folders from AMBER files.

Module Contents

class iphasimulator.simulation_gromacs_runner.GromacsRunFiles

Files generated for a staged GROMACS run.

output_dir: pathlib.Path
minim_mdp_path: pathlib.Path
nvt_mdp_path: pathlib.Path
npt_mdp_path: pathlib.Path
production_mdp_path: pathlib.Path
run_script_path: pathlib.Path
class iphasimulator.simulation_gromacs_runner.GromacsPreparedRunFolder

Files generated for a GROMACS run folder.

output_dir: pathlib.Path
workflow_type: str
dry_polymer_dir: pathlib.Path
solvated_polymer_dir: pathlib.Path
charmm_gui_membrane_dir: pathlib.Path
step5_input_gro_path: pathlib.Path
topol_top_path: pathlib.Path
index_ndx_path: pathlib.Path
mdp_paths: tuple[pathlib.Path, ...]
local_script_path: pathlib.Path
hpc_script_path: pathlib.Path
charmm_gui_membrane_hpc_script_path: pathlib.Path
class iphasimulator.simulation_gromacs_runner.GromacsTopologyValidation

Validation result for GROMACS topology include files.

topol_top_path: pathlib.Path
is_standalone: bool
included_files: tuple[pathlib.Path, ...]
missing_files: tuple[pathlib.Path, ...]
property valid: bool
class iphasimulator.simulation_gromacs_runner.GromacsLocalMinimizationCheck

Files and command needed to run local GROMACS minimisation.

output_dir: pathlib.Path
required_files: tuple[pathlib.Path, ...]
missing_files: tuple[pathlib.Path, ...]
command: tuple[str, ...]
property ready: bool
property command_text: str
class iphasimulator.simulation_gromacs_runner.GromacsBoxValidation

Box-size validation against GROMACS nonbonded cutoffs.

gro_path: pathlib.Path
mdp_path: pathlib.Path
box_vectors_nm: tuple[float, ...]
shortest_box_vector_nm: float
cutoffs_nm: dict[str, float]
property max_cutoff_nm: float | None
property valid: bool
class iphasimulator.simulation_gromacs_runner.GromacsSolvationFiles

Files generated for the standard GROMACS solvate/genion workflow.

output_dir: pathlib.Path
ions_mdp_path: pathlib.Path
solvation_itp_paths: tuple[pathlib.Path, ...]
solvent_itp_path: pathlib.Path
cation_itp_path: pathlib.Path
anion_itp_path: pathlib.Path
solvate_script_path: pathlib.Path
local_script_path: pathlib.Path
hpc_script_path: pathlib.Path
charmm_gui_membrane_hpc_script_path: pathlib.Path
property tip3p_ions_itp_path: pathlib.Path

Backward-compatible alias for older callers.

class iphasimulator.simulation_gromacs_runner.GromacsSolvatedTopologyValidation

Water and ion molecule counts parsed from a GROMACS topology.

topol_top_path: pathlib.Path
molecule_counts: dict[str, int]
water_count: int
cation_count: int
anion_count: int
property sodium_count: int

Backward-compatible alias; may include POT/K in newer workflows.

property chloride_count: int

Backward-compatible alias for anion count.

property has_water: bool
property has_ions: bool
class iphasimulator.simulation_gromacs_runner.GromacsGromppValidation

Result of a lightweight GROMACS grompp validation command.

command: tuple[str, ...]
returncode: int
stdout: str
stderr: str
property ok: bool
class iphasimulator.simulation_gromacs_runner.GromacsCoordinateTopologyValidation

Atom-count comparison between a GRO coordinate file and topology.

gro_path: pathlib.Path
topol_top_path: pathlib.Path
coordinate_atom_count: int
molecule_counts: dict[str, int]
molecule_atom_counts: dict[str, int]
expected_atom_count: int | None
property can_compare: bool
property valid: bool
iphasimulator.simulation_gromacs_runner.GROMACS_POLYMER_MDP_TEMPLATE_NAMES = ('step6.0_minimization.mdp', 'step6.1_nvt.mdp', 'step6.2_npt.mdp', 'step7_production.mdp')
iphasimulator.simulation_gromacs_runner.GROMACS_CHARMM_GUI_MEMBRANE_MDP_TEMPLATE_NAMES = ('step6.0_minimization.mdp', 'step6.1_equilibration.mdp', 'step6.2_equilibration.mdp',...
iphasimulator.simulation_gromacs_runner.GROMACS_MDP_TEMPLATE_NAMES = ('step6.0_minimization.mdp', 'step6.1_nvt.mdp', 'step6.2_npt.mdp', 'step7_production.mdp')
iphasimulator.simulation_gromacs_runner.GROMACS_ALL_MDP_TEMPLATE_NAMES = ('step6.0_minimization.mdp', 'step6.1_nvt.mdp', 'step6.2_npt.mdp', 'step7_production.mdp',...
iphasimulator.simulation_gromacs_runner.GROMACS_WORKFLOW_MDP_TEMPLATE_NAMES
iphasimulator.simulation_gromacs_runner.INCLUDE_PATTERN
iphasimulator.simulation_gromacs_runner.LOCAL_MINIMIZATION_REQUIRED_FILENAMES = ('step5_input.gro', 'topol.top', 'index.ndx', 'step6.0_minimization.mdp', 'run_step6_local.sh')
iphasimulator.simulation_gromacs_runner.MDP_CUTOFF_KEYS = ('rlist', 'rcoulomb', 'rvdw')
iphasimulator.simulation_gromacs_runner.WATER_MOLECULE_NAMES = ('SOL', 'WAT', 'TIP3', 'TIP3P', 'HOH')
iphasimulator.simulation_gromacs_runner.CATION_MOLECULE_NAMES = ('SOD', 'NA', 'NA+', 'POT', 'K', 'K+')
iphasimulator.simulation_gromacs_runner.ANION_MOLECULE_NAMES = ('CLA', 'CL', 'CL-')
iphasimulator.simulation_gromacs_runner.GROMACS_SOLVATION_TEMPLATE_DIR = 'data/gromacs_solvation'
iphasimulator.simulation_gromacs_runner.GROMACS_SOLVATION_TEMPLATE_NAMES = ('ions.mdp', 'tip3_ions_atomtypes.itp', 'TIP3_SOL.itp', 'TIP3.itp', 'SOD.itp', 'POT.itp', 'CLA.itp')
iphasimulator.simulation_gromacs_runner.GROMACS_SOLVATION_TOPOLOGY_INCLUDE_NAMES = ('tip3_ions_atomtypes.itp', 'TIP3_SOL.itp', 'SOD.itp', 'CLA.itp')
iphasimulator.simulation_gromacs_runner.MINIM_MDP = Multiline-String
Show Value
"""; 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
"""
iphasimulator.simulation_gromacs_runner.NVT_MDP = Multiline-String
Show Value
"""; 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
"""
iphasimulator.simulation_gromacs_runner.NPT_MDP = Multiline-String
Show Value
"""; 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
"""
iphasimulator.simulation_gromacs_runner.PRODUCTION_MDP = Multiline-String
Show Value
"""; 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
"""
iphasimulator.simulation_gromacs_runner.write_gromacs_run_files(output_dir: str | pathlib.Path, system_name: str = 'system') → GromacsRunFiles

Write basic GROMACS mdp files and a staged run script.

iphasimulator.simulation_gromacs_runner.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.

iphasimulator.simulation_gromacs_runner.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.

iphasimulator.simulation_gromacs_runner.GROMACS_WORKFLOW_HPC_STEPS
iphasimulator.simulation_gromacs_runner.count_gro_atoms(gro_path: str | pathlib.Path) → int

Read the atom count from the second line of a GROMACS .gro file.

iphasimulator.simulation_gromacs_runner.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.

iphasimulator.simulation_gromacs_runner.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.

iphasimulator.simulation_gromacs_runner.validate_gromacs_solvated_topology(output_dir: str | pathlib.Path, *, topology_name: str = 'topol.top') → GromacsSolvatedTopologyValidation

Validate that topology molecule counts include solvent and ions.

iphasimulator.simulation_gromacs_runner.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.

iphasimulator.simulation_gromacs_runner.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.

iphasimulator.simulation_gromacs_runner.check_gromacs_minimization_inputs(output_dir: str | pathlib.Path) → GromacsLocalMinimizationCheck

Check the files needed before running local GROMACS minimisation.

iphasimulator.simulation_gromacs_runner.run_gromacs_local_minimization(output_dir: str | pathlib.Path, *, runner=subprocess.run) → subprocess.CompletedProcess

Run the local minimisation script from inside the GROMACS folder.

iphasimulator.simulation_gromacs_runner.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.