forked from openkim-hackathons/HeatCapacity
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathrunner
More file actions
executable file
·88 lines (84 loc) · 2.86 KB
/
runner
File metadata and controls
executable file
·88 lines (84 loc) · 2.86 KB
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
#!/usr/bin/env python3
"""
Universal runner for Crystal Genome Tests.
"""
import json
from ast import literal_eval
from shutil import copy
from test_driver.test_driver import TestDriver
model_name = input("Model name?\n")
print(model_name)
temperature_K = input("Temperature (K)?\n")
if temperature_K != "":
temperature_K = float(temperature_K)
print(temperature_K)
else:
print("No temperature given")
temperature_K = 0
pressure_eV_angstrom3 = input("pressure (eV/angstrom^3)?\n")
if pressure_eV_angstrom3 != "":
pressure_eV_angstrom3 = float(pressure_eV_angstrom3)
print(pressure_eV_angstrom3)
else:
print("No pressure given")
pressure_eV_angstrom3 = None
cell_cauchy_stress_eV_angstrom3 = input(
"Cauchy stress (literal list of floats, Voigt order xx,yy,zz,yz,xz,xy, eV/angstrom^3)?\n"
).split()
if cell_cauchy_stress_eV_angstrom3 != []:
cell_cauchy_stress_eV_angstrom3 = [
float(component) for component in cell_cauchy_stress_eV_angstrom3
]
print(cell_cauchy_stress_eV_angstrom3)
else:
print("No stress given")
cell_cauchy_stress_eV_angstrom3 = None
runtime_args_text = input("Runtime arguments (literal dictonary)?\n")
if runtime_args_text != "":
runtime_args = literal_eval(runtime_args_text)
print(runtime_args)
else:
runtime_args = {}
print("No runtime arguments given")
query_result = literal_eval(
input("Initial parameters from query or test_generator (literal list of dicts)?\n")
)
print(json.dumps(query_result, indent=2))
test = TestDriver(model_name)
successful_run = False
for structure in query_result:
try:
species_match = (
structure["stoichiometric-species"]["source-value"]
== query_result[0]["stoichiometric-species"]["source-value"]
)
prototype_match = (
structure["prototype-label"]["source-value"]
== query_result[0]["prototype-label"]["source-value"]
)
assert species_match and prototype_match, (
"The input structures must have identical "
"prototype-label and stoichiometric-species"
)
test(
structure,
temperature_K=temperature_K,
pressure_eV_angstrom3=pressure_eV_angstrom3,
cell_cauchy_stress_eV_angstrom3=cell_cauchy_stress_eV_angstrom3,
**runtime_args
)
successful_run = True
except Exception as e:
print(
"The following exception prevented one of the parameter sets from "
f"returning a result: \n{repr(e)}"
)
exc = e
if not successful_run:
raise RuntimeError(
"No parameter sets successfully ran. Last exception is attached, "
"see output file for others, if any."
) from exc
test.deduplicate_property_instances(allow_rotation=False)
test.write_property_instances_to_file()
copy("kim-tools.log", "output/kim-tools.log")