This commit is contained in:
@@ -0,0 +1,96 @@
|
||||
from __future__ import annotations
|
||||
|
||||
import csv
|
||||
import math
|
||||
import sys
|
||||
from pathlib import Path
|
||||
|
||||
|
||||
MAX_DISP = 6.0e-2
|
||||
DISP_TOL = 1.0e-10
|
||||
|
||||
|
||||
def require(condition: bool, message: str) -> None:
|
||||
if not condition:
|
||||
raise RuntimeError(message)
|
||||
|
||||
|
||||
def read_rows(path: Path) -> list[dict[str, str]]:
|
||||
require(path.exists(), f"missing output file: {path}")
|
||||
with path.open(newline="", encoding="utf-8") as handle:
|
||||
return list(csv.DictReader(handle))
|
||||
|
||||
|
||||
def check_generated_deck(case_dir: Path) -> None:
|
||||
deck = case_dir / "two_arches_reference_point.inp"
|
||||
require(deck.exists(), "reference-point output has no generated input deck")
|
||||
text = deck.read_text(encoding="ascii")
|
||||
require("*MATERIAL, NAME=LOWER_MATERIAL" in text and "4.0E10, 0.20" in text,
|
||||
"generated deck does not preserve the lower arch material")
|
||||
require("*MATERIAL, NAME=UPPER_MATERIAL" in text and "2.0E10, 0.30" in text,
|
||||
"generated deck does not preserve the upper arch material")
|
||||
require("*BOUNDARY, AMPLITUDE=RAMP" in text and "UPPER_MID, 3, 3" in text,
|
||||
"generated deck does not use upper midpoint displacement control")
|
||||
require("*DYNAMIC" in text, "displacement reference deck must remain dynamic")
|
||||
require("*CLOAD" not in text, "displacement reference deck must not use edge loads")
|
||||
require("*STATIC" not in text, "displacement reference deck must not use static edge-load control")
|
||||
|
||||
|
||||
def check_path(case_dir: Path) -> None:
|
||||
rows = read_rows(case_dir / "two_arches_reference_point.csv")
|
||||
require(len(rows) == 1,
|
||||
"V5 two_arches acceptance expects one reference point, not a sweep")
|
||||
row = rows[0]
|
||||
para = float(row["para"])
|
||||
target = float(row["target_disp_upper"])
|
||||
disp = float(row["disp_upper"])
|
||||
residual = float(row["disp_residual"])
|
||||
active = int(row["active_contact"])
|
||||
max_penetration = float(row["max_penetration"])
|
||||
force_norm = float(row["contact_force_norm"])
|
||||
work_estimate = float(row["contact_work_estimate"])
|
||||
cumulative_work = float(row["contact_cumulative_work"])
|
||||
gap_residual = float(row["contact_gap_residual"])
|
||||
search_active = float(row["contact_search_active"])
|
||||
max_displacement = float(row["max_displacement"])
|
||||
status = row["status"].strip()
|
||||
mode = row["reference_mode"].strip()
|
||||
|
||||
require(status == "CONVERGED", f"unconverged reference point: {status}")
|
||||
require(mode == "displacement", f"unexpected reference mode: {mode}")
|
||||
require(math.isclose(target, -MAX_DISP * para, rel_tol=0.0, abs_tol=1.0e-12),
|
||||
f"target displacement is inconsistent with para={para}")
|
||||
require(abs(disp - target) <= DISP_TOL,
|
||||
f"disp_upper residual too large: {disp - target:.12e}")
|
||||
require(abs(residual - (disp - target)) <= 1.0e-12,
|
||||
"disp_residual column is inconsistent")
|
||||
require(active > 0, "reference point did not activate shell contact")
|
||||
require(search_active >= active,
|
||||
"contact search active count is inconsistent with active contact")
|
||||
require(0.0 <= max_penetration <= 5.0e-3,
|
||||
f"contact penetration is out of expected bound: {max_penetration:.12e}")
|
||||
require(gap_residual >= 0.0 and gap_residual <= 5.0e-3,
|
||||
f"contact gap residual is out of expected bound: {gap_residual:.12e}")
|
||||
require(force_norm > 0.0, "reference point has no contact force")
|
||||
require(work_estimate >= -1.0e-12,
|
||||
f"contact work estimate is negative: {work_estimate:.12e}")
|
||||
require(cumulative_work >= -1.0e-12,
|
||||
f"cumulative contact work is negative: {cumulative_work:.12e}")
|
||||
require(max_displacement <= 2.0e-3,
|
||||
f"reference point developed dynamic overshoot: {max_displacement:.12e}")
|
||||
require(disp < 0.0, "upper midpoint displacement is not downward")
|
||||
|
||||
|
||||
def main(argv: list[str]) -> int:
|
||||
if len(argv) != 2:
|
||||
print("usage: check_two_arches_reference_point.py CASE_OUTPUT_DIR")
|
||||
return 2
|
||||
case_dir = Path(argv[1])
|
||||
check_generated_deck(case_dir)
|
||||
check_path(case_dir)
|
||||
print("two_arches displacement reference-point checks passed")
|
||||
return 0
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
raise SystemExit(main(sys.argv))
|
||||
Reference in New Issue
Block a user