Skip to content

Model quality check sheet

Module: crashmetrics.quality (NumPy only). Synthetic runs to try it come from crashmetrics.synthetic.

Before anyone reads injury values or intrusions from a crash run, the run itself has to be trusted: did it finish, is the mass right, how much mass did mass scaling add, is the energy balance sound, do the contacts behave? Teams usually check this by hand in several files. check_model does it in one pass and gives one sheet per run.

from crashmetrics.quality import check_model

sheet = check_model("runs/loop12", target_mass=1500.0, target_cg=(1305, 0, 550))
print(sheet.summary())          # or sheet.table() for Markdown
sheet.passed, sheet.failures, sheet.warnings

It reads d3hsp, glstat, matsum and sleout from the run folder (upper case or a job prefix such as run1.glstat also work). A missing or unreadable file skips its checks; at least one file is needed.

The checks

Group Check Passes when From
Run Termination Normal termination d3hsp
Run End time reached Problem time ≥ 99.5 % of the termination time d3hsp, glstat
Run Errors No error messages d3hsp
Run Warnings Reported; advisory limit if you set one d3hsp
Mass Total mass Within ± 1 % of target_mass d3hsp
Mass Centre of gravity Within 10 mm of target_cg d3hsp
Mass Added mass, start ≤ 5 % of the model mass glstat
Mass Added mass, peak ≤ 5 % of the model mass glstat
Mass Added mass, growth Advisory: ≤ 1 % point during the run glstat
Mass Added mass per part ≤ 20 % of the part's mass matsum, d3hsp
Time step Time step Advisory: falls ≤ 10 % below its first value glstat
Time step Mass scaling Reported (dt2ms) d3hsp
Time step Smallest elements Advisory: mass factor ≤ 4 d3hsp, glstat
Energy Energy ratio 0.95 to 1.05 glstat
Energy Hourglass energy ≤ 10 % of the internal energy glstat
Energy Negative contact energy ≤ 5 % (total sliding energy) glstat
Energy Damping energy ≤ 5 % glstat
Energy Hourglass energy per part ≤ 10 % of the part's internal energy matsum
Energy Negative internal energy per part ≤ 1 % matsum
Contacts Negative energy per contact ≤ 1 % of the peak internal energy sleout, glstat

Each check has a status:

  • PASS or FAIL: against its limit. A sheet passes when nothing fails.
  • WARN: an advisory limit was passed; the sheet still passes.
  • INFO: reported without a limit (no target given, or the limit set to None).
  • SKIP: the file or value is missing; the note says which.

Values are in kg, mm, ms and kJ for any unit system (unit_system=, default mm-ms-kg).

The limits are common practice, not a standard

The defaults are widely used rules of thumb. Set your team's values with QualityLimits. The energy checks are those of LS-DYNA energy checks and take EnergyLimits.

from crashmetrics.energy_check import EnergyLimits
from crashmetrics.quality import QualityLimits

limits = QualityLimits(added_mass=3.0, mass_tolerance=0.5, warnings=50,
                       contact_negative=None,                  # report only
                       energy=EnergyLimits(part_hourglass=0.05))
sheet = check_model("runs/loop12", limits=limits)

What the checks mean

  • Added mass. Mass scaling adds mass to elements whose time step is below the chosen one (dt2ms). The start value shows what the mesh needs; growth during the run means elements deform into smaller time steps. Too much added mass changes the crash energy.
  • Added mass per part needs the per-part added mass in matsum (written when mass scaling is on) and the part masses in d3hsp.
  • Smallest elements. The table of smallest time steps in d3hsp shows which elements control the run. With mass scaling, the mass factor is (time step / element time step)²: a factor of 20 means that element is 20 times heavier than meshed. The note lists the parts that fill the table, which is where to remesh.
  • Time step. Without mass scaling the time step falls as elements deform; a large fall often comes just before an error termination.
  • Negative energy per contact. Negative contact energy comes from initial penetrations or parts passing through each other. The energy group checks the total; this check names the contact.
  • Hourglass energy per part names the parts whose elements deform in zero-energy modes; their absorbed energy is not reliable.

Several runs side by side

from crashmetrics.quality import quality_matrix

print(quality_matrix([check_model(f"runs/{name}") for name in runs]))

One row per check, one column per run, with the status and the number behind it (percent, mm or factor). values=False gives the status only.

From data already read

from crashmetrics.quality import check_model_data

sheet = check_model_data("loop12", d3hsp=d, glstat=g, matsum=p, sleout=s,
                         target_mass=1500.0)

Use this when the files have other names or the data comes from a binout reader.

Synthetic runs

crashmetrics.synthetic writes d3hsp, glstat and sleout next to matsum, secforc and swforc. ModelQuality sets what the solver would report (added mass, time step, contact energies, warnings, termination) without changing the crash itself.

Run Set-up The sheet should show
baseline 0.4 % added mass rising to 0.6 %, friction only in the contacts Passed
poor_model_quality 5.8 % added mass rising to 7.9 %, 16 % hourglass in the crash boxes, negative energy in the self contact, 0.21 µs elements 4 failures, 2 warnings
ModelQuality(error_at=38.0, ...) Stops at 38 ms with an error Termination, end time and errors fail

Example

"""Example 33: model quality check sheet of a crash run.

Before reading injury values or intrusions, check the run itself. Two
runs of the same synthetic frontal crash (crashmetrics.synthetic writes
d3hsp, glstat, matsum and sleout in the LS-DYNA layout; point
check_model at your own run folder instead): a well prepared model and
a poorly prepared one, and a run that stopped with an error.

1. The sheet of the good model, against target mass and centre of gravity.
2. The poor model: what fails and why.
3. Both side by side.
4. A run that terminated with an error, and your own limits.
"""

from dataclasses import replace

from crashmetrics.energy_check import EnergyLimits
from crashmetrics.quality import QualityLimits, check_model, quality_matrix
from crashmetrics.synthetic import ModelQuality, frontal_model, simulate

for variant in ("baseline", "poor_model_quality"):
    simulate(frontal_model(variant)).write(f"runs/{variant}")
target = {"target_mass": 1500.0, "target_cg": (1305.0, 0.0, 550.0)}   # kg, mm

# --- 1. A well prepared model ----------------------------------------------------
good = check_model("runs/baseline", **target)
print(good.summary())

# --- 2. A poorly prepared model --------------------------------------------------
poor = check_model("runs/poor_model_quality", **target)
print()
print(f"Model quality, {poor.run}: {poor.verdict()}")
for check in (*poor.failures, *poor.warnings):
    note = f" ({check.note})" if check.note else ""
    print(f"  {check.status} {check.name}: {check.value}, limit {check.limit}{note}")

# --- 3. Side by side -------------------------------------------------------------
print()
print(quality_matrix([good, poor]))

# --- 4. An error termination, and your own limits --------------------------------
stopped = replace(frontal_model(), name="stopped", quality=ModelQuality(
    error_at=38.0, mass_scaled=False, timestep_drop=0.25))
simulate(stopped).write("runs/stopped")
sheet = check_model("runs/stopped")
print()
for name in ("Termination", "End time reached", "Errors", "Time step"):
    check = sheet.check(name)
    print(f"{check.status} {name}: {check.value}"
          + (f" ({check.note})" if check.note else ""))
limits = QualityLimits(added_mass=3.0, mass_tolerance=0.5,
                       energy=EnergyLimits(hourglass=0.05, part_hourglass=0.03))
strict = check_model("runs/baseline", limits=limits, **target)
print(f"Baseline with stricter limits: {strict.verdict()}: "
      + "; ".join(f"{c.name} {c.value} (limit {c.limit})" for c in strict.failures))

Output:

Model quality, baseline: PASSED, 1 skipped
Run:
  PASS Termination                        normal  [normal]
  PASS End time reached                   100.0 of 100.0 ms (100.0 %)  [≥ 99.5 %]
  PASS Errors                             0  [0]
  INFO Warnings                           2  (most frequent: 41123 x1, 40538 x1)
Mass:
  PASS Total mass                         1500.0 kg (+0.00 % of target 1500.0)  [± 1 %]
  PASS Centre of gravity                  (1310, 2.00, 545.0) mm, 7.35 mm from target  [≤ 10 mm]
  PASS Added mass, start                  0.40 %  [≤ 5 %]
  PASS Added mass, peak                   0.60 % (9.00 kg)  [≤ 5 %]
  PASS Added mass, growth                 +0.20 % points  [≤ 1 % points]
  SKIP Added mass per part                -  (no added mass in matsum)
Time step:
  PASS Time step                          1.00 µs, lowest 1.00 µs (-0.0 %)  [≤ 10 % drop]
  INFO Mass scaling                       dt2ms -0.0011111: time step 1.000 µs  (negative dt2ms: mass added only where needed)
  PASS Smallest elements                  0.900 µs: shell 110000 of part 110; mass factor 1.23  [≤ 4 x mass]  (in the table: part 110 x6, part 120 x4)
Energy:
  PASS Energy ratio                       1.009  [0.95 to 1.05]
  PASS Hourglass energy                   2.2 %  [≤ 10 %]
  PASS Negative contact energy            0.0 %  [≤ 5 %]
  PASS Damping energy                     0.0 %  [≤ 5 %]
  PASS Hourglass energy per part          3.1 %  [≤ 10 %]  (part 110 (Crash box LH))
  PASS Negative internal energy per part  0.0 %  [≤ 1 %]
Contacts:
  PASS Negative energy per contact        none (3 contacts)  [≤ 1 % of internal energy]

Model quality, poor_model_quality: FAILED (4 checks), 2 warnings, 1 skipped
  FAIL Added mass, start: 5.80 %, limit ≤ 5 %
  FAIL Added mass, peak: 7.90 % (118 kg), limit ≤ 5 %
  FAIL Hourglass energy per part: 18.8 %, limit ≤ 10 % (part 110 (Crash box LH); over the limit: part 110, 111)
  FAIL Negative energy per contact: 4.43 % (-7.69 kJ) in contact 2 (Front end self contact), limit ≤ 1 % of internal energy (over the limit: contact 2)
  WARN Added mass, growth: +2.10 % points, limit ≤ 1 % points (elements deform into smaller time steps)
  WARN Smallest elements: 0.210 µs: shell 150000 of part 150; mass factor 22.7, limit ≤ 4 x mass (in the table: part 150 x6, part 120 x4)

| Group | Check | baseline | poor_model_quality |
| --- | --- | --- | --- |
| Run | Termination | ✅ | ✅ |
| Run | End time reached | ✅ 100 | ✅ 100 |
| Run | Errors | ✅ 0 | ✅ 0 |
| Run | Warnings | ℹ️ 2 | ℹ️ 37 |
| Mass | Total mass | ✅ 1500 | ✅ 1500 |
| Mass | Centre of gravity | ✅ 7.35 | ✅ 7.35 |
| Mass | Added mass, start | ✅ 0.400 | ❌ 5.80 |
| Mass | Added mass, peak | ✅ 0.600 | ❌ 7.90 |
| Mass | Added mass, growth | ✅ 0.200 | ⚠️ 2.10 |
| Mass | Added mass per part | ➖ | ➖ |
| Time step | Time step | ✅ 0 | ✅ 0 |
| Time step | Mass scaling | ℹ️ | ℹ️ |
| Time step | Smallest elements | ✅ 1.23 | ⚠️ 22.7 |
| Energy | Energy ratio | ✅ 1.01 | ✅ 0.964 |
| Energy | Hourglass energy | ✅ 2.24 | ✅ 4.59 |
| Energy | Negative contact energy | ✅ 0 | ✅ 3.68 |
| Energy | Damping energy | ✅ 0 | ✅ 0 |
| Energy | Hourglass energy per part | ✅ 3.06 | ❌ 18.8 |
| Energy | Negative internal energy per part | ✅ 0 | ✅ 0 |
| Contacts | Negative energy per contact | ✅ 0 | ❌ 4.43 |
| | **Verdict** | **PASSED** | **FAILED** |

FAIL Termination: error
FAIL End time reached: 38.00 of 100.0 ms (38.0 %)
FAIL Errors: 1 (40509: Negative volume in a solid element (synthetic).)
WARN Time step: 1.00 µs, lowest 0.750 µs (-25.0 %)
Baseline with stricter limits: FAILED (1 check), 1 skipped: Hourglass energy per part 3.1 % (limit ≤ 3 %)

Tested with

  • Synthetic runs, whose faults are known.
  • Real LS-DYNA output (MIT licence, in the repository): a drop test (glstat, matsum) and its trimmed d3hsp, including the mass centre.
  • Real run folders checked locally (no licence or not MIT, so not included): a ball drop with all files; a bolted joint whose energy ratio grows with external work; a quasi-static crimping run with very heavy mass scaling; a run whose glstat has one state (reported as unreadable, its checks skipped).