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_runreadsmatsum(part energies) andsecforc(section forces) of a run folder into aCrashRun;select_parts/select_sectionspick 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_sequencechecks 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
¶
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).
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).
peak
instance-attribute
¶
Largest absorbed energy, kJ (above energy if the part unloads).
EnergyRanking
dataclass
¶
EnergyRanking(
run: str,
time: float,
total: float,
rows: tuple[PartEnergy, ...],
groups: tuple[PartEnergy, ...] = (),
excluded: tuple[int, ...] = (),
)
Parts ranked by absorbed energy.
groups
class-attribute
instance-attribute
¶
groups: tuple[PartEnergy, ...] = ()
Groups (part_id 0), in the order given.
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.
flipped
instance-attribute
¶
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).
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, ...] = (),
)
SequenceStage
dataclass
¶
SequenceStage(
name: str,
parts: tuple[int, ...],
energy: float,
onset: float,
end: float,
crushed: bool,
)
One stage of a crush chain.
onset
instance-attribute
¶
ms when the stage has absorbed onset of its energy (NaN if it
does not crush).
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.
share_of_change
instance-attribute
¶
% 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
¶
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.
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.
table
¶
Markdown table, parts by their largest energy; with
relative_to (a run index) the other runs show the change.
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
¶
Part IDs from IDs and title patterns ("Crash box*").
select_sections
¶
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 |
None
|
include_eroded
|
bool
|
Add the internal energy of eroded elements (matsum |
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
|
|
'auto'
|
orientation
|
Literal['auto', 'as_written']
|
|
'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
|
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.