crashmetrics.pedestrian.clearance¶
clearance
¶
Bonnet clearance: why a headform impact point is red.
A headform point is red for one of two reasons: the head runs out of space and hits a hard part under the bonnet (bottoming out), or the bonnet itself is too stiff where it is hit (a hinge, a reinforcement, the wing edge). This module tells them apart, point by point:
- Geometry:
clearancemeasures the free space under each impact point to the hard parts (engine, strut towers, battery, hinges ...), along the headform's path and along the surface normal, for the 165 mm headform sphere, from a mesh (crashmetrics.mesh.read_mesh) or any point clouds.impact_directionandHEADFORMSgive the Euro NCAP impact directions and headforms. - What is needed:
required_clearanceis the smallest deformation space that keeps HIC15 below a target for a given pulse shape (the square wave is the physical limit),clearance_tablefor all colour limits. - What happened:
head_impactreads the headform's nodout (CFC 1000 acceleration, penetration and speed along the impact direction);assess_impactgives HIC15 and its colour, the first contact peak, the deceleration plateau, the deepest penetration, whether and when the head bottomed out (from the geometry, from a second peak in the pulse, or both), the speed and energy left at that moment, the share of the HIC window after it, the extra space that would have stopped the head on the plateau, and a diagnosis. - The grid:
assess_gridassesses all points, prints a text map of the grid with the colours and the bottoming points, counts the points lost per cause, gives the Euro NCAP head score (crashmetrics.pedestrian.headform_score), andcompare_gridscompares two design loops.
Lengths are in mm, times in ms, speeds in m/s, accelerations
in g, for any unit system of the model. crashmetrics.pedestrian.
synthetic writes a bonnet, its hard parts and a grid of headform
impacts to try all of this without a solver.
COLOUR_LIMITS
module-attribute
¶
COLOUR_LIMITS: dict[str, float] = {
"green": 650.0,
"yellow": 1000.0,
"orange": 1350.0,
"brown": 1700.0,
}
Upper HIC15 limit of each colour (Euro NCAP).
HEADFORMS
module-attribute
¶
HEADFORMS: dict[str, Headform] = {
"child": Headform("child", 3.5, 165.0, 50.0, 40.0),
"adult": Headform("adult", 4.5, 165.0, 65.0, 40.0),
}
Euro NCAP headforms: child 3.5 kg at 50°, adult 4.5 kg at 65°, both 165 mm and 40 km/h.
PULSE_SHAPES
module-attribute
¶
PULSE_SHAPES: dict[
str, Callable[[FloatArray], FloatArray]
] = {
"square": lambda t: np.ones_like(t),
"half_sine": lambda t: np.sin(np.pi * t),
"triangle": lambda t: 1.0 - np.abs(2.0 * t - 1.0),
"rising": lambda t: t,
"falling": lambda t: 1.0 - t,
}
Deceleration pulse shapes over the stopping time (0 to 1). The square wave stops the head in the least space for a HIC; real bonnet pulses need more.
DIAGNOSES
module-attribute
¶
DIAGNOSES: dict[str, str] = {
"ok": "within the target colour",
"bottoming": "the head bottoms out on a hard part, which sets the HIC",
"light_bottoming": "the head touches a hard part, but the HIC is within the target",
"first_peak": "the first contact peak sets the HIC (its HIC alone is 70 % or more of the total): the bonnet is locally heavy or stiff in contact (reinforcement, latch, hinge, edge)",
"stiff": "the deceleration plateau sets the HIC without reaching a hard part: the bonnet structure is too stiff in bending",
}
Diagnosis codes of assess_impact.
Headform
dataclass
¶
A headform impactor (Euro NCAP, UN GTR 9).
ImpactPoint
dataclass
¶
ImpactPoint(
key: Hashable,
point: tuple[float, float, float],
headform: str = "child",
run: str = "",
)
A grid point: its position, headform and run folder.
Clearance
dataclass
¶
Clearance(
point: tuple[float, float, float],
direction: tuple[float, float, float],
distance: float,
part: str,
contact: tuple[float, float, float] | None,
lateral: float,
normal_distance: float = nan,
normal_part: str = "",
centre: tuple[float, float, float] | None = None,
)
Free space under one impact point.
distance
instance-attribute
¶
Travel of the headform along direction from first contact until
the sphere touches a hard part, mm (inf: nothing within
max_distance).
contact
instance-attribute
¶
The hard-part point touched first, mm.
normal_distance
class-attribute
instance-attribute
¶
The same along the inward surface normal (NaN without a surface).
centre
class-attribute
instance-attribute
¶
Headform centre at first contact, mm: point + radius * normal
with a surface, point - radius * direction without one.
HeadImpact
dataclass
¶
HeadImpact(
name: str,
time: FloatArray,
acceleration: FloatArray,
penetration: FloatArray,
velocity: FloatArray,
headform: Headform,
direction: tuple[float, float, float],
contact_time: float,
cfc: float | None = 1000.0,
source: str = "",
)
Headform motion of one impact (mm, ms, m/s, g).
acceleration
instance-attribute
¶
Resultant, g (CFC 1000 unless cfc was None).
penetration
instance-attribute
¶
Travel along the impact direction from first contact, mm.
velocity
instance-attribute
¶
Speed along the impact direction, m/s (negative: rebound).
contact_time
instance-attribute
¶
ms of first contact (unfiltered acceleration reaches contact_g).
ImpactAssessment
dataclass
¶
ImpactAssessment(
name: str,
hic: float,
hic_window: tuple[float, float],
colour: str,
peak: float,
peak_time: float,
first_peak: float,
first_peak_time: float,
plateau: float,
penetration: float,
penetration_time: float,
clearance: float,
margin: float,
part: str,
bottoming: bool,
bottoming_time: float,
bottoming_source: str,
residual_speed: float,
residual_energy: float,
residual_share: float,
extra_space: float,
hic_share_after: float,
diagnosis: str,
reason: str,
)
What happened in one headform impact (mm, ms, m/s, g, J).
plateau
instance-attribute
¶
Mean acceleration from the first peak to bottoming (or to the deepest penetration), g.
margin
instance-attribute
¶
Space left at the deepest penetration: clearance - stack + skin -
penetration, mm (negative: used up).
residual_speed
instance-attribute
¶
Speed along the impact direction when bottoming, m/s.
residual_energy
instance-attribute
¶
Headform energy left when bottoming, J (share of the impact energy
in residual_share).
extra_space
instance-attribute
¶
Space that would have stopped the residual speed on the plateau, mm.
hic_share_after
instance-attribute
¶
Share of the HIC window's velocity change after bottoming (0 to 1).
GridAssessment
dataclass
¶
GridAssessment(
points: dict[Hashable, ImpactAssessment],
protocol: str = "euroncap_2026",
notes: tuple[str, ...] = tuple(),
)
All impact points of a grid.
lost_points
¶
Grid points lost to each cause (1 per point minus its colour's points).
score
¶
score(**kwargs: object) -> HeadformScore
Euro NCAP head score of the predicted HIC15 values
(headform_score; keyword arguments are passed on).
map
¶
Text map of a (row, column) grid: colour letter (G Y O B R), with
* for bottoming and ^ for a first-peak or stiff point.
table
¶
Markdown table of the points, worst first.
GridComparison
dataclass
¶
GridComparison(
baseline: str,
variant: str,
changes: tuple[
tuple[Hashable, str, str, float, float], ...
],
score: tuple[float, float],
grid_points: tuple[float, float],
no_longer_bottoming: tuple[Hashable, ...],
new_bottoming: tuple[Hashable, ...],
)
impact_direction
¶
impact_direction(
headform: str | Headform | float = "child",
*,
rearward: ArrayLike = (1.0, 0.0, 0.0),
up: ArrayLike = (0.0, 0.0, 1.0),
) -> FloatArray
Unit vector of the headform's path: rearward and down at the headform's angle to the ground (or an angle in degrees).
rearward and up are the vehicle's rearward and upward axes in
the model (x rearward and z up by default, as in most crash models).
read_impact_points
¶
read_impact_points(
path: str | Path,
) -> dict[Hashable, ImpactPoint]
Impact points from a CSV with the columns row, column,
x, y, z and optionally headform (child or adult) and
run (the run folder, relative to the CSV). Keys are
(row, column), as integers when they are numbers.
surface_normals
¶
surface_normals(
surface: ArrayLike,
points: ArrayLike,
*,
up: ArrayLike = (0.0, 0.0, 1.0),
neighbours: int = 24,
) -> FloatArray
Outward (upward) unit normals of a surface point cloud at points,
from a plane fitted to the nearest neighbours surface points.
clearance
¶
clearance(
points: Mapping[Hashable, ArrayLike] | ArrayLike,
hard_parts: Mapping[str, ArrayLike],
direction: ArrayLike | Mapping[Hashable, ArrayLike],
*,
surface: ArrayLike | None = None,
radius: float = 82.5,
max_distance: float = 400.0,
up: ArrayLike = (0.0, 0.0, 1.0),
unit_system: str = "mm-ms-kg",
) -> dict[Hashable, Clearance]
Free space under impact points to the hard parts.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
points
|
Mapping[Hashable, ArrayLike] | ArrayLike
|
Impact points on the bonnet: |
required |
hard_parts
|
Mapping[str, ArrayLike]
|
Part name -> its node coordinates (n, 3), for example
|
required |
direction
|
ArrayLike | Mapping[Hashable, ArrayLike]
|
The headform's path ( |
required |
surface
|
ArrayLike | None
|
Bonnet surface points. The headform touches the bonnet at the impact point with its centre on the surface normal, which on an inclined bonnet is not the leading point of the sphere along its path; give the surface for the right result there. It also adds the clearance along the inward surface normal. Without it the headform is assumed to hit the surface head-on. |
None
|
radius
|
float
|
Headform radius, mm (82.5: the 165 mm Euro NCAP headform). |
82.5
|
max_distance
|
float
|
Hard parts farther than this along the path are ignored, mm. |
400.0
|
unit_system
|
str
|
Of the coordinates (results in mm). |
'mm-ms-kg'
|
clearance_map
¶
clearance_map(
clearances: Mapping[Hashable, Clearance],
*,
needed: float | None = None,
normal: bool = False,
) -> str
Text map of the free space (mm) of a (row, column) grid: - for
no hard part within reach, ! after points with less than
needed mm (required_clearance plus the stack, say). normal
maps the clearance along the surface normal instead.
required_clearance
¶
required_clearance(
hic: float,
*,
speed: float = 40.0,
shape: str = "half_sine",
window_ms: float = 15.0,
) -> float
Smallest stopping distance (mm) that keeps HIC15 at hic for a
head at speed (km/h) stopped by a pulse of shape
(PULSE_SHAPES).
The pulse is scaled in time and level until it stops the head and gives exactly that HIC; its stopping distance is returned. The square wave gives the physical lower limit (about 68 mm for HIC 1000 at 40 km/h). Add the crushed thickness of the bonnet and the headform skin to compare with the geometric clearance.
clearance_table
¶
clearance_table(
*,
speed: float = 40.0,
shapes: Sequence[str] = (
"square",
"half_sine",
"triangle",
),
limits: Mapping[str, float] | None = None,
) -> str
Markdown table: deformation space needed (mm) to stay within each colour limit, per pulse shape.
head_impact
¶
head_impact(
source: str | Path | AsciiOutput,
*,
node: int | None = None,
direction: ArrayLike | None = None,
headform: str | Headform = "child",
unit_system: str = "mm-ms-kg",
cfc: float | None = 1000.0,
contact_g: float = 2.0,
name: str | None = None,
) -> HeadImpact
The headform's motion from nodout.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
source
|
str | Path | AsciiOutput
|
A nodout file, a run folder with one, or an |
required |
node
|
int | None
|
The headform's centre of gravity node; the only (or first) node of the file by default. |
None
|
direction
|
ArrayLike | None
|
Impact direction; |
None
|
headform
|
str | Headform
|
|
'child'
|
cfc
|
float | None
|
SAE J211 class for the acceleration (Euro NCAP: 1000); None for none. Unevenly spaced output is resampled first. |
1000.0
|
contact_g
|
float
|
First contact: the unfiltered acceleration first reaches this, g. The penetration is measured from then. |
2.0
|
assess_impact
¶
assess_impact(
impact: HeadImpact,
clearance: Clearance | float | None = None,
*,
stack: float = 5.0,
skin: float = 3.0,
rise: float = 1.25,
first_fraction: float = 0.3,
target: str = "yellow",
window_ms: float = 15.0,
) -> ImpactAssessment
HIC, bottoming out and its cause for one impact.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
impact
|
HeadImpact
|
From |
required |
clearance
|
Clearance | float | None
|
A |
None
|
stack
|
float
|
Crushed thickness of the bonnet outer and inner panels between the head and the hard part, mm. |
5.0
|
skin
|
float
|
Compression of the headform skin under the bonnet load, mm: the
head centre travels this much more than the bonnet. The head
bottoms out when its penetration reaches |
3.0
|
rise
|
float
|
Pulse test: a later peak at least |
1.25
|
first_fraction
|
float
|
The first contact peak is the first local peak above this fraction of the highest acceleration. |
0.3
|
target
|
str
|
Colour the point should reach; worse colours get a cause. |
'yellow'
|
assess_grid
¶
assess_grid(
impacts: Mapping[Hashable, HeadImpact],
clearances: Mapping[Hashable, Clearance | float]
| None = None,
*,
protocol: str = "euroncap_2026",
**kwargs: float | str,
) -> GridAssessment
assess_impact for every point of a grid (keyword arguments are
passed on); clearances by the same keys.
compare_grids
¶
compare_grids(
baseline: GridAssessment,
variant: GridAssessment,
*,
names: tuple[str, str] = ("baseline", "variant"),
) -> GridComparison
Colour, score and bottoming changes between two grids (same keys).
crashmetrics.pedestrian.synthetic¶
synthetic
¶
A synthetic bonnet and its headform impacts, for examples and tests.
bonnet_model gives a bonnet surface over hard parts (engine, intake
plenum, strut towers, battery, hinges, cowl) and a Euro NCAP-like grid
of impact points every 100 mm; simulate_grid impacts every point with
the child (front rows) or adult (rear rows) headform at 40 km/h;
BonnetRun.write writes what a real headform study gives:
bonnet.k: the bonnet outer and the hard parts as shell meshes (read withcrashmetrics.mesh.read_mesh);impact_points.csv: the grid points, headform and run folder of each (read withcrashmetrics.pedestrian.clearance.read_impact_points);- one folder per impact with a
nodoutof the headform centre node.
Each impact is a lumped model along the headform's path: the headform
(mass, a stiff skin contact) pushes a local bonnet mass, held by the
bonnet's elastic-plastic bending support (the inner panel). The free
space under the point is measured from the meshes with
crashmetrics.pedestrian.clearance.clearance; when the bonnet has used
it up (less the stack of the panels), it lands on the hard part, which
is stiff and crushes at a high force. Stiff zones (latch, hinges, wing
edges) have a higher bending force and more local mass.
VARIANTS change one thing with a known effect: the engine 20 mm lower
(the points over the plenum stop being red) and a stiffer bonnet inner
panel (the head stops in less space, but the bonnet itself is now too
stiff). The truth of every impact is kept
(BonnetRun.truth) to test the analysis against. The model is for
teaching and testing, not a vehicle simulation; the files say so.
Units of the files: mm, ms, kg.
VARIANTS
module-attribute
¶
VARIANTS: dict[str, str] = {
"baseline": "Reference bonnet: the head bottoms out on the intake plenum, the strut towers, the battery, the hinges and the cowl; the latch and the wing edges are stiff",
"lower_engine": "Engine and plenum 20 mm lower: the plenum points go from red to brown, orange or yellow",
"stiff_inner": "Inner panel 40 % stiffer: the head stops in less space, but the bonnet itself is now too stiff and the score drops",
}
Variants of bonnet_model and what the analysis should find.
HardPart
dataclass
¶
HardPart(
part_id: int,
name: str,
top: float,
x: tuple[float, float] = (0.0, 0.0),
y: tuple[float, float] = (0.0, 0.0),
centre: tuple[float, float] | None = None,
radius: float = 0.0,
height: float = 80.0,
crush_force: float = 15.0,
stiffness: float = 15.0,
)
A hard part under the bonnet: a box (x, y ranges) or a
vertical cylinder (centre, radius), from top down by
height (mm).
StiffZone
dataclass
¶
StiffZone(
name: str,
x: tuple[float, float],
y: tuple[float, float],
plateau_factor: float,
mass_factor: float = 1.0,
)
A stiffer area of the bonnet (latch, hinge, wing edge).
BonnetModel
dataclass
¶
BonnetModel(
name: str,
hard_parts: tuple[HardPart, ...],
stiff_zones: tuple[StiffZone, ...],
z_front: float = 770.0,
slope: float = 0.17,
crown: float = 70.0,
length: float = 1100.0,
half_width: float = 700.0,
rows: tuple[int, ...] = tuple(range(1, 11)),
columns: tuple[int, ...] = tuple(range(-6, 7)),
adult_from_row: int = 6,
plateau: float = 2.0,
hardening: float = 0.0015,
bonnet_stiffness: float = 0.25,
bonnet_mass: float = 0.45,
skin_stiffness: float = 0.6,
skin_damping: float = 0.25,
stack: float = 5.0,
notes: str = "",
)
A bonnet over hard parts (mm, kg, kN).
z_front
class-attribute
instance-attribute
¶
Bonnet height at the leading edge (x = 0, y = 0), mm.
crown
class-attribute
instance-attribute
¶
Drop from the centre line to y = +-700 mm.
rows
class-attribute
instance-attribute
¶
Grid rows; row r is at x = 100 r mm.
columns
class-attribute
instance-attribute
¶
Grid columns; column c is at y = 100 c mm (LH positive).
adult_from_row
class-attribute
instance-attribute
¶
Rows from here on are adult headform points.
plateau
class-attribute
instance-attribute
¶
Bending (crush) force of the bonnet inner panel, kN.
hardening
class-attribute
instance-attribute
¶
Rise of that force per mm of bonnet travel (share).
bonnet_stiffness
class-attribute
instance-attribute
¶
Elastic bending stiffness of the bonnet, kN/mm.
bonnet_mass
class-attribute
instance-attribute
¶
Local bonnet mass the head accelerates, kg.
skin_stiffness
class-attribute
instance-attribute
¶
Headform skin contact stiffness, kN/mm.
skin_damping
class-attribute
instance-attribute
¶
Hunt-Crossley damping of the skin contact, s/m: the vinyl skin absorbs energy, so the bonnet does not bounce off the head, and the damping force grows with the compression (no jump at first touch).
stack
class-attribute
instance-attribute
¶
Crushed thickness of bonnet outer and inner, mm.
points
¶
Grid points on the bonnet surface, by (row, column).
ImpactTruth
dataclass
¶
ImpactTruth(
clearance: float,
part: str,
bottoming_time: float,
residual_speed: float,
max_hard_force: float,
)
What the lumped model did at one point (mm, ms, m/s, J).
BonnetRun
dataclass
¶
BonnetRun(
model: BonnetModel,
time: FloatArray,
keys: list[tuple[int, int]],
points: dict[
tuple[int, int], tuple[float, float, float]
],
directions: dict[tuple[int, int], FloatArray],
clearances: dict[Hashable, Clearance],
travel: FloatArray,
speed: FloatArray,
acceleration: FloatArray,
truth: dict[tuple[int, int], ImpactTruth] = dict(),
)
Impacts of all grid points of a BonnetModel (mm, ms).
travel
instance-attribute
¶
(time, point): head travel along its path from first contact (negative before it), mm.
bonnet_model
¶
bonnet_model(variant: str = 'baseline') -> BonnetModel
The reference bonnet or one of VARIANTS.
simulate_grid
¶
simulate_grid(
model: BonnetModel,
*,
duration: float = 16.0,
pre_contact: float = 1.0,
output_step: float = 0.1,
step: float = 0.004,
) -> BonnetRun
Impact every grid point (child or adult headform at 40 km/h).
The head starts pre_contact ms before touching the bonnet; output
every output_step ms (10 kHz). Times in ms.