Load paths and energy across runs¶
Modules: crashmetrics.loadpath (analysis) and crashmetrics.synthetic
(a toy frontal crash that writes LS-DYNA-style output). NumPy only.
These are the questions after every crash run:
- Which parts absorbed the energy, and when?
- How was the load shared between the upper, middle and lower load paths?
- Did the structure crush in the intended order (crash box before rail)?
- Against the previous loop, which parts changed? That is, what is the culprit?
crashmetrics.loadpath answers them from the two files every crash run
writes: matsum (part energies) and secforc (section forces).
| Step | Functions |
|---|---|
| Read a run folder; pick parts and sections by ID or title | load_run, select_parts, select_sections |
| Energy per part and group, share, when it is absorbed | energy_ranking, energy_history |
| Section forces: one component, the main load positive, CFC filter | section_forces |
| Peak, mean force, impulse, loading time | force_metrics |
| Load split between paths, against a target | load_split |
| Crush sequence of chains of parts | crush_sequence |
| Baseline against variant: changes ranked, culprit parts, curve similarity | compare_runs |
| Many runs side by side; CSV | energy_matrix |
| All of it as Markdown | loadpath_report |
Results are in kJ, kN and ms, whatever the model units (unit_system=,
default mm-ms-kg).
No data at hand? Use the synthetic frontal model¶
from crashmetrics.synthetic import VARIANTS, frontal_model, simulate
simulate(frontal_model("baseline")).write("runs/baseline") # matsum + secforc
crashmetrics.synthetic is a lumped full-width frontal crash against a
rigid wall at 56 km/h. It has 1500 kg on parallel load paths:
| Path (LH and RH) | Parts, front to rear | Mean force, kN |
|---|---|---|
| Main rail | bumper beam (half), crash box, front rail, rear rail | 45, 95, 150, 230 |
| Upper | upper (shotgun) rail, after a 60 mm gap | 45 |
| Lower | subframe extension, subframe (half), after a 90 mm gap | 35, 80 |
A part crushes at its strength: an initial peak to start the first fold, then folding waves around the mean force. In a chain the weakest part crushes first, as in a real structure, so a rear part weaker than the one in front of it gives a wrong crush sequence.
The result is a realistic run: 432 mm of crush, a 53 g peak, about 1.3 m/s rebound, and the energy balance closed within 0.2 %.
| Variant | What changes | What the analysis should find |
|---|---|---|
baseline |
Reference car | Load split about 17 / 59 / 24 %; crush in order |
weak_front_rail_lh |
LH front rail 80 kN instead of 150 kN | The LH front rail crushes before the LH crash box; it absorbs 15 kJ less; the rear rails pick it up |
no_lower_path |
Subframe extensions and subframe removed | The middle path carries about 80 %; the rear rails crush (+17 kJ each) |
weak_welds_front_rail_lh |
LH front rail flange welds at about a third of their strength | The welds unzip and the rail absorbs 3 kJ less; see Spot weld failure |
poor_model_quality |
The same crash from a poorly prepared model (added mass, hourglass, contact energy) | See Model quality check sheet |
The files are written in the LS-DYNA ASCII layout and say in their
header that they are synthetic. The model also has spot welds and writes
swforc, and it writes glstat, sleout and a short d3hsp for the
model quality checks. The write_... functions write any data in those
layouts. The model is for teaching and for testing
tools, not a vehicle simulation.
Reading runs¶
from crashmetrics.loadpath import load_run, select_parts
run = load_run("runs/baseline") # name = folder name
run = load_run("job12", unit_system="mm-s-t") # files: matsum or job12.matsum
select_parts(run, "Crash box*") # [110, 111]
select_parts(run, [120, "Rear rail*"]) # IDs and title patterns
load_runreadsmatsumandsecforc(alsoMATSUMor a job prefix such asrun1.matsum). Either may be missing, but not both.- Titles come from the files' legend, so the
*PARTand*DATABASE_CROSS_SECTIONtitles in your model decide how easy the selection is. - Patterns use
*and?, case ignored.
unit_system |
Force | Energy | Time |
|---|---|---|---|
mm-ms-kg (default) |
kN | J (kN mm) | ms |
mm-s-t |
N | mJ (N mm) | s |
mm-s-kg |
mN | µJ | s |
m-s-kg |
N | J | s |
1. Energy absorption¶
from crashmetrics.loadpath import energy_history, energy_ranking
groups = {"crash boxes": "Crash box*", "front rails": "Front rail*",
"upper rails": "Upper rail*", "lower path": "Subframe*"}
ranking = energy_ranking(run, exclude="Body*", groups=groups)
print(ranking.table(top=8))
t, energy = energy_history(run, groups) # kJ over time, for plots
- Absorbed energy is the matsum internal energy plus the internal
energy of eroded elements (
include_eroded=True), at the end of the run or attime=. - Each row gives the share and cumulative share, the times at 10 / 50 /
90 % of the part's energy (
onset=sets the first), and the hourglass energy as a share of the part's energy. excludethe parts that only carry kinetic energy (the body, rigid barriers).groupsare summed.
2. Section forces¶
from crashmetrics.loadpath import force_metrics, section_forces
forces = section_forces(run, cfc=60) # kN, main load positive
forces[13] # one section over time
for m in force_metrics(forces):
print(m.name, m.peak, m.mean, m.impulse)
- Component:
"auto"(default) takes, per section, the axis with the largest impulse."x","y","z"or"total"(magnitude) choose one. - Sign: with
orientation="auto", sections whose force is mainly negative are reversed. So the main load is positive whatever way the section normal points;forces.flippedsays which. Use"as_written"for the file's sign. - Filter:
cfc=60or180(SAE J211) before reading peaks. Unevenly spaced output (MPP) is resampled at its median time step first. force_metrics:- peak and its time;
- impulse (integral of the positive force, kN ms = N s);
- onset and end (first and last time above 10 % of the peak);
- mean force (impulse over that time).
3. Load split¶
from crashmetrics.loadpath import load_split
paths = {"upper": "Upper rail*", "middle": "Front rail*",
"lower": "Subframe extension*"}
split = load_split(forces, paths, target={"upper": 20, "middle": 55, "lower": 25})
print(split.summary())
split.history # % per path over time
The share of each path is its impulse over the summed impulse. peak
gives each path's peak force, and history the share at each time
(where the total force is above 5 % of its peak).
One cut per path
Give each path the sections that cut it once, for example the front rails LH and RH for the middle path. Sections in series along the same path (crash box, front rail, rear rail) carry the same load, so adding them counts it twice. A section given for two paths is reported.
target (path → %) is checked against tolerance percentage points
(default 5). Load split targets are design choices, not a protocol.
4. Crush sequence¶
from crashmetrics.loadpath import crush_sequence
chains = {"main rail LH": ["Bumper*", "Crash box LH", "Front rail LH", "Rear rail LH"]}
for check in crush_sequence(run, chains):
print(check.summary())
- A stage (one part, a pattern, or a list of parts summed) starts
when it has absorbed 10 % of its final energy (
onset=). - Violation: a stage starts before the stage in front of it.
- Warning: a stage starts before the one in front has absorbed half
of its energy (
overlap=). - Not crushed: stages absorbing less than 2 % of the chain's energy
(
min_energy=), such as rear rails taking only elastic load, are left out of the order check and listed as not crushed.
Energy is used rather than force because a stage that carries the load without crushing (a stiff rear rail behind a crushing crash box) has a high force but no energy.
5. Comparing runs¶
from crashmetrics.loadpath import compare_runs, energy_matrix
comparison = compare_runs(baseline, variant, exclude="Body*", groups=groups, cfc=60)
print(comparison.summary())
comparison.culprits # the parts that explain most of the change
matrix = energy_matrix([baseline, variant, other], exclude="Body*")
print(matrix.table(top=10)) # change against the first run in brackets
matrix.to_csv("energy.csv")
- Matching: parts and sections by ID. Parts or sections only in one
run are listed in
notes; a removed part counts as a change to zero. - Culprits: the fewest parts, largest change first, that together
explain 80 % (
explain=) of the summed absolute energy change. The share is of all changes, so energy moving from one part to another shows on both. - Sections: peak and impulse in both runs. With
rate=True(default) each section also gets an ISO/TS 18571 rating of the variant curve against the baseline curve (1 means the same curve), which ranks which section's force history changed most. loadpath_report(run, baseline=..., groups=..., paths=..., chains=...)puts the ranking, split, sequence and comparison in one Markdown page.
Examples¶
One run¶
"""Example 30: load paths and energy absorption of one frontal crash run.
A full-width frontal run at 56 km/h (synthetic: the toy model of
crashmetrics.synthetic writes matsum and secforc in the LS-DYNA ASCII
format; point load_run at your own run folder instead):
1. Which parts absorbed the energy, and when.
2. Section forces: one component, the main load positive, CFC 60.
3. Load split between the upper, middle and lower load paths.
4. Crush sequence: bumper, crash box, front rail, rear rail, in order?
"""
from crashmetrics.loadpath import (
crush_sequence,
energy_history,
energy_ranking,
force_metrics,
load_run,
load_split,
section_forces,
)
from crashmetrics.synthetic import frontal_model, simulate
# --- The run (replace with load_run("path/to/your/run")) -------------------------
simulate(frontal_model("baseline")).write("runs/baseline")
run = load_run("runs/baseline") # matsum + secforc, mm-ms-kg
# --- 1. Energy absorption --------------------------------------------------------
groups = {"bumper": "Bumper*", "crash boxes": "Crash box*",
"front rails": "Front rail*", "rear rails": "Rear rail*",
"upper rails": "Upper rail*", "lower path": "Subframe*"}
ranking = energy_ranking(run, exclude="Body*", groups=groups)
print(ranking.table(top=8))
print()
t, energy = energy_history(run, groups)
print("Energy absorbed by group over time (kJ):")
print(f"{'ms':>6}" + "".join(f"{g:>13}" for g in groups))
for ms in (5, 10, 20, 30, 40, 60):
k = int(abs(t - ms).argmin())
print(f"{ms:6d}" + "".join(f"{energy[g][k]:13.1f}" for g in groups))
# --- 2. Section forces -----------------------------------------------------------
forces = section_forces(run, cfc=60)
flipped = [forces.names[i] for i, f in zip(forces.ids, forces.flipped) if f]
print()
print(f"Section forces: component {set(forces.components)}, CFC 60; sign reversed "
f"for {len(flipped)} of {len(forces.ids)} sections (their normals point "
"forwards)")
print(f"{'section':24} {'peak kN':>8} {'at ms':>6} {'mean kN':>8} {'kN ms':>8} "
f"{'from-to ms':>11}")
for m in force_metrics(forces):
if m.name.endswith("LH"):
print(f"{m.name:24} {m.peak:8.1f} {m.peak_time:6.1f} {m.mean:8.1f} "
f"{m.impulse:8.0f} {m.onset:5.1f}-{m.end:4.1f}")
# --- 3. Load split ---------------------------------------------------------------
# One cut per path (LH + RH): sections in series along a path carry the
# same load and must not be added.
paths = {"upper": "Upper rail*", "middle": "Front rail*",
"lower": "Subframe extension*"}
split = load_split(forces, paths, target={"upper": 20, "middle": 55, "lower": 25})
print()
print(split.summary())
k = int(abs(split.time - 35.0).argmin())
print(" at 35 ms: " + ", ".join(f"{p} {split.history[k, i]:.0f} %"
for i, p in enumerate(split.paths)))
# --- 4. Crush sequence -----------------------------------------------------------
chains = {f"main rail {s}": ["Bumper*", f"Crash box {s}", f"Front rail {s}",
f"Rear rail {s}"] for s in ("LH", "RH")}
print()
for check in crush_sequence(run, chains):
print(check.summary())
Output:
Absorbed energy, baseline, at 100 ms: 176.5 kJ
| # | Part | kJ | Share | Cumulative | 10/50/90 % at ms | Hourglass |
| --- | --- | --- | --- | --- | --- | --- |
| 1 | Front rail LH (120) | 32.65 | 18.5 % | 18.5 % | 15.6 / 23.7 / 35.8 | 2.0 % |
| 2 | Front rail RH (121) | 32.65 | 18.5 % | 37.0 % | 15.6 / 23.7 / 35.8 | 2.0 % |
| 3 | Subframe (152) | 31.48 | 17.8 % | 54.9 % | 17.9 / 25.8 / 38.1 | 2.0 % |
| 4 | Upper rail LH (140) | 16.31 | 9.2 % | 64.1 % | 6.29 / 17.3 / 34.5 | 2.0 % |
| 5 | Upper rail RH (141) | 16.31 | 9.2 % | 73.3 % | 6.29 / 17.3 / 34.5 | 2.0 % |
| 6 | Crash box LH (110) | 14.91 | 8.4 % | 81.8 % | 3.59 / 7.89 / 12.5 | 3.1 % |
| 7 | Crash box RH (111) | 14.91 | 8.4 % | 90.2 % | 3.59 / 7.89 / 12.5 | 3.1 % |
| 8 | Subframe extension LH (150) | 4.81 | 2.7 % | 93.0 % | 6.79 / 10.8 / 15.0 | 3.1 % |
| Group | kJ | Share | 10/50/90 % at ms |
| --- | --- | --- | --- |
| bumper | 3.56 | 2.0 % | 0.287 / 1.34 / 2.38 |
| crash boxes | 29.81 | 16.9 % | 3.59 / 7.89 / 12.5 |
| front rails | 65.31 | 37.0 % | 15.6 / 23.7 / 35.8 |
| rear rails | 4.04 | 2.3 % | 42.1 / 43.4 / 45.3 |
| upper rails | 32.62 | 18.5 % | 6.29 / 17.3 / 34.5 |
| lower path | 41.11 | 23.3 % | 9.92 / 22.5 / 36.7 |
Energy absorbed by group over time (kJ):
ms bumper crash boxes front rails rear rails upper rails lower path
5 3.6 6.8 0.0 0.0 1.5 0.0
10 3.6 20.4 0.1 0.1 7.8 4.2
20 3.7 29.9 21.8 0.1 18.9 16.7
30 3.7 29.9 48.0 0.1 27.0 30.9
40 3.7 29.9 63.8 0.1 31.7 39.3
60 3.6 29.8 65.3 4.0 32.6 41.1
Section forces: component {'x'}, CFC 60; sign reversed for 8 of 10 sections (their normals point forwards)
section peak kN at ms mean kN kN ms from-to ms
Crash box LH 249.6 44.4 144.6 7491 0.8-52.6
Front rail LH 248.9 44.4 144.1 7466 0.8-52.6
Rear rail LH 241.0 44.4 139.3 7217 0.8-52.6
Upper rail LH 49.5 35.8 41.9 2096 2.2-52.2
Subframe extension LH 85.8 36.8 64.6 3021 4.8-51.6
Load split, baseline:
upper 16.7 % (target 20 % ± 5) impulse 4192 kN ms, peak 98.97 kN
middle 59.3 % (target 55 % ± 5) impulse 14931 kN ms, peak 497.8 kN
lower 24.0 % (target 25 % ± 5) impulse 6042 kN ms, peak 171.7 kN
at 35 ms: upper 18 %, middle 50 %, lower 31 %
main rail LH: in order
Bumper beam 0.287 ms -> Crash box LH 3.59 ms -> Front rail LH 15.6 ms -> Rear rail LH 42.1 ms
main rail RH: in order
Bumper beam 0.287 ms -> Crash box RH 3.59 ms -> Front rail RH 15.6 ms -> Rear rail RH 42.1 ms
Baseline against variants¶
"""Example 31: compare crash runs and find the culprit part.
Three runs of the same frontal crash (synthetic, crashmetrics.synthetic):
the baseline, a variant with a thinner LH front rail, and one without
the lower load path. Point load_run at your own run folders instead.
1. Thinner LH front rail: which parts changed, and the crush sequence.
2. No lower load path: where its load went (load split, rear rails).
3. All runs side by side (energy matrix, CSV).
4. A Markdown report of one run against the baseline.
"""
from crashmetrics.loadpath import (
compare_runs,
crush_sequence,
energy_matrix,
load_run,
load_split,
loadpath_report,
section_forces,
)
from crashmetrics.synthetic import frontal_model, simulate
runs = {}
for variant in ("baseline", "weak_front_rail_lh", "no_lower_path"):
simulate(frontal_model(variant)).write(f"runs/{variant}")
runs[variant] = load_run(f"runs/{variant}")
base = runs["baseline"]
groups = {"crash boxes": "Crash box*", "front rails": "Front rail*",
"rear rails": "Rear rail*", "upper rails": "Upper rail*",
"lower path": "Subframe*"}
chains = {f"main rail {s}": ["Bumper*", f"Crash box {s}", f"Front rail {s}",
f"Rear rail {s}"] for s in ("LH", "RH")}
# --- 1. Thinner LH front rail ----------------------------------------------------
weak = runs["weak_front_rail_lh"]
print(compare_runs(base, weak, exclude="Body*", groups=groups, cfc=60).summary(top=4))
print()
for check in crush_sequence(weak, chains):
print(check.summary())
# --- 2. No lower load path -------------------------------------------------------
print()
nolower = runs["no_lower_path"]
print(compare_runs(base, nolower, exclude="Body*", groups=groups, cfc=60,
rate=False).summary(top=3))
paths = {"upper": "Upper rail*", "middle": "Front rail*",
"lower": "Subframe extension*"}
print()
print(f"{'load split':20}" + "".join(f"{p:>9}" for p in paths))
for name, run in runs.items():
have = {p: s for p, s in paths.items() if p != "lower" or name != "no_lower_path"}
split = load_split(section_forces(run, cfc=60), have)
share = dict(zip(split.paths, split.share))
print(f"{name:20}" + "".join(
f"{share[p]:8.1f}%" if p in share else f"{'-':>9}" for p in paths))
# --- 3. All runs side by side ----------------------------------------------------
print()
matrix = energy_matrix(list(runs.values()), exclude="Body*")
print("Absorbed energy, kJ (change against the baseline):")
print(matrix.table(top=8))
matrix.to_csv("energy_matrix.csv") # for Excel or a dashboard
# --- 4. Report -------------------------------------------------------------------
report = loadpath_report(weak, baseline=base, exclude="Body*", groups=groups,
paths=paths, chains=chains, top=5, cfc=60)
print()
print("\n".join(report.splitlines()[:9]))
print(f"... {len(report.splitlines())} lines of Markdown")
Output:
weak_front_rail_lh against baseline: absorbed energy 176.5 -> 176.3 kJ (-0.185)
Parts that explain most of the change:
Front rail LH (120): 32.65 -> 17.41 kJ (-15.2, 50 % of all change)
Rear rail LH (130): 2.02 -> 6.92 kJ (+4.90, 16 % of all change)
Rear rail RH (131): 2.02 -> 6.92 kJ (+4.90, 16 % of all change)
Groups:
crash boxes: 29.81 -> 29.81 kJ (-0.001)
front rails: 65.31 -> 50.07 kJ (-15.2)
rear rails: 4.04 -> 13.84 kJ (+9.80)
upper rails: 32.62 -> 34.68 kJ (+2.06)
lower path: 41.11 -> 44.31 kJ (+3.20)
Sections, most changed first:
Rear rail LH (15): peak 241.0 -> 247.1 kN, impulse -12.2 %, ISO 18571 0.81
Front rail LH (13): peak 248.9 -> 255.3 kN, impulse -12.0 %, ISO 18571 0.81
Crash box LH (11): peak 249.6 -> 256.1 kN, impulse -12.0 %, ISO 18571 0.81
Subframe extension LH (31): peak 85.84 -> 90.04 kN, impulse +5.7 %, ISO 18571 0.90
main rail LH: OUT OF ORDER
Bumper beam 0.287 ms -> Crash box LH 19.9 ms -> Front rail LH 3.99 ms -> Rear rail LH 38.3 ms
violation: Front rail LH starts at 3.99 ms, before Crash box LH (19.9 ms)
main rail RH: in order
Bumper beam 0.287 ms -> Crash box RH 3.59 ms -> Front rail RH 15.5 ms -> Rear rail RH 38.3 ms
no_lower_path against baseline: absorbed energy 176.5 -> 176.6 kJ (+0.122)
Parts that explain most of the change:
Subframe (152): 31.48 -> removed kJ (-31.5, 38 % of all change)
Rear rail LH (130): 2.02 -> 19.28 kJ (+17.3, 21 % of all change)
Rear rail RH (131): 2.02 -> 19.28 kJ (+17.3, 21 % of all change)
Groups:
crash boxes: 29.81 -> 29.81 kJ (+0)
front rails: 65.31 -> 65.31 kJ (+0)
rear rails: 4.04 -> 38.56 kJ (+34.5)
upper rails: 32.62 -> 39.33 kJ (+6.72)
lower path: 41.11 -> 0 kJ (-41.1)
Sections, most changed first:
Rear rail LH (15): peak 241.0 -> 249.6 kN, impulse +36.2 %
Rear rail RH (16): peak 241.0 -> 249.6 kN, impulse +36.2 %
Front rail LH (13): peak 248.9 -> 257.1 kN, impulse +35.7 %
Note: parts only in baseline: [150, 151, 152]
Note: group lower path: no parts in no_lower_path
Note: sections only in baseline: [31, 32]
load split upper middle lower
baseline 16.7% 59.3% 24.0%
weak_front_rail_lh 16.7% 58.1% 25.3%
no_lower_path 19.3% 80.7% -
Absorbed energy, kJ (change against the baseline):
| Part | baseline | weak_front_rail_lh | no_lower_path |
| --- | --- | --- | --- |
| Subframe (152) | 31.48 | 34.68 (+3.20) | - |
| Front rail LH (120) | 32.65 | 17.41 (-15.2) | 32.65 (+0) |
| Front rail RH (121) | 32.65 | 32.65 (+0) | 32.65 (+0) |
| Upper rail LH (140) | 16.31 | 17.34 (+1.03) | 19.67 (+3.36) |
| Upper rail RH (141) | 16.31 | 17.34 (+1.03) | 19.67 (+3.36) |
| Rear rail LH (130) | 2.02 | 6.92 (+4.90) | 19.28 (+17.3) |
| Rear rail RH (131) | 2.02 | 6.92 (+4.90) | 19.28 (+17.3) |
| Crash box LH (110) | 14.91 | 14.91 (-0.001) | 14.91 (+0) |
# Load paths: weak_front_rail_lh
Source: `runs/weak_front_rail_lh`
## Energy absorption
Absorbed energy, weak_front_rail_lh, at 100 ms: 176.3 kJ
| # | Part | kJ | Share | Cumulative | 10/50/90 % at ms | Hourglass |
... 59 lines of Markdown
The thinner LH rail is found as a culprit, its crush order is flagged, and the energy it no longer absorbs shows up in both rear rails. Without the lower path, the middle path's share goes from 59 % to 81 % and the rear rails crush, which is where cabin intrusion would start.
Tested with¶
- Synthetic runs, whose truth is known: every number above.
- Real LS-DYNA output (MIT licence, in the repository): two runs of a helmet study's neck section (secforc; the main load found on z, run 1 against run 0 rated 0.91), and a drop test matsum in mm-ton-s.
- A crush test of a hat section found in a public repository (checked locally only; its licence is unclear, so it is not included): 9 parts, 3201 states, the load on the y axis found and its sign reversed, unevenly spaced MPP output resampled before CFC 60 and 180.