Complete V5 acceptance milestone
This commit is contained in:
@@ -0,0 +1,33 @@
|
||||
# Euler Column Buckling Benchmark
|
||||
|
||||
This benchmark verifies the V5 linear buckling path on a pinned-pinned
|
||||
Euler-Bernoulli column with a known analytical critical load:
|
||||
|
||||
```text
|
||||
Pcr = pi^2 E I / (K L)^2
|
||||
```
|
||||
|
||||
The benchmark tool assembles the beam bending stiffness and calls the production
|
||||
`geom_beam2d_column_stiffness`, `buckling_dense_solve` and
|
||||
`buckling_euler_column_load` routines from `femlite_core`.
|
||||
|
||||
Files:
|
||||
|
||||
- `euler_column_buckling.inp`: benchmark input with `E`, `I`, `L`, element
|
||||
count and effective length factor.
|
||||
- `check_buckling_results.py`: CTest checker.
|
||||
- `run_case.bat`: double-click runner.
|
||||
|
||||
Generated outputs:
|
||||
|
||||
- `buckling_summary.csv`: Euler reference, computed first three load factors,
|
||||
residual, relative error and KG mode normalization.
|
||||
- `buckling_mode_1.csv`: first-mode transverse displacement and rotation by
|
||||
column node.
|
||||
|
||||
Acceptance:
|
||||
|
||||
- First buckling load relative error must be at most `2.0e-2`.
|
||||
- First modal residual must be at most `1.0e-8`.
|
||||
- The first mode must be normalized such that `phi^T KG phi = 1`.
|
||||
- Pinned-end transverse displacement must remain zero.
|
||||
@@ -0,0 +1,85 @@
|
||||
from __future__ import annotations
|
||||
|
||||
import csv
|
||||
import subprocess
|
||||
import sys
|
||||
from pathlib import Path
|
||||
|
||||
|
||||
def require(condition: bool, message: str) -> None:
|
||||
if not condition:
|
||||
raise RuntimeError(message)
|
||||
|
||||
|
||||
def read_key_values(path: Path) -> dict[str, str]:
|
||||
with path.open(newline="", encoding="utf-8") as handle:
|
||||
return {row["key"]: row["value"] for row in csv.DictReader(handle)}
|
||||
|
||||
|
||||
def find_tool(build_dir: Path) -> Path:
|
||||
candidates = [
|
||||
build_dir / "euler_column_buckling_benchmark.exe",
|
||||
build_dir / "euler_column_buckling_benchmark",
|
||||
build_dir / "Release" / "euler_column_buckling_benchmark.exe",
|
||||
build_dir / "Release" / "euler_column_buckling_benchmark",
|
||||
]
|
||||
for candidate in candidates:
|
||||
if candidate.exists():
|
||||
return candidate
|
||||
raise RuntimeError(f"missing euler_column_buckling_benchmark tool under {build_dir}")
|
||||
|
||||
|
||||
def main() -> int:
|
||||
if len(sys.argv) != 3:
|
||||
raise RuntimeError("usage: check_buckling_results.py BUILD_DIR OUTPUT_DIR")
|
||||
|
||||
build_dir = Path(sys.argv[1]).resolve()
|
||||
output_dir = Path(sys.argv[2]).resolve()
|
||||
repo_root = Path(__file__).resolve().parents[2]
|
||||
input_file = repo_root / "examples" / "euler_column_buckling" / "euler_column_buckling.inp"
|
||||
tool = find_tool(build_dir)
|
||||
output_dir.mkdir(parents=True, exist_ok=True)
|
||||
|
||||
completed = subprocess.run(
|
||||
[str(tool), str(input_file), str(output_dir)],
|
||||
cwd=repo_root,
|
||||
text=True,
|
||||
stdout=subprocess.PIPE,
|
||||
stderr=subprocess.STDOUT,
|
||||
)
|
||||
print(completed.stdout)
|
||||
if completed.returncode != 0:
|
||||
raise RuntimeError(f"{tool} exited with code {completed.returncode}")
|
||||
|
||||
summary = output_dir / "buckling_summary.csv"
|
||||
mode = output_dir / "buckling_mode_1.csv"
|
||||
require(summary.exists(), f"missing summary: {summary}")
|
||||
require(mode.exists(), f"missing mode shape: {mode}")
|
||||
|
||||
values = read_key_values(summary)
|
||||
element_count = int(values["element_count"])
|
||||
exact = float(values["euler_pcr"])
|
||||
factor = float(values["mode_1_factor"])
|
||||
residual = float(values["mode_1_residual"])
|
||||
rel_error = float(values["relative_error"])
|
||||
kg_norm = float(values["kg_mode_norm"])
|
||||
|
||||
require(element_count >= 8, f"element count too small: {element_count}")
|
||||
require(exact > 0.0 and factor > 0.0, "critical load values must be positive")
|
||||
require(rel_error <= 2.0e-2, f"Euler buckling relative error too large: {rel_error}")
|
||||
require(residual <= 1.0e-8, f"buckling residual too large: {residual}")
|
||||
require(abs(kg_norm - 1.0) <= 1.0e-8, f"mode is not KG-normalized: {kg_norm}")
|
||||
|
||||
with mode.open(newline="", encoding="utf-8") as handle:
|
||||
rows = list(csv.DictReader(handle))
|
||||
require(len(rows) == element_count + 1, "mode output node count mismatch")
|
||||
w_values = [abs(float(row["w"])) for row in rows]
|
||||
require(max(w_values) > 0.0, "mode shape is blank")
|
||||
require(w_values[0] <= 1.0e-12 and w_values[-1] <= 1.0e-12, "pinned end displacement is not zero")
|
||||
|
||||
print(f"Euler buckling benchmark passed: Pcr={factor:.6e}, error={rel_error:.3e}")
|
||||
return 0
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
raise SystemExit(main())
|
||||
@@ -0,0 +1,6 @@
|
||||
*HEADING
|
||||
FemLite Euler pinned-pinned column linear buckling benchmark
|
||||
**
|
||||
** E, I, L, element_count, effective_length_factor
|
||||
*BUCKLING COLUMN
|
||||
210.0E9, 8.0E-6, 3.0, 8, 1.0
|
||||
@@ -0,0 +1,32 @@
|
||||
@echo off
|
||||
setlocal
|
||||
|
||||
set "CASE_DIR=%~dp0"
|
||||
set "ROOT_DIR=%CASE_DIR%..\.."
|
||||
set "OUT_DIR=%CASE_DIR%results\auto_run"
|
||||
set "TOOL=%ROOT_DIR%\build-win-gcc-16\euler_column_buckling_benchmark.exe"
|
||||
set "INP=%CASE_DIR%euler_column_buckling.inp"
|
||||
|
||||
if not exist "%OUT_DIR%" mkdir "%OUT_DIR%"
|
||||
del /Q "%OUT_DIR%\buckling_summary.csv" 2>nul
|
||||
del /Q "%OUT_DIR%\buckling_mode_1.csv" 2>nul
|
||||
|
||||
if not exist "%TOOL%" (
|
||||
echo Building euler_column_buckling_benchmark...
|
||||
cmake --build "%ROOT_DIR%\build-win-gcc-16" --config Release --target euler_column_buckling_benchmark
|
||||
if errorlevel 1 goto fail
|
||||
)
|
||||
|
||||
"%TOOL%" "%INP%" "%OUT_DIR%"
|
||||
if errorlevel 1 goto fail
|
||||
|
||||
echo.
|
||||
echo Euler column buckling benchmark completed.
|
||||
if not "%FEMLITE_NO_PAUSE%"=="1" pause
|
||||
exit /b 0
|
||||
|
||||
:fail
|
||||
echo.
|
||||
echo Euler column buckling benchmark failed.
|
||||
if not "%FEMLITE_NO_PAUSE%"=="1" pause
|
||||
exit /b 1
|
||||
Reference in New Issue
Block a user