Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
173 commits
Select commit Hold shift + click to select a range
3e2d734
Add CLI entry-point for Boresch ghost atom modifications.
lohedges Feb 25, 2025
40a5958
Fix formatting of output name. (Prefix only.) [ci skip]
lohedges Feb 25, 2025
4827b56
Add __all__ to CLI module. [ci skip]
lohedges Feb 25, 2025
4d9a991
Use input file name as base for output by default.
lohedges Feb 26, 2025
56fc0d9
Update environment for GCMC.
lohedges May 14, 2025
b67efda
Add GCMC configuration options and validation.
lohedges May 16, 2025
bed7677
GCMC configuration handling and self-consistency checks.
lohedges May 16, 2025
9096415
Fix post equilibration minimisation.
lohedges May 16, 2025
cdcd68d
Implemented per-lambda GCMC for base runner.
lohedges May 16, 2025
ca0e73b
Separate the SOMD2 and GCMC log levels.
lohedges May 16, 2025
cba820e
Set gcmc_kwargs to None if not performing GCMC.
lohedges May 19, 2025
d170705
Need unique GCMC log and ghost file for each lambda.
lohedges May 19, 2025
62dce3b
Added GCMC implementation for replica exchange.
lohedges May 19, 2025
99d951a
Unable to decouple SOMD2 and GCMC loggers.
lohedges May 19, 2025
a9bac0b
Log GCMC moves.
lohedges May 19, 2025
1dfcdfc
Write final ghost residue indices. [ci skip]
lohedges May 19, 2025
b5bbc42
Manually compute timings so they include GCMC sampling time.
lohedges May 19, 2025
fef2286
Logging tweaks. [ci skip]
lohedges May 19, 2025
00e7f95
Add GCMC move to equilibration stage.
lohedges May 19, 2025
04c99f6
Use PDB topology format for GCMC simulations.
lohedges May 20, 2025
cae9eba
Use 'ratio' rather than 'scale' for clarity.
lohedges May 20, 2025
793017d
Enable replica exchange to work with NVT.
lohedges May 20, 2025
6c746c3
Pass GCMC specific kwargs to DynamicsCache constructor.
lohedges May 20, 2025
5890c5b
Pass GCMC kwargs through to _create_dynamics method. [ci skip]
lohedges May 20, 2025
2f1a45c
Fix module name. [ci skip]
lohedges May 20, 2025
3d188ab
Pass output directory to DynamicsCache constructor.
lohedges May 20, 2025
d977c10
Create instance of GCMCSampler, then append to list.
lohedges May 20, 2025
811d10a
Fix log messages. [ci skip]
lohedges May 20, 2025
32e936f
Fix name clashes caused by manual timer.
lohedges May 20, 2025
95077e2
No need to convert to int. [ci skip]
lohedges May 20, 2025
da3cadb
Requires manual context management via push and pop.
lohedges May 20, 2025
d1043e0
PyCUDA context management now handled by GCMCSampler.
lohedges May 21, 2025
ac2487a
Consolidate saving of end-state topology to single place.
lohedges May 21, 2025
de3bd9c
PyCUDA context needs to be pushed and popped by the thread.
lohedges May 21, 2025
85921dd
Use d.context() for clarity.
lohedges May 21, 2025
29c78f3
Swap GCMC water state when mixing replicas.
lohedges May 21, 2025
59746e1
Call .context() on Dynamics not DynamicsData object.
lohedges May 21, 2025
3596fc4
Switch position of ghost residue writing.
lohedges May 22, 2025
0da38fd
Use NumPy to find water indices where state differs between replicas.
lohedges May 22, 2025
a02eafe
Make sure we store a copy of the water state array.
lohedges May 22, 2025
7302e48
Improve logging of water state swaps. [ci skip]
lohedges May 22, 2025
1bf1fdf
Rename attribute: self._gcmc --> self._gcmc_samplers.
lohedges May 22, 2025
cc6210d
Grammar tweak. [ci skip]
lohedges May 22, 2025
09de1b5
GCMC and real waters are no longer differentiated. [ci skip]
lohedges May 23, 2025
4a98573
Change parameter name. [ci skip]
lohedges May 23, 2025
5773604
Flag ghost waters when checkpointing.
lohedges May 23, 2025
ff105ce
Remove ghost waters from GCMC checkpoint systems.
lohedges May 23, 2025
e7c1469
Initialise gcmc_sampler array with NoneType entries.
lohedges May 24, 2025
7ca5216
Consolidate water state updates.
lohedges May 24, 2025
e5841f9
Separate per-block and average timings.
lohedges May 24, 2025
7579bed
Report average speed correctly.
lohedges May 24, 2025
701d55e
Fix indentation of return statement. [ci skip]
lohedges May 24, 2025
5abd7e7
Fix variable names. [ci skip]
lohedges May 24, 2025
3a98b8c
Remove unused variable. [ci skip]
lohedges May 24, 2025
8bb1b0b
Standardise variable name. [ci skip]
lohedges May 24, 2025
e1ca4e4
Clarify performance logging. [ci skip]
lohedges May 27, 2025
00b367e
Add GCMC term to energy.
lohedges May 27, 2025
b501770
Pass through GCMC specific options to dynamics.run().
lohedges May 27, 2025
2f4359f
Access list, not object directly. [ci skip]
lohedges May 27, 2025
a7f7581
Pass excess chemical potential, not Adams value. [ci skip]
lohedges May 27, 2025
d82606c
Missing beta factor for GCMC term. [ci skip]
lohedges May 27, 2025
f7e1043
Energy now already includes pressure and GC term.
lohedges May 27, 2025
609a1a2
No need to store volume. [ci skip]
lohedges May 27, 2025
6c69768
Add missing NumPy import. [ci skip]
lohedges May 27, 2025
8dc0d5c
Enforce NVT for GCMC.
lohedges May 28, 2025
0805d92
GCMC currently only supported on CUDA platform. [ci skip]
lohedges May 28, 2025
c2c2694
Standardise logger output. [ci skip]
lohedges May 28, 2025
b947064
Fix ghost file name for repex simulation. [ci skip]
lohedges May 28, 2025
d86fcfb
Only reconstruct SOMD1 system when ghost atom mods are enabled.
lohedges Jun 2, 2025
a0145f5
Trajectory reconstruction fails with PDB, so use PRM7 too.
lohedges Jun 2, 2025
22cf751
Log the number of waters in the GCMC volume when checkpointing.
lohedges Jun 3, 2025
edfd3d8
Fix method name [ci skip]
lohedges Jun 3, 2025
e451ef2
Log output formatting tweak. [ci skip]
lohedges Jun 4, 2025
af4f704
Need to push/pop the PyCUDA context when logging number of waters.
lohedges Jun 4, 2025
5b6a2f7
Allow GPU oversubscription for regular runner.
lohedges Jun 5, 2025
648fe36
Log the oversubscription factor. [ci skip]
lohedges Jun 5, 2025
0d1acd4
Add section on GPU oversubscription using NVIDIA MPS. [ci skip]
lohedges Jun 6, 2025
8b428d3
Write energy components when a crash occurs.
lohedges Jun 6, 2025
1f53615
Simply fractional time calculation. [ci skip]
lohedges Jun 6, 2025
3f45b7a
Move location of energy component saving. [ci skip]
lohedges Jun 6, 2025
aa374f1
Reset the GCMCSampler following equilibration.
lohedges Jun 6, 2025
ecc1452
Change GCMC parameter name. [ci skip]
lohedges Jun 9, 2025
0133994
Don't evaluate timing statistics on error. [ci skip]
lohedges Jun 9, 2025
f98df3e
Comment tweak. [ci skip]
lohedges Jun 9, 2025
f0d4a40
Set success to False if keyboard interrupt. [ci skip]
lohedges Jun 9, 2025
df2b98e
Return when exception is caught. [ci skip]
lohedges Jun 9, 2025
06f9efa
Typo. [ci skip]
lohedges Jun 9, 2025
1341dcc
Fix formatting of energy components output. [ci skip]
lohedges Jun 9, 2025
b1dc921
No need to store lambda array in parquet metadata. [ci skip]
lohedges Jun 13, 2025
fe607f2
Raise exception if dynamics cache context creation fails. [ci skip]
lohedges Jun 17, 2025
62f2218
Use sys.exit() rather than exit(). [ci skip]
lohedges Jun 17, 2025
7febee4
Use a lock file when checkpointing. [ci skip]
lohedges Jun 18, 2025
34d7acc
Fix parameter name. [ci skip]
lohedges Jun 18, 2025
2f208f9
Use file lock when writing repex stats and state. [ci skip]
lohedges Jun 18, 2025
01f41f3
Don't pickle GCMC samplers. [ci skip]
lohedges Jun 18, 2025
8d53377
Formatting tweak. [ci skip]
lohedges Jun 19, 2025
43a775a
Convert Sire containers to a list when loading config files. [ci skip]
lohedges Jun 20, 2025
71d788c
Convert Sire containers to lists prior to comparison. [ci skip]
lohedges Jun 20, 2025
bd86e57
Reset water state when context is recreated. [ci skip]
lohedges Jun 21, 2025
fc4e764
Merge branch 'main' into feature_gcmc [ci skip]
lohedges Jun 21, 2025
d0b5a6b
Clarify reason for resetting the water state. [ci skip]
lohedges Jun 21, 2025
4dcb75d
Merge branch 'feature_ghostly' into feature_gcmc [ci skip]
lohedges Jun 21, 2025
d756925
Formatting tweaks. [ci skip]
lohedges Jun 21, 2025
f083672
Add GCMC section to README. [ci skip]
lohedges Jun 21, 2025
d0b3ea9
Add link to description of Parquet format. [ci skip]
lohedges Jun 21, 2025
708de44
Use sys.exit() rather than exit(). [ci skip]
lohedges Jun 21, 2025
a24ea0e
Add note that GCMC is currently limited to the CUDA platform. [ci skip]
lohedges Jun 21, 2025
9ac6e91
Fix bug in attempt to not pickle GCMCSampler. [ci skip]
lohedges Jun 23, 2025
b4c24aa
Checkpoint after dynamics block to avoid crash sync issues. [ci skip]
lohedges Jun 23, 2025
160f8f8
Don't reset the time to zero. [ref OpenBioSim/sire#320] [ci skip]
lohedges Jun 25, 2025
393c8d3
Bind GCMC sampler to dynamics object to allow crash recovery. [ci skip]
lohedges Jun 26, 2025
5e2f29a
Fix storing of initial time.
lohedges Jun 26, 2025
92336d7
Use a single GCMC based conditional block. [ci skip]
lohedges Jun 26, 2025
da79206
Fix post-equilibration time reset. [ci skip]
lohedges Jun 26, 2025
e31a7a5
Typo. [ci skip]
lohedges Jun 26, 2025
7dc652d
Fix accidental change to water state update during replica mixing.
lohedges Jun 26, 2025
258e1b6
Decouple ghostly and add as an external dependency. [ci skip]
lohedges Jun 30, 2025
2d16a12
Log ghost modifications. [ci skip]
lohedges Jul 1, 2025
3b01e2b
Set pressure based on the presence of solvent. [ci skip]
lohedges Jul 2, 2025
938372f
Timeout must be a float in seconds. [ci skip]
lohedges Jul 4, 2025
ed9fcb1
Use no cutoff for vacuum. [ci skip]
lohedges Jul 9, 2025
9606076
Save end-state topologies in base class constructor. [ci skip]
lohedges Jul 9, 2025
71e3c5d
Add support for OPC water. [ci skip]
lohedges Jul 10, 2025
a36f0dc
Add link to ghostly repo. [ci skip]
lohedges Aug 15, 2025
6731da8
Use spawn start method for multiprocessing processes. [closes #72]
lohedges Aug 29, 2025
1eef48b
Patch in fix from #73. [ci skip]
lohedges Sep 3, 2025
97556ac
Remove checkpoint_frequency from allowed_diffs. [ref #74]
lohedges Sep 4, 2025
6044747
Use warning level.
lohedges Sep 4, 2025
7be1591
Set start_block to zero when not checkpointing. [ref #74]
lohedges Sep 4, 2025
ef36f2a
Treat restarts for lambda windows independently. [ref #74]
lohedges Sep 4, 2025
1274802
Handle time rounding issues. [ci skip] [ref #74]
lohedges Sep 8, 2025
cc80924
Fix start time index. [ci skip]
lohedges Sep 22, 2025
f9f0d19
Typos. [ci skip]
lohedges Sep 23, 2025
1037a70
Save GCMC system topology to AMBER and PDB format. [ci skip]
lohedges Sep 24, 2025
21d93e2
Create backup files to aid restarts following a crash. [ci skip]
lohedges Sep 25, 2025
c979eec
Add option to restart from backup files. [ci skip]
lohedges Sep 25, 2025
12cffec
Adjust default HMR factor. [ci skip]
lohedges Sep 26, 2025
20f9e5b
Add option to restrict workers for checkpointing. [ci skip]
lohedges Sep 26, 2025
573ca62
Move lock file operations outside of checkpoint function. [ci skip]
lohedges Sep 29, 2025
c86ab10
Pass dynamics kwargs to GCMC sampler constructor. [ci skip]
lohedges Sep 29, 2025
86042a4
Only pass required dynamics kwargs. [ci skip]
lohedges Sep 29, 2025
21274ca
Decouple backup from checkpointing. [ci skip]
lohedges Sep 29, 2025
2c9cfba
Rename previous trajectory file so it isn't cleaned up. [ci skip]
lohedges Sep 29, 2025
9b12054
Fix backup method name. [ci skip]
lohedges Sep 29, 2025
d9d8ad0
Reset GCMC water state when restarting. [ci skip]
lohedges Sep 30, 2025
70451d7
Reset default HMR factor for now. [ci skip]
lohedges Oct 1, 2025
4da4c20
Fix missing format strings. [ci skip]
lohedges Oct 2, 2025
18f79fb
Expose GCMC acceptance tolerance option. [ci skip]
lohedges Oct 2, 2025
5f06daa
Enforce frame_frequency <= checkpoint_frequency [ci skip]
lohedges Oct 3, 2025
64a05db
Handle case where no trajectory frames are written. [ci skip]
lohedges Oct 3, 2025
68fa844
Remove redundant GCMC validation. [ci skip]
lohedges Oct 6, 2025
afc7571
Reset logger attributes for spawned child processes. [ci skip]
lohedges Oct 6, 2025
d8f8c22
Only run CI on default branches and for PRs.
lohedges Oct 6, 2025
0905caf
Save GCMC topology for all indices for non-repex simulations.
lohedges Oct 7, 2025
bb89d20
Fix method name.
lohedges Oct 8, 2025
57c3173
Use new GCMCSampler.bind_dynamics() method.
lohedges Oct 8, 2025
d213ab0
Add support for multi-conformational seeding.
lohedges Oct 9, 2025
42cdf2d
Fix invalid variable name.
lohedges Oct 9, 2025
8c5544d
Simplify multiconformational seeding.
lohedges Oct 9, 2025
cad087b
Pad trajectory chunk file names.
lohedges Oct 9, 2025
192d76e
Add note about temporary file limit issue. [ci skip]
lohedges Oct 21, 2025
0d426e3
Remove redundant attribute.
lohedges Oct 23, 2025
cc1b3ba
Expose membrane barostat surface_tension configuration option.
lohedges Oct 23, 2025
ac0f322
Logging tweak. [ci skip]
lohedges Oct 23, 2025
20cea14
Add note about using Runner class via Python API. [ci skip]
lohedges Oct 23, 2025
f34f4b4
Default to one frame per checkpoint.
lohedges Oct 25, 2025
13a3014
Expose option to adjust the trajectory page size.
lohedges Oct 25, 2025
1851693
Docstring clarification. [ci skip]
lohedges Oct 27, 2025
fe2e20a
Update to recommended RBFE shift_delta value.
lohedges Oct 29, 2025
f712e76
Add swap_end_states option to GCMC kwargs.
lohedges Oct 29, 2025
778d73d
Always save GCMC system, but only at first checkpoint block.
lohedges Oct 29, 2025
e0a3166
Merge branch 'feature_gcmc' into merge_feature_gcmc
lohedges Oct 30, 2025
c74e49b
Add macOS specific environment and handle missing loch package.
lohedges Oct 31, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions .github/workflows/main.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,9 @@ name: Build and test
on:
workflow_dispatch:
push:
branches:
- "**"
branches: [devel, main]
pull_request:
branches:
- "main"
branches: [devel, main]

jobs:
pre_job:
Expand Down Expand Up @@ -36,6 +34,8 @@ jobs:
defaults:
run:
shell: ${{ matrix.platform.shell }}
env:
ENVIRONMENT_FILE: ${{ matrix.platform.name == 'macos' && 'environment_macos.yaml' || 'environment.yaml' }}
steps:
#
- name: Checkout the repository (commit)
Expand All @@ -53,7 +53,7 @@ jobs:
auto-update-conda: true
python-version: ${{ matrix.python-version }}
activate-environment: somd2
environment-file: environment.yaml
environment-file: ${{ env.ENVIRONMENT_FILE }}
miniforge-version: latest
run-post: ${{ matrix.platform.name != 'windows' }}
#
Expand Down
82 changes: 76 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@ conda env create -f environment.yaml

(We recommend using [Miniforge](https://github.com/conda-forge/miniforge).)

> [!NOTE]
> On macOS, you will need to use the `environment_macos.yaml` file instead.

Now install `somd2` into the environment:

```
Expand All @@ -33,8 +36,10 @@ somd2 --help

In order to run an alchemical free-energy simulation you will need to
first create a stream file containing the _perturbable_ system of interest.
This can be created using [BioSimSpace](https://github.com/OpenBioSim/biosimspace). For example, following the tutorial
[here](https://biosimspace.openbiosim.org/versions/2023.4.0/tutorials/hydration_freenrg.html). Once the system is created, it can be streamed to file using, e.g.:
This can be created using [BioSimSpace](https://github.com/OpenBioSim/biosimspace).
For example, following the tutorial
[here](https://biosimspace.openbiosim.org/versions/2023.4.0/tutorials/hydration_freenrg.html).
Once the system is created, it can be streamed to file using, e.g.:

```python
import BioSimSpace as BSS
Expand Down Expand Up @@ -112,12 +117,31 @@ the value of `--rest2-scale`. By passing multiple values for `--rest2-scale`, th
user can fully control the schedule. When doing so, the number of values must
match the number of lambda windows.

## GCMC

SOMD2 also supports grand canonical Monte Carlo (GCMC) water sampling using
the [loch](https://github.com/OpenBioSim/loch) package. This can be enabled
using the `--gcmc` option. To define a GCMC region, use the `--gcmc-selection`
option, which should be a `Sire` selection string that specifies the atoms
defining the centre of geometry for the GCMC region. The radius of the GCMC
sphere can be controlled using the `--gcmc-radius` option. To see all GCMC
related options, run:

```
somd2 --help | grep -A2 ' --gcmc'
```

> [!NOTE]
> GCMC is currently only supported when using the CUDA platform and isn't
> available on macOS, where the `pycuda` package is not available.

## Analysis

Simulation output will be written to the directory specified using the
`--output-directory` parameter. This will contain a number of files, including
Parquet files for the energy trajectories of each λ window. These can be
processed using [BioSimSpace](https://github.com/OpenBioSim/biosimspace) as follows:
[Parquet files](https://en.wikipedia.org/wiki/Apache_Parquet) for the energy
trajectories of each λ window. These can be processed using
[BioSimSpace](https://github.com/OpenBioSim/biosimspace) as follows:

```python
import BioSimSpace as BSS
Expand Down Expand Up @@ -149,6 +173,15 @@ can be controlled via the `--null-energy` option. The number of neighbours shoul
be chosen as a trade off between accuracy and computational cost. A value of around
20% of the number of replicas has been found to be a good starting point.

## Ghost atom modifications

We support modification of ghost atom bonded terms to avoid spurious coupling
to the physical system using the approach described in
[this](https://pubs.acs.org/doi/10.1021/acs.jctc.0c01328) paper.
These are enabled by default, but can be disabled using the ``--no-ghost-modifications``
option. Modifications are implemented using the [ghostly](https://gitbub.com/OpenBioSim/ghostly)
package.

## Note for SOMD1 users

For existing users of `somd1`, it's possible to generate input for `somd2` by passing
Expand Down Expand Up @@ -186,5 +219,42 @@ somd2 somd1.bss --pert-file somd1.pert --somd1-compatibility
(This only shows the limited options required. Others will take default values and can be set accordingly.)

If you want to load an existing system from a perturbation file and use the
new `somd2` ghost atom bonded-term modifications, then simply omit the
`--somd1-compatibility` option.
new `somd2` [ghost atom bonded-term modifications](https://github.com/OpenBioSim/ghostly),
then simply omit the `--somd1-compatibility` option.

## GPU oversubscription

If you have an NVIDIA GPU that supports the multi-process service (MPS), you can
oversubscibe the GPU to run multiple OpenMM contexts on the same GPU at once,
increasing the throughput of your simulation. To do this, you will need to first
enable MPS by running the following command:

```
nvidia-cuda-mps-control -d
```

The number of contexts that can be run in parallel is then controlled by the
`--oversubscription-factor` option, which defaults to 1.

More details on MPS, including tuning options, can be found in the following
[techical blog](https://developer.nvidia.com/blog/maximizing-openmm-molecular-dynamics-throughput-with-nvidia-multi-process-service/).

## Python API

``SOMD2`` can also be used as a Python API, allowing it to be embedded
within other Python scripts. When doing so, it is important to to wrap
code within a ``if __name__ == "__main__":`` block since multiprocessing
is used with the ``spawn`` start method.

**## Known issues**

If using the regular `Runner` class via the Python API, then you will need to
guard calls to its `run()` method within a `if __name__ == "__main__":` block
since it uses multiprocessing with the `spawn` start method.

During a checkpoint cycle trajectory frames are stored in memory before being
paged to disk. When running replica exchange simulations with a large number
of replicas this can lead to exceeding the temporary file storage limit on
some systems, causing the simulation to hang. This can be resolved by either
reducing the frequency at which frames are stored, or checkpointing more.
(Frames are written to disk and cleared from memory at each checkpoint.)
5 changes: 5 additions & 0 deletions environment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,10 @@ channels:
dependencies:
- biosimspace
- git
- filelock
- loguru
- numba
- pycuda
- pip:
- git+https://github.com/openbiosim/ghostly
- git+https://github.com/openbiosim/loch
14 changes: 14 additions & 0 deletions environment_macos.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
name: somd2

channels:
- conda-forge
- openbiosim/label/dev

dependencies:
- biosimspace
- git
- filelock
- loguru
- numba
- pip:
- git+https://github.com/openbiosim/ghostly
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ dynamic = ["version"]
license-files = ["LICENSE"]

[project.scripts]
somd2 = "somd2.app:cli"
somd2 = "somd2.app:somd2"

[project.urls]
repository = "https://github.com/OpenBioSim/somd2"
Expand Down
Loading
Loading