Skip to content

crashmetrics.loadpath

loadpath

Load paths and energy absorption, in one run and across runs.

The questions after every crash run: which parts absorbed the energy, how the load was shared between the upper, middle and lower load paths, whether the structure crushed in the intended order, and, against a baseline, which parts changed (the "culprit").

  • Runs: load_run reads matsum (part energies) and secforc (section forces) of a run folder into a CrashRun; select_parts / select_sections pick IDs by number or by title pattern ("Crash box*").
  • Energy: energy_ranking (absorbed energy per part and per group, share, cumulative share, when each part absorbs it, hourglass share), energy_history (groups over time).
  • Section forces: section_forces (one component, consistent sign, optional CFC filter), force_metrics (peak, mean, impulse, onset), load_split (share of each load path, over the run and over time, against a target).
  • Crush sequence: crush_sequence checks that chains of parts start to absorb energy in the intended order.
  • Comparison: compare_runs (part energy and section force changes ranked, the parts that explain most of the change, ISO/TS 18571 similarity of the force curves), energy_matrix (many runs side by side), loadpath_report (all of it as Markdown).

Results are in kJ, kN and ms; the run's unit system (UNITS) converts them. crashmetrics.synthetic writes runs to try all of this without a solver.

Selector module-attribute

Selector = int | str

A part or section: its ID, or a title pattern (* and ?, case ignored).

UNITS module-attribute

UNITS: dict[str, tuple[float, float, float]] = {
    "mm-ms-kg": (1.0, 0.001, 1.0),
    "mm-s-t": (0.001, 1e-06, 1000.0),
    "mm-s-kg": (1e-06, 1e-09, 1000.0),
    "m-s-kg": (0.001, 0.001, 1000.0),
}

Unit system -> factors to kN, kJ and ms (force, energy, time). In mm-ms-kg the force is kN and the energy J (kN mm); in mm-s-t N and mJ.

CrashRun dataclass

CrashRun(
    name: str,
    energies: PartEnergies | None = None,
    sections: AsciiOutput | None = None,
    unit_system: str = "mm-ms-kg",
    source: str = "",
)

Part energies and section forces of one run (model units).

factors property

factors: tuple[float, float, float]

To kN, kJ and ms.

PartEnergy dataclass

PartEnergy(
    part_id: int,
    name: str,
    energy: float,
    peak: float,
    share: float,
    cumulative: float,
    hourglass: float,
    onset: float,
    half: float,
    end: float,
)

Energy absorbed by one part (or group).

energy instance-attribute

energy: float

kJ at the ranking time.

peak instance-attribute

peak: float

Largest absorbed energy, kJ (above energy if the part unloads).

share instance-attribute

share: float

% of the energy of all ranked parts.

cumulative instance-attribute

cumulative: float

% of the parts down to this one.

hourglass instance-attribute

hourglass: float

Hourglass energy, % of the part's energy.

onset instance-attribute

onset: float

ms when the part has absorbed onset of its energy.

half instance-attribute

half: float

ms at 50 % of its energy.

end instance-attribute

end: float

ms at 90 % of its energy.

EnergyRanking dataclass

EnergyRanking(
    run: str,
    time: float,
    total: float,
    rows: tuple[PartEnergy, ...],
    groups: tuple[PartEnergy, ...] = (),
    excluded: tuple[int, ...] = (),
)

Parts ranked by absorbed energy.

time instance-attribute

time: float

ms.

total instance-attribute

total: float

kJ of all ranked parts.

groups class-attribute instance-attribute

groups: tuple[PartEnergy, ...] = ()

Groups (part_id 0), in the order given.

table

table(top: int | None = 10) -> str

Markdown table of the top parts (and the groups).

SectionForces dataclass

SectionForces(
    run: str,
    time: FloatArray,
    ids: tuple[int, ...],
    names: dict[int, str],
    force: FloatArray,
    components: tuple[str, ...],
    flipped: tuple[bool, ...],
    cfc: float | None = None,
)

One force component of several sections, kN, main load positive.

time instance-attribute

time: FloatArray

ms.

force instance-attribute

force: FloatArray

(time, section), kN.

components instance-attribute

components: tuple[str, ...]

Component used for each section.

flipped instance-attribute

flipped: tuple[bool, ...]

Sections whose sign was reversed (orientation="auto").

SectionMetrics dataclass

SectionMetrics(
    section_id: int,
    name: str,
    peak: float,
    peak_time: float,
    mean: float,
    impulse: float,
    onset: float,
    end: float,
)

Force measures of one section (kN, ms; impulse kN ms = N s).

mean instance-attribute

mean: float

Impulse divided by the time from onset to the end of loading.

onset instance-attribute

onset: float

First time the force reaches onset of its peak.

end instance-attribute

end: float

Last time the force is above onset of its peak.

LoadSplit dataclass

LoadSplit(
    run: str,
    paths: tuple[str, ...],
    sections: tuple[tuple[int, ...], ...],
    impulse: tuple[float, ...],
    share: tuple[float, ...],
    peak: tuple[float, ...],
    time: FloatArray,
    force: FloatArray,
    history: FloatArray,
    target: tuple[float, ...] | None = None,
    tolerance: float = 5.0,
    warnings: tuple[str, ...] = (),
)

Share of the load carried by each load path.

impulse instance-attribute

impulse: tuple[float, ...]

kN ms per path.

share instance-attribute

share: tuple[float, ...]

% of the summed impulse.

peak instance-attribute

peak: tuple[float, ...]

kN, peak force of each path (its sections summed).

force instance-attribute

force: FloatArray

(time, path), kN.

history instance-attribute

history: FloatArray

(time, path), % of the total force at each time (NaN below 5 % of the total peak).

SequenceStage dataclass

SequenceStage(
    name: str,
    parts: tuple[int, ...],
    energy: float,
    onset: float,
    end: float,
    crushed: bool,
)

One stage of a crush chain.

energy instance-attribute

energy: float

kJ at the end.

onset instance-attribute

onset: float

ms when the stage has absorbed onset of its energy (NaN if it does not crush).

end instance-attribute

end: float

ms at 90 % of its energy.

crushed instance-attribute

crushed: bool

Absorbs at least min_energy of the chain's energy.

SequenceCheck dataclass

SequenceCheck(
    chain: str,
    stages: tuple[SequenceStage, ...],
    violations: tuple[str, ...],
    warnings: tuple[str, ...],
)

Crush order of one chain, front to rear.

PartChange dataclass

PartChange(
    part_id: int,
    name: str,
    baseline: float,
    variant: float,
    change: float,
    change_pct: float,
    share_of_change: float,
)

Absorbed energy of a part in two runs.

baseline instance-attribute

baseline: float

kJ (NaN if the part is not in the baseline).

change instance-attribute

change: float

kJ.

change_pct instance-attribute

change_pct: float

% of the baseline energy (NaN for a new part).

share_of_change instance-attribute

share_of_change: float

% of the summed absolute changes of all parts.

SectionChange dataclass

SectionChange(
    section_id: int,
    name: str,
    peak: tuple[float, float],
    impulse: tuple[float, float],
    impulse_change_pct: float,
    rating: float | None,
)

Force measures of a section in two runs.

rating instance-attribute

rating: float | None

ISO/TS 18571 rating of the variant curve against the baseline (1: the same curve).

RunComparison dataclass

RunComparison(
    baseline: str,
    variant: str,
    total: tuple[float, float],
    parts: tuple[PartChange, ...],
    sections: tuple[SectionChange, ...] = (),
    groups: tuple[PartChange, ...] = (),
    culprits: tuple[PartChange, ...] = (),
    notes: tuple[str, ...] = (),
)

A variant against a baseline.

total instance-attribute

total: tuple[float, float]

Absorbed energy of the compared parts, kJ.

parts instance-attribute

parts: tuple[PartChange, ...]

By absolute change, largest first.

culprits class-attribute instance-attribute

culprits: tuple[PartChange, ...] = ()

The fewest parts that explain explain of the absolute change.

EnergyMatrix dataclass

EnergyMatrix(
    runs: tuple[str, ...],
    part_ids: tuple[int, ...],
    names: tuple[str, ...],
    values: FloatArray,
)

Absorbed energy of parts (rows) in several runs (columns), kJ.

values instance-attribute

values: FloatArray

(part, run), kJ; NaN where a run lacks the part.

table

table(
    top: int | None = None, relative_to: int | None = 0
) -> str

Markdown table, parts by their largest energy; with relative_to (a run index) the other runs show the change.

to_csv

to_csv(path: str | Path) -> Path

Write part_id,name,<run>... (kJ).

load_run

load_run(
    directory: str | Path,
    name: str | None = None,
    *,
    unit_system: str = "mm-ms-kg",
    matsum: str | Path | None = None,
    secforc: str | Path | None = None,
) -> CrashRun

Read the matsum and secforc of a run folder.

Files are found by name (matsum, MATSUM or a job prefix such as run1.matsum), or given, or read from the folder's binout files; either may be missing, not both. name defaults to the folder name.

select_parts

select_parts(
    run: CrashRun, selectors: Selector | Iterable[Selector]
) -> list[int]

Part IDs from IDs and title patterns ("Crash box*").

select_sections

select_sections(
    run: CrashRun, selectors: Selector | Iterable[Selector]
) -> list[int]

Section IDs from IDs and title patterns.

energy_ranking

energy_ranking(
    run: CrashRun,
    *,
    time: float | None = None,
    parts: Selector | Iterable[Selector] | None = None,
    exclude: Selector | Iterable[Selector] | None = None,
    groups: Mapping[str, Selector | Iterable[Selector]]
    | None = None,
    include_eroded: bool = True,
    onset: float = 0.1,
) -> EnergyRanking

Parts ranked by absorbed (internal) energy.

Parameters:

Name Type Description Default
time float | None

ms; default the end of the run.

None
parts Selector | Iterable[Selector] | None

Parts to rank (default all) and to leave out (rigid barriers, the body carrying the kinetic energy).

None
exclude Selector | Iterable[Selector] | None

Parts to rank (default all) and to leave out (rigid barriers, the body carrying the kinetic energy).

None
groups Mapping[str, Selector | Iterable[Selector]] | None

Name -> parts, summed (for example {"crash boxes": "Crash box*"}).

None
include_eroded bool

Add the internal energy of eroded elements (matsum eroded_ie).

True
onset float

Fraction of its energy at which a part counts as started.

0.1

energy_history

energy_history(
    run: CrashRun,
    groups: Mapping[str, Selector | Iterable[Selector]],
    *,
    include_eroded: bool = True,
) -> tuple[FloatArray, dict[str, FloatArray]]

(time ms, group name -> absorbed energy kJ over time), for plots.

section_forces

section_forces(
    run: CrashRun,
    sections: Selector | Iterable[Selector] | None = None,
    *,
    component: Component = "auto",
    orientation: Literal["auto", "as_written"] = "auto",
    cfc: float | None = None,
) -> SectionForces

Section forces in kN with a consistent sign.

Parameters:

Name Type Description Default
component Component

"x", "y", "z", "total" (magnitude) or "auto" (per section, the axis with the largest impulse).

'auto'
orientation Literal['auto', 'as_written']

"auto" reverses sections whose force is mainly negative, so the main load is positive whatever the section normal; with "as_written" the sign is the file's.

'auto'
cfc float | None

SAE J211 filter class (60 or 180 for structure); default none. Unevenly spaced output (MPP) is first resampled at its median time step.

None

force_metrics

force_metrics(
    forces: SectionForces,
    *,
    window: tuple[float, float] | None = None,
    onset: float = 0.1,
) -> tuple[SectionMetrics, ...]

Peak, mean force, impulse and loading time of each section.

load_split

load_split(
    forces: SectionForces,
    paths: Mapping[str, Selector | Iterable[Selector]],
    *,
    window: tuple[float, float] | None = None,
    target: Mapping[str, float] | None = None,
    tolerance: float = 5.0,
) -> LoadSplit

Share of the load in each path, from section forces.

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 carry the same load and would count it twice. target (path -> %) is checked with tolerance percentage points.

crush_sequence

crush_sequence(
    run: CrashRun,
    chains: Mapping[
        str, Sequence[Selector | Iterable[Selector]]
    ],
    *,
    onset: float = 0.1,
    overlap: float = 0.5,
    min_energy: float = 0.02,
) -> tuple[SequenceCheck, ...]

Check that the parts of each chain start crushing in order.

Parameters:

Name Type Description Default
chains Mapping[str, Sequence[Selector | Iterable[Selector]]]

Name -> stages front to rear; a stage is a part, a title pattern or a list of them (summed), for example {"main LH": ["Bumper*", "Crash box LH", "Front rail LH"]}.

required
onset float

A stage starts when it has absorbed this fraction of its energy.

0.1
overlap float

Warning when a stage starts before the stage in front of it has absorbed this fraction of its energy.

0.5
min_energy float

Stages absorbing less than this fraction of the chain's energy count as not crushed (elastic only) and are left out of the order check.

0.02

compare_runs

compare_runs(
    baseline: CrashRun,
    variant: CrashRun,
    *,
    exclude: Selector | Iterable[Selector] | None = None,
    groups: Mapping[str, Selector | Iterable[Selector]]
    | None = None,
    sections: Selector | Iterable[Selector] | None = None,
    component: Component = "auto",
    cfc: float | None = None,
    rate: bool = True,
    explain: float = 0.8,
) -> RunComparison

Part energies and section forces of a variant against a baseline.

Parts and sections are matched by ID. culprits are the fewest parts, largest change first, that together explain explain of the summed absolute energy change. With rate, each section's force curve gets an ISO/TS 18571 rating against the baseline curve.

energy_matrix

energy_matrix(
    runs: Sequence[CrashRun],
    *,
    exclude: Selector | Iterable[Selector] | None = None,
) -> EnergyMatrix

Absorbed energy at the end of each run, parts by ID.

loadpath_report

loadpath_report(
    run: CrashRun,
    *,
    baseline: CrashRun | None = None,
    exclude: Selector | Iterable[Selector] | None = None,
    groups: Mapping[str, Selector | Iterable[Selector]]
    | None = None,
    paths: Mapping[str, Selector | Iterable[Selector]]
    | None = None,
    target: Mapping[str, float] | None = None,
    chains: Mapping[
        str, Sequence[Selector | Iterable[Selector]]
    ]
    | None = None,
    top: int = 10,
    cfc: float | None = None,
) -> str

Markdown report: energy ranking, load split, crush sequence and, with baseline, the comparison.