From 2ec6b3bc4e5f00a6f6e14982604cb7324681ba05 Mon Sep 17 00:00:00 2001 From: Lester Hedges Date: Wed, 2 Dec 2026 15:04:56 +0000 Subject: [PATCH] Log the system size and generated Boresch restraint. --- CHANGELOG.md | 1 + src/somd2/runner/_base.py | 20 ++++++++++++++++++++ 2 files changed, 21 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 70692cd..f4a60c7 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -52,6 +52,7 @@ Changelog * Log the per-window GCMC, terminal flip and dynamics messages of replica exchange runs at debug level, rather than info, reducing the size of the log by around 30 times. Progress is still logged once per cycle [#298](https://github.com/OpenBioSim/somd2/pull/298). * Fixed an `IndexError` when querying GPU memory if OpenCL enumerates fewer devices than the requested device index, allowing fallback to `pynvml` [#301](https://github.com/OpenBioSim/somd2/pull/301). * Pair the free and vacuum legs of relative perturbations in `somd2-view` and `somd2-summary` to give relative hydration free energies, which were previously only reported for absolute perturbations [#304](https://github.com/OpenBioSim/somd2/pull/304). +* Log the number of atoms and virtual sites in the input system, and the Boresch restraint generated for ABFE bound legs [#307](https://github.com/OpenBioSim/somd2/pull/307). [2026.2.0](https://github.com/openbiosim/somd2/compare/2026.1.0...2026.2.0) - Sep 2026 -------------------------------------------------------------------------------------- diff --git a/src/somd2/runner/_base.py b/src/somd2/runner/_base.py index e8047b0..562ae22 100644 --- a/src/somd2/runner/_base.py +++ b/src/somd2/runner/_base.py @@ -63,6 +63,7 @@ def __init__(self, system, config): """ self._load_system(system) self._set_config(config) + self._log_system_size() self._check_inputs() # The system is fully prepared before the reference copy is stored and @@ -109,6 +110,22 @@ def _load_system(self, system): else: self._system = system.clone() + def _log_system_size(self): + """ + Log the number of atoms and virtual sites in the input system. + """ + try: + num_virtual_sites = sum( + mol.property("n_virtual_sites").as_integer() + for mol in self._system.molecules("property n_virtual_sites") + ) + except KeyError: + num_virtual_sites = 0 + _logger.info( + f"System contains {self._system.num_atoms()} atoms and " + f"{num_virtual_sites} virtual sites." + ) + def _set_config(self, config): """ Validate the configuration and set up the output directory. @@ -1769,6 +1786,9 @@ def _add_boresch_restraint(self, device=None): _logger.error(msg) raise RuntimeError(msg) + for restraint in restraints: + _logger.info(f"Boresch restraint: {restraint}") + self._dynamics_kwargs["restraints"] = ( self._dynamics_kwargs["restraints"] or [] ) + [restraints]