Complete V5 acceptance milestone

This commit is contained in:
shenw
2026-06-26 12:54:40 +08:00
parent 26639d8dc2
commit a01a4fda24
105 changed files with 8694 additions and 8922 deletions
@@ -0,0 +1,103 @@
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_springback_results.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)
case_dir = Path(__file__).resolve().parent
inp = case_dir / "roll_forming_springback_benchmark.inp"
text = inp.read_text(encoding="utf-8")
require("*ROLL FORMING SPRINGBACK" in text, "missing springback block")
tool = build_dir / "roll_forming_springback_benchmark.exe"
if not tool.exists():
tool = build_dir / "roll_forming_springback_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 / "springback_summary.csv"
history = out_dir / "springback_history.csv"
zone = out_dir / "plastic_zone.csv"
require(summary.exists(), "summary output missing")
require(history.exists(), "history output missing")
require(zone.exists(), "plastic zone output missing")
require(summary.stat().st_size > 0, "summary output empty")
require(history.stat().st_size > 0, "history output empty")
require(zone.stat().st_size > 0, "plastic zone output empty")
data = read_key_values(summary)
require(int(data["samples"]) == 8, "unexpected sample count")
require(int(data["total_points"]) == 81, "unexpected material point count")
require(data["forming_force"] > 1.0e4, "forming force too small")
require(data["forming_force"] < 3.0e4, "forming force too large")
require(data["plastic_work"] > 0.0, "plastic work must be positive")
require(data["friction_energy"] > 0.0, "friction energy must be positive")
require(data["active_plastic_points"] > 0, "plastic zone did not activate")
require(0.20 <= data["plastic_zone_fraction"] <= 1.0,
"plastic zone fraction outside expected range")
require(data["max_eqps"] > 1.0e-4, "equivalent plastic strain too small")
require(data["release_curvature"] > 0.0, "release curvature must be positive")
require(data["residual_curvature"] > 0.0, "residual curvature must be positive")
require(data["formed_displacement"] > data["residual_displacement"],
"springback should reduce displacement")
require(data["residual_displacement"] > 0.0,
"residual displacement should remain positive")
require(0.05 < data["springback_ratio"] < 0.95,
"springback ratio outside expected range")
require(abs(data["residual_moment"]) <= max(1.0, data["peak_moment"]) * 1.0e-6,
"unloaded residual moment is too large")
with history.open(newline="") as handle:
rows = list(csv.DictReader(handle))
require(len(rows) == 8, "history should have one row per forming sample")
require(float(rows[-1]["plastic_work"]) >= data["plastic_work"] * 0.99,
"history plastic work did not reach summary value")
with zone.open(newline="") as handle:
points = list(csv.DictReader(handle))
require(len(points) == 81, "plastic zone should cover all material points")
active = [row for row in points if int(row["active"]) == 1]
require(len(active) == int(data["active_plastic_points"]),
"active plastic point count mismatch")
require(max(float(row["eqps"]) for row in active) >= data["max_eqps"] * 0.99,
"plastic zone max eqps mismatch")
return 0
if __name__ == "__main__":
raise SystemExit(main())