-
Notifications
You must be signed in to change notification settings - Fork 5
/
submit_singlepoint.py
99 lines (83 loc) · 2.47 KB
/
submit_singlepoint.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
"""Example code for submitting single point calculation."""
from aiida.common import NotExistent
from aiida.engine import run_get_node
from aiida.orm import Str, load_code
from aiida.plugins import CalculationFactory
import click
from aiida_mlip.helpers.help_load import load_model, load_structure
def singlepoint(params: dict) -> None:
"""
Prepare inputs and run a single point calculation.
Parameters
----------
params : dict
A dictionary containing the input parameters for the calculations
Returns
-------
None
"""
structure = load_structure(params["struct"])
# Select model to use
model = load_model(params["model"], params["arch"])
# Select calculation to use
SinglepointCalc = CalculationFactory("mlip.sp")
# Define inputs
inputs = {
"metadata": {"options": {"resources": {"num_machines": 1}}},
"code": params["code"],
"arch": Str(params["arch"]),
"struct": structure,
"model": model,
"precision": Str(params["precision"]),
"device": Str(params["device"]),
}
# Run calculation
result, node = run_get_node(SinglepointCalc, **inputs)
print(f"Printing results from calculation: {result}")
print(f"Printing node of calculation: {node}")
# Arguments and options to give to the cli when running the script
@click.command("cli")
@click.argument("codelabel", type=str)
@click.option(
"--struct",
default=None,
type=str,
help="Specify the structure (aiida node or path to a structure file)",
)
@click.option(
"--model",
default=None,
type=str,
help="Specify path or URI of the model to use",
)
@click.option(
"--arch",
default="mace_mp",
type=str,
help="MLIP architecture to use for calculations.",
)
@click.option(
"--device", default="cpu", type=str, help="Device to run calculations on."
)
@click.option(
"--precision", default="float64", type=str, help="Chosen level of precision."
)
def cli(codelabel, struct, model, arch, device, precision) -> None:
"""Click interface."""
try:
code = load_code(codelabel)
except NotExistent as exc:
print(f"The code '{codelabel}' does not exist.")
raise SystemExit from exc
params = {
"code": code,
"struct": struct,
"model": model,
"arch": arch,
"device": device,
"precision": precision,
}
# Submit single point
singlepoint(params)
if __name__ == "__main__":
cli()