Recipes¶
Short, copy-paste answers to "how do I…" questions. Each assumes
import dynars (Python) or use dynars::... (Rust) and a parsed deck. For the
concepts behind them, see Concepts; for full APIs, the
reference.
Census: what does this deck contain?¶
How big is the model, and what does it include?¶
Find every part that uses a given material¶
List every material with its density¶
Dump all node coordinates to a NumPy array (or CSV)¶
Get shell connectivity as one array¶
Find dangling references and print clickable locations¶
Follow a boundary condition to its load curve¶
Check every deck in a folder at once¶
from glob import glob
ws = dynars.Workspace()
roots = glob("runs/*/main.k")
decks = ws.parse_decks(roots) # shared *INCLUDEs read once
reports = ws.validate_decks(decks, [
dynars.Rule.references_resolve(),
dynars.Rule.duplicate_ids(),
])
for root, r in zip(roots, reports):
print("OK " if r.is_clean() else "FAIL", root, r.count(dynars.Severity.Error))
print(ws.stats())
use dynars::Workspace;
use dynars::validate::Rule;
let ws = Workspace::new();
let roots = ["runs/a/main.k", "runs/b/main.k"];
let decks: Vec<_> = ws.parse_decks(roots).into_iter()
.filter_map(|(_root, d)| d.ok()).collect();
let reports = ws.validate_decks(&decks, [Rule::references_resolve(), Rule::duplicate_ids()]);
println!("{} decks checked", reports.len());
Plot a global energy history from a binout¶
Filter an acceleration channel and compute HIC¶
from dynars import signal, injury
b = dynars.parse_binout("binout*")
# One node's acceleration history, by node id (read(..., id=) -> [T]):
node = 1000001
t = b.read("nodout", "time")
dt = t[1] - t[0]
ax = b.read("nodout", "x_acceleration", id=node)
ay = b.read("nodout", "y_acceleration", id=node)
az = b.read("nodout", "z_acceleration", id=node)
a = signal.cfc(injury.resultant(ax, ay, az), 1000, dt) # CFC1000
print("HIC36 =", injury.hic36(a, dt), " 3ms clip =", injury.clip(a, dt))
Read one node's displacement history across all states (d3plot)¶
Change a material property and write the deck back¶
Surgical, include-aware, byte-minimal: only the one field changes; comments, rulers, and the rest of the deck are preserved verbatim.
Read a keyword dynars doesn't ship¶
See Schemas for the class-based (@keyword / #[derive(Keyword)])
front ends and reference declarations.