LS-DYNA ASCII output¶
Module: crashmetrics.lsdyna_ascii (also importable from
crashmetrics.lsdyna); command crashmetrics-ascii.
LS-DYNA writes its time-history output either to binout or, with
*DATABASE_<NAME> and BINARY = 1 (the SMP default) or 3, to ASCII files
named after the database: nodout, rcforc, sleout and so on. These
readers turn the ASCII files into NumPy arrays for the injury criteria,
scoring and feature functions in this package.
Supported files¶
| File | Content | Entities | Channels |
|---|---|---|---|
nodout |
Nodal motion (*DATABASE_HISTORY_NODE) |
Nodes | x_displacement ... z_coordinate, x_velocity, x_acceleration, rotational rx_displacement, rx_velocity, rx_acceleration ... |
rcforc |
Contact resultant forces | Contacts | surfa_x_force ... surfa_mass, surfa_x_moment ..., the same for surfb_ |
sleout |
Contact (sliding interface) energies | Contacts | surfa_energy, surfb_energy, friction_energy; file totals in totals |
secforc |
Cross-section forces (*DATABASE_CROSS_SECTION) |
Sections | x_force ... total_force, x_moment ... total_moment, x_centroid ..., area |
rwforc |
Rigid wall forces | Walls | normal_force, x_force, y_force, z_force |
sbtout |
Seatbelts | Belts, slip rings, retractors | belt_force, belt_length, ring_slip, retractor_pull_out, retractor_force |
deforc |
Discrete elements (springs, dampers) | Elements | x_force ... resultant_force, change_in_length, x_moment ... relative_rotation |
jntforc |
Joints and joint stiffnesses | Joints | x_force ..., resultant_force, resultant_moment, x_force_local ..., stiffness output such as phi_degrees, joint_energy |
abstat |
Airbags and control volumes | Airbags | volume, pressure, internal_energy, dm_dt_in, density, dm_dt_out, total_mass, gas_temp, surface_area, reaction, dm_dt_outp, dm_dt_outv |
rbdout |
Rigid body motion | Rigid bodies | global_x ..., global_dx ... global_rdz, global_vx ..., global_ax ..., the same with local_, dircos_11 ... dircos_33 |
spcforc |
Constraint (SPC) reactions | Nodes | x_force ... z_moment; resultants in totals |
swforc |
Spotwelds and constrained welds | Weld element or constraint IDs | axial, shear, failure, length, resultant_moment, torsion, failure_time |
The channel names are the binout variable names, and
crashmetrics.binout returns binout outputs as the same
objects, so code written for one works with the other. The glstat and matsum readers are part of the
energy checks.
Reading one file¶
from crashmetrics.lsdyna import read_nodout, read_rcforc, read_secforc
nodout = read_nodout("run01/nodout")
print(nodout.summary()) # title, version, states, entities, channels
t = nodout.time # (n,) in the model's time unit
az = nodout.channel("z_acceleration", 22626) # (n,) for one node
all_az = nodout.channel("z_acceleration") # (n, n_nodes); one node -> (n,)
a_res = nodout.magnitude(("x_acceleration", "y_acceleration", "z_acceleration"), 22626)
head = nodout.entity(22626) # {channel: (n,)}
big = read_nodout("run01/nodout", ids=[22626, 22627]) # read only these nodes
AsciiOutput holds:
| Attribute | Content |
|---|---|
kind |
File type, e.g. "nodout" |
time, cycle |
Output times (and cycles where the file gives them) |
ids |
Entity IDs in file order |
data |
Channel name → array (n_times, n_entities); NaN where an entity has no value |
totals |
File-level sums printed by LS-DYNA (sleout, spcforc) |
names |
Entity titles from the {BEGIN LEGEND} block |
title, version |
Model title and LS-DYNA version line |
Methods: channel(name, id), entity(id), magnitude(channels, id),
name(id), summary() and to_csv(path, channels=None, ids=None)
(a wide table, columns channel[id]).
Units
Values are in the model's units. For an mm, ms, kg, kN model (dummy and most vehicle models), acceleration in mm/ms² × 1000 is m/s², force is in kN, moment in kN·mm (= N·m) and angular velocity in rad/ms. Convert before calling the injury criteria, which work in SI units and g.
Contact sides¶
rcforc and sleout call the two contact sides slave / master in
older LS-DYNA versions and SURFA / SURFB from R13 on. Both are read
as surfa_* (slave) and surfb_* (master). Single-surface contacts
have no resultants in rcforc and do not appear as entities there.
A whole run directory¶
from crashmetrics.lsdyna import read_run
run = read_run("run01") # {"nodout": ..., "rcforc": ..., ...}
wall = run["rwforc"].channel("normal_force", 1)
belt = run["sbtout"].channel("belt_force", 1)
Files are found by name (nodout, NODOUT, or with a job-ID prefix
such as run1.nodout). Requested databases without any output state are
left out; skip_errors=True leaves out unreadable files instead of
raising. A file with any other name is read with read_ascii(path),
which recognises the type from its content.
Command line¶
crashmetrics-ascii run01 # summary of every ASCII file in run01
crashmetrics-ascii run01 run02 --csv tables # also write run01_nodout.csv, ...
crashmetrics-ascii results/contact.txt --kind rcforc
The exit code is 0 when everything was read and 2 when a file or directory could not be read.
Complete example¶
The real LS-DYNA R16 output of a helmeted Hybrid III head: HIC and BrIC
from the head centre of gravity node in nodout, the upper neck load
from secforc, and a run directory with rcforc and spcforc:
"""Example 18: LS-DYNA ASCII output (nodout, secforc, rcforc, spcforc).
Real LS-DYNA R16 output of a helmeted Hybrid III head (MIT-licensed
helmet fit study, see tests/data/lsdyna/README.md): the head centre of
gravity node in a 3.12 m/s drop test (nodout) and the upper neck section
force in a pendulum test (secforc). The model units are mm, ms, kg, kN.
Point the paths at your own run directory instead.
The same files can be summarised or written to CSV on the command line:
crashmetrics-ascii run01 --csv results
"""
from pathlib import Path
import numpy as np
from crashmetrics.features import signal_features
from crashmetrics.head import bric
from crashmetrics.lsdyna import read_nodout, read_run, read_secforc
from crashmetrics.pedestrian import calculate_hic
from crashmetrics.signals import cfc_filter, resample_uniform
data = Path(__file__).resolve().parents[1] / "tests" / "data" / "lsdyna"
# --- 1. nodout: head CG acceleration and angular velocity ---------------------
nodout = read_nodout(data / "helmet" / "drop" / "nodout")
print(nodout.summary())
node = nodout.ids[0]
t = nodout.time / 1000.0 # ms -> s
head_g = []
for axis in "xyz": # mm/ms^2 -> g, CFC 1000
a_g = nodout.channel(f"{axis}_acceleration", node) * 1000.0 / 9.80665
t_u, a_u = resample_uniform(t, a_g, 10_000.0) # output is not exactly uniform
head_g.append(cfc_filter(t_u, a_u, 1000))
resultant = np.sqrt(sum(a**2 for a in head_g))
hic = calculate_hic(t_u, resultant)
print(f"\nHead CG: peak {resultant.max():.1f} g, HIC15 {hic.value:.1f} "
f"({hic.start_time_ms:.1f} to {hic.end_time_ms:.1f} ms)")
omega = [nodout.channel(f"r{axis}_velocity", node) * 1000.0 for axis in "xyz"]
# The model's x axis is the head's pitch axis, so the x and y critical
# velocities swap places: (56.45, 66.25, 42.87) rad/s.
print(f"BrIC {bric(t, *omega, critical=(56.45, 66.25, 42.87)).value:.3f}")
print("The study reported HIC 195.2 and BrIC 0.388 from these files.")
# --- 2. secforc: upper neck section forces and moments ------------------------
secforc = read_secforc(data / "helmet" / "pendulum" / "secforc")
section = secforc.ids[0]
force_n = 1000.0 * secforc.channel("total_force", section) # kN -> N
moment_nm = secforc.channel("total_moment", section) # kN mm = N m
tension_n = 1000.0 * secforc.channel("z_force", section)
print(f"\n{secforc.name(section)}: peak force {force_n.max():.0f} N, "
f"peak tension {tension_n.max():.0f} N, peak moment {moment_nm.max():.2f} N m "
f"(section area {secforc.channel('area', section)[-1]:.0f} mm^2)")
# --- 3. A whole run directory: every ASCII file it contains -------------------
run = read_run(data / "pladebuk")
print(f"\nFiles found: {', '.join(run)}")
contacts = run["rcforc"]
print("rcforc contacts: " + ", ".join(
f"{cid} ({' '.join(contacts.name(cid).split())})" for cid in contacts.ids))
spc = run["spcforc"]
reaction = np.nansum(spc.channel("y_force"), axis=1)
print(f"spcforc: {len(spc.ids)} constrained nodes; y reaction at t = "
f"{spc.time[-1]:g}: sum of nodes {reaction[-1]:.3f}, "
f"printed resultant {spc.totals['y_force'][-1]:.3f}")
# --- 4. Into a feature table (see example 11) ------------------------------------
features = signal_features(t_u, resultant, prefix="head_res.", spectrum=False)
print(f"\n{len(features)} features of the head resultant, e.g. " + ", ".join(
f"{k} {features[k]:.3g}" for k in ("head_res.t_peak_abs_ms", "head_res.rise_ms",
"head_res.width50_ms")))
Output:
nodout: LSTC 50th% Full_FE H-III Dummy (Beta Version, February 17, 2019)
ls-dyna smp s R16 R16.0_619_d222963 date 03/18/2025
251 states, time 0 to 25
entities: 22626
channels: x_displacement, y_displacement, z_displacement, x_velocity, y_velocity, z_velocity, x_acceleration, y_acceleration, z_acceleration, x_coordinate, y_coordinate, z_coordinate, rx_displacement, ry_displacement, rz_displacement, rx_velocity, ry_velocity, rz_velocity, rx_acceleration, ry_acceleration, rz_acceleration
Head CG: peak 90.8 g, HIC15 194.6 (6.0 to 10.6 ms)
BrIC 0.388
The study reported HIC 195.2 and BrIC 0.388 from these files.
Upper_Neck_Force_INJURY: peak force 3834 N, peak tension 1030 N, peak moment 58.27 N m (section area 2515 mm^2)
Files found: rcforc, spcforc
rcforc contacts: 80085 (Left_on_left_action), 8008 (Right_on_right_action), 80086 (Mortar silent backup for contact 80085), 8009 (Mortar silent backup for contact 8008)
spcforc: 32 constrained nodes; y reaction at t = 0.1: sum of nodes 13.769, printed resultant 13.769
19 features of the head resultant, e.g. head_res.t_peak_abs_ms 8.7, head_res.rise_ms 2.25, head_res.width50_ms 4.41
How the files are read, and what was checked¶
- Values are found by their labels and the column headers of the file, not by fixed positions, so extra lines and columns from newer LS-DYNA versions are skipped rather than misread.
- Numbers that touch each other (
0.00000E+00-3.12000E+00), Fortran exponents without theE(1.00000-100) and overflow fields (*****, read as NaN) are handled. - If a run was restarted and the file goes back in time, the states from the restart time on are replaced by the restarted ones.
- MPP and SMP files have the same layout and are read the same way.
The readers were checked on real LS-DYNA output from public projects:
native ASCII files from LS-DYNA R13, R14 and R16 (SMP), and MPP binout
files from 2013 to 2021 converted to ASCII with LS-DYNA's l2a tool (see
tests/data/lsdyna/README.md):
| File | Checked against |
|---|---|
nodout, secforc |
36 runs of a helmet study: HIC, BrIC and neck moment recomputed from the arrays read here equal the study's own results to 1e-15 |
nodout, rcforc, sleout, secforc, spcforc, swforc, abstat, deforc |
Every value of 21 real files (up to 270 000 values each) compared with a second, independent parser: no difference |
sleout, spcforc |
Sum over contacts or nodes against LS-DYNA's printed totals (force transducer contacts are not in the sleout totals) |
rwforc, sbtout, jntforc, rbdout |
The layout written by l2a only; no public real file with data was found |
If one of your files is not read correctly, please open an issue with a short excerpt.
Not covered yet: elout, ncforc, nodfor, bndout, gceout,
sphout, dbfsi and binout itself.