Skip to content

crashmetrics.quality

quality

Model quality check sheet: is this run fit to be trusted?

Before anyone reads injury values or intrusions from a crash run, the run itself is checked: did it finish, is the mass right, how much mass did mass scaling add, is the energy balance sound, do the contacts behave. check_model does that in one pass from the files every run writes and returns a QualitySheet with a status per check.

  • Run (d3hsp, glstat): termination, end time reached, errors, warnings.
  • Mass (d3hsp, glstat, matsum): total mass and centre of gravity against targets; added mass at the start and at its peak, its growth, added mass per part.
  • Time step (glstat, d3hsp): time step and its drop, the mass scaling setting, the smallest elements and the mass factor they need.
  • Energy (glstat, matsum): energy ratio, hourglass, negative contact energy, damping and the part checks of crashmetrics.energy_check.
  • Contacts (sleout, glstat): negative energy of each contact.

A check is PASS, FAIL, WARN (advisory limits), INFO (no limit) or SKIP (file or value missing); a sheet passes when nothing fails. Limits are in QualityLimits; they are common practice, not a standard, so set your team's values. Values are reported in kg, mm, ms and kJ. quality_matrix puts several runs side by side. crashmetrics.synthetic writes runs to try this without a solver.

MASS_TO_KG module-attribute

MASS_TO_KG: dict[str, float] = {
    "mm-ms-kg": 1.0,
    "mm-s-t": 1000.0,
    "mm-s-kg": 1.0,
    "m-s-kg": 1.0,
}

Unit system -> factor from the model's mass unit to kg.

QualityLimits dataclass

QualityLimits(
    mass_tolerance: float = 1.0,
    cg_tolerance: float = 10.0,
    added_mass: float | None = 5.0,
    added_mass_growth: float | None = 1.0,
    part_added_mass: float | None = 20.0,
    end_time: float = 99.5,
    timestep_drop: float | None = 10.0,
    element_mass_factor: float | None = 4.0,
    contact_negative: float | None = 1.0,
    warnings: int | None = None,
    energy: EnergyLimits = EnergyLimits(),
)

Acceptance limits of the check sheet (None switches a check to INFO). Breaking a limit fails the check, except the advisory ones, which warn.

mass_tolerance class-attribute instance-attribute

mass_tolerance: float = 1.0

Total mass against the target, %.

cg_tolerance class-attribute instance-attribute

cg_tolerance: float = 10.0

Distance of the centre of gravity from the target, mm.

added_mass class-attribute instance-attribute

added_mass: float | None = 5.0

Added mass at the start and at its peak, % of the model mass.

added_mass_growth class-attribute instance-attribute

added_mass_growth: float | None = 1.0

Advisory: growth of the added mass during the run, % points.

part_added_mass class-attribute instance-attribute

part_added_mass: float | None = 20.0

Added mass of a part, % of the part's mass.

end_time class-attribute instance-attribute

end_time: float = 99.5

Problem time reached, % of the termination time.

timestep_drop class-attribute instance-attribute

timestep_drop: float | None = 10.0

Advisory: fall of the time step below its first value, %.

element_mass_factor class-attribute instance-attribute

element_mass_factor: float | None = 4.0

Advisory: mass factor the smallest element needs to reach the mass-scaled time step, (dt / dt_element)^2.

contact_negative class-attribute instance-attribute

contact_negative: float | None = 1.0

Most negative energy of one contact, % of the peak internal energy.

warnings class-attribute instance-attribute

warnings: int | None = None

Advisory: number of solver warnings.

energy class-attribute instance-attribute

energy: EnergyLimits = field(default_factory=EnergyLimits)

Limits of the energy checks (its added mass limit is not used: added_mass above is).

QualityCheck dataclass

QualityCheck(
    group: str,
    name: str,
    value: str,
    limit: str,
    status: str,
    note: str = "",
    number: float | None = None,
)

One line of the sheet.

status instance-attribute

status: str

PASS, FAIL, WARN, INFO or SKIP.

number class-attribute instance-attribute

number: float | None = None

The value as a number, where it is one.

QualitySheet dataclass

QualitySheet(
    run: str,
    checks: tuple[QualityCheck, ...],
    files: dict[str, str] = dict(),
    notes: tuple[str, ...] = (),
)

The check sheet of one run.

files class-attribute instance-attribute

files: dict[str, str] = field(default_factory=dict)

File kind -> path read.

notes class-attribute instance-attribute

notes: tuple[str, ...] = ()

Files that could not be read.

passed property

passed: bool

No check failed.

check

check(name: str) -> QualityCheck

A check by name.

counts

counts() -> dict[str, int]

Number of checks per status.

summary

summary() -> str

Plain text: the verdict and one line per check.

table

table() -> str

Markdown table of the sheet.

check_model_data

check_model_data(
    name: str,
    *,
    d3hsp: D3hsp | None = None,
    glstat: GlobalEnergies | None = None,
    matsum: PartEnergies | None = None,
    sleout: AsciiOutput | None = None,
    unit_system: str = "mm-ms-kg",
    target_mass: float | None = None,
    target_cg: Sequence[float] | None = None,
    limits: QualityLimits | None = None,
    files: dict[str, str] | None = None,
    notes: Sequence[str] = (),
) -> QualitySheet

The check sheet from data already read (see check_model).

check_model

check_model(
    directory: str | Path,
    name: str | None = None,
    *,
    unit_system: str = "mm-ms-kg",
    target_mass: float | None = None,
    target_cg: Sequence[float] | None = None,
    limits: QualityLimits | None = None,
) -> QualitySheet

The model quality check sheet of a run folder.

Parameters:

Name Type Description Default
directory str | Path

Run folder with d3hsp, glstat, matsum and sleout (upper case or a job prefix such as run1.glstat also work); glstat, matsum and sleout are also read from binout files. Missing files skip their checks; at least one is needed.

required
name str | None

Run name; the folder name by default.

None
unit_system str

Unit system of the model (masses to kg, lengths to mm, times to ms, energies to kJ).

'mm-ms-kg'
target_mass float | None

Target vehicle mass (kg) and centre of gravity (x, y, z in mm, in the model's coordinate system); without them mass and centre of gravity are reported only.

None
target_cg float | None

Target vehicle mass (kg) and centre of gravity (x, y, z in mm, in the model's coordinate system); without them mass and centre of gravity are reported only.

None
limits QualityLimits | None

QualityLimits; the defaults if omitted.

None

quality_matrix

quality_matrix(
    sheets: Sequence[QualitySheet], *, values: bool = True
) -> str

Markdown table of several runs side by side: one row per check, one column per run (status, and the number where the check has one).