Advance V5 nonlinear benchmarks and shell solver

This commit is contained in:
shenw
2026-06-27 16:43:00 +08:00
parent a2a11179d9
commit db68340aaf
84 changed files with 38720 additions and 971 deletions
@@ -1,16 +1,49 @@
# Spherical Cap Central Point Load Smoke Case
# Spherical Cap Central Point Load Benchmark
This folder contains the original spherical-cap benchmark notes plus a
compact FemLite smoke case:
This folder contains a displacement-control FemLite benchmark derived from
`models.sme.spherical_cap_with_central_point_load.pdf`:
- `spherical_cap_s4_static.inp`
- `generate_spherical_cap.py`
- `spherical_cap_displacement_control.inp`
- `spherical_cap_displacement_control_shell4.inp`
- `check_spherical_cap_results.py`
- `run_case.bat`
The reference model is a nonlinear postbuckling benchmark with displacement
control. FemLite V4.8 does not claim full postbuckling continuation. The
included input uses the documented material scale, radius, thickness, and
central loading idea in a small S4 cap patch so the curved shell geometry,
edge constraints, static driver, and central response output are exercised.
The reference model is the NAFEMS spherical cap postbuckling case: radius
`a = 10 m`, thickness `th = 0.203840 m`, `E = 210 GPa`, `nu = 0.3`, cap angle
`pi/4`, fixed rim, and crown displacement control. The generated FemLite
input set models the full 3D cap with a crown S3 fan and PDF meridional S4
shell bands. `spherical_cap_displacement_control.inp` keeps the Shell-16
geometry/material baseline; `spherical_cap_displacement_control_shell4.inp`
uses the PDF Shell-4 mesh as an explicit nonlinear direct-displacement
diagnostic input for the V5.11 follow-up work. Both decks now use
`*NONLINEAR CONTINUATION, METHOD=ARC_LENGTH_OR_DISPLACEMENT_CONTROL,
SHELL_GEOMETRIC=YES` so the production S4 corotational nonlinear path is selected
whenever the nonlinear route is attempted. Both decks prescribe the crown
displacement to `-6.2 m`; the reaction is nondimensionalized as
```text
Fn = -F*a/(E*th^3*2*pi), wn = -w/th
```
FemLite currently checks the displacement-control shell path that its
small-strain shell formulation can support. By default, the checker runs
static-linear Shell-16 samples at the PDF table displacement values and writes
`spherical_cap_load_displacement.csv`. If the environment variable
`FEMLITE_SPHERICAL_CAP_NONLINEAR=1` is set, the checker instead attempts a real
`--static-nonlinear` Shell-4 direct-displacement path and validates
`continuation_path.csv`. That nonlinear route is intentionally diagnostic today:
FemLite has the opt-in corotational S4 frame/objectivity foundation, elastic
S4 algorithmic tangent from production internal-force finite differences,
prestress-delta membrane geometric stiffness, and shell pressure follower
tangent for `DLOAD P`. It still does not include the full Shell-4/8/16
postbuckling solve chain: plastic/multilayer shell algorithmic tangents,
bending/shear prestress terms, all follower-load families and generalized
Riks/arc-length equations. Non-`ELASTIC` S4 shell materials are rejected on the
corotational tangent path until their algorithmic tangents are implemented. The
example must not be marked as full PDF postbuckling PASS until V5.11-1/V5.11-3
are finished and the optional nonlinear checker reaches the target displacement
with post-peak load drop and restiffening.
Run:
@@ -19,3 +52,10 @@ run_case.bat
```
Results are written to `results\auto_run`.
Important output files:
- `continuation_path.csv`: production accepted-increment direct displacement
path, present only when the optional nonlinear diagnostic route completes.
- `spherical_cap_load_displacement.csv`: checker-derived nondimensional
`wn = -w/th` and `Fn = -F*a/(E*th^3*2*pi)` curve.
@@ -0,0 +1,515 @@
from __future__ import annotations
import csv
import math
import os
import re
import shutil
import subprocess
import sys
from pathlib import Path
REFERENCE_SHELL16 = (
(0.332, 2.326),
(0.580, 6.720),
(0.994, 13.642),
(1.502, 18.487),
(1.757, 20.887),
(1.717, 25.668),
(3.705, 28.680),
)
def require(condition: bool, message: str) -> None:
if not condition:
raise AssertionError(message)
def parse_float_marker(text: str, name: str) -> float:
match = re.search(rf"{name}=([+-]?\d+\.\d+E[+-]\d+)", text)
require(match is not None, f"missing {name} marker")
return float(match.group(1))
def parse_int_marker(text: str, name: str) -> int:
match = re.search(rf"{name}=(\d+)", text)
require(match is not None, f"missing {name} marker")
return int(match.group(1))
def clean_output(out_dir: Path) -> None:
out_dir.mkdir(parents=True, exist_ok=True)
for pattern in (
"case_*.inp",
"history.csv",
"nodes_*.csv",
"elements_*.csv",
"reactions_*.csv",
"result_*.vtk",
"continuation_path.csv",
"spherical_cap_load_displacement.csv",
):
for path in out_dir.glob(pattern):
path.unlink()
contact_dir = out_dir / "contact"
if contact_dir.exists():
shutil.rmtree(contact_dir)
for child in out_dir.glob("sample_*"):
if child.is_dir():
shutil.rmtree(child)
def read_single_row(path: Path, key: str, value: int) -> dict[str, str]:
require(path.exists(), f"missing output: {path}")
with path.open(newline="", encoding="utf-8") as handle:
for row in csv.DictReader(handle):
if int(row[key]) == value:
return row
raise AssertionError(f"{path.name} does not contain {key}={value}")
def read_history(path: Path) -> list[dict[str, str]]:
require(path.exists(), f"missing output: {path}")
with path.open(newline="", encoding="utf-8") as handle:
return list(csv.DictReader(handle))
def read_rows(path: Path) -> list[dict[str, str]]:
require(path.exists(), f"missing output: {path}")
with path.open(newline="", encoding="utf-8") as handle:
return list(csv.DictReader(handle))
def collect_sample(
sample_dir: Path,
crown_node: int,
radius: float,
thickness: float,
young: float,
) -> tuple[float, float, float, float]:
denom = young * thickness**3 * 2.0 * math.pi
node_path = sample_dir / "nodes_00000001.csv"
reaction_path = sample_dir / "reactions_00000001.csv"
node_row = read_single_row(node_path, "node_id", crown_node)
reaction_row = read_single_row(reaction_path, "node_id", crown_node)
uz = float(node_row["uz"])
reaction_uz = float(reaction_row["reaction_uz"])
wn = -uz / thickness
fn = -reaction_uz * radius / denom
return wn, fn, uz, reaction_uz
def write_sample_input(source_text: str, path: Path, displacement: float) -> None:
updated = re.sub(
r"FINAL_CROWN_DISPLACEMENT_M=[+-]?\d+\.\d+E[+-]\d+",
f"FINAL_CROWN_DISPLACEMENT_M={displacement:.8E}",
source_text,
)
updated = re.sub(
r"CROWN,\s*3,\s*3,\s*[+-]?\d+\.\d+E[+-]\d+",
f"CROWN, 3, 3, {displacement:.10E}",
updated,
count=1,
)
path.write_text(updated, encoding="ascii", newline="\n")
def run_linear_sample(
repo: Path,
femlite: Path,
sample_inp: Path,
sample_dir: Path,
) -> str:
sample_dir.mkdir(parents=True, exist_ok=True)
completed = subprocess.run(
[
str(femlite),
str(sample_inp),
"--static-linear",
"--output-dir",
str(sample_dir),
"--output-interval",
"1",
],
cwd=repo,
text=True,
stdout=subprocess.PIPE,
stderr=subprocess.STDOUT,
)
if completed.returncode != 0:
print(completed.stdout)
raise RuntimeError(f"{femlite} exited with code {completed.returncode}")
return completed.stdout
def run_nonlinear_path(
repo: Path,
femlite: Path,
inp: Path,
out_dir: Path,
) -> str:
completed = subprocess.run(
[
str(femlite),
str(inp),
"--static-nonlinear",
"--output-dir",
str(out_dir),
"--output-interval",
"1",
"--allow-cutback",
"--max-newton",
"50",
"--newton-tol",
"1.0e-7",
],
cwd=repo,
text=True,
stdout=subprocess.PIPE,
stderr=subprocess.STDOUT,
)
if completed.returncode != 0:
print(completed.stdout)
raise RuntimeError(f"{femlite} exited with code {completed.returncode}")
return completed.stdout
def collect_path_curve(
path_rows: list[dict[str, str]],
radius: float,
thickness: float,
young: float,
) -> tuple[list[tuple[float, float, float, float]], list[dict[str, float]]]:
denom = young * thickness**3 * 2.0 * math.pi
curve: list[tuple[float, float, float, float]] = []
records: list[dict[str, float]] = []
previous_time = -1.0
for row in path_rows:
step = int(row["step"])
time = float(row["time"])
control_count = int(row["control_dof_count"])
prescribed = float(row["prescribed_max"])
actual = float(row["actual_max"])
residual_linf = float(row["constraint_residual_linf"])
residual_l2 = float(row["constraint_residual_l2"])
reaction = float(row["control_reaction_sum"])
work = float(row["control_work"])
iterations = int(row["iterations"])
status_code = int(row["status_code"])
failure_code = int(row["failure_code"])
residual_norm = float(row["residual_norm"])
relative_residual = float(row["relative_residual"])
correction_norm = float(row["correction_norm"])
require(step >= 1, "continuation path step must be positive")
require(time > previous_time, "continuation path time is not increasing")
require(control_count == 1, "spherical cap should have one controlled crown DOF")
require(status_code == 2, "accepted continuation row is not converged")
require(failure_code == 0, "accepted continuation row records a failure")
require(iterations > 0, "accepted continuation row has no Newton iterations")
require(residual_linf <= 1.0e-8, "crown constraint residual is too large")
require(residual_l2 <= 1.0e-8, "crown constraint residual norm is too large")
require(abs(actual - prescribed) <= 1.0e-8 * max(1.0, prescribed),
"actual crown displacement differs from prescribed displacement")
wn = prescribed / thickness
fn = -reaction * radius / denom
uz = -prescribed
curve.append((wn, fn, uz, reaction))
records.append(
{
"step": float(step),
"time": time,
"wn": wn,
"fn": fn,
"uz": uz,
"reaction_uz": reaction,
"control_work": work,
"iterations": float(iterations),
"residual_norm": residual_norm,
"relative_residual": relative_residual,
"correction_norm": correction_norm,
}
)
previous_time = time
return curve, records
def write_curve_csv(path: Path, records: list[dict[str, float]]) -> None:
with path.open("w", newline="", encoding="utf-8") as handle:
writer = csv.DictWriter(
handle,
fieldnames=(
"step",
"time",
"wn",
"Fn",
"uz",
"reaction_uz",
"control_work",
"iterations",
"residual_norm",
"relative_residual",
"correction_norm",
),
)
writer.writeheader()
for record in records:
writer.writerow(
{
"step": int(record["step"]),
"time": f"{record['time']:.10E}",
"wn": f"{record['wn']:.10E}",
"Fn": f"{record['fn']:.10E}",
"uz": f"{record['uz']:.10E}",
"reaction_uz": f"{record['reaction_uz']:.10E}",
"control_work": f"{record['control_work']:.10E}",
"iterations": int(record["iterations"]),
"residual_norm": f"{record['residual_norm']:.10E}",
"relative_residual": f"{record['relative_residual']:.10E}",
"correction_norm": f"{record['correction_norm']:.10E}",
}
)
def interpolate_fn(curve: list[tuple[float, float, float, float]], target_wn: float) -> float:
require(curve, "cannot interpolate an empty curve")
require(curve[0][0] <= target_wn <= curve[-1][0],
f"target wn={target_wn:.6E} is outside the path")
for left, right in zip(curve, curve[1:]):
w0, f0, _uz0, _rz0 = left
w1, f1, _uz1, _rz1 = right
if w0 <= target_wn <= w1:
if abs(w1 - w0) <= 1.0e-14:
return f1
t = (target_wn - w0) / (w1 - w0)
return f0 + t * (f1 - f0)
return curve[-1][1]
def parse_input_counts(path: Path) -> tuple[int, int, int]:
node_count = 0
tri_count = 0
quad_count = 0
mode = ""
for raw_line in path.read_text(encoding="ascii").splitlines():
line = raw_line.strip()
if not line or line.startswith("**"):
continue
if line.startswith("*"):
upper = line.upper()
if upper.startswith("*NODE"):
mode = "node"
elif upper.startswith("*ELEMENT") and "TYPE=S3" in upper:
mode = "tri"
elif upper.startswith("*ELEMENT") and "TYPE=S4" in upper:
mode = "quad"
else:
mode = ""
continue
if mode == "node":
node_count += 1
elif mode == "tri":
tri_count += 1
elif mode == "quad":
quad_count += 1
return node_count, tri_count, quad_count
def check_curve_signature(curve: list[tuple[float, float, float, float]]) -> tuple[float, float, float]:
require(len(curve) >= len(REFERENCE_SHELL16), f"expected displacement-control samples, got {len(curve)}")
final_wn, final_fn, final_uz, final_reaction = curve[-1]
require(final_wn > 30.0, f"final nondimensional displacement is too small: {final_wn:.6E}")
require(final_uz < -6.0, f"final crown displacement is too small: {final_uz:.6E}")
require(final_reaction < 0.0, f"downward prescribed crown displacement should produce negative reaction: {final_reaction:.6E}")
positive = [(wn, fn) for wn, fn, _uz, _rz in curve if wn > 1.0e-12]
require(all(fn > 0.0 for _wn, fn in positive), "nondimensional reaction force must stay positive")
for (w0, f0), (w1, f1) in zip(positive, positive[1:]):
require(w1 > w0, "crown displacement samples are not strictly increasing")
require(f1 + 1.0e-8 >= f0, "current small-strain shell response should be monotone")
ratios = [fn / wn for wn, fn in positive]
secant = ratios[-1]
require(0.25 < secant < 0.37, f"unexpected nondimensional secant stiffness: {secant:.6E}")
spread = max(ratios) - min(ratios)
require(spread / secant < 5.0e-4, f"linear displacement-control samples are inconsistent: {spread:.6E}")
return final_wn, final_fn, secant
def check_postbuckling_signature(
curve: list[tuple[float, float, float, float]],
) -> tuple[float, float, float]:
require(len(curve) >= 10, f"expected a resolved nonlinear path, got {len(curve)}")
final_wn, final_fn, final_uz, final_reaction = curve[-1]
require(final_wn > 30.0, f"final nondimensional displacement is too small: {final_wn:.6E}")
require(final_uz < -6.0, f"final crown displacement is too small: {final_uz:.6E}")
require(final_reaction < 0.0, f"downward prescribed crown displacement should produce negative reaction: {final_reaction:.6E}")
positive = [(wn, fn) for wn, fn, _uz, _rz in curve if wn > 1.0e-12]
require(len(positive) >= 9, "nonlinear path has too few positive displacement points")
require(all(fn > 0.0 for _wn, fn in positive), "nondimensional reaction force must stay positive")
for (w0, _f0), (w1, _f1) in zip(positive, positive[1:]):
require(w1 > w0, "crown displacement path is not strictly increasing")
forces = [fn for _wn, fn in positive]
peak_index = max(range(len(forces)), key=lambda index: forces[index])
require(peak_index < len(forces) - 2, "nonlinear path has no post-peak segment")
post_peak_forces = forces[peak_index + 1 :]
trough_force = min(post_peak_forces)
trough_index = peak_index + 1 + post_peak_forces.index(trough_force)
peak_force = forces[peak_index]
require(
trough_force < 0.99 * peak_force,
"nonlinear path does not show a load drop after the first limit point",
)
require(
max(forces[trough_index + 1 :]) > 1.05 * trough_force,
"nonlinear path does not show restiffening after the load drop",
)
secant = final_fn / final_wn
return final_wn, final_fn, secant
def main() -> int:
if len(sys.argv) != 4:
raise SystemExit("usage: check_spherical_cap_results.py REPO_ROOT FEMLITE_EXE OUTPUT_DIR")
repo = Path(sys.argv[1]).resolve()
femlite = Path(sys.argv[2]).resolve()
out_dir = Path(sys.argv[3]).resolve()
case_dir = repo / "examples" / "spherical_cap_with_central_point_load"
reference_inp = case_dir / "spherical_cap_displacement_control.inp"
path_inp = case_dir / "spherical_cap_displacement_control_shell4.inp"
text = reference_inp.read_text(encoding="ascii")
path_text = path_inp.read_text(encoding="ascii")
require("smoke" not in text.lower(), "spherical-cap benchmark input still describes a smoke case")
require("Spherical Cap with Central Point Load" in text, "input does not identify the reference model")
require("METHOD=ARC_LENGTH_OR_DISPLACEMENT_CONTROL" in text,
"Shell-16 input must use direct displacement-control continuation output")
require("METHOD=ARC_LENGTH_OR_DISPLACEMENT_CONTROL" in path_text,
"Shell-4 path input must use direct displacement-control continuation output")
require("SHELL_GEOMETRIC=YES" in text,
"Shell-16 input must explicitly request geometric shell kinematics")
require("SHELL_GEOMETRIC=YES" in path_text,
"Shell-4 path input must explicitly request geometric shell kinematics")
radius = parse_float_marker(text, "RADIUS_M")
thickness = parse_float_marker(text, "THICKNESS_M")
young = parse_float_marker(text, "YOUNG_PA")
cap_angle = parse_float_marker(text, "CAP_ANGLE_RAD")
meridional = parse_int_marker(text, "MERIDIONAL_ELEMENTS")
circumferential = parse_int_marker(text, "CIRCUMFERENTIAL_ELEMENTS")
crown_node = parse_int_marker(text, "CROWN_NODE")
require(abs(radius - 10.0) <= 1.0e-12, "reference radius mismatch")
require(abs(thickness - 0.203840) <= 1.0e-12, "reference thickness mismatch")
require(abs(young - 210.0e9) <= 1.0, "reference Young modulus mismatch")
require(abs(cap_angle - math.pi / 4.0) <= 1.0e-8, "reference sector angle mismatch")
require(meridional == 16, "benchmark must use the PDF shell 16-element meridional discretization")
require(circumferential >= 4 * meridional, "circumferential mesh is too coarse for the 3D shell cap")
node_count, tri_count, quad_count = parse_input_counts(reference_inp)
require(node_count == 1 + meridional * circumferential, "unexpected spherical cap node count")
require(tri_count == circumferential, "unexpected crown fan triangle count")
require(quad_count == (meridional - 1) * circumferential, "unexpected shell band quadrilateral count")
path_radius = parse_float_marker(path_text, "RADIUS_M")
path_thickness = parse_float_marker(path_text, "THICKNESS_M")
path_young = parse_float_marker(path_text, "YOUNG_PA")
path_meridional = parse_int_marker(path_text, "MERIDIONAL_ELEMENTS")
path_circumferential = parse_int_marker(path_text, "CIRCUMFERENTIAL_ELEMENTS")
require(abs(path_radius - radius) <= 1.0e-12, "Shell-4 radius mismatch")
require(abs(path_thickness - thickness) <= 1.0e-12, "Shell-4 thickness mismatch")
require(abs(path_young - young) <= 1.0, "Shell-4 Young modulus mismatch")
require(path_meridional == 4, "nonlinear path input must use PDF Shell-4 meridional mesh")
require(path_circumferential >= 4 * path_meridional,
"Shell-4 circumferential mesh is too coarse")
path_node_count, path_tri_count, path_quad_count = parse_input_counts(path_inp)
require(path_node_count == 1 + path_meridional * path_circumferential,
"unexpected Shell-4 node count")
require(path_tri_count == path_circumferential,
"unexpected Shell-4 crown fan triangle count")
require(path_quad_count == (path_meridional - 1) * path_circumferential,
"unexpected Shell-4 shell band quadrilateral count")
clean_output(out_dir)
final_displacement = parse_float_marker(text, "FINAL_CROWN_DISPLACEMENT_M")
final_wn_target = -final_displacement / thickness
require_nonlinear = os.environ.get("FEMLITE_SPHERICAL_CAP_NONLINEAR") == "1"
if require_nonlinear:
stdout = run_nonlinear_path(repo, femlite, path_inp, out_dir)
print(stdout)
history = read_history(out_dir / "history.csv")
require(len(history) == 1, "static nonlinear run should emit one final history row")
path_rows = read_rows(out_dir / "continuation_path.csv")
require(len(path_rows) >= 10, "continuation path has too few accepted increments")
curve, records = collect_path_curve(path_rows, radius, thickness, young)
write_curve_csv(out_dir / "spherical_cap_load_displacement.csv", records)
curve_with_origin = [(0.0, 0.0, 0.0, 0.0)] + curve
mode_label = "nonlinear displacement-control path"
signature_checker = check_postbuckling_signature
else:
target_wn_values = [target_wn for _target_fn, target_wn in REFERENCE_SHELL16]
sample_wn_values = target_wn_values + [final_wn_target]
curve = []
records = []
for index, target_wn in enumerate(sample_wn_values, start=1):
displacement = -target_wn * thickness
sample_inp = out_dir / f"case_{index:02d}.inp"
sample_dir = out_dir / f"sample_{index:02d}"
write_sample_input(text, sample_inp, displacement)
stdout = run_linear_sample(repo, femlite, sample_inp, sample_dir)
if index == len(sample_wn_values):
print(stdout)
history = read_history(sample_dir / "history.csv")
require(len(history) == 1, "static linear sample should emit exactly one history row")
sample = collect_sample(sample_dir, crown_node, radius, thickness, young)
require(abs(sample[0] - target_wn) <= 2.0e-7 * max(1.0, target_wn),
"sample displacement mismatch")
curve.append(sample)
records.append(
{
"step": float(index),
"time": float(index) / float(len(sample_wn_values)),
"wn": sample[0],
"fn": sample[1],
"uz": sample[2],
"reaction_uz": sample[3],
"control_work": 0.0,
"iterations": 1.0,
"residual_norm": 0.0,
"relative_residual": 0.0,
"correction_norm": 0.0,
}
)
write_curve_csv(out_dir / "spherical_cap_load_displacement.csv", records)
curve_with_origin = [(0.0, 0.0, 0.0, 0.0)] + curve
mode_label = "small-strain displacement samples"
signature_checker = check_curve_signature
final_wn, final_fn, secant = signature_checker(curve_with_origin)
require(abs(final_wn - final_wn_target) <= 2.0e-7 * max(1.0, final_wn_target),
"final path displacement does not reach the requested crown displacement")
sampled = [
(target_wn, ref_fn, interpolate_fn(curve_with_origin, target_wn))
for ref_fn, target_wn in REFERENCE_SHELL16
]
require(len(sampled) == len(REFERENCE_SHELL16), "failed to sample all PDF table displacements")
print(
f"spherical cap {mode_label}: "
f"points={len(curve)}, final_wn={final_wn:.6E}, final_Fn={final_fn:.6E}, "
f"secant={secant:.6E}"
)
print(
"sampled at PDF Shell-16 wn values: "
+ ", ".join(f"wn={wn:.3f}:Fn={fn:.6E} (PDF {ref_fn:.3f})" for wn, ref_fn, fn in sampled)
)
return 0
if __name__ == "__main__":
raise SystemExit(main())
@@ -0,0 +1,167 @@
from __future__ import annotations
import math
from pathlib import Path
RADIUS = 10.0
THICKNESS = 0.203840
YOUNG = 210.0e9
POISSON = 0.30
DENSITY = 7800.0
CAP_ANGLE = math.pi / 4.0
FINAL_CROWN_DISPLACEMENT = -6.20
STATIC_INITIAL_INCREMENT = 0.10
STATIC_TOTAL_TIME = 1.0
STATIC_MIN_INCREMENT = 1.0e-5
STATIC_MAX_INCREMENT = 0.10
CASES = (
("spherical_cap_displacement_control.inp", 16, 64, 0.10),
("spherical_cap_displacement_control_shell4.inp", 4, 16, 0.02),
)
def ring_node(ring: int, sector: int, circumferential_elements: int) -> int:
if ring < 1:
return 1
return 2 + (ring - 1) * circumferential_elements + sector % circumferential_elements
def node_coordinates(
meridional_elements: int,
circumferential_elements: int,
) -> dict[int, tuple[float, float, float]]:
nodes: dict[int, tuple[float, float, float]] = {1: (0.0, 0.0, 0.0)}
for ring in range(1, meridional_elements + 1):
theta = CAP_ANGLE * ring / meridional_elements
radial = RADIUS * math.sin(theta)
z = RADIUS * (math.cos(theta) - 1.0)
for sector in range(circumferential_elements):
phi = 2.0 * math.pi * sector / circumferential_elements
nodes[ring_node(ring, sector, circumferential_elements)] = (
radial * math.cos(phi),
radial * math.sin(phi),
z,
)
return nodes
def wrapped_lines(values: list[int], prefix: str = "") -> list[str]:
lines: list[str] = []
for index in range(0, len(values), 12):
chunk = values[index : index + 12]
head = prefix if index == 0 else ""
lines.append(head + ", ".join(str(value) for value in chunk))
return lines
def write_input(
path: Path,
meridional_elements: int,
circumferential_elements: int,
static_increment: float,
) -> None:
nodes = node_coordinates(meridional_elements, circumferential_elements)
rim_nodes = [
ring_node(meridional_elements, sector, circumferential_elements)
for sector in range(circumferential_elements)
]
tri_elements: list[tuple[int, int, int, int]] = []
quad_elements: list[tuple[int, int, int, int, int]] = []
elem_id = 1
for sector in range(circumferential_elements):
tri_elements.append(
(
elem_id,
1,
ring_node(1, sector, circumferential_elements),
ring_node(1, sector + 1, circumferential_elements),
)
)
elem_id += 1
for ring in range(1, meridional_elements):
for sector in range(circumferential_elements):
quad_elements.append(
(
elem_id,
ring_node(ring, sector, circumferential_elements),
ring_node(ring, sector + 1, circumferential_elements),
ring_node(ring + 1, sector + 1, circumferential_elements),
ring_node(ring + 1, sector, circumferential_elements),
)
)
elem_id += 1
with path.open("w", encoding="ascii", newline="\n") as handle:
handle.write("*HEADING\n")
handle.write("Spherical Cap with Central Point Load displacement-control benchmark\n")
handle.write("** Reference: COMSOL model models.sme.spherical_cap_with_central_point_load.pdf\n")
handle.write("** Source benchmark: Lyons and Holsgrove, NAFEMS, 2005.\n")
handle.write(f"** RADIUS_M={RADIUS:.8E}\n")
handle.write(f"** THICKNESS_M={THICKNESS:.8E}\n")
handle.write(f"** YOUNG_PA={YOUNG:.8E}\n")
handle.write(f"** POISSON={POISSON:.8E}\n")
handle.write(f"** CAP_ANGLE_RAD={CAP_ANGLE:.8E}\n")
handle.write(f"** MERIDIONAL_ELEMENTS={meridional_elements}\n")
handle.write(f"** CIRCUMFERENTIAL_ELEMENTS={circumferential_elements}\n")
handle.write(f"** CROWN_NODE=1\n")
handle.write(f"** FINAL_CROWN_DISPLACEMENT_M={FINAL_CROWN_DISPLACEMENT:.8E}\n")
handle.write("** Reference nondimensionalization: Fn=-F*a/(E*th^3*2*pi), wn=-w/th.\n")
handle.write("*NODE\n")
for node_id in sorted(nodes):
x, y, z = nodes[node_id]
handle.write(f"{node_id}, {x:.10E}, {y:.10E}, {z:.10E}\n")
handle.write("*ELEMENT, TYPE=S3, ELSET=CAP_TRI\n")
for elem in tri_elements:
handle.write("{}, {}, {}, {}\n".format(*elem))
handle.write("*ELEMENT, TYPE=S4, ELSET=CAP_QUAD\n")
for elem in quad_elements:
handle.write("{}, {}, {}, {}, {}\n".format(*elem))
handle.write("*NSET, NSET=CROWN\n")
handle.write("1\n")
handle.write("*NSET, NSET=RIM\n")
for line in wrapped_lines(rim_nodes):
handle.write(line + "\n")
handle.write("*MATERIAL, NAME=STEEL\n")
handle.write("*DENSITY\n")
handle.write(f"{DENSITY:.10E}\n")
handle.write("*ELASTIC\n")
handle.write(f"{YOUNG:.10E}, {POISSON:.10E}\n")
handle.write("*SHELL SECTION, ELSET=CAP_TRI, MATERIAL=STEEL\n")
handle.write(f"{THICKNESS:.10E}\n")
handle.write("*SHELL SECTION, ELSET=CAP_QUAD, MATERIAL=STEEL\n")
handle.write(f"{THICKNESS:.10E}\n")
handle.write("*BOUNDARY\n")
handle.write("RIM, 1, 6, 0.0\n")
handle.write("CROWN, 1, 2, 0.0\n")
handle.write("CROWN, 4, 6, 0.0\n")
handle.write("*AMPLITUDE, NAME=CROWN_DISP\n")
handle.write("0.0, 0.0, 1.0, 1.0\n")
handle.write("*BOUNDARY, AMPLITUDE=CROWN_DISP\n")
handle.write(f"CROWN, 3, 3, {FINAL_CROWN_DISPLACEMENT:.10E}\n")
handle.write(
"*NONLINEAR CONTINUATION, "
"METHOD=ARC_LENGTH_OR_DISPLACEMENT_CONTROL, SHELL_GEOMETRIC=YES\n"
)
handle.write("*STEP\n")
handle.write("*STATIC\n")
handle.write(
f"{static_increment:.10E}, {STATIC_TOTAL_TIME:.10E}, "
f"{STATIC_MIN_INCREMENT:.10E}, {static_increment:.10E}\n"
)
handle.write("*END STEP\n")
def main() -> int:
base = Path(__file__).parent
for filename, meridional, circumferential, static_increment in CASES:
write_input(base / filename, meridional, circumferential, static_increment)
return 0
if __name__ == "__main__":
raise SystemExit(main())
@@ -1,3 +1,3 @@
@echo off
call "%~dp0..\run_example_case.bat" "%~dp0" "spherical_cap_with_central_point_load" "--static-linear" "spherical_cap_s4_static.inp" "1"
call "%~dp0..\run_example_case.bat" "%~dp0" "spherical_cap_with_central_point_load" "--static-linear" "spherical_cap_displacement_control.inp" "1"
exit /b %errorlevel%
@@ -0,0 +1,173 @@
*HEADING
Spherical Cap with Central Point Load displacement-control benchmark
** Reference: COMSOL model models.sme.spherical_cap_with_central_point_load.pdf
** Source benchmark: Lyons and Holsgrove, NAFEMS, 2005.
** RADIUS_M=1.00000000E+01
** THICKNESS_M=2.03840000E-01
** YOUNG_PA=2.10000000E+11
** POISSON=3.00000000E-01
** CAP_ANGLE_RAD=7.85398163E-01
** MERIDIONAL_ELEMENTS=4
** CIRCUMFERENTIAL_ELEMENTS=16
** CROWN_NODE=1
** FINAL_CROWN_DISPLACEMENT_M=-6.20000000E+00
** Reference nondimensionalization: Fn=-F*a/(E*th^3*2*pi), wn=-w/th.
*NODE
1, 0.0000000000E+00, 0.0000000000E+00, 0.0000000000E+00
2, 1.9509032202E+00, 0.0000000000E+00, -1.9214719597E-01
3, 1.8023995550E+00, 7.4657834050E-01, -1.9214719597E-01
4, 1.3794968964E+00, 1.3794968964E+00, -1.9214719597E-01
5, 7.4657834050E-01, 1.8023995550E+00, -1.9214719597E-01
6, 1.1945836920E-16, 1.9509032202E+00, -1.9214719597E-01
7, -7.4657834050E-01, 1.8023995550E+00, -1.9214719597E-01
8, -1.3794968964E+00, 1.3794968964E+00, -1.9214719597E-01
9, -1.8023995550E+00, 7.4657834050E-01, -1.9214719597E-01
10, -1.9509032202E+00, 2.3891673840E-16, -1.9214719597E-01
11, -1.8023995550E+00, -7.4657834050E-01, -1.9214719597E-01
12, -1.3794968964E+00, -1.3794968964E+00, -1.9214719597E-01
13, -7.4657834050E-01, -1.8023995550E+00, -1.9214719597E-01
14, -3.5837510760E-16, -1.9509032202E+00, -1.9214719597E-01
15, 7.4657834050E-01, -1.8023995550E+00, -1.9214719597E-01
16, 1.3794968964E+00, -1.3794968964E+00, -1.9214719597E-01
17, 1.8023995550E+00, -7.4657834050E-01, -1.9214719597E-01
18, 3.8268343237E+00, 0.0000000000E+00, -7.6120467489E-01
19, 3.5355339059E+00, 1.4644660941E+00, -7.6120467489E-01
20, 2.7059805007E+00, 2.7059805007E+00, -7.6120467489E-01
21, 1.4644660941E+00, 3.5355339059E+00, -7.6120467489E-01
22, 2.3432602027E-16, 3.8268343237E+00, -7.6120467489E-01
23, -1.4644660941E+00, 3.5355339059E+00, -7.6120467489E-01
24, -2.7059805007E+00, 2.7059805007E+00, -7.6120467489E-01
25, -3.5355339059E+00, 1.4644660941E+00, -7.6120467489E-01
26, -3.8268343237E+00, 4.6865204053E-16, -7.6120467489E-01
27, -3.5355339059E+00, -1.4644660941E+00, -7.6120467489E-01
28, -2.7059805007E+00, -2.7059805007E+00, -7.6120467489E-01
29, -1.4644660941E+00, -3.5355339059E+00, -7.6120467489E-01
30, -7.0297806080E-16, -3.8268343237E+00, -7.6120467489E-01
31, 1.4644660941E+00, -3.5355339059E+00, -7.6120467489E-01
32, 2.7059805007E+00, -2.7059805007E+00, -7.6120467489E-01
33, 3.5355339059E+00, -1.4644660941E+00, -7.6120467489E-01
34, 5.5557023302E+00, 0.0000000000E+00, -1.6853038770E+00
35, 5.1327996716E+00, 2.1260752369E+00, -1.6853038770E+00
36, 3.9284747919E+00, 3.9284747919E+00, -1.6853038770E+00
37, 2.1260752369E+00, 5.1327996716E+00, -1.6853038770E+00
38, 3.4018865378E-16, 5.5557023302E+00, -1.6853038770E+00
39, -2.1260752369E+00, 5.1327996716E+00, -1.6853038770E+00
40, -3.9284747919E+00, 3.9284747919E+00, -1.6853038770E+00
41, -5.1327996716E+00, 2.1260752369E+00, -1.6853038770E+00
42, -5.5557023302E+00, 6.8037730757E-16, -1.6853038770E+00
43, -5.1327996716E+00, -2.1260752369E+00, -1.6853038770E+00
44, -3.9284747919E+00, -3.9284747919E+00, -1.6853038770E+00
45, -2.1260752369E+00, -5.1327996716E+00, -1.6853038770E+00
46, -1.0205659614E-15, -5.5557023302E+00, -1.6853038770E+00
47, 2.1260752369E+00, -5.1327996716E+00, -1.6853038770E+00
48, 3.9284747919E+00, -3.9284747919E+00, -1.6853038770E+00
49, 5.1327996716E+00, -2.1260752369E+00, -1.6853038770E+00
50, 7.0710678119E+00, 0.0000000000E+00, -2.9289321881E+00
51, 6.5328148244E+00, 2.7059805007E+00, -2.9289321881E+00
52, 5.0000000000E+00, 5.0000000000E+00, -2.9289321881E+00
53, 2.7059805007E+00, 6.5328148244E+00, -2.9289321881E+00
54, 4.3297802812E-16, 7.0710678119E+00, -2.9289321881E+00
55, -2.7059805007E+00, 6.5328148244E+00, -2.9289321881E+00
56, -5.0000000000E+00, 5.0000000000E+00, -2.9289321881E+00
57, -6.5328148244E+00, 2.7059805007E+00, -2.9289321881E+00
58, -7.0710678119E+00, 8.6595605624E-16, -2.9289321881E+00
59, -6.5328148244E+00, -2.7059805007E+00, -2.9289321881E+00
60, -5.0000000000E+00, -5.0000000000E+00, -2.9289321881E+00
61, -2.7059805007E+00, -6.5328148244E+00, -2.9289321881E+00
62, -1.2989340844E-15, -7.0710678119E+00, -2.9289321881E+00
63, 2.7059805007E+00, -6.5328148244E+00, -2.9289321881E+00
64, 5.0000000000E+00, -5.0000000000E+00, -2.9289321881E+00
65, 6.5328148244E+00, -2.7059805007E+00, -2.9289321881E+00
*ELEMENT, TYPE=S3, ELSET=CAP_TRI
1, 1, 2, 3
2, 1, 3, 4
3, 1, 4, 5
4, 1, 5, 6
5, 1, 6, 7
6, 1, 7, 8
7, 1, 8, 9
8, 1, 9, 10
9, 1, 10, 11
10, 1, 11, 12
11, 1, 12, 13
12, 1, 13, 14
13, 1, 14, 15
14, 1, 15, 16
15, 1, 16, 17
16, 1, 17, 2
*ELEMENT, TYPE=S4, ELSET=CAP_QUAD
17, 2, 3, 19, 18
18, 3, 4, 20, 19
19, 4, 5, 21, 20
20, 5, 6, 22, 21
21, 6, 7, 23, 22
22, 7, 8, 24, 23
23, 8, 9, 25, 24
24, 9, 10, 26, 25
25, 10, 11, 27, 26
26, 11, 12, 28, 27
27, 12, 13, 29, 28
28, 13, 14, 30, 29
29, 14, 15, 31, 30
30, 15, 16, 32, 31
31, 16, 17, 33, 32
32, 17, 2, 18, 33
33, 18, 19, 35, 34
34, 19, 20, 36, 35
35, 20, 21, 37, 36
36, 21, 22, 38, 37
37, 22, 23, 39, 38
38, 23, 24, 40, 39
39, 24, 25, 41, 40
40, 25, 26, 42, 41
41, 26, 27, 43, 42
42, 27, 28, 44, 43
43, 28, 29, 45, 44
44, 29, 30, 46, 45
45, 30, 31, 47, 46
46, 31, 32, 48, 47
47, 32, 33, 49, 48
48, 33, 18, 34, 49
49, 34, 35, 51, 50
50, 35, 36, 52, 51
51, 36, 37, 53, 52
52, 37, 38, 54, 53
53, 38, 39, 55, 54
54, 39, 40, 56, 55
55, 40, 41, 57, 56
56, 41, 42, 58, 57
57, 42, 43, 59, 58
58, 43, 44, 60, 59
59, 44, 45, 61, 60
60, 45, 46, 62, 61
61, 46, 47, 63, 62
62, 47, 48, 64, 63
63, 48, 49, 65, 64
64, 49, 34, 50, 65
*NSET, NSET=CROWN
1
*NSET, NSET=RIM
50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61
62, 63, 64, 65
*MATERIAL, NAME=STEEL
*DENSITY
7.8000000000E+03
*ELASTIC
2.1000000000E+11, 3.0000000000E-01
*SHELL SECTION, ELSET=CAP_TRI, MATERIAL=STEEL
2.0384000000E-01
*SHELL SECTION, ELSET=CAP_QUAD, MATERIAL=STEEL
2.0384000000E-01
*BOUNDARY
RIM, 1, 6, 0.0
CROWN, 1, 2, 0.0
CROWN, 4, 6, 0.0
*AMPLITUDE, NAME=CROWN_DISP
0.0, 0.0, 1.0, 1.0
*BOUNDARY, AMPLITUDE=CROWN_DISP
CROWN, 3, 3, -6.2000000000E+00
*NONLINEAR CONTINUATION, METHOD=ARC_LENGTH_OR_DISPLACEMENT_CONTROL, SHELL_GEOMETRIC=YES
*STEP
*STATIC
2.0000000000E-02, 1.0000000000E+00, 1.0000000000E-05, 2.0000000000E-02
*END STEP
@@ -1,36 +0,0 @@
*HEADING
FemLite V4.8 compact spherical cap central point-load smoke case
** Reference scale: radius=10 m, thickness=0.20384 m, E=210 GPa, nu=0.3.
*NODE
1, -1.0, -1.0, -0.1005
2, 0.0, -1.0, -0.0501
3, 1.0, -1.0, -0.1005
4, -1.0, 0.0, -0.0501
5, 0.0, 0.0, 0.0000
6, 1.0, 0.0, -0.0501
7, -1.0, 1.0, -0.1005
8, 0.0, 1.0, -0.0501
9, 1.0, 1.0, -0.1005
*ELEMENT, TYPE=S4, ELSET=CAP
1, 1, 2, 5, 4
2, 2, 3, 6, 5
3, 4, 5, 8, 7
4, 5, 6, 9, 8
*NSET, NSET=EDGE
1, 2, 3, 4, 6, 7, 8, 9
*NSET, NSET=CROWN
5
*MATERIAL, NAME=STEEL
*DENSITY
7800.0
*ELASTIC
2.10E11, 0.30
*SHELL SECTION, ELSET=CAP, MATERIAL=STEEL
2.0384E-1
*BOUNDARY
EDGE, 1, 6, 0.0
*STEP
*STATIC
*CLOAD
CROWN, 3, -1.0E5
*END STEP