Skip to content

Commit 0effc8e

Browse files
authored
Merge pull request #375 from OpenBioSim/fix_sire_265
Add test to validate correct update of triclinic box vectors in SOMD
2 parents b136f91 + 3f9e852 commit 0effc8e

File tree

2 files changed

+94
-2
lines changed

2 files changed

+94
-2
lines changed

tests/Process/test_somd.py

+46-1
Original file line numberDiff line numberDiff line change
@@ -129,11 +129,56 @@ def test_pert_res_num(perturbable_system):
129129
assert unique1[0] == "perturbed residue number = 2"
130130

131131

132+
def test_triclinic():
133+
"""
134+
Test the triclinic box vectors can be updated correctly with OpenMM 8.2+.
135+
"""
136+
137+
# Load the triclinic alanine dipeptide system.
138+
system = BSS.IO.readMolecules(
139+
BSS.IO.expand(url, ["ala_triclinic.rst7", "ala_triclinic.prm7"])
140+
)
141+
142+
# Create a short production protocol.
143+
protocol = BSS.Protocol.Production(runtime=BSS.Types.Time(0.001, "nanoseconds"))
144+
145+
# Run the process, check that it finished without error, and returns a system.
146+
run_process(system, protocol)
147+
148+
149+
def test_triclinic_fep():
150+
"""
151+
Test the triclinic box vectors can be updated correctly with OpenMM 8.2+.
152+
"""
153+
154+
# Load the triclinic alanine dipeptide system.
155+
system = BSS.IO.readPerturbableSystem(
156+
*BSS.IO.expand(
157+
url,
158+
[
159+
"ethane_methanol_triclinic0.prm7",
160+
"ethane_methanol_triclinic0.rst7",
161+
"ethane_methanol_triclinic1.prm7",
162+
"ethane_methanol_triclinic1.rst7",
163+
],
164+
)
165+
)
166+
167+
# Create a short production FEP protocol.
168+
protocol = BSS.Protocol.FreeEnergy(runtime=0.1 * BSS.Units.Time.picosecond)
169+
170+
# Run the process, check that it finished without error, and returns a system.
171+
run_process(system, protocol)
172+
173+
132174
def run_process(system, protocol):
133175
"""Helper function to run various simulation protocols."""
134176

177+
# Use CUDA platform is CUDA_VISIBLE_DEVICES is set.
178+
platform = "CUDA" if "CUDA_VISIBLE_DEVICES" in os.environ else "CPU"
179+
135180
# Initialise the SOMD process.
136-
process = BSS.Process.Somd(system, protocol, name="test", platform="CPU")
181+
process = BSS.Process.Somd(system, protocol, name="test", platform=platform)
137182

138183
# Start the SOMD simulation.
139184
process.start()

tests/Sandpit/Exscientia/Process/test_somd.py

+48-1
Original file line numberDiff line numberDiff line change
@@ -269,11 +269,58 @@ def test_restraint_mdr(tmp_path, restraint_mdr):
269269
assert "permanent distance restraints dictionary" in lines[-1]
270270

271271

272+
def test_triclinic():
273+
"""
274+
Test the triclinic box vectors can be updated correctly with OpenMM 8.2+.
275+
"""
276+
277+
# Load the triclinic alanine dipeptide system.
278+
system = BSS.IO.readMolecules(
279+
BSS.IO.expand(url, ["ala_triclinic.rst7", "ala_triclinic.prm7"])
280+
)
281+
282+
# Create a short production protocol.
283+
protocol = BSS.Protocol.Production(runtime=BSS.Types.Time(0.001, "nanoseconds"))
284+
285+
# Run the process, check that it finished without error, and returns a system.
286+
run_process(system, protocol)
287+
288+
289+
def test_triclinic_fep():
290+
"""
291+
Test the triclinic box vectors can be updated correctly with OpenMM 8.2+.
292+
"""
293+
294+
# Load the triclinic alanine dipeptide system.
295+
system = BSS.IO.readPerturbableSystem(
296+
*BSS.IO.expand(
297+
url,
298+
[
299+
"ethane_methanol_triclinic0.prm7",
300+
"ethane_methanol_triclinic0.rst7",
301+
"ethane_methanol_triclinic1.prm7",
302+
"ethane_methanol_triclinic1.rst7",
303+
],
304+
)
305+
)
306+
307+
# Create a short production FEP protocol.
308+
protocol = BSS.Protocol.FreeEnergy(runtime=0.1 * BSS.Units.Time.picosecond)
309+
310+
# Run the process, check that it finished without error, and returns a system.
311+
run_process(system, protocol)
312+
313+
272314
def run_process(system, protocol, **kwargs):
273315
"""Helper function to run various simulation protocols."""
274316

317+
# Use CUDA platform is CUDA_VISIBLE_DEVICES is set.
318+
platform = "CUDA" if "CUDA_VISIBLE_DEVICES" in os.environ else "CPU"
319+
275320
# Initialise the SOMD process.
276-
process = BSS.Process.Somd(system, protocol, name="test", platform="CPU", **kwargs)
321+
process = BSS.Process.Somd(
322+
system, protocol, name="test", platform=platform, **kwargs
323+
)
277324

278325
# Start the SOMD simulation.
279326
process.start()

0 commit comments

Comments
 (0)