trusty¶
Top-level classes and functions: the world and its settings, materials, meshes and solver reports. Each module has its own page in the menu.
Trusty โ a modular physics simulation library.
Backend
¶
ConvergenceCriterion
¶
Bases: Enum
HexMesh
¶
IterReport
¶
LinearSystemReport
¶
LinearSolverType
¶
LoggingObserver
¶
Bases: SolverObserver
ARAP
¶
Resists only departure from a rotation, with no volume term, for shape deformation in geometry processing rather than a physical material.
Corotational
¶
Linear elasticity in a frame that rotates with the material, for stiff bodies that rotate far but deform little.
FiberReinforced
¶
A soft matrix stiffened along one fiber direction that resists only stretching, for tendon, ligament and other fibrous tissue.
Hencky
¶
Linear elasticity in logarithmic strain, for stiff solids such as metals, and the elastic part of HenckyVonMises.
HenckyVonMises
¶
Hencky elasticity with von Mises plasticity and hardening, for ductile metals such as steel and aluminium that stay deformed once they yield.
HolzapfelGasserOgden
¶
A soft matrix stiffened exponentially along up to three fiber families with dispersion, for arterial walls, the annulus fibrosus and other layered fibrous tissue.
NeohookeanBW
¶
The classical Bonet and Wood Neo-Hookean, for matching textbook results and other codes; its energy is infinite at zero volume, so elements cannot invert.
QuadraticVolume
¶
Resists change of volume only, with no shear stiffness, for fluid-like material that flows freely in shape.
StableFung
¶
Stable Neo-Hookean that stiffens exponentially as it stretches, for soft biological tissue.
StableNeoHookean
¶
The default: a rubber-like solid that stays robust under large compression and inversion.
MaterialModel
¶
Bases: Enum
NewtonConfig
¶
SolveReport
¶
SolverObserver
¶
TetMesh
¶
TimeStepping
¶
World
¶
gravity
property
¶
Uniform body acceleration (m/s^2), as an (x, y, z) tuple.
max_lagged_iterations
property
¶
Most solves per step; each re-freezes the lagged terms (friction) at the last one's result. A step stops early once a solve moves nothing.
last_report
¶
The last step's solve report; a default-constructed report before the first step.
alive
¶
Whether the handle refers to a live entity of this world. False for a destroyed entity and for an integer no factory returned; a handle from a different world is not detected.
destroy
¶
Destroy a live entity (a body, joint, pin, actuator, ...) and every entity that cannot outlive it. Legal between any two steps; the next step simulates the world without it.
make_beam_hex_mesh
¶
Structured axis-aligned hex mesh; size is (Lx, Ly, Lz), res is (nx, ny, nz).
make_beam_tet_mesh
¶
Structured axis-aligned tet mesh (6-tet Kuhn decomposition per hex cell). size is (Lx, Ly, Lz), res is (nx, ny, nz).
make_hex_mesh
¶
Wrap externally-built (vertices, hexes) arrays into a HexMesh. Use this when reading via meshio from Python.
make_tet_mesh
¶
Wrap externally-built (vertices, tets) arrays into a TetMesh. Use this when reading via meshio from Python.
get_max_threads
¶
Worker threads currently available -- the machine's concurrency unless set_max_threads lowered it.
read_tet_msh
¶
Read a Gmsh .msh file (format 2.2) and return the contained tet mesh. Only 4-node tetrahedra are extracted; orientation is fixed to det([X1-X0|X2-X0|X3-X0]) > 0.
set_max_threads
¶
Cap the worker-thread count for this process. Unset by default, so a lone simulation uses every core. Set 1 when running N independent simulations in parallel (one per process, or one per thread since step() releases the GIL): their internal parallelism otherwise oversubscribes the machine and the pool loses most of what it gained. Takes effect on the next parallel region, so it can be raised or lowered at any time.
triangle_components
¶
Connected component (through shared vertices) of each row of a (F, 3) triangle array, numbered from 0 in order of each component's first triangle. Splits a solid's boundary into its outer surface and the surface of each internal void.
generate_particle_grid
¶
generate_particle_grid(
lo,
hi,
spacing: float,
mode: SamplingMode = "poisson",
*,
seed: int = 12345,
poisson_r_factor: float = 1.0,
) -> np.ndarray
Fill an axis-aligned box with MPM particles.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
lo
|
(array - like, shape(3))
|
Lower / upper corners of the seed box. |
required |
hi
|
(array - like, shape(3))
|
Lower / upper corners of the seed box. |
required |
spacing
|
float
|
Target inter-particle spacing. For |
required |
mode
|
('poisson', 'uniform')
|
Sampling strategy. Default |
'poisson'
|
seed
|
int
|
RNG seed for Poisson-disk sampling (ignored for uniform). |
12345
|
poisson_r_factor
|
float
|
Scales |
1.0
|
Returns:
| Type | Description |
|---|---|
np.ndarray of shape (N, 3), dtype float64.
|
|
add_floor_plane
¶
Attach a horizontal floor plane (origin=(0,0,z), normal=(0,0,1))
to world as a contact.ContactPlane component. Returns the new
entity (an int). friction_mu is the floor's Coulomb
coefficient; 0 (the default) is a frictionless floor. Requires a
build with contact enabled (contact.add_plane is only registered
then).
save_checkpoint
¶
Write the state world's next step starts from to the .npz file path.
load_checkpoint
¶
Restore save_checkpoint's file into world, built by the same script, so its next
step continues the saved trajectory.