LS-DYNA energy checks¶
Modules: crashmetrics.energy_check, crashmetrics.lsdyna,
crashmetrics.d3hsp; command crashmetrics-energy.
A simulation result is only as good as its energy balance. These checks
work for any load case (frontal, side, pedestrian, component tests).
The other ASCII files (nodout, rcforc, sleout, secforc,
rwforc, sbtout, abstat ...) are read by the
LS-DYNA ASCII output readers.
From the command line¶
Each run is a directory with glstat (and optionally matsum), or a
glstat file:
crashmetrics-energy run01 run02 run03
crashmetrics-energy run01 --hourglass 0.05 --added-mass 2 --ratio-min 0.9 --ratio-max 1.1
crashmetrics-energy run01 --hourglass off
The exit code is 0 if every run passes, 1 if a check fails and 2 if a run could not be read, so it fits batch scripts and job queues.
From Python¶
from crashmetrics.energy_check import EnergyLimits, check_energies
from crashmetrics.lsdyna import check_run, read_d3hsp, read_glstat, read_matsum
report = check_run("run01", limits=EnergyLimits(hourglass=0.05))
print(report.summary())
report.passed, report.failures, report.failed_parts
# Step by step, or with energies from another source:
report = check_energies(read_glstat("run01/glstat"), read_matsum("run01/matsum"))
The checks¶
| Check | Value | Default limit |
|---|---|---|
energy_ratio |
total / (initial total + external work), min and max over the run | 0.95 to 1.05 |
hourglass |
peak hourglass / peak internal energy | ≤ 0.10 |
negative_contact |
most negative contact (sliding) energy / reference energy | ≤ 0.05 |
damping |
peak system damping energy / reference energy | ≤ 0.05 |
added_mass |
peak added mass, % of model mass | ≤ 5 % |
eroded_energy |
peak eroded energy / reference energy | reported only |
part_hourglass |
per part: peak hourglass / peak internal energy | ≤ 0.10 |
part_negative_internal |
per part: most negative / peak internal energy | ≤ 0.01 |
- The reference energy is the largest initial total energy plus external work, so impacts and prescribed-motion or quasi-static cases are both handled.
- Part checks cover parts with at least 1 % of the model's peak internal
energy (
part_min_internal_share); all parts are inreport.parts. - Hourglass, damping and rigidwall energies appear in the output only
when
HGEN,RYLENandRWENare 2 in*CONTROL_ENERGY; missing channels are reported as skipped, with a hint. - The 10 % hourglass limit is LS-DYNA's rule of thumb; the other
defaults are common rules of thumb. Use your company's guideline
values in
EnergyLimitsor on the command line.
For the full pre-flight check of a run (termination, mass, added mass, time step and contacts as well as these energy checks), see the Model quality check sheet.
Run information from d3hsp¶
run = read_d3hsp("run01/d3hsp")
print(run.summary())
run.termination, run.warnings, run.errors
run.model, run.total_mass, run.min_timestep
run.parameters["time_step_scale_factor"], run.keyword_counts["*CONTACT_option"]
run.elapsed_seconds, run.memory
| Attribute | Content |
|---|---|
termination, termination_time |
"normal", "error" or "incomplete" (no banner: still running or killed) |
version, parallel, precision, release, revision, platform, ncpu, command_line, input_file, run_date |
Run information |
messages, warnings, errors, message_counts() |
Warning and error messages with their text |
model |
Nodes, elements by type, materials, contacts |
parameters |
Every echoed label..... value setting |
keyword_counts |
Keywords in the deck |
part_masses, rigid_parts, total_mass, mass_center |
Mass summary and the mass centre of the model |
smallest_timesteps, min_timestep |
The 100 smallest time steps |
problem_time, problem_cycles, cpu_seconds, elapsed_seconds, workers, worker_type, timing, memory |
Timing and memory |
The readers find values by their labels, so the line order and the optional channels of different LS-DYNA versions do not matter. They were verified on real LS-DYNA R14.1 and R16.1 SMP output; MPP output is accepted but has not been checked on real files yet.
For binout files, crashmetrics.binout gives the same objects
(read_binout(run).glstat(), .matsum()), and check_run reads them
by itself when a run folder has no ASCII glstat. See
LS-DYNA binout.
Complete example¶
The repository's small LS-DYNA R14.1 sample (from the MIT-licensed K-agent project):
"""Example 9: LS-DYNA energy balance checks and the d3hsp run summary.
Uses the small LS-DYNA R14.1 output in tests/data (from the MIT-licensed
K-agent project). Point `run` at your own run directory instead.
The same check is available on the command line:
crashmetrics-energy run01 run02 --hourglass 0.05 --added-mass 2
"""
from pathlib import Path
from crashmetrics.energy_check import EnergyLimits, check_energies
from crashmetrics.lsdyna import check_run, read_d3hsp, read_glstat, read_matsum
data = Path(__file__).resolve().parents[1] / "tests" / "data" / "lsdyna" / "kagent"
run = data / "drop_e2e" # contains glstat and matsum
# --- 1. One call for a run directory ---------------------------------------
report = check_run(run, limits=EnergyLimits(hourglass=0.05))
print(report.summary())
print()
# --- 2. Or step by step, with your own limits --------------------------------
glstat = read_glstat(run / "glstat")
matsum = read_matsum(run / "matsum")
print(f"glstat: {len(glstat.time)} states up to t = {glstat.time[-1]:.4g}; "
f"matsum parts {[int(p) for p in matsum.part_ids]}")
strict = check_energies(glstat, matsum, EnergyLimits(energy_ratio=(0.98, 1.02),
hourglass=0.02))
for check in strict.checks:
value = "-" if check.value is None else f"{check.value:.4g}"
print(f" {check.name:22s} {check.status:7s} value {value:8s} limit {check.limit}")
print(f"Passed: {strict.passed}")
print()
# --- 3. Run information from d3hsp -------------------------------------------
d3hsp = read_d3hsp(data / "cold_start" / "d3hsp_minimal")
print(d3hsp.summary())
Output:
Energy check: PASSED
Reference energy: 2009.89
Check Value Limit Status Where
---------------------- ----- ------------ ------- ------
energy_ratio 1 0.95 to 1.05 PASS t=0
hourglass 0 <= 0.05 PASS t=0
negative_contact 0 <= 0.05 PASS
damping 0 <= 0.05 PASS
added_mass - <= 5 % SKIPPED
eroded_energy 0 - INFO
part_hourglass 0 <= 0.1 PASS part 1
part_negative_internal 0 <= 0.01 PASS
- energy_ratio: min 1.0000, max 1.0000 (solver ratio); added mass raises the ratio
- added_mass: no added mass percentage in the output
- part_hourglass: 1 of 2 parts checked (peak internal energy >= 1% of the model's)
glstat: 3 states up to t = 2.943e-05; matsum parts [1, 2]
energy_ratio pass value 1 limit 0.98 to 1.02
hourglass pass value 0 limit <= 0.02
negative_contact pass value 0 limit <= 0.05
damping pass value 0 limit <= 0.05
added_mass skipped value - limit <= 5 %
eroded_energy info value 0 limit -
part_hourglass pass value 0 limit <= 0.1
part_negative_internal pass value 0 limit <= 0.01
Passed: True
Termination: NORMAL (10/23/26 14:41:58)
LS-DYNA smp s R14, revision R14.1.1-4-gaf1eb871e8, WINDOWS X64 SSE2
Input: ball_drop.k
Model: nodes 988, solid_elements 8, shell_elements 900, beam_elements 0, thick_shell_elements 0, materials 2, contacts 1, parts_with_added_mass 0
Total mass: 0.000134069 (2 parts, 1 rigid)
Smallest time step: 8.409e-07 (shell 100099, part 1)
Problem time 0.0030004 in 3568 cycles
Elapsed: 1 s using 4 SMP threads, CPU 2 s
Warnings: 0, errors: 0