Complete V5 acceptance milestone
This commit is contained in:
@@ -0,0 +1,84 @@
|
||||
from __future__ import annotations
|
||||
|
||||
import csv
|
||||
import subprocess
|
||||
import sys
|
||||
from pathlib import Path
|
||||
|
||||
|
||||
def read_key_values(path: Path) -> dict[str, float]:
|
||||
result: dict[str, float] = {}
|
||||
with path.open(newline="") as handle:
|
||||
reader = csv.reader(handle)
|
||||
next(reader)
|
||||
for key, value in reader:
|
||||
result[key] = float(value)
|
||||
return result
|
||||
|
||||
|
||||
def require(condition: bool, message: str) -> None:
|
||||
if not condition:
|
||||
raise AssertionError(message)
|
||||
|
||||
|
||||
def main() -> int:
|
||||
if len(sys.argv) != 3:
|
||||
raise SystemExit("usage: check_roller_kinematics.py BUILD_DIR OUTPUT_DIR")
|
||||
|
||||
repo = Path(__file__).resolve().parents[2]
|
||||
build_dir = Path(sys.argv[1]).resolve()
|
||||
out_dir = Path(sys.argv[2]).resolve()
|
||||
out_dir.mkdir(parents=True, exist_ok=True)
|
||||
|
||||
inp = Path(__file__).resolve().parent / "roll_forming_kinematics_benchmark.inp"
|
||||
text = inp.read_text(encoding="utf-8")
|
||||
require("*ROLLER KINEMATICS" in text, "missing roller kinematics block")
|
||||
|
||||
tool = build_dir / "roll_forming_kinematics_benchmark.exe"
|
||||
if not tool.exists():
|
||||
tool = build_dir / "roll_forming_kinematics_benchmark"
|
||||
completed = subprocess.run(
|
||||
[str(tool), str(inp), str(out_dir)],
|
||||
cwd=repo,
|
||||
text=True,
|
||||
stdout=subprocess.PIPE,
|
||||
stderr=subprocess.STDOUT,
|
||||
)
|
||||
if completed.returncode != 0:
|
||||
print(completed.stdout)
|
||||
raise RuntimeError(f"{tool} exited with code {completed.returncode}")
|
||||
|
||||
summary = out_dir / "roller_kinematics_summary.csv"
|
||||
history = out_dir / "roller_kinematics_history.csv"
|
||||
require(summary.exists(), "summary output missing")
|
||||
require(history.exists(), "history output missing")
|
||||
require(summary.stat().st_size > 0, "summary output empty")
|
||||
require(history.stat().st_size > 0, "history output empty")
|
||||
|
||||
data = read_key_values(summary)
|
||||
require(int(data["samples"]) == 6, "unexpected sample count")
|
||||
require(int(data["active_count"]) == 6, "all roller samples should be active")
|
||||
require(data["mean_slip_with_spin"] > data["mean_slip_without_spin"] * 1.5,
|
||||
"spin should increase tangential slip")
|
||||
require(data["mean_traction_with_spin"] > data["mean_traction_without_spin"] * 1.1,
|
||||
"spin should change regularized tangential traction")
|
||||
require(data["max_delta_traction"] > 50.0, "traction delta is too small")
|
||||
require(data["friction_energy_with_spin"] > data["friction_energy_without_spin"],
|
||||
"spin should increase friction energy")
|
||||
require(data["roller_torque_with_spin"] > 0.0, "roller torque should be positive")
|
||||
require(data["mean_pressure"] > 1.0e5, "mean pressure should be nonzero")
|
||||
|
||||
with history.open(newline="") as handle:
|
||||
rows = list(csv.DictReader(handle))
|
||||
require(len(rows) == 6, "history should have one row per sample")
|
||||
for row in rows:
|
||||
require(float(row["traction_with_spin"]) > float(row["traction_without_spin"]),
|
||||
"each sample should show spin-dependent traction")
|
||||
require(float(row["friction_energy_with_spin"]) >= 0.0,
|
||||
"friction energy must be nonnegative")
|
||||
|
||||
return 0
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
raise SystemExit(main())
|
||||
Reference in New Issue
Block a user