58 lines
1.6 KiB
Python
58 lines
1.6 KiB
Python
from __future__ import annotations
|
|
|
|
import argparse
|
|
import sys
|
|
from pathlib import Path
|
|
|
|
|
|
def main() -> int:
|
|
parser = argparse.ArgumentParser()
|
|
parser.add_argument("--library", required=True)
|
|
parser.add_argument("--input", required=True)
|
|
args = parser.parse_args()
|
|
|
|
root = Path(__file__).resolve().parents[2]
|
|
sys.path.insert(0, str(root / "Python"))
|
|
|
|
from sphlite_debug import PHASE_SOLID, STATUS_ACTIVE, SPHLite, SPHLiteError
|
|
|
|
solver = SPHLite(args.library)
|
|
if PHASE_SOLID != 4 or STATUS_ACTIVE != 0:
|
|
raise AssertionError("Python constants are not locked")
|
|
|
|
solver.initialize()
|
|
try:
|
|
solver.read_inp(args.input)
|
|
solver.build_model()
|
|
count = solver.particle_count()
|
|
if count != 4:
|
|
raise AssertionError(f"expected 4 particles, got {count}")
|
|
state = solver.particle_state()
|
|
if state["phase"][0] != PHASE_SOLID:
|
|
raise AssertionError("unexpected particle phase")
|
|
solver.set_output_directory(root / "build-codex-unix")
|
|
solver.write_output(0, 0.0)
|
|
restart = root / "build-codex-unix" / "python_restart.tmp"
|
|
solver.write_restart(restart)
|
|
solver.read_restart(restart)
|
|
solver.run_explicit()
|
|
finally:
|
|
solver.finalize()
|
|
|
|
missing = SPHLite(args.library)
|
|
missing.initialize()
|
|
try:
|
|
try:
|
|
missing.read_inp(root / "tests" / "data" / "does_not_exist.inp")
|
|
except SPHLiteError:
|
|
pass
|
|
else:
|
|
raise AssertionError("missing input did not raise")
|
|
finally:
|
|
missing.finalize()
|
|
return 0
|
|
|
|
|
|
if __name__ == "__main__":
|
|
raise SystemExit(main())
|