Skip to content

crashmetrics.spotweld

spotweld

Spot weld and connection failure, in one run and across runs.

A load path only works while its connections hold. LS-DYNA writes the force of every spot weld (and other *CONSTRAINED connections) to swforc; this module turns that file into answers:

  • Runs: load_welds reads swforc into a WeldRun (forces in kN, time in ms, failure time of each weld).
  • Every weld: weld_summary gives peak axial and shear force, the forces just before failure, and with WeldLimits the utilisation (share of the failing load reached) of each weld; WeldSummary.failed and WeldSummary.critical list the failed welds and the ones close to failure.
  • Failure over time: failure_history gives the number of failed welds over time, the failure sequence, the first failure per group and bursts (several welds of a group failing within a short time: unzipping).
  • Comparison: compare_welds gives the welds that fail only in the variant, those that no longer fail, earlier and later failures, counts per group and the largest utilisation changes.
  • weld_report puts it in one Markdown page.

swforc has no titles, so groups are given as name -> weld IDs (for example ID ranges of a flange; groups_by_id builds them from the numbering). Forces are in kN and times in ms for any unit system (crashmetrics.loadpath.UNITS). crashmetrics.synthetic writes runs with failing welds to try this without a solver.

Groups module-attribute

Groups = Mapping[str, Iterable[int]]

Group name -> weld IDs (a list, a range ...). A weld in several groups counts in the first.

WeldLimits dataclass

WeldLimits(
    axial: float,
    shear: float,
    n: float = 2.0,
    m: float = 2.0,
    compression: bool = False,
)

Force-based failure criterion of a spot weld, (axial / axial_limit)^n + (shear / shear_limit)^m >= 1 (*CONSTRAINED_SPOTWELD; with n = m = 2 the usual ellipse). Limits in kN. Axial compression does not count unless compression is set.

function

function(axial: ArrayLike, shear: ArrayLike) -> FloatArray

The failure function (1 or more: failed).

utilisation

utilisation(
    axial: ArrayLike, shear: ArrayLike
) -> FloatArray

Share of the failing load reached: 1 / the factor by which both forces could grow until the criterion is met (0.8: at 80 % of failure). Equal to function^(1/n) when n = m.

WeldRun dataclass

WeldRun(
    name: str,
    time: FloatArray,
    ids: tuple[int, ...],
    axial: FloatArray,
    shear: FloatArray,
    failure_time: FloatArray,
    measure: FloatArray | None = None,
    source: str = "",
)

Spot weld forces of one run.

time instance-attribute

time: FloatArray

ms.

axial instance-attribute

axial: FloatArray

(time, weld), kN; tension positive.

shear instance-attribute

shear: FloatArray

(time, weld), kN.

failure_time instance-attribute

failure_time: FloatArray

ms per weld; NaN if it holds to the end.

measure class-attribute instance-attribute

measure: FloatArray | None = None

The file's own failure measure (time, weld) where it prints fractions (some weld materials), else None.

failed property

failed: tuple[int, ...]

IDs of the failed welds, by failure time.

Weld dataclass

Weld(
    weld_id: int,
    group: str,
    peak_axial: float,
    peak_shear: float,
    peak_time: float,
    utilisation: float,
    failed: bool,
    failure_time: float,
    axial_at_failure: float,
    shear_at_failure: float,
)

One weld over the run (kN, ms).

peak_time instance-attribute

peak_time: float

ms of the peak resultant force (of the peak utilisation with limits).

utilisation instance-attribute

utilisation: float

Peak share of the failing load (NaN without limits for this weld).

axial_at_failure instance-attribute

axial_at_failure: float

Forces at the last state before failure (NaN if the weld holds).

WeldSummary dataclass

WeldSummary(
    run: str,
    welds: tuple[Weld, ...],
    notes: tuple[str, ...] = (),
)

Every weld of a run.

failed property

failed: tuple[Weld, ...]

Failed welds, first failure first.

critical

critical(threshold: float = 0.8) -> tuple[Weld, ...]

Welds that hold but reach threshold of their failing load, highest first (needs limits).

groups

groups() -> tuple[GroupCount, ...]

Welds, failed welds and highest utilisation per group.

table

table(top: int = 10) -> str

Markdown: groups, failed welds (first top) and critical welds.

GroupCount dataclass

GroupCount(
    name: str,
    welds: int,
    failed: int,
    first_failure: float,
    utilisation: float,
)

Welds of one group.

first_failure instance-attribute

first_failure: float

ms, NaN if none failed.

utilisation instance-attribute

utilisation: float

Highest peak utilisation of the group (NaN without limits).

Burst dataclass

Burst(
    group: str,
    start: float,
    end: float,
    welds: tuple[int, ...],
)

Several welds of one group failing close together (unzipping).

FailureHistory dataclass

FailureHistory(
    run: str,
    time: FloatArray,
    count: FloatArray,
    by_group: dict[str, FloatArray],
    sequence: tuple[tuple[float, int, str], ...],
    first: dict[str, tuple[float, int]],
    bursts: tuple[Burst, ...],
)

Weld failures over time.

time instance-attribute

time: FloatArray

ms.

count instance-attribute

count: FloatArray

Failed welds at each time.

sequence instance-attribute

sequence: tuple[tuple[float, int, str], ...]

(ms, weld ID, group), in order of failure.

first instance-attribute

first: dict[str, tuple[float, int]]

Group -> (ms, weld ID) of its first failure.

WeldChange dataclass

WeldChange(
    weld_id: int,
    group: str,
    failure_time: tuple[float, float],
    utilisation: tuple[float, float],
    peak_shear: tuple[float, float],
    peak_axial: tuple[float, float],
)

One weld in two runs.

failure_time instance-attribute

failure_time: tuple[float, float]

ms in the baseline and the variant (NaN: holds).

WeldComparison dataclass

WeldComparison(
    baseline: str,
    variant: str,
    failed: tuple[int, int],
    new_failures: tuple[WeldChange, ...],
    recovered: tuple[WeldChange, ...],
    earlier: tuple[WeldChange, ...],
    later: tuple[WeldChange, ...],
    increased: tuple[WeldChange, ...],
    groups: tuple[tuple[str, int, int, int], ...],
    notes: tuple[str, ...] = (),
)

Weld failures of a variant against a baseline.

failed instance-attribute

failed: tuple[int, int]

Number of failed welds in each run.

new_failures instance-attribute

new_failures: tuple[WeldChange, ...]

Fail in the variant only, first failure first.

recovered instance-attribute

recovered: tuple[WeldChange, ...]

Fail in the baseline only.

earlier instance-attribute

earlier: tuple[WeldChange, ...]

Fail in both, sooner in the variant (largest shift first).

increased instance-attribute

increased: tuple[WeldChange, ...]

Welds holding in both, by utilisation increase (largest first).

groups instance-attribute

groups: tuple[tuple[str, int, int, int], ...]

(group, welds, failed in baseline, failed in variant).

load_welds

load_welds(
    path: str | Path | AsciiOutput,
    name: str | None = None,
    *,
    unit_system: str = "mm-ms-kg",
) -> WeldRun

Read the spot weld forces of a run.

path is a run folder (with swforc, SWFORC or a job prefix such as run1.swforc, or binout files with swforc), a swforc file, or an AsciiOutput already read. A weld counts as failed from the first state LS-DYNA marks it failure. name defaults to the folder name.

groups_by_id

groups_by_id(
    run: WeldRun,
    divisor: int = 1000,
    names: Mapping[int, str] | None = None,
) -> dict[str, list[int]]

Groups from the weld numbering: welds with the same ID // divisor form a group, named names[prefix] or "<prefix>xxx" (for models that number welds by part or flange).

weld_summary

weld_summary(
    run: WeldRun,
    *,
    limits: WeldLimits
    | Mapping[str, WeldLimits]
    | None = None,
    groups: Groups | None = None,
) -> WeldSummary

Peak forces, utilisation and failure of every weld.

Parameters:

Name Type Description Default
limits WeldLimits | Mapping[str, WeldLimits] | None

One WeldLimits for all welds, or group name -> limits (a "default" entry covers the other welds). Without limits the utilisation is NaN, unless the file prints its own failure measure (then its peak is used).

None
groups Groups | None

Group name -> weld IDs.

None

failure_history

failure_history(
    run: WeldRun,
    *,
    groups: Groups | None = None,
    burst_window: float = 1.0,
    burst_size: int = 3,
) -> FailureHistory

Failed welds over time, the failure sequence and bursts.

A burst is burst_size or more welds of one group, each failing within burst_window ms of the one before (welds outside every group form one group of their own).

compare_welds

compare_welds(
    baseline: WeldRun,
    variant: WeldRun,
    *,
    limits: WeldLimits
    | Mapping[str, WeldLimits]
    | None = None,
    groups: Groups | None = None,
    time_tolerance: float = 0.5,
) -> WeldComparison

Weld failures and loading of a variant against a baseline.

Welds are matched by ID. A failure counts as earlier or later when its time differs by more than time_tolerance ms.

weld_report

weld_report(
    run: WeldRun,
    *,
    baseline: WeldRun | None = None,
    limits: WeldLimits
    | Mapping[str, WeldLimits]
    | None = None,
    groups: Groups | None = None,
    top: int = 10,
) -> str

Markdown report: groups, failed and critical welds, the failure sequence and, with baseline, the comparison.