Skip to content

hertzforge.io.punch

punch

Read Nastran punch files (.pch): the eigenvectors, as a ShapeSet.

A bulk deck has the mesh and no results; the modes a correlation needs are in the punch file that SOL 103 writes with DISPLACEMENT(PUNCH) = ALL in case control. Its layout is documented in every Nastran vendor's reference and is the same across them, which is why the punch is read and the .f06 print file is not: the print file is formatted for reading, and vendors differ in its columns.

The layout: each line is 72 columns of data with an optional sequence number in columns 73-80, which is ignored. A mode starts at a $EIGENVALUE = <lambda> MODE = <k> header, under $ header lines naming the output ($DISPLACEMENTS, $EIGENVECTOR) and its form ($REAL OUTPUT or $COMPLEX OUTPUT). Lambda is the eigenvalue in (rad/s)^2, so the frequency in Hz is sqrt(lambda)/2pi; a negative lambda (a rigid body mode with numerical error) gives 0 Hz. Each grid then has one line of id, type and three translations, and a -CONT- line with the three rotations. Every grid must have the same number of values, 3 or 6, and every mode the same grids.

$COMPLEX OUTPUT is refused, because no sample file has shown the header layout of a complex modal solution's eigenvalue, and a guessed frequency on every mode would be worse than the refusal.

Only G (grid) rows are kept. S (scalar) points have one value that belongs to no direction, so they are skipped instead of being assigned to an axis.

Real normal modes have no damping, so the damping is 0. The punch does not record how the modes were normalized, so the ShapeSet is marked unscaled. A punch has no units, like the deck it came from, so the shapes are read as written.

Functions:

Name Description
sniff

True for a .pch file with a $EIGENVALUE = ... MODE = ... header

load

Read the real eigenvectors in a punch file as a ShapeSet.

Functions:

sniff

sniff(path: str | PathLike) -> bool

True for a .pch file with a $EIGENVALUE = ... MODE = ... header in its first 64 kB.

A punch from a run that wrote no eigenvectors has the suffix and nothing this reads, so the header is what is looked for.

load

load(path: str | PathLike, **_unused: Any) -> Any

Read the real eigenvectors in a punch file as a ShapeSet.

Each frequency comes from its mode's eigenvalue, sqrt(lambda)/2pi Hz, and 0 Hz for a negative one; the damping is zero and the shapes are marked unscaled, since the punch records neither. Raises ValueError for complex output, for a file with no eigenvectors, and for modes that do not cover the same grids with the same number of values.