Skip to content

Commit

Permalink
Merge pull request #375 from OpenBioSim/fix_sire_265
Browse files Browse the repository at this point in the history
Add test to validate correct update of triclinic box vectors in SOMD
  • Loading branch information
lohedges authored Dec 13, 2024
2 parents b136f91 + 3f9e852 commit 0effc8e
Show file tree
Hide file tree
Showing 2 changed files with 94 additions and 2 deletions.
47 changes: 46 additions & 1 deletion tests/Process/test_somd.py
Original file line number Diff line number Diff line change
Expand Up @@ -129,11 +129,56 @@ def test_pert_res_num(perturbable_system):
assert unique1[0] == "perturbed residue number = 2"


def test_triclinic():
"""
Test the triclinic box vectors can be updated correctly with OpenMM 8.2+.
"""

# Load the triclinic alanine dipeptide system.
system = BSS.IO.readMolecules(
BSS.IO.expand(url, ["ala_triclinic.rst7", "ala_triclinic.prm7"])
)

# Create a short production protocol.
protocol = BSS.Protocol.Production(runtime=BSS.Types.Time(0.001, "nanoseconds"))

# Run the process, check that it finished without error, and returns a system.
run_process(system, protocol)


def test_triclinic_fep():
"""
Test the triclinic box vectors can be updated correctly with OpenMM 8.2+.
"""

# Load the triclinic alanine dipeptide system.
system = BSS.IO.readPerturbableSystem(
*BSS.IO.expand(
url,
[
"ethane_methanol_triclinic0.prm7",
"ethane_methanol_triclinic0.rst7",
"ethane_methanol_triclinic1.prm7",
"ethane_methanol_triclinic1.rst7",
],
)
)

# Create a short production FEP protocol.
protocol = BSS.Protocol.FreeEnergy(runtime=0.1 * BSS.Units.Time.picosecond)

# Run the process, check that it finished without error, and returns a system.
run_process(system, protocol)


def run_process(system, protocol):
"""Helper function to run various simulation protocols."""

# Use CUDA platform is CUDA_VISIBLE_DEVICES is set.
platform = "CUDA" if "CUDA_VISIBLE_DEVICES" in os.environ else "CPU"

# Initialise the SOMD process.
process = BSS.Process.Somd(system, protocol, name="test", platform="CPU")
process = BSS.Process.Somd(system, protocol, name="test", platform=platform)

# Start the SOMD simulation.
process.start()
Expand Down
49 changes: 48 additions & 1 deletion tests/Sandpit/Exscientia/Process/test_somd.py
Original file line number Diff line number Diff line change
Expand Up @@ -269,11 +269,58 @@ def test_restraint_mdr(tmp_path, restraint_mdr):
assert "permanent distance restraints dictionary" in lines[-1]


def test_triclinic():
"""
Test the triclinic box vectors can be updated correctly with OpenMM 8.2+.
"""

# Load the triclinic alanine dipeptide system.
system = BSS.IO.readMolecules(
BSS.IO.expand(url, ["ala_triclinic.rst7", "ala_triclinic.prm7"])
)

# Create a short production protocol.
protocol = BSS.Protocol.Production(runtime=BSS.Types.Time(0.001, "nanoseconds"))

# Run the process, check that it finished without error, and returns a system.
run_process(system, protocol)


def test_triclinic_fep():
"""
Test the triclinic box vectors can be updated correctly with OpenMM 8.2+.
"""

# Load the triclinic alanine dipeptide system.
system = BSS.IO.readPerturbableSystem(
*BSS.IO.expand(
url,
[
"ethane_methanol_triclinic0.prm7",
"ethane_methanol_triclinic0.rst7",
"ethane_methanol_triclinic1.prm7",
"ethane_methanol_triclinic1.rst7",
],
)
)

# Create a short production FEP protocol.
protocol = BSS.Protocol.FreeEnergy(runtime=0.1 * BSS.Units.Time.picosecond)

# Run the process, check that it finished without error, and returns a system.
run_process(system, protocol)


def run_process(system, protocol, **kwargs):
"""Helper function to run various simulation protocols."""

# Use CUDA platform is CUDA_VISIBLE_DEVICES is set.
platform = "CUDA" if "CUDA_VISIBLE_DEVICES" in os.environ else "CPU"

# Initialise the SOMD process.
process = BSS.Process.Somd(system, protocol, name="test", platform="CPU", **kwargs)
process = BSS.Process.Somd(
system, protocol, name="test", platform=platform, **kwargs
)

# Start the SOMD simulation.
process.start()
Expand Down

0 comments on commit 0effc8e

Please sign in to comment.