Solid¶
Solid¶
Bases: Mechanics
Solid mechanics model for three-dimensional continua.
The element type (Tetra1, Tetra2, Hexa1, Hexa2) is inferred from the number of nodes per element in the connectivity.
Attributes:
-
nodes–Nodal coordinates with shape [n_nod, 3].
-
elements–Element connectivity with shape [n_elem, nodes_per_element].
-
material(Material | None) –Vectorized material model.
-
forces(Tensor) –Applied nodal forces with shape [n_nod, 3].
-
displacements(Tensor) –Prescribed nodal displacements with shape [n_nod, 3].
-
constraints(Tensor) –Boolean mask of constrained DOFs with shape [n_nod, 3].
__init__(nodes, elements, material)
¶
Initialize a finite-element model.
Parameters:
-
nodes(Tensor) –Nodal coordinates with shape [n_nod, n_dim].
-
elements(Tensor) –Connectivity with shape [n_elem, n_nodes_per_element].
-
material(Material | None) –Material model. If not vectorized, it is vectorized over elements during initialization. May be
Nonefor shells that use a laminate section instead.
solve(increments=None, max_iter=10, rtol=1e-08, atol=1e-06, stol=1e-10, cutback_factor=0.5, growth_factor=1.1, max_cutbacks=10, verbose=False, method=None, device=None, return_intermediate=False, aggregate_integration_points=True, use_cached_solve=False, nlgeom=False, alpha=0.0, differentiable_parameters=None)
¶
Solve the quasi-static finite-element problem by load increments.
Parameters:
-
increments(Tensor | None, default:None) –Monotonic load scale factors, typically [0, 1]. Results are always returned at exactly these values. If a Newton solve does not converge, the increment is subdivided internally and retried, and the substep is grown again after each success.
-
max_iter(int, default:10) –Maximum Newton iterations before an increment is cut back.
-
rtol(float, default:1e-08) –Relative residual tolerance for Newton convergence.
-
atol(float, default:1e-06) –Absolute residual tolerance for Newton convergence.
-
stol(float, default:1e-10) –Tolerance used by iterative linear solvers.
-
cutback_factor(float, default:0.5) –Factor applied to the substep size after a Newton solve failed to converge.
-
growth_factor(float, default:1.1) –Factor applied to the substep size after a Newton solve converged, capped at the requested increment.
-
max_cutbacks(int, default:10) –Number of successive cutbacks accepted within an increment before the solve is given up.
-
verbose(bool, default:False) –If True, reports the solver configuration and a table of per-increment progress, updated in place inside notebooks.
-
method(Literal['spsolve', 'minres', 'cg', 'pardiso'] | None, default:None) –Linear solver backend name.
-
device(str | None, default:None) –Optional device hint for the linear solver backend.
-
return_intermediate(bool, default:False) –If True, returns values for all increments.
-
aggregate_integration_points(bool, default:True) –If True, averages flux, gradient, and state over integration points.
-
use_cached_solve(bool, default:False) –If True, reuses cached linear solver data.
-
nlgeom(bool, default:False) –If True, includes geometric nonlinearity.
-
alpha(float, default:0.0) –Damping factor for viscous stabilization. Dissipated energy is accumulated in
self.stabilization_energy. -
differentiable_parameters(Tensor | Iterable[Tensor] | None, default:None) –Explicit parameter(s) to differentiate through implicit Newton/sparse solves. Accepts either a single tensor or an iterable of tensors.
Returns:
-
tuple[Tensor, Tensor, Tensor, Tensor, Tensor]–Tuple of displacement, internal force, flux, gradient, and material state. If return_intermediate is True, each tensor includes an increment dimension as the leading axis.
plot(u=0.0, node_property=None, element_property=None, orientations=None, show_edges=True, show_undeformed=False, show_outline=False, bcs=False, clip=None, plotter=None, **kwargs)
¶
Plot the mesh with optional node and element properties.
Parameters:
-
u(float or Tensor, default:0.0) –Displacement field. Defaults to 0.0.
-
node_property(dict[str, Tensor], default:None) –Nodal property to plot. Defaults to None.
-
element_property(dict[str, Tensor], default:None) –Element property to plot. Defaults to None.
-
orientations(Tensor, default:None) –Element orientations with shape [n_elem, k, 3] with k <= 3, drawn as red, green, and blue arrows. Defaults to None.
-
show_edges(bool, default:True) –Show edges. Defaults to True.
-
show_undeformed(bool, default:False) –Show undeformed mesh. Defaults to False.
-
show_outline(bool, default:False) –Show a box around the full mesh. Defaults to False.
-
bcs(bool, default:False) –If True, render boundary conditions (forces as arrows, prescribed displacements as arrows and tip markers, and constrained DOFs as cones). Defaults to False.
-
clip(tuple[str, float], default:None) –Property and value to cut the mesh at. Culls orientations and boundary conditions with it. Defaults to None.
-
plotter(Plotter, default:None) –PyVista plotter. Defaults to None.
-
**kwargs–Additional keyword arguments passed to pyvista.Plotter.add_mesh.
solve_modes(n_modes)
¶
Compute the natural frequencies and mode shapes.
Solves the generalized eigenvalue problem
Parameters:
-
n_modes(int) –Number of eigenpairs to compute.
Returns:
-
tuple[Tensor, Tensor]–Tuple
(omega_sq, modes)whereomega_sqhas shape[n_modes](squared angular frequencies, differentiable) andmodeshas shape[n_modes, n_nod, n_dof_per_node](detached).
SolidHeat¶
Bases: Heat, Solid
Solid heat conduction model.
Uses the same elements and plotting as Solid, but with a single
temperature degree of freedom per node.
Attributes:
-
nodes–Nodal coordinates with shape [n_nod, 3].
-
elements–Element connectivity with shape [n_elem, nodes_per_element].
-
material(Material | None) –Vectorized thermal material model.
-
heat_flux(Tensor) –Applied nodal heat sources with shape [n_nod, 1].
-
temperatures(Tensor) –Prescribed nodal temperatures with shape [n_nod, 1].
-
constraints(Tensor) –Boolean mask of constrained DOFs with shape [n_nod, 1].
__init__(nodes, elements, material)
¶
Initialize the solid heat conduction problem.
Parameters:
-
nodes(Tensor) –Nodal coordinates with shape [n_nod, 3].
-
elements(Tensor) –Connectivity with shape [n_elem, nodes_per_element].
-
material(Material) –Thermal material model, e.g.
IsotropicConductivity3D.
solve(increments=None, max_iter=10, rtol=1e-08, atol=1e-06, stol=1e-10, cutback_factor=0.5, growth_factor=1.1, max_cutbacks=10, verbose=False, method=None, device=None, return_intermediate=False, aggregate_integration_points=True, use_cached_solve=False, nlgeom=False, alpha=0.0, differentiable_parameters=None)
¶
Solve the quasi-static finite-element problem by load increments.
Parameters:
-
increments(Tensor | None, default:None) –Monotonic load scale factors, typically [0, 1]. Results are always returned at exactly these values. If a Newton solve does not converge, the increment is subdivided internally and retried, and the substep is grown again after each success.
-
max_iter(int, default:10) –Maximum Newton iterations before an increment is cut back.
-
rtol(float, default:1e-08) –Relative residual tolerance for Newton convergence.
-
atol(float, default:1e-06) –Absolute residual tolerance for Newton convergence.
-
stol(float, default:1e-10) –Tolerance used by iterative linear solvers.
-
cutback_factor(float, default:0.5) –Factor applied to the substep size after a Newton solve failed to converge.
-
growth_factor(float, default:1.1) –Factor applied to the substep size after a Newton solve converged, capped at the requested increment.
-
max_cutbacks(int, default:10) –Number of successive cutbacks accepted within an increment before the solve is given up.
-
verbose(bool, default:False) –If True, reports the solver configuration and a table of per-increment progress, updated in place inside notebooks.
-
method(Literal['spsolve', 'minres', 'cg', 'pardiso'] | None, default:None) –Linear solver backend name.
-
device(str | None, default:None) –Optional device hint for the linear solver backend.
-
return_intermediate(bool, default:False) –If True, returns values for all increments.
-
aggregate_integration_points(bool, default:True) –If True, averages flux, gradient, and state over integration points.
-
use_cached_solve(bool, default:False) –If True, reuses cached linear solver data.
-
nlgeom(bool, default:False) –If True, includes geometric nonlinearity.
-
alpha(float, default:0.0) –Damping factor for viscous stabilization. Dissipated energy is accumulated in
self.stabilization_energy. -
differentiable_parameters(Tensor | Iterable[Tensor] | None, default:None) –Explicit parameter(s) to differentiate through implicit Newton/sparse solves. Accepts either a single tensor or an iterable of tensors.
Returns:
-
tuple[Tensor, Tensor, Tensor, Tensor, Tensor]–Tuple of displacement, internal force, flux, gradient, and material state. If return_intermediate is True, each tensor includes an increment dimension as the leading axis.