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_weldsreadsswforcinto aWeldRun(forces in kN, time in ms, failure time of each weld). - Every weld:
weld_summarygives peak axial and shear force, the forces just before failure, and withWeldLimitsthe utilisation (share of the failing load reached) of each weld;WeldSummary.failedandWeldSummary.criticallist the failed welds and the ones close to failure. - Failure over time:
failure_historygives 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_weldsgives 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_reportputs 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
¶
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.
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.
measure
class-attribute
instance-attribute
¶
The file's own failure measure (time, weld) where it prints fractions (some weld materials), else None.
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
¶
ms of the peak resultant force (of the peak utilisation with limits).
utilisation
instance-attribute
¶
Peak share of the failing load (NaN without limits for this weld).
axial_at_failure
instance-attribute
¶
Forces at the last state before failure (NaN if the weld holds).
WeldSummary
dataclass
¶
WeldSummary(
run: str,
welds: tuple[Weld, ...],
notes: tuple[str, ...] = (),
)
GroupCount
dataclass
¶
Burst
dataclass
¶
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, ...],
)
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
¶
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.
new_failures
instance-attribute
¶
new_failures: tuple[WeldChange, ...]
Fail in the variant only, first failure first.
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
¶
(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 |
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.