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 structure name option to MD CLI #138

Merged
merged 4 commits into from
May 8, 2024
Merged
Show file tree
Hide file tree
Changes from 3 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
15 changes: 15 additions & 0 deletions janus_core/cli/md.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,17 @@ def md(
ctx: Context,
ensemble: Annotated[str, Option(help="Name of thermodynamic ensemble.")],
struct: StructPath,
struct_name: Annotated[
str,
Option(
help=(
"""
Name of structure to simulate. Default is inferred from filepath or
chemical formula.
"""
)
),
] = None,
steps: Annotated[int, Option(help="Number of steps in simulation.")] = 0,
timestep: Annotated[float, Option(help="Timestep for integrator, in fs.")] = 1.0,
temp: Annotated[float, Option(help="Temperature, in K.")] = 300.0,
Expand Down Expand Up @@ -174,6 +185,9 @@ def md(
Name of thermodynamic ensemble.
struct : Path
Path of structure to simulate.
struct_name : str
Name of structure to simulate. Default is inferred from filepath or chemical
formula.
steps : int
Number of steps in simulation. Default is 0.
timestep : float
Expand Down Expand Up @@ -275,6 +289,7 @@ def md(
# Set up single point calculator
s_point = SinglePoint(
struct_path=struct,
struct_name=struct_name,
architecture=arch,
device=device,
read_kwargs=read_kwargs,
Expand Down
29 changes: 29 additions & 0 deletions tests/test_md_cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -342,3 +342,32 @@ def test_invalid_config():
)
assert result.exit_code == 1
assert isinstance(result.exception, ValueError)


def test_struct_name(tmp_path):
""" "Test specifying the structure name."""
struct_name = "EXAMPLE"
struct_path = tmp_path / struct_name
stats_path = tmp_path / f"{struct_name}-nvt-T10.0-stats.dat"
traj_path = tmp_path / f"{struct_name}-nvt-T10.0-traj.xyz"
final_path = tmp_path / f"{struct_name}-nvt-T10.0-final.xyz"
result = runner.invoke(
app,
[
"md",
"--struct",
DATA_PATH / "NaCl.cif",
"--ensemble",
"nvt",
"--steps",
"2",
"--temp",
"10",
"--struct-name",
str(struct_name),
ElliottKasoar marked this conversation as resolved.
Show resolved Hide resolved
],
)
assert result.exit_code == 0
assert stats_path.exists()
assert traj_path.exists()
assert final_path.exists()
Loading