Skip to content

hertzforge.core.fem

fem

Beams, plates and solids, and the eigensolution they give.

Hertzforge is an analysis toolset, and this module is the smallest modeling capability that produces something worth analyzing. It has three-dimensional two-node beams; flat-shell plates, as four-node rectangles (MITC4) and three-node triangles (MITC3); solids, as eight-node hexahedra with incompatible modes, six-node wedges and four-node tetrahedra; and lumped masses, discrete springs, rigid links and grounds. These are assembled into mass and stiffness matrices and solved for real normal modes, dense for a small model and sparse past SPARSE_ABOVE degrees of freedom. A demonstration needs a reference model, an analytical answer the measured one can be compared against, and building one should not require another package.

There are three ways to build a model. The first is member by member, as the example below does. The second is to give a geometry's element groups their properties (GroupProperties): a material and a thickness for an element group of plates, a material and a section for one of beams, a material alone for one of solids, a mass for point masses, a stiffness for springs and the directions held for ground. from_geometry then builds every element as the element it is, which is how an Exodus file describes a structure and how a model of a simple test article is built in the app. The third is to draw a shape as a surface mesh and let from_geometry, given one material and one section, put a beam along every edge of it. That is the shortest route from any geometry to a set of modes.

This is not a general finite element code. The quad plate takes any flat convex quad (Plate); a warped one is refused rather than solved badly. The triangle takes any flat shape. Every shell is flat, so a curved surface is a faceted one. A solid carries three translations per node and no rotations, and the linear wedge and tetrahedron lock in bending where the brick does not (Solid). The constraints are held degrees of freedom (fixed, add_ground) and rigid links, which the eigensolution eliminates exactly instead of approximating them with a stiff member (constraint_transform). There is no general multipoint constraint and no static solution; modes are the only result, and the strain and stress each mode puts in each solid element are read from them (core.element_shapes). Wiring a surface mesh's edges with from_geometry makes a grillage of beams, not plates. That is a modeling choice with a known cost, not an approximation hidden inside an element: it shows the order of mode density and the mode families a shape has, and it is not shell theory.

Everything here is SI, because the mass and stiffness matrices are the one place in Hertzforge where several dimensions have to be consistent with each other at once. A length in millimeters beside a modulus in pascals is not wrong in any single entry; it is wrong only in the answer. The objects that come out (Geometry, ShapeSet) carry their units, so the conversion happens once, at the boundary, as it does everywhere else.

from hertzforge import fem

aluminum = fem.Material('aluminum', youngs_modulus=70e9, density=2700)
tube = fem.Section.round_tube('16 mm tube', outer=0.016, wall=0.001)

model = fem.Model('cantilever')
for i in range(11):
    model.add_node(100 + i, i * 0.1, 0.0, 0.0)
model.add_chain(range(100, 111), aluminum, tube)
shapes = model.eigensolution(maximum_frequency=2000,
                             fixed=['100'], damping=0.01)

The beam is Euler-Bernoulli with a consistent mass matrix: no shear flexibility and no section rotary inertia. That is accurate while a member is slender (length more than about ten times its depth), and the frequencies come out increasingly high when it is not. An arm 180 mm long and 16 mm deep is well inside that limit; a short, deep mounting stub is not, and its frequencies read high.

References

The Euler-Bernoulli beam element and its consistent mass matrix are textbook, and so is the eigenproblem; the first three are where they are set out. The plate and brick formulations each come from a paper, the last four.

  1. Przemieniecki, J. S. (1968). Theory of Matrix Structural Analysis. McGraw-Hill.
  2. Cook, R. D., Malkus, D. S., Plesha, M. E., & Witt, R. J. (2002). Concepts and Applications of Finite Element Analysis, 4th ed. Wiley. The cubic Hermite shape functions the consistent mass follows from, and why consistent rather than lumped changes the frequencies returned.
  3. Craig, R. R., & Kurdila, A. J. (2006). Fundamentals of Structural Dynamics, 2nd ed. Wiley. The generalized symmetric eigenproblem this solves, and normalization to unit modal mass.
  4. Dvorkin, E. N., & Bathe, K.-J. (1984). A continuum mechanics based four-node shell element for general non-linear analysis. Engineering Computations. The MITC4 assumed transverse shear, tied at the edge midpoints.
  5. Lee, P.-S., & Bathe, K.-J. (2004). Development of MITC isotropic triangular shell finite elements. Computers & Structures. The MITC3 triangle, tied along its edges.
  6. Wilson, E. L., Taylor, R. L., Doherty, W. P., & Ghaboussi, J. (1973). Incompatible displacement models. In Numerical and Computer Methods in Structural Mechanics. Academic Press. The bubble modes that let a trilinear brick bend.
  7. Taylor, R. L., Beresford, P. J., & Wilson, E. L. (1976). A non-conforming element for stress analysis. International Journal for Numerical Methods in Engineering. Those modes' strains from the centroid's Jacobian, so a distorted brick still passes the patch test.

Classes:

Name Description
Material

An isotropic elastic material.

LibraryMaterial

A material the library offers, with where its numbers came from.

Section

A beam cross section, as the four numbers the element needs.

GroupProperties

What an element group of a geometry is made of, for Model.from_geometry.

Beam

One two-node beam element.

Plate

One four-node plate-bending element.

Triangle

One three-node triangular plate-bending element.

Solid

One solid element: a hexahedron, a wedge or a tetrahedron, told

RigidLink

Two nodes held rigidly together, with no mass of their own. In each

Spring

A discrete spring between two degrees of freedom, or from one to

Tie

A node held to a point of a surface, in a frame of its own: along

LumpedMass

A rigid item carried at a node: a motor, a battery, a camera.

Face

A face for drawing: shading, not stiffness.

NotConverged

The block Lanczos ran out of basis before the modes asked for

Model

A structure's nodes, elements, masses, springs and constraints, and

Functions:

Name Description
ground_axes

A ground's directions as AXES names, in their order.

material

A library material by name, such as material('6061-T6'): the same

with_article

A shape's name with its article, for a sentence: 'a channel', 'an

angle_major_axis

Where an angle's major principal axis lies, which is the direction

connected_pieces

The connected components of an adjacency map, largest first.

polish_modes

Refine a block of approximate modes until they are converged.

block_lanczos_modes

The count eigenpairs nearest the shift, by block Lanczos on the

predicted_count

How many modes have an eigenvalue below limit, read off how the

blas_threads

Hold each BLAS thread pool to a quarter of the logical CPUs (at

group_masses

{element group: mass in kg}, what each of a geometry's element

mated_ties

Every tie the geometry's mated surfaces make, as (the set, the

signed_modes

These modes, one per column, each with a definite sign.

Classes

Material dataclass

Material(name: str, youngs_modulus: float, density: float, poissons_ratio: float = 0.3, modulus_of_rigidity: float | None = None)

An isotropic elastic material.

The modulus is in Pa and the density in kg/m^3. The shear modulus is derived from the modulus and Poisson's ratio unless modulus_of_rigidity is given. For carbon fiber laminates the isotropic relation is a poor estimate, and the torsional stiffness it implies can be off by a factor of two, so it can be stated directly.

Attributes:

Name Type Description
is_rigid bool

Whether this is RIGID, the material that makes rigid links. A

shear_modulus float

The shear modulus in Pa: modulus_of_rigidity when it is stated,

Attributes
is_rigid property
is_rigid: bool

Whether this is RIGID, the material that makes rigid links. A modulus left blank in the Element Groups table (None) is a material not yet finished, not a link.

shear_modulus property
shear_modulus: float

The shear modulus in Pa: modulus_of_rigidity when it is stated, otherwise E / (2 (1 + nu)), the isotropic relation.

LibraryMaterial dataclass

LibraryMaterial(material: Material, note: str)

A material the library offers, with where its numbers came from.

The note names the kind of source and what the values are typical of. A handbook's typical modulus and density are what a modal solution needs, and they are not what a particular heat of a particular alloy measures, so a person with the part's certification in hand types those numbers over the library's.

Section dataclass

Section(name: str, area: float, iy: float, iz: float, j: float, shape: str = '', dimensions: tuple[float, ...] = ())

A beam cross section, as the four numbers the element needs.

iy and iz are second moments of area about the element's own local y and z axes, and j is the St Venant torsion constant, which equals the polar second moment only for a circular section. For any other section it is smaller, and using the polar value overstates the torsional stiffness; the constructors below use the correct formula for the shapes they build. Areas are in m^2 and the moments in m^4.

A section built from one of the shapes (SHAPES) remembers it: shape and its dimensions in meters, in the order the constructor takes them, so a table can show the dimensions and a file or a session script can rebuild the section from them. One rule sets which way a shape faces: its width or flanges run along local y and its depth or height along local z, so the orientation vector (which names local y) points across the flanges, and iy is the strong-axis bending of an I-beam or a channel. An angle is the exception, because its leg axes are not principal and the element has no product term. Its iy and iz are its principal moments, and the orientation vector points along the major principal axis (angle_major_axis gives where that is relative to the legs).

The element assumes the shear center is at the centroid. For the symmetric shapes it is; for a channel and an angle it is not, and the twisting that a load through their centroid causes is not in the model.

polar is the inertia term, always the true polar second moment (iy + iz), because rotary inertia about the axis depends only on where the material is and has nothing to do with warping.

Methods:

Name Description
of_shape

The section of a named shape (SHAPES), given its dimensions

round_tube

A circular tube, given its outside diameter and wall thickness.

rod

A solid circular rod.

rectangle

A solid rectangle, width along local y and height along z.

rectangular_tube

A rectangular tube of one wall thickness, width along local y

square_tube

A square tube, given its outside width and wall thickness: a

i_beam

A doubly symmetric I-beam, with overall depth along local z and

channel

A channel, with overall depth along local z and the flanges

angle

An angle of one thickness, its short leg no longer than its long

Attributes:

Name Type Description
polar float

The polar second moment, iy + iz, in m^4: the rotary inertia

Attributes
polar property
polar: float

The polar second moment, iy + iz, in m^4: the rotary inertia term. The torsional stiffness uses j, which is smaller for any section but a circle.

Methods:
of_shape classmethod
of_shape(name: str, shape: str, dimensions: Sequence[float]) -> Section

The section of a named shape (SHAPES), given its dimensions in meters in the order the shape's constructor takes them.

A shape not in SHAPES, the wrong number of dimensions, or dimensions the constructor refuses raise ValueError.

Parameters:

Name Type Description Default
name str

What to call the section.

required
shape str

A key of SHAPES.

required
dimensions sequence of float

The shape's dimensions, in meters.

required

Returns:

Type Description
Section
round_tube classmethod
round_tube(name: str, outer: float, wall: float) -> Section

A circular tube, given its outside diameter and wall thickness.

rod classmethod
rod(name: str, diameter: float) -> Section

A solid circular rod.

rectangle classmethod
rectangle(name: str, width: float, height: float) -> Section

A solid rectangle, width along local y and height along z.

rectangular_tube classmethod
rectangular_tube(name: str, width: float, height: float, wall: float) -> Section

A rectangular tube of one wall thickness, width along local y and height along z, both outside dimensions.

square_tube classmethod
square_tube(name: str, width: float, wall: float) -> Section

A square tube, given its outside width and wall thickness: a rectangular tube with equal sides.

i_beam classmethod
i_beam(name: str, depth: float, flange_width: float, flange_thickness: float, web_thickness: float) -> Section

A doubly symmetric I-beam, with overall depth along local z and flanges flange_width wide along y. Fillets are left out, which puts the area and the torsion constant a few percent under a rolled shape's table values (for a W8x31, 8.99 in² against 9.13, and J of 0.50 in⁴ against 0.54).

channel classmethod
channel(name: str, depth: float, flange_width: float, flange_thickness: float, web_thickness: float) -> Section

A channel, with overall depth along local z and the flanges flange_width wide (web included), running along +y from the web. iz is about the centroid, which is off the web; the shear center is further off it on the other side, and the element does not include that. The flanges have one thickness. A rolled channel's flanges taper toward their tips and its table flange thickness is an average, so this iz is high for one (a C6x10.5 gives 1.06 in⁴ against the table's 0.86); for a bent-plate channel it is exact.

angle classmethod
angle(name: str, long_leg: float, short_leg: float, thickness: float) -> Section

An angle of one thickness, its short leg no longer than its long one. Its leg axes are not principal and the element has no product term, so iy and iz are the principal moments, major and minor, and the orientation vector should point along the major principal axis (angle_major_axis).

GroupProperties dataclass

GroupProperties(material: Material | None = None, thickness: float | None = None, section: Section | None = None, orientation: tuple[float, float, float] | None = None, mass: float | None = None, stiffness: tuple[float | None, ...] | None = None, ground: tuple[str, ...] | bool = ())

What an element group of a geometry is made of, for Model.from_geometry.

There is one property set per element group of one element type, the way finite element formats state a structure. An element group of plates (triangles or quads) takes a material and a thickness, in meters. An element group of beams takes a material and a section, and optionally an orientation vector for the roll, as Model.add_beam takes it. An element group of solids takes the material alone, and an element group of two-node lines made of RIGID is a set of rigid links. An element group given both a thickness and a section, or a group of plates or beams given neither, is refused by name when the model is built.

An element group of point elements given a mass, and no material, is a set of lumped masses: GroupProperties(mass=m) puts m kilograms at the node of every element in the element group (a bolt, a sensor, a fitting too small to mesh), which is how a finite element deck states one, as a CONM2 or a point-mass element group.

An element group given a stiffness, six numbers in the global X, Y, Z, RX, RY and RZ directions (N/m and N m/rad) with None for free, is a group of springs. Every two-node line in it is a spring between its two nodes in each direction given (Model.add_spring), the nodes free to coincide, and every point element is a spring from its node to ground. That is a Nastran CBUSH, or CELAS cards one direction at a time. An element group given ground holds points, and each one's node is held in each direction given (Model.add_ground): all six with ground=True, the translations alone with ground=('X', 'Y', 'Z'). That is a support, or the far end of a spring to ground drawn as a line. A Nastran SPC1 reads as one, its components the directions.

Attributes:

Name Type Description
kind str

What the element group is: 'ground', 'mass', 'spring', 'rigid',

Attributes
kind property
kind: str

What the element group is: 'ground', 'mass', 'spring', 'rigid', 'plate', 'beam' or 'solid', or else what is wrong with it ('no material', 'both a thickness and a section'). Ground comes first, then a mass, then a stiffness, whatever else is set, since each is the one thing such a group can use. A rigid element group takes no thickness and no section, and any left from before the material was picked are ignored. A material alone is an element group of solids, which take nothing else; an element group of plates or beams given only a material is refused where the elements are built, by what they are.

Beam dataclass

Beam(node_a: int, node_b: int, material: Material, section: Section, orientation: tuple[float, float, float] | None = None, color: int = 1, group: str = '')

One two-node beam element.

Plate dataclass

Plate(nodes: tuple[int, int, int, int], material: Material, thickness: float, color: int = 1, group: str = '')

One four-node plate-bending element.

A flat shell: plane-stress membrane action in its own plane and Mindlin bending out of it, with the transverse shear tied at the edge midpoints (MITC4, in its covariant form). The tying is necessary. A plain bilinear Mindlin element locks in shear as the plate gets thin, and a 12x12 mesh of the locking element puts the first elastic mode of a thin free plate several times too high.

Any convex quad is accepted. A quad that is not convex, has no area, or is warped beyond QUAD_WARP of its shorter diagonal is refused: the element is flat, and its corners are projected onto their mean plane.

Nodes run around the perimeter: 1-2 is the first edge, 1-4 the second, and corner 3 is opposite corner 1. The thickness is in meters.

Triangle dataclass

Triangle(nodes: tuple[int, int, int], material: Material, thickness: float, color: int = 1, group: str = '')

One three-node triangular plate-bending element.

The same theory as the quad, so a mesh of triangles and a mesh of rectangles agree: a flat shell with plane-stress membrane action in its own plane and Mindlin bending out of it, with the transverse shear tied along the three edges (MITC3, Lee & Bathe 2004). The tying keeps a linear triangle from locking in shear as the plate gets thin; a plain linear Mindlin triangle locks badly. Any flat triangle is a valid element, and only a degenerate one (zero area) is refused.

Nodes run around the perimeter, counterclockwise about the normal the element takes as its own +z. The thickness is in meters.

Solid dataclass

Solid(nodes: tuple[int, ...], material: Material, color: int = 1, group: str = '')

One solid element: a hexahedron, a wedge or a tetrahedron, told apart by how many nodes it names (8, 6, 4, or 10 for a quadratic tetrahedron).

Each node has three translations and no rotations. A solid has no rotational stiffness, and the rotations of a node that only solids touch are grounded by the eigensolution rather than left as degrees of freedom with nothing on them (Model.dangling_rotations).

The hexahedron is trilinear with Wilson's incompatible bending modes, in Taylor's form (the extra modes' strains are taken from the Jacobian at the centroid, so a distorted brick still passes the patch test). A plain trilinear brick is far too stiff in bending, and a part meshed a few elements through its thickness would come out a third high. With the modes, one layer of bricks bends like a beam. The wedge is the linear six-node element and the tetrahedron the constant-strain one. They are for transitions and imported meshes, not what a part is meshed with here (mesh.block makes bricks); a linear tetrahedron locks in bending, and a mesh of them is accurate only where it is fine.

Nodes run around the bottom face and then the top, the same way round (the UFF 2412 and Nastran CHEXA/CPENTA/CTETRA order).

RigidLink(node_a: int, node_b: int, group: str = '')

Two nodes held rigidly together, with no mass of their own. In each rigid body the node added to the model first leads, and the others follow its translation and rotation exactly (Model.add_rigid_link, RIGID).

Spring dataclass

Spring(node_a: int, direction_a: int, node_b: int | None, direction_b: int, stiffness: float, name: str = '')

A discrete spring between two degrees of freedom, or from one to ground: the flexible counterpart of a RigidLink, and what a Nastran CELAS states.

Each end is a node and a signed direction code (direction_code: 1-3 the translations, 4-6 the rotations). The spring resists the difference of the two motions, each taken along its own sign, so 'X+' to 'X+' is the ordinary axial spring. node_b None grounds it. The stiffness is in N/m between translations and N m/rad between rotations.

Tie dataclass

Tie(node_a: int, nodes_b: tuple[int, ...], weights: tuple[float, ...], frame: tuple, modes: tuple[str, str, str], stiffness: tuple[float, float, float], group: str = '')

A node held to a point of a surface, in a frame of its own: along the surface's normal there, and in its plane. The point moves as the surface's nodes around it do, weighted (a point inside a triangle is its three corners, a point on a node that node alone). Each of the frame's three directions is held rigidly, by a spring, or not at all (Model.add_tie). Only translations are tied, which is how a node of one mesh is tied to a surface of another (Mate Surfaces, core.mates): a tie to the point it lies on carries a rigid motion exactly, where a tie to a nearby node resists a rotation.

LumpedMass dataclass

LumpedMass(node: int, mass: float, inertia: tuple[float, float, float] = (0.0, 0.0, 0.0), name: str = '')

A rigid item carried at a node: a motor, a battery, a camera.

The mass is in kg and the inertias, in kg m^2, are about the global axes through the node. A point mass leaves them zero, which is accurate for something small compared with the members carrying it and wrong for a battery the size of the structure: a mass with no inertia cannot rock, so a rocking mode will not appear.

Face dataclass

Face(nodes: tuple[int, ...], color: int = 1, group: str = '')

A face for drawing: shading, not stiffness.

A grillage of beams draws as a wireframe, and a wireframe of a deck is hard to read. Faces spanning nodes that are already there give the renderer something to shade and the animation something to deform, and they add nothing to the matrices. That is why they are a separate kind rather than a zero-stiffness element.

NotConverged

Bases: Exception

The block Lanczos ran out of basis before the modes asked for converged; the caller solves by ARPACK instead.

Model

Model(name: str = '', length_unit: str = 'm')

A structure's nodes, elements, masses, springs and constraints, and the modes they give.

One set of element matrices is assembled two ways. Dense (matrices) is (6 x nodes) square, and every mode is solved; it is exact, and it is used for a model of up to SPARSE_ABOVE degrees of freedom. Sparse (sparse_matrices) stores only the nonzeros, and the lowest modes are found by shift-invert Lanczos. A plate model of the BARC at a quarter inch, 1,500 nodes, is about 13 GB dense; sparse, its eighth-inch mesh of 6,150 nodes solves in three seconds in under half a gigabyte.

Attributes: name: What the model is called; it becomes the geometry's name and the shape set's comment. length_unit: What the coordinates are in. Everything inside is SI; this is what the Geometry is told on the way out. beams: Every member, as Beam records naming two nodes, a material and a section. plates, triangles, solids: The plate and solid elements, as Plate, Triangle and Solid records. rigid_links: Rigid, massless links between two nodes, as RigidLink records (add_rigid_link). masses: Lumped masses, as LumpedMass records at a node. springs: Discrete springs between two degrees of freedom or to ground, as Spring records (add_spring). grounds: The nodes held, and in which directions, {node: axes 0-5} (add_ground). faces: Surfaces for drawing, as Face records naming three or four nodes. They carry no stiffness; wire_faces puts beams on their edges.

Methods:

Name Description
add_node

Add a node at (x, y, z) in meters and return its id.

add_beam

Add one beam element between two existing nodes and return it.

add_chain

A run of beams through consecutive nodes: one member in one call.

add_plate

One four-node plate element over existing nodes, thickness in

add_triangle

One triangular plate element over three existing nodes, thickness

add_solid

One solid element over eight, six, four or ten existing nodes:

add_rigid_link

Join two nodes rigidly, adding no mass.

add_spring

A spring between two degrees of freedom, or from one to ground.

move_node

Move a node already in the model to (x, y, z): how a node tied

add_tie

Tie node node_a's translation to a point that moves with

add_ground

Hold a node in some or all of the six directions.

rigid_bodies

The sets of nodes the rigid links join, each in the model's node

add_mass

Add a lumped mass at an existing node and return it.

add_face

Add a drawing face over three or four existing nodes and return

from_geometry

A structure from a geometry: its elements built from their element

pieces

The structure's disconnected parts, as lists of node ids, largest

wire_faces

Put a beam along every edge of every face, and return how many were

distribute_mass

Share total over the nodes by the beams meeting at each, as lumped

position

A node's position in meters. The array is the model's own, not a

group

The part this node was added as part of, such as 'arm 2' or 'top

dof_strings

Every degree of freedom, '101X+', '101Y+', ..., in the matrices'

matrices

Assemble the global mass and stiffness matrices, dense.

sparse_matrices

The same mass and stiffness matrices as matrices, stored sparse

rigid_body_vectors

The six rigid-body motions, as columns over the model's DOFs:

eigensolution

Real normal modes, mass-normalized, as a ShapeSet.

scaled_system

The sparse eigenproblem as the sparse solver sets it up.

constraint_transform

T, with u = T q: every degree of freedom of the model written in terms

dangling_rotations

The nodes whose rotations nothing acts on.

idle_lead_rotations

(lead node, axis 0-2) for each rotation of a rigid body's lead that

oblique_lead_lines

(lead node, unit direction) for each rigid body that only

loose_nodes

The nodes nothing touches: no element, no rigid link and no lumped

geometry

The model as a Geometry: its nodes, and its beams, rigid links,

Attributes:

Name Type Description
node_ids list[int]

The node ids in the order they were added, which is the matrices'

num_nodes int

How many nodes the model has.

num_dof int

The degrees of freedom, six per node: the matrices' size.

structural_mass float

What the elements weigh, in kg (beams, plates, triangles and

total_mass float

What the model weighs in kg: structural_mass plus every lumped

Attributes
node_ids property
node_ids: list[int]

The node ids in the order they were added, which is the matrices' row order.

num_nodes property
num_nodes: int

How many nodes the model has.

num_dof property
num_dof: int

The degrees of freedom, six per node: the matrices' size.

structural_mass property
structural_mass: float

What the elements weigh, in kg (beams, plates, triangles and solids), before any lumped mass is added.

total_mass property
total_mass: float

What the model weighs in kg: structural_mass plus every lumped mass.

Methods:
add_node
add_node(node_id: int, x: float, y: float, z: float, group: str = '') -> int

Add a node at (x, y, z) in meters and return its id.

group names the part the node belongs to. An id already in the model is refused with ValueError rather than moved.

add_beam
add_beam(node_a: int, node_b: int, material: Material, section: Section, orientation: Sequence[float] | None = None, color: int = 1, group: str = '') -> Beam

Add one beam element between two existing nodes and return it.

orientation names a direction the local x-y plane contains, which sets which way the section's iy and iz act; without one, global Z is used, or global Y for a nearly vertical member. Raises ValueError for a node not in the model or a beam from a node to itself.

add_chain
add_chain(nodes: Sequence[int], material: Material, section: Section, orientation: Sequence[float] | None = None, color: int = 1, group: str = '') -> list[Beam]

A run of beams through consecutive nodes: one member in one call.

add_plate
add_plate(nodes: Sequence[int], material: Material, thickness: float, color: int = 1, group: str = '') -> Plate

One four-node plate element over existing nodes, thickness in meters. A quad that is not convex, has no area or is warped is refused (Plate).

add_triangle
add_triangle(nodes: Sequence[int], material: Material, thickness: float, color: int = 1, group: str = '') -> Triangle

One triangular plate element over three existing nodes, thickness in meters. A triangle with no area is refused.

add_solid
add_solid(nodes: Sequence[int], material: Material, color: int = 1, group: str = '') -> Solid

One solid element over eight, six, four or ten existing nodes: a hexahedron, a wedge, a tetrahedron or a ten-node tetrahedron.

A solid with no volume is refused, and so is one made of RIGID. One numbered the other way round (its volume negative) is the same element and is accepted.

Parameters:

Name Type Description Default
nodes sequence of int

The corners, bottom face then top, the same way round; a ten-node tetrahedron's four corners, then the midsides of edges 1-2, 2-3, 1-3, 1-4, 2-4, 3-4.

required
material Material

What it is made of.

required
color optional

As for a plate.

1
group optional

As for a plate.

1

Returns:

Type Description
Solid
add_rigid_link(node_a: int, node_b: int, group: str = '') -> RigidLink

Join two nodes rigidly, adding no mass.

Links that share nodes join into one rigid body, however they are chained. Each body moves as its first node does (the one added to the model first), and the others follow it exactly. The eigensolution eliminates the followers' degrees of freedom rather than stiffening anything, so the answer is the limit of an infinitely stiff member and the matrices stay well conditioned.

Parameters:

Name Type Description Default
node_a int

The nodes, both already in the model, and different.

required
node_b int

The nodes, both already in the model, and different.

required
group str

The part the link belongs to (its element group, from a geometry).

''

Returns:

Type Description
RigidLink
add_spring
add_spring(dof_a: str, dof_b: str | None, stiffness: float, name: str = '') -> Spring

A spring between two degrees of freedom, or from one to ground.

The ends are written the way fixed writes them, a node and a direction: model.add_spring('101Z+', '201Z+', 5e5) joins two nodes' Z translations, model.add_spring('101RY+', '201RY+', 2e3) their rotations about Y, and model.add_spring('1Z+', None, 1e4) grounds node 1 in Z. The nodes may coincide, as at a joint between two parts meshed to the same point, where no beam can go, and a joint stiff in more than one direction is one spring per direction. A spring adds no mass. A spring to a node nothing else touches is a spring to ground, since that node is grounded whole (loose_nodes). A spring on a rotation must be on a node that a beam, plate or rigid link holds, or on a ground point; otherwise the solve refuses it.

A spring far stiffer than the structure costs the solve accuracy: two beams joined by springs ten orders of magnitude stiffer than their EI/L came out 0.2 % low on the dense solver, where five orders were within 3e-5 of the single beam. A joint meant to be rigid should be a rigid link (add_rigid_link), which costs no accuracy.

Parameters:

Name Type Description Default
dof_a str

The first end, as '': 'X+' to 'Z+' a translation, 'RX+' to 'RZ+' a rotation; a minus sign turns the end around.

required
dof_b str or None

The second end, the same way, or None for ground. Both ends are translations or both are rotations.

required
stiffness float

Positive: N/m between translations, N m/rad between rotations.

required
name str

What the spring is called (its element group, from a geometry).

''

Returns:

Type Description
Spring
move_node
move_node(node: int, x: float, y: float, z: float) -> None

Move a node already in the model to (x, y, z): how a node tied to a surface is put on it (add_tie), the way a tie constraint's position adjustment does in other solvers. Elements are built from the positions when the matrices are assembled, so a move before then is a move of every element on the node.

add_tie
add_tie(node_a: int, node_b: Any, normal: Sequence[float], normal_mode: str = 'rigid', shear_mode: str = 'rigid', normal_stiffness: float = 0.0, shear_stiffness: float = 0.0, group: str = '', weights: Sequence[float] | None = None) -> Tie

Tie node node_a's translation to a point that moves with node_b (one node, or several weighted by weights), along normal and in the plane across it.

Each of the two is held rigidly ('rigid'), by a spring of the given stiffness ('stiffness'), or not at all ('free'); the plane's two directions are held alike. A rigid direction makes node_a follow node_b there exactly: the eigensolution writes that part of node_a's motion through node_b's, as it does a rigid link's followers, with no stiffness to cost accuracy. Rotations are not tied, so a tie between two solids' nodes adds no rotation that nothing resists. A tie spans no gap: a node a hair off the surface is tied as if on it, so it should be moved there first (move_node); from_geometry does for mated surfaces. A node follows one tie at most.

Parameters:

Name Type Description Default
node_a int

The node that follows.

required
node_b int or sequence of int

The node it follows, or the nodes the point it follows moves with: a surface's corners around it. All already in the model, none of them node_a.

required
normal sequence of float

The direction across the surface; any length but zero.

required
normal_mode ('rigid', 'stiffness', 'free')

How the normal and the plane are held.

'rigid'
shear_mode ('rigid', 'stiffness', 'free')

How the normal and the plane are held.

'rigid'
normal_stiffness float

In N/m, positive where the mode is 'stiffness'.

0.0
shear_stiffness float

In N/m, positive where the mode is 'stiffness'.

0.0
group str

What the tie belongs to (its set of mated surfaces).

''
weights sequence of float

Each of node_b's share of the point's motion, summing to one; equal shares when omitted.

None

Returns:

Type Description
Tie
add_ground
add_ground(node: int, directions: Any = True) -> int

Hold a node in some or all of the six directions.

This is a support, solved as fixed would hold it but carried by the model; a ground point in a geometry builds one. A node nothing else touches is held whole already (loose_nodes); this holds a node the structure also touches. A node held twice is held in the directions of both.

Parameters:

Name Type Description Default
node int

The node, already in the model.

required
directions bool or sequence of str

The directions held, as AXES names ('X', 'RY') or anything ground_axes reads; True for all six. Holding none is refused.

True

Returns:

Type Description
int

The node.

rigid_bodies
rigid_bodies() -> list[list[int]]

The sets of nodes the rigid links join, each in the model's node order, so its first node is the one the others follow.

add_mass
add_mass(node: int, mass: float, inertia: Sequence[float] = (0.0, 0.0, 0.0), name: str = '') -> LumpedMass

Add a lumped mass at an existing node and return it.

mass is in kg and inertia in kg m^2 about the global axes through the node (LumpedMass). Raises ValueError for a node not in the model.

add_face
add_face(nodes: Sequence[int], color: int = 1, group: str = '') -> Face

Add a drawing face over three or four existing nodes and return it.

A face adds no stiffness and no mass (Face). Raises ValueError for any other node count or a node not in the model.

from_geometry classmethod
from_geometry(geometry: Geometry, material: Material | None = None, section: Section | None = None, total_mass: float | None = None, name: str = '', groups: dict[int, str] | None = None, sections: dict[str, Section] | None = None) -> Model

A structure from a geometry: its elements built from their element groups' properties or, without them, beams on its edges.

When geometry.group_properties gives what each element group is made of (GroupProperties), every element becomes the element it is: a quad a plate, a triangle a triangle, a two-node line a beam, a rigid link or springs, a hexahedron, wedge or tetrahedron a solid, and a point element a lumped mass, a spring to ground or a ground point, each with its element group's properties, and each set of mated surfaces (geometry.mates) ties between its two sides (add_tie). That is the model an Exodus file describes, one property set per element group of one element type. An element group with no properties, or an element type the solver has no element for, is refused by name, and material, section and sections are not used. Nodes no element touches are grounded at solve time (loose_nodes) rather than refused, as a deck's reference points are; a point mass on such a node, and a geometry in more than one piece, are refused.

Without element group properties a grillage is built, and material and section are required. Every element contributes its own edges as beams (a face its perimeter, a line element its run, so a wireframe geometry holds together), and each face of three or four nodes is also kept as a Face for drawing. This is a check on a shape, not a mesher. The beams stand in for whatever the real structure is, with one section for the whole model chosen to put the modes where they are wanted, and shell bending, membrane action and any real thickness are not represented. What it shows is the order of mode density and the mode families a shape has, which is usually the first question about a display model. A node connected to nothing, and a geometry in more than one piece, are refused.

Parameters:

Name Type Description Default
geometry Geometry

The shape. The model takes its name and its length unit.

required
material Material

The grillage's material.

None
section Section

The grillage's section.

None
total_mass float

What the model weighs in all, in kg. Whatever the elements and point masses do not already weigh is shared over the nodes by the length of beam each carries (distribute_mass), so it needs beams to share over; a model already heavier than this is refused.

None
name str

The model's name; the geometry's name when not given.

''
groups dict of int to str

{node: part}, the label of the part each node belongs to (Model.group), since the first question asked of a result is which part of the structure a mode is in. Taken from the geometry's element groups when not given.

None
sections dict of str to Section

For a grillage, {part: section}: the beams on the edges of the elements in an element group whose name starts with part take that section, so a part can be made stiffer or softer than the rest without redrawing anything.

None

Returns:

Type Description
Model
pieces
pieces() -> list[list[int]]

The structure's disconnected parts, as lists of node ids, largest first.

One piece is a structure; more than one is that many free bodies, each with its own six zero-frequency modes. It is the first thing to check on a model that comes back with too many zero-frequency modes. Elements, rigid links and springs between two nodes all join what they connect.

wire_faces
wire_faces(material: Material, section: Section, color: int = 1, group: str = '') -> int

Put a beam along every edge of every face, and return how many were added.

This is the shortest route from a shape to a structure: draw it as a surface mesh and let its own edges be its members. The geometry is then the model, with nothing derived, nothing tied, and no second set of nodes that exist only to be drawn.

Beams are used, not axial springs. A spring on each edge leaves a quad free to shear and a flat sheet free to fold, since the edges never change length and nothing resists it, and the model comes back a mechanism with as many zero-frequency modes as it has panels. A beam carries moment, so a wireframe of them is a space frame and is stable. It is the same beam element the rest of this module uses.

Shared edges are wired once. An edge that already has a beam is left alone, so explicit members (a truss strut, a standoff) can be placed first and keep their own section. Each new beam is in group, or in 'edge N' when no group is given.

distribute_mass
distribute_mass(total: float, spin: float = 1.0 / 12.0) -> dict[int, float]

Share total over the nodes by the beams meeting at each, as lumped masses, and return {node: mass}.

A node's share is proportional to the length of beam it carries (half of every beam that reaches it), so the mass follows the material. Sharing it equally would let the node count decide where the mass goes, and a node count only says how finely something was drawn.

Each node also gets a rotary inertia, without which its three rotational degrees of freedom carry no mass, the mass matrix is singular and the Cholesky factorization fails. It is spin * m * L^2, with L the mean length of the beams meeting there (the patch of structure the node stands for, spun about its own middle); the default 1/12 is a uniform rod's. Masses shared by an earlier call are replaced. Only beams count, so a model with no beams is refused.

Parameters:

Name Type Description Default
total float

The mass to share, in kg.

required
spin float

The rotary inertia's factor.

1/12

Returns:

Type Description
dict of int to float

{node: mass in kg}.

position
position(node: int) -> ndarray

A node's position in meters. The array is the model's own, not a copy.

group
group(node: int) -> str

The part this node was added as part of, such as 'arm 2' or 'top deck'.

It is a label for the modeler: nothing here reads it, but which part of a structure a mode is in is the first question asked of any result, and working that out from coordinates afterwards is guesswork.

dof_strings
dof_strings() -> list[str]

Every degree of freedom, '101X+', '101Y+', ..., in the matrices' own order.

matrices
matrices() -> tuple[ndarray, ndarray]

Assemble the global mass and stiffness matrices, dense.

Rows and columns run node by node in the order the nodes were added, six per node in DIRECTIONS order, which is what dof_strings() lists. Every node has its six rows, including a node nothing touches; the eigensolution holds those.

Returns:

Type Description
tuple of numpy.ndarray

(mass, stiffness), each (num_dof, num_dof) and symmetric.

sparse_matrices
sparse_matrices(ticker: Any = None) -> tuple[Any, Any]

The same mass and stiffness matrices as matrices, stored sparse (scipy CSR).

Each node couples only to the nodes of the elements it touches, so a row holds a few dozen nonzero entries out of thousands, and the storage grows in proportion to the number of nodes.

Parameters:

Name Type Description Default
ticker Ticker

Told one tick per element as it is assembled.

None

Returns:

Type Description
tuple of scipy.sparse.csr_matrix

(mass, stiffness), symmetric.

rigid_body_vectors
rigid_body_vectors() -> ndarray

The six rigid-body motions, as columns over the model's DOFs: translations along X, Y and Z, then rotations about X, Y and Z through the nodes' mean position.

They are written down from the node positions rather than found from the matrices, because they are what the null space of an unconstrained stiffness matrix should be, and so they check it. The eigensolution does not use them to recognize a rigid mode; it uses the mode's strain energy (ZERO_ENERGY).

eigensolution
eigensolution(maximum_frequency: float | None = None, num_modes: int | None = None, damping: float = 0.0, fixed: Sequence[str] = (), solver: str = 'auto', progress: Callable[[int, int], None] | None = None) -> ShapeSet

Real normal modes, mass-normalized, as a ShapeSet.

fixed names degrees of freedom to ground: '101X+' fixes one, and '101' fixes all six of that node; the sign makes no difference. Rigid links are eliminated exactly (constraint_transform). Ground points (add_ground), nodes nothing touches (loose_nodes) and rotations nothing acts on (dangling_rotations, idle_lead_rotations) are held as well. A mode that strains no element (ZERO_ENERGY) is given a frequency of exactly 0 Hz.

There are two solvers, giving one answer. The dense solver, for a model of up to SPARSE_ABOVE degrees of freedom, solves the symmetric generalized problem K phi = lambda M phi whole: M is factored (Cholesky), the problem reduced to a standard symmetric one and the result transformed back, which gives every mode, mass-normalized to machine precision. The sparse solver, for larger models, stores the matrices as their nonzeros (sparse_matrices) and finds the lowest modes by shift-invert block Lanczos (block_lanczos_modes, the method large finite element codes use, its solves taken a block at a time), refined by polish_modes; a model the block method does not converge is solved by ARPACK (scipy.sparse.linalg.eigsh) instead, with a warning. Its one factorization is Accelerate's supernodal Cholesky on a Mac and SuperLU's symmetric LU elsewhere (sparse_solve.factor_symmetric). It finds the lowest num_modes, or every mode up to maximum_frequency, and one of the two must be given. Its memory grows with the number of nodes instead of its square: a plate model of 1,500 nodes that needs about 13 GB dense needs tens of megabytes sparse.

damping is a fraction of critical, given to every mode. A model has no damping of its own; it is stated so the modes can synthesize an FRF that looks like a measurement.

Parameters:

Name Type Description Default
maximum_frequency float

Keep every mode up to this frequency, in Hz.

None
num_modes int

Keep this many, the lowest, rigid ones included. With maximum_frequency as well, the lowest this many of those.

None
damping float

The fraction of critical damping every mode is given.

0.0
fixed sequence of str

Degrees of freedom to ground, as above. A node that follows a rigid link cannot be fixed by itself (constraint_transform).

()
solver ('auto', 'dense', 'sparse')

Which solver; 'auto' is dense up to SPARSE_ABOVE degrees of freedom and sparse beyond.

'auto'
progress callable

Told (done, total) as the solve advances. The sparse solver gives the assembly, the eigen iterations and the polish each a fixed part of the total, counted in the stage's own pieces: per element, then per solve against an estimate that is extended while they run, then per polish step. A stage that is one call and cannot count itself (the sparse factorization, the dense eigensolution) is announced as (done, core.progress.BUSY). The window's progress bar reads it, and anything it raises stops the solve.

None

Returns:

Type Description
ShapeSet

The modes in ascending frequency, at every degree of freedom (dof_strings), with mass in kg. A node the geometry measures in a turned displacement frame has its six components written in that frame, as every shape set's DOFs are read. Each mode's leading component is positive (signed_modes), so a model solved twice gives the same shapes.

scaled_system
scaled_system(fixed: Sequence[str] = (), ticker: Any = None) -> tuple[Any, ...]

The sparse eigenproblem as the sparse solver sets it up.

The shift is -(2 pi)^2, just below zero, so the rigid-body modes (eigenvalue 0) are nearest it and come first, and K - sigma M = K + |sigma| M is positive definite even when K alone is singular (free-free). The scaling is symmetric and diagonal, S K S and S M S with S = 1/sqrt of the shifted diagonal, which keeps the eigenvalues and makes the modes S phi'. It is needed because a model of plates mixes meters with radians, and rigid links put lever arms into the rotations: unscaled, the rigid-link test model's shifted matrix has a condition number of 4e12, and Lanczos, which converges no better than its linear solves, leaves residuals of 1e-2. Scaled, the condition number is 4e9. This is public so a test can give the polish a start of its own choosing.

Parameters:

Name Type Description Default
fixed sequence of str

Degrees of freedom to ground, as eigensolution takes them.

()
ticker Ticker

Passed to sparse_matrices.

None

Returns:

Type Description
tuple

(K, M, T, S, sigma, stiffness): the constrained, symmetrically scaled stiffness and mass in CSC form; the constraint transform T and the scaling S, which carry a solution back to every degree of freedom as T (S phi); the shift sigma; and the unconstrained sparse stiffness.

constraint_transform
constraint_transform(fixed: Sequence[str] = (), sparse: bool = False) -> Any

T, with u = T q: every degree of freedom of the model written in terms of those that remain free.

Held degrees of freedom are removed (those fixed names, and those the eigensolution holds on its own), and each rigid body's followers are written through its first node, u_b = u_a + θ_a × (x_b − x_a) and θ_b = θ_a. With nothing to constrain, T is the identity.

Parameters:

Name Type Description Default
fixed sequence of str

Degrees of freedom to ground, as eigensolution takes them. A rigid body is grounded through its first node; naming one of its followers is refused, since fixing a follower alone would fix part of a rigid body and not the rest.

()
sparse bool

Return it as a scipy CSR matrix, for the sparse solver.

False

Returns:

Type Description
ndarray or csr_matrix

(num_dof, remaining) and real.

dangling_rotations
dangling_rotations() -> list[int]

The nodes whose rotations nothing acts on.

These are nodes touched by solids or translational springs and by nothing that carries a rotation: no beam, plate or triangle, and no rigid link, whose lead's rotation moves its followers. Neither a solid nor a spring along an axis gives a rotational stiffness, so these rotations are grounded by the eigensolution; left free, they would be degrees of freedom with neither mass nor stiffness, and the factorization would fail. A mass hung from a structure on springs is one case, since its node is no beam's. Nodes already held in all three rotations are not listed, and a lumped mass with rotary inertia on one of these nodes is refused at solve time.

Returns:

Type Description
list of int

The nodes, in the model's order.

idle_lead_rotations
idle_lead_rotations() -> list[tuple[int, int]]

(lead node, axis 0-2) for each rotation of a rigid body's lead that nothing acts on.

A body that only solids touch, with its nodes on one line, cannot feel a rotation about that line: the rotation moves no follower, and a solid has no rotational stiffness, so the rotation is a degree of freedom with neither mass nor stiffness. Tying two brick meshes whose columns line up (the app's Tie on any two conforming brick meshes) makes such bodies, each tied node leading only the nodes straight above it. These rotations are grounded like those of a node only solids touch (dangling_rotations): the rotation about the line where the line runs along a global axis, and all three where the body's nodes coincide. A line at a slant is held through a rotated basis in constraint_transform (oblique_lead_lines): a fine mesh tied to a coarse one node to nearest node has most of its ties on slanted arms, and left to the factorization, which refused the matrix on a Mac and handed back garbage elsewhere, no solver could find the modes.

Returns:

Type Description
list of (int, int)

The lead's node and the rotation's axis, in the model's order.

oblique_lead_lines
oblique_lead_lines() -> list[tuple[int, ndarray]]

(lead node, unit direction) for each rigid body that only solids touch whose nodes lie on one line at a slant to the axes.

Such a body's rotation about its line is a degree of freedom with neither mass nor stiffness, as idle_lead_rotations says, and no single rotation of the lead can be held for it; the constraint transform writes the lead's rotation in a basis turned to the line and leaves that component out. A fine brick mesh tied to a coarse one node to nearest node makes these by the dozen, each fine node's arm to its lead running diagonally.

Returns:

Type Description
list of (int, numpy.ndarray)

The lead and the line's direction, a unit vector, in the model's order.

loose_nodes
loose_nodes() -> list[int]

The nodes nothing touches: no element, no rigid link and no lumped mass (a spring alone does not count).

A finite element deck often has them (a reference point, a constraint's own grid point), and a model built from its element groups grounds them whole rather than refusing the deck. The grillage path of from_geometry still refuses them, since there a loose node is a drawn node that was never wired.

Returns:

Type Description
list of int

The nodes, in the model's order.

geometry
geometry(beams: bool = True) -> Geometry

The model as a Geometry: its nodes, and its beams, rigid links, plates, triangles, solids and faces as elements, each in the element group of the part it belongs to.

Beams become element type 21 (beam2) rather than tracelines, because they are elements. A traceline is a line drawn through nodes to make a display readable, and treating the two alike would make the model's own connectivity indistinguishable from a drawing aid as soon as anything edited it. Rigid links are two-node lines too, in element groups of their own; plates and triangles are written as quads and triangles (types 44 and 41), and solids by their node count (SOLID_CODES).

beams=False leaves the beams out, for a model whose members are all covered by surfaces: there the beams run inside the shells, and drawing them puts a wireframe over the thing it is the skeleton of.

Functions:

ground_axes

ground_axes(directions: Any) -> tuple[str, ...]

A ground's directions as AXES names, in their order.

True means all six, and False, None or an empty value means none. Otherwise the names are given as a sequence, or as one string separated by spaces or commas ('X', 'RY'); sign and case make no difference, so 'x+' is 'X'. A name that is not a direction raises ValueError.

material

material(name: str) -> Material

A library material by name, such as material('6061-T6'): the same entry the Element Groups table's Material drop-down fills a row from. The rigid link, RIGID, is found by its name too.

A name not in the library raises KeyError with the library's names listed, so a typo can be seen as one.

with_article

with_article(shape: str) -> str

A shape's name with its article, for a sentence: 'a channel', 'an I-beam', 'an angle'.

angle_major_axis

angle_major_axis(long_leg: float, short_leg: float, thickness: float) -> float

Where an angle's major principal axis lies, which is the direction its orientation vector points, in degrees from the long leg toward the short leg; 45 for an equal angle.

Parameters:

Name Type Description Default
long_leg float

The angle's dimensions, in any one unit.

required
short_leg float

The angle's dimensions, in any one unit.

required
thickness float

The angle's dimensions, in any one unit.

required

Returns:

Type Description
float

Degrees from the long leg, 0 to 180.

connected_pieces

connected_pieces(neighbors: dict[int, set[int]]) -> list[list[int]]

The connected components of an adjacency map, largest first.

One piece is a structure; more than one is that many free bodies, each with its own six zero-frequency modes. The model (over its elements) and a geometry's drawing (over its face edges, before a model exists) both use this one search, so the two agree about what "joined" means.

polish_modes

polish_modes(stiffness: Any, mass: Any, sigma: float, vectors: ndarray, wanted: int, factor: Any = None, ticker: Any = None) -> tuple[ndarray, ndarray, ndarray]

Refine a block of approximate modes until they are converged.

This is block inverse iteration with the shifted factor (K - sigma M), each step followed by Rayleigh-Ritz on the block (the small projected generalized problem, solved densely). It repeats until each of the first wanted modes has a relative residual below POLISH_RESIDUAL, or a step no longer halves the largest of them (the floor the conditioning sets), or POLISH_STEPS steps are spent. The residual of a mode is |K v - lambda M v| over |(K - sigma M) v|, which is defined for a rigid-body mode too (its numerator and |K v| are both zero). The block is refined as a whole: the Ritz step separates the modes inside it exactly, and the iteration removes what comes in from outside it at a rate set by the gap between the last wanted mode and the first one beyond the block, which is why the caller passes extra modes above the wanted ones.

Parameters:

Name Type Description Default
stiffness scipy.sparse matrix

K and M, in CSC form.

required
mass scipy.sparse matrix

K and M, in CSC form.

required
sigma float

The shift.

required
vectors ndarray

(n, m), the approximate modes to start from.

required
wanted int

How many of the lowest modes must converge.

required
factor optional

The factorization of (K - sigma M), as sparse_solve.factor_symmetric gives it (anything with solve and shape); computed when not given.

None
ticker Ticker

Told one tick per step.

None

Returns:

Type Description
(ndarray, ndarray, ndarray)

The eigenvalues and the mass-normal vectors for the whole block, in ascending order, and each mode's residual after the last step.

block_lanczos_modes

block_lanczos_modes(factor: Any, mass: Any, sigma: float, count: int, width: int = LANCZOS_BLOCK, ticker: Any = None, seed: int = 0) -> tuple[ndarray, ndarray]

The count eigenpairs nearest the shift, by block Lanczos on the shift-inverted operator A = (K - sigma M)^-1 M.

A is self-adjoint in the M-inner product, and its largest eigenvalues theta are the modes nearest the shift, lambda = sigma + 1 / theta. The Krylov basis is grown a block at a time: each new block is A applied to the last (one block solve with the factor), M-orthogonalized against the whole basis twice, and M-orthonormalized (_m_orthonormal). The coefficients fill the Rayleigh-Ritz matrix H = V^T M A V, each block column mirrored into its row since A is self-adjoint, and the Ritz pairs are H's eigenpairs. The computed relation A V = V R + Q B is kept beside it, R the coefficients above the diagonal and the orthonormalization's triangle below, and a Ritz pair's residual |A x - theta x|_M then has two parts, read for nothing: the last block's share, |B s|, which another block of basis shrinks, and |(R - H) s|, which no basis can shrink, since it is how far the computed operator is from self-adjoint and the basis from orthogonal (LU's solves leave the operator 8e-9 off on the rigid-link model, Cholesky's 1e-15; measured). The iteration stops when every wanted mode's first part over its theta is under LANCZOS_RESIDUAL, or at the floor, or when the basis spans the whole space, and reports the whole residual, both parts, as what it claims for each pair. A direction the orthogonalization leaves empty is left out, and the block shrinks by it. The basis is held as (n, dimension) column-major arrays, V and M V, so the products against it run in place.

Why a block method: the single-vector Lanczos of ARPACK applies the operator one vector at a time, and a sparse factor solves a block of right-hand sides for little more than one (the supernodal solve runs on every core). The sixty-eight single solves of a 270,000-DOF model were 2.5 s; twelve block solves of twelve are about 1 s. LOBPCG with the factor as a preconditioner on K was tried first and failed on the free-free rigid modes; shift-invert Lanczos has no such case, since the shift puts the rigid modes nearest it and a block wider than six finds all six.

Parameters:

Name Type Description Default
factor Any

The factorization of (K - sigma M), as sparse_solve.factor_symmetric gives it.

required
mass scipy.sparse matrix

M.

required
sigma float

The shift.

required
count int

How many modes, the nearest the shift.

required
width int

The block width; at most count's size allows.

LANCZOS_BLOCK
ticker Ticker

Told one tick per column solved, the estimate extended ahead.

None
seed int

The random start's seed: a model solved twice gives one answer.

0

Returns:

Type Description
(ndarray, ndarray, ndarray)

The eigenvalues lambda, nearest the shift first, the Ritz vectors as columns, M-orthonormal, and each pair's residual |A x - theta x|_M / theta as the relation claims it.

Raises:

Type Description
NotConverged

When the basis reaches its limit (LANCZOS_BASIS times count, at most the size), or runs out of directions, with a wanted residual's first part above 1e-5.

predicted_count

predicted_count(eigenvalues: Any, limit: float) -> int | None

How many modes have an eigenvalue below limit, read off how the count of the lowest modes grows with their eigenvalue.

The count of modes below an eigenvalue grows as a power of it, the power set by the structure's dimension (Weyl's law: one half for a bar, one for a plate, three halves for a solid, and in between for a model that mixes them), so a line through log count against log eigenvalue, fitted to the upper half of the elastic modes found, reaches the limit's count. None when fewer than eight elastic modes were found to fit, and the caller doubles instead.

Parameters:

Name Type Description Default
eigenvalues array_like

The lowest modes' eigenvalues, (rad/s)², rigid modes included.

required
limit float

The eigenvalue the count is wanted below.

required

Returns:

Type Description
int or None

The expected count, rigid modes included, at least one more than were found.

References

A standard result, used here to size the next search:

  1. H. Weyl, Das asymptotische Verteilungsgesetz der Eigenwerte linearer partieller Differentialgleichungen, Mathematische Annalen, 1912.

blas_threads

blas_threads() -> Iterator[int | None]

Hold each BLAS thread pool to a quarter of the logical CPUs (at least one, at most BLAS_MOST_THREADS) for the duration, and yield that count; None, and nothing limited, when the user has set OPENBLAS_NUM_THREADS themselves.

The sparse eigensolution runs inside this. Its steps alternate between numpy's BLAS and scipy's, which are separate libraries with separate pools, and the operations are small enough that a pool's threads mostly wait on one another, so fewer threads are faster and two full pools contend (BLAS_CPUS_PER_THREAD). The limit is undone on the way out, so the rest of the package keeps every core. oneMKL's pool is left alone: it is PARDISO's, and the factorization is large work that every core shortens.

group_masses

group_masses(geometry: Geometry) -> dict[int, float | None]

{element group: mass in kg}, what each of a geometry's element groups weighs as the model built from it counts it.

Each element group's elements are built as Model.from_geometry builds them, with that group's properties, and weighed as Model.total_mass weighs a model: beams, plates, triangles and solids by their density, point masses by their mass, and rigid links, springs and ground points as nothing. A group whose properties do not yet make elements (no properties, no material, a beam section not finished) is None, so a partial sum can say what it leaves out.

Parameters:

Name Type Description Default
geometry Geometry

The geometry, with its element groups' properties (group_properties).

required

Returns:

Type Description
dict of int to float or None

Every element group the geometry's elements belong to, in kg.

mated_ties

mated_ties(geometry: Geometry) -> list[tuple]

Every tie the geometry's mated surfaces make, as (the set, the second side's nodes, their weights, the tied node, the normal, the point it is moved onto): what from_geometry builds them from, and where a tied node sits in the model it solves.

Parameters:

Name Type Description Default
geometry Geometry

The geometry, with its mates.

required

Returns:

Type Description
list of tuple

signed_modes

signed_modes(shapes: ndarray) -> ndarray

These modes, one per column, each with a definite sign.

An eigensolver's mode has no sign of its own, and which one comes out can change from one solve of the same model to the next. Each mode is turned so its leading component is positive: the first degree of freedom, in the model's order, whose magnitude is within SIGN_TIE of the mode's largest. First within a tolerance rather than the largest outright, because an antisymmetric mode has two components of equal size and opposite sign, and round-off would otherwise pick between them.