Skip to content

Commit

Permalink
adopt names
Browse files Browse the repository at this point in the history
  • Loading branch information
wiederm committed Apr 18, 2024
1 parent 14243fe commit 7a0be53
Show file tree
Hide file tree
Showing 10 changed files with 47 additions and 58 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ There is an example `test_config.yaml` file provided in the `scripts` directory
For a stability test using a pure 15 Angstrom waterbox the `config.yaml` file may look like this
```
tests:
- protocol: "waterbox_protocol" # which protocol is performed
- protocol: "waterbox_test" # which protocol is performed
edge_length: 15 # waterbox edge length in Angstrom
ensemble: "NVT" # thermodynamic esamble that is used. Oter options are 'NpT' and 'NVE'.
nnp: "ani2x" # the NNP used
Expand Down
36 changes: 13 additions & 23 deletions guardowl/protocols.py
Original file line number Diff line number Diff line change
Expand Up @@ -398,7 +398,7 @@ def perform_stability_test(self, parms: StabilityTestParameters) -> None:
self._run_simulation(_parms, qsim)


def run_hipen_protocol(
def run_hipen_test(
hipen_idx: Union[int, List[int]],
nnp: str,
temperature: Union[int, List[int]],
Expand Down Expand Up @@ -438,15 +438,11 @@ def run_hipen_protocol(
def _run_protocol(hipen_idx: int):
name = list(TestsystemFactory._HIPEN_SYSTEMS.keys())[hipen_idx]

log.info(
f"Performing vacuum stability test for {name} using {nnp}."
)
log.info(f"Performing vacuum stability test for {name} using {nnp}.")
opt = SmallMoleculeVacuumOption(name)

testsystem = TestsystemFactory().generate_testsystem(opt)
system = SystemFactory.initialize_system(
nnp, testsystem.topology
)
system = SystemFactory.initialize_system(nnp, testsystem.topology)
log_file_name = f"vacuum_{name}_{nnp}"

# Select protocol based on whether temperature is a list or a single value
Expand Down Expand Up @@ -482,7 +478,7 @@ def _run_protocol(hipen_idx: int):
_run_protocol(idx)


def run_waterbox_protocol(
def run_waterbox_test(
edge_length: int,
ensemble: str,
nnp: str,
Expand Down Expand Up @@ -565,7 +561,7 @@ def run_waterbox_protocol(
log.info(f"Simulation files saved to {output_folder}")


def run_pure_liquid_protocol(
def run_organic_liquid_test(
molecule_name: Union[str, List[str]],
nr_of_molecule: Union[int, List[int]],
ensemble: str,
Expand Down Expand Up @@ -627,14 +623,14 @@ def run_pure_liquid_protocol(

opt = LiquidOption(name, nr_of_molecules)
testsystem = TestsystemFactory().generate_testsystem(opt)
system = SystemFactory.initialize_system(
nnp, testsystem.topology
)
system = SystemFactory.initialize_system(nnp, testsystem.topology)

temperature_str = (
f"{temperature}K" if isinstance(temperature, int) else "multi-temp"
)
log_file_name = f"pure_liquid_{name}_{nr_of_molecules}_{nnp}_{ensemble}_{temperature_str}"
log_file_name = (
f"pure_liquid_{name}_{nr_of_molecules}_{nnp}_{ensemble}_{temperature_str}"
)

log.info(f"Simulation output will be written to {log_file_name}")

Expand Down Expand Up @@ -662,7 +658,7 @@ def run_pure_liquid_protocol(
from typing import Literal


def run_alanine_dipeptide_protocol(
def run_alanine_dipeptide_test(
nnp: str,
temperature: int,
reporter: StateDataReporter,
Expand Down Expand Up @@ -769,9 +765,7 @@ def run_DOF_scan(
The name of the molecule for simulation, defaults to 'ethanol'.
"""
log.info(
f"Initiating DOF scan for {name} using {nnp}."
)
log.info(f"Initiating DOF scan for {name} using {nnp}.")

from guardowl.protocols import BondProfileProtocol, DOFTestParameters
from guardowl.testsystems import TestsystemFactory, SmallMoleculeVacuumOption
Expand Down Expand Up @@ -926,9 +920,7 @@ def _above_threshold(mol: Chem.Mol) -> bool:
continue
# set the minimized positions
reference_testsystem.positions = minimized_position
system = SystemFactory.initialize_system(
nnp, reference_testsystem.topology
)
system = SystemFactory.initialize_system(nnp, reference_testsystem.topology)
log_file_name = f"ref_{name}_{nnp}"

params = MinimizationTestParameters(
Expand All @@ -952,9 +944,7 @@ def _above_threshold(mol: Chem.Mol) -> bool:
minimize_testsystem = reference_testsystem
minimize_testsystem.positions = start_position

system = SystemFactory.initialize_system(
nnp, minimize_testsystem.topology
)
system = SystemFactory.initialize_system(nnp, minimize_testsystem.topology)
log_file_name = f"minimize_{name}_{nnp}"

params = MinimizationTestParameters(
Expand Down
2 changes: 1 addition & 1 deletion guardowl/tests/stability_test_alanine_dipeptide.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# config.yaml
tests:
- protocol: "alanine_dipeptide_protocol"
- protocol: "alanine_dipeptide_test"
env: "vacuum"
ensemble: "npt"
nnp: "ani2x"
Expand Down
4 changes: 2 additions & 2 deletions guardowl/tests/stability_test_hipen.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# config.yaml
tests:
- protocol: "hipen_protocol"
hipen_idx: [0,1]
- protocol: "hipen_test"
hipen_idx: [0, 1]
nnp: "ani2x"
temperature: 300
nr_of_simulation_steps: 5
2 changes: 1 addition & 1 deletion guardowl/tests/stability_test_pure_liquid.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# config.yaml
tests:
- protocol: "pure_liquid_protocol"
- protocol: "organic_liquid_test"
molecule_name: ["ethane", "butane"]
nr_of_molecule: [10, 20]
ensemble: "npt"
Expand Down
2 changes: 1 addition & 1 deletion guardowl/tests/stability_test_waterbox.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# config.yaml
tests:
- protocol: "waterbox_protocol"
- protocol: "waterbox_test"
edge_length: 5
ensemble: "npt"
nnp: "ani2x"
Expand Down
25 changes: 12 additions & 13 deletions guardowl/tests/test_stability_protocol.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ def test_setup_vacuum_protocol_individual_parts(

@pytest.mark.parametrize("params", get_available_nnps())
def test_run_vacuum_protocol(params: Dict[str, Tuple[str, int, float]]) -> None:
from guardowl.protocols import run_hipen_protocol
from guardowl.protocols import run_hipen_test

reporter = StateDataReporter(
file=None, # it is necessary to set this to None since it otherwise can't be passed to mp
Expand All @@ -95,7 +95,7 @@ def test_run_vacuum_protocol(params: Dict[str, Tuple[str, int, float]]) -> None:
output_folder = "test_stability_protocol"
nnp_instance = PotentialFactory().initialize_potential(params)

run_hipen_protocol(
run_hipen_test(
1,
nnp_instance,
300,
Expand All @@ -108,7 +108,7 @@ def test_run_vacuum_protocol(params: Dict[str, Tuple[str, int, float]]) -> None:

@pytest.mark.parametrize("ensemble", ["NVE", "NVT", "NpT"])
@pytest.mark.parametrize("params", get_available_nnps())
def test_setup_waterbox_protocol_individual_parts(
def test_setup_waterbox_test_individual_parts(
ensemble: str, params: Dict[str, Tuple[str, int, float]], temperature: int = 300
) -> None:
"""Test if we can run a simulation for a number of steps"""
Expand All @@ -120,7 +120,6 @@ def test_setup_waterbox_protocol_individual_parts(
testsystem = TestsystemFactory().generate_testsystem(opt)
nnp_instance = PotentialFactory().initialize_potential(params)


system = SystemFactory().initialize_system(
nnp_instance,
testsystem.topology,
Expand Down Expand Up @@ -168,10 +167,10 @@ def test_setup_waterbox_protocol_individual_parts(

@pytest.mark.parametrize("ensemble", ["NVE", "NVT", "NpT"])
@pytest.mark.parametrize("params", get_available_nnps())
def test_run_waterbox_protocol(
def test_run_waterbox_test(
ensemble: str, params: Dict[str, Tuple[str, int, float]]
) -> None:
from guardowl.protocols import run_waterbox_protocol
from guardowl.protocols import run_waterbox_test

reporter = StateDataReporter(
file=None, # it is necessary to set this to None since it otherwise can't be passed to mp
Expand All @@ -188,7 +187,7 @@ def test_run_waterbox_protocol(
output_folder = "test_stability_protocol"
nnp_instance = PotentialFactory().initialize_potential(params)

run_waterbox_protocol(
run_waterbox_test(
5,
ensemble,
nnp_instance,
Expand All @@ -204,10 +203,10 @@ def test_run_waterbox_protocol(
@pytest.mark.parametrize("environment", ["vacuum", "solution"])
@pytest.mark.parametrize("ensemble", ["NVE", "NVT", "NpT"])
@pytest.mark.parametrize("params", get_available_nnps())
def test_run_alanine_dipeptide_protocol(
def test_run_alanine_dipeptide_test(
environment: str, ensemble: str, params: Dict[str, Tuple[str, int, float]]
) -> None:
from guardowl.protocols import run_alanine_dipeptide_protocol
from guardowl.protocols import run_alanine_dipeptide_test

reporter = StateDataReporter(
file=None, # it is necessary to set this to None since it otherwise can't be passed to mp
Expand All @@ -223,7 +222,7 @@ def test_run_alanine_dipeptide_protocol(
platform = get_fastest_platform()
output_folder = "test_stability_protocol"
nnp_instance = PotentialFactory().initialize_potential(params)
run_alanine_dipeptide_protocol(
run_alanine_dipeptide_test(
nnp_instance,
300,
reporter,
Expand All @@ -237,10 +236,10 @@ def test_run_alanine_dipeptide_protocol(

@pytest.mark.parametrize("ensemble", ["NVE", "NVT", "NpT"])
@pytest.mark.parametrize("params", get_available_nnps())
def test_run_pure_liquid_protocol(
def test_run_organic_liquid_test(
ensemble: str, params: Dict[str, Tuple[str, int, float]]
) -> None:
from guardowl.protocols import run_pure_liquid_protocol
from guardowl.protocols import run_organic_liquid_test

reporter = StateDataReporter(
file=None, # it is necessary to set this to None since it otherwise can't be passed to mp
Expand All @@ -258,7 +257,7 @@ def test_run_pure_liquid_protocol(
output_folder = "test_stability_protocol"
nnp_instance = PotentialFactory().initialize_potential(params)

run_pure_liquid_protocol(
run_organic_liquid_test(
nnp=nnp_instance,
temperature=300,
reporter=reporter,
Expand Down
2 changes: 1 addition & 1 deletion scripts/alanine.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# config.yaml
tests:
- protocol: "perform_alanine_dipeptide_protocol"
- protocol: "perform_alanine_dipeptide_test"
env: "solution"
ensemble: "npt"
nnp: "ani2x"
Expand Down
16 changes: 8 additions & 8 deletions scripts/perform_stability_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -139,17 +139,17 @@ def process_test(test: Dict[str, Any], platform: Platform, output: str) -> None:
"""
from guardowl.protocols import (
run_DOF_scan,
run_hipen_protocol,
run_waterbox_protocol,
run_alanine_dipeptide_protocol,
run_pure_liquid_protocol,
run_hipen_test,
run_waterbox_test,
run_alanine_dipeptide_test,
run_organic_liquid_test,
)

protocol_function = {
"hipen_protocol": run_hipen_protocol,
"waterbox_protocol": run_waterbox_protocol,
"alanine_dipeptide_protocol": run_alanine_dipeptide_protocol,
"pure_liquid_protocol": run_pure_liquid_protocol,
"hipen_test": run_hipen_test,
"waterbox_test": run_waterbox_test,
"alanine_dipeptide_test": run_alanine_dipeptide_test,
"organic_liquid_test": run_organic_liquid_test,
"DOF_scan": run_DOF_scan,
}.get(test.get("protocol"))

Expand Down
14 changes: 7 additions & 7 deletions scripts/test_config.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# config.yaml
potentials:
- physicsml-model:
- model_name: 'MACE'
- model_name: "MACE"
- precision: 64
- position_scaling: 10.0
- output_scaling: 4.184 * 627
Expand All @@ -11,45 +11,45 @@ potentials:
- model_name: "ANI2x"

tests:
- protocol: "alanine_dipeptide_protocol"
- protocol: "alanine_dipeptide_test"
env: "solution"
ensemble: "npt"
nnp: "ani2x"
annealing: false
nr_of_simulation_steps: 50
temperature: 300

- protocol: "alanine_dipeptide_protocol"
- protocol: "alanine_dipeptide_test"
env: "vacuum"
ensemble: "npt"
nnp: "ani2x"
annealing: false
nr_of_simulation_steps: 500
temperature: 300

- protocol: "hipen_protocol"
- protocol: "hipen_test"
hipen_idx: [0, 1, 15]
nnp: "ani2x"
temperature: [300, 400, 500]
nr_of_simulation_steps: 500

- protocol: "waterbox_protocol"
- protocol: "waterbox_test"
edge_length: 25
ensemble: "npt"
nnp: "ani2x"
annealing: false
nr_of_simulation_steps: 50
temperature: 300

- protocol: "waterbox_protocol"
- protocol: "waterbox_test"
edge_length: 25
ensemble: "npt"
nnp: "ani2x"
annealing: false
nr_of_simulation_steps: 50
temperature: 500

- protocol: "pure_liquid_protocol"
- protocol: "organic_liquid_test"
molecule_name: ["ethane", "butane", "methanol"]
nr_of_molecule: [100, 200, 300]
ensemble: "npt"
Expand Down

0 comments on commit 7a0be53

Please sign in to comment.