Skip to content

Commit

Permalink
Allow ensemble type to be passed as a string from the command line
Browse files Browse the repository at this point in the history
  • Loading branch information
fjclark committed May 1, 2024
1 parent fb59df8 commit 3cd1a11
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 10 deletions.
5 changes: 3 additions & 2 deletions maize/steps/exs/biosimspace/_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,9 @@ def required_callables(cls) -> list[str]:
save_name: FileParameter[Path] = FileParameter(optional=True)
"""
If supplied, the output files will be saved with
this name. E.g., if set to Path("output"), the output
files will be output.rst7 and output.prm7.
this name. E.g., if set to Path("output") (or "output"
through the CLI), the output files will be output.rst7
and output.prm7.
"""

# Output
Expand Down
4 changes: 2 additions & 2 deletions maize/steps/exs/biosimspace/afe.py
Original file line number Diff line number Diff line change
Expand Up @@ -235,7 +235,7 @@ def _get_protocol(self) -> "BSS.Protocol._protocol.Protocol":

pressure = (
None
if self.ensemble.value == Ensemble.NVT
if Ensemble(self.ensemble.value) == Ensemble.NVT
else self.pressure.value * BSS.Units.Pressure.atm
)

Expand Down Expand Up @@ -441,7 +441,7 @@ class _AFEBase(_BioSimSpaceBase, ABC):
temperature: Parameter[float] = Parameter(default=300.0)
"""The temperature, in K. Default = 300.0 K."""

ensemble: Parameter[Ensemble] = Parameter(default=Ensemble.NPT)
ensemble: Parameter[Literal["NVT", "NPT"]] = Parameter(default="NVT")
"""The ensemble to use. Default = NPT."""

pressure: Parameter[float] = Parameter(default=1)
Expand Down
6 changes: 3 additions & 3 deletions maize/steps/exs/biosimspace/equilibrate.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

from abc import ABC
from pathlib import Path
from typing import Any
from typing import Any, Literal

import pytest

Expand Down Expand Up @@ -54,7 +54,7 @@ class _EquilibrateBase(_BioSimSpaceBase, ABC):
temperature_end: Parameter[float] = Parameter(default=300.0)
"""The ending temperature, in K. Default = 300.0 K."""

ensemble: Parameter[Ensemble] = Parameter(default=Ensemble.NVT)
ensemble: Parameter[Literal["NVT", "NPT"]] = Parameter(default="NVT")
"""The ensemble to use for the equilibration. Default = NVT."""

pressure: Parameter[float] = Parameter(default=1)
Expand Down Expand Up @@ -113,7 +113,7 @@ def _get_protocol(self) -> "BSS.Protocol._protocol.Protocol":

pressure = (
None
if self.ensemble.value == Ensemble.NVT
if Ensemble(self.ensemble.value) == Ensemble.NVT
else self.pressure.value * BSS.Units.Pressure.atm
)

Expand Down
6 changes: 3 additions & 3 deletions maize/steps/exs/biosimspace/production.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

from abc import ABC
from pathlib import Path
from typing import Any
from typing import Any, Literal

import pytest

Expand Down Expand Up @@ -64,7 +64,7 @@ class _ProductionBase(_BioSimSpaceBase, ABC):
temperature: Parameter[float] = Parameter(default=300.0)
"""The temperature, in K. Default = 300.0 K."""

ensemble: Parameter[Ensemble] = Parameter(default=Ensemble.NPT)
ensemble: Parameter[Literal["NVT", "NPT"]] = Parameter(default="NVT")
"""The ensemble to use. Default = NPT."""

pressure: Parameter[float] = Parameter(default=1)
Expand Down Expand Up @@ -127,7 +127,7 @@ def _get_protocol(self) -> "BSS.Protocol._protocol.Protocol":

pressure = (
None
if self.ensemble.value == Ensemble.NVT
if Ensemble(self.ensemble.value) == Ensemble.NVT
else self.pressure.value * BSS.Units.Pressure.atm
)

Expand Down

0 comments on commit 3cd1a11

Please sign in to comment.