Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add test to validate correct update of triclinic box vectors in SOMD #375

Merged
merged 1 commit into from
Dec 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
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
Loading