Planar¶
Planar¶
Bases: Mechanics
Planar mechanics model for plane-stress or plane-strain problems.
The element type (Tria1, Tria2, Quad1, Quad2) is inferred from the number of nodes per element in the connectivity.
Attributes:
-
nodes–Nodal coordinates with shape [n_nod, 2].
-
elements–Element connectivity with shape [n_elem, nodes_per_element].
-
material(Material | None) –Vectorized material model.
-
thickness–Element thicknesses with shape [n_elem].
-
forces(Tensor) –Applied nodal forces with shape [n_nod, 2].
-
displacements(Tensor) –Prescribed nodal displacements with shape [n_nod, 2].
-
constraints(Tensor) –Boolean mask of constrained DOFs with shape [n_nod, 2].
__init__(nodes, elements, material, thickness=1.0)
¶
Initialize the planar FEM problem.
Parameters:
-
nodes(Tensor) –Nodal coordinates with shape [n_nod, 2].
-
elements(Tensor) –Connectivity with shape [n_elem, nodes_per_element].
-
material(Material) –Plane-stress or plane-strain material model.
-
thickness(Tensor | float, default:1.0) –Element thickness. A float is expanded to all elements, a tensor assigns one thickness per element.
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, orientation=None, node_labels=False, node_markers=False, axes=False, bcs=True, color='black', alpha=1.0, cmap='viridis', linewidth=1.0, figsize=(8.0, 6.0), colorbar=False, vmin=None, vmax=None, title=None, ax=None, **kwargs)
¶
Plot the mesh with matplotlib, optionally with results.
Parameters:
-
u(float | Tensor, default:0.0) –Nodal displacements added to the positions, e.g. to plot the deformed configuration. Defaults to 0.0 (undeformed).
-
node_property(Tensor | None, default:None) –Scalar nodal field with shape [n_nod] rendered as interpolated contours.
-
element_property(Tensor | None, default:None) –Element field rendered as flat colors (shape [n_elem]) or as vector arrows (shape [n_elem, 2]).
-
orientation(Tensor | None, default:None) –Element-wise material angles in radians rendered as line markers.
-
node_labels(bool, default:False) –If True, annotates nodes with their indices.
-
node_markers(bool, default:False) –If True, draws markers at nodal positions.
-
axes(bool, default:False) –If True, shows the coordinate axes.
-
bcs(bool, default:True) –If True, indicates applied forces as arrows scaled relative to each other and constrained DOFs as markers. In the undeformed configuration, prescribed non-zero displacements are drawn to scale as arrows with a dot at the tip instead of a marker. In the deformed configuration, only the dot is drawn, marking the position the node was pulled to.
-
color(str, default:'black') –Line and marker color.
-
alpha(float, default:1.0) –Opacity of nodal contour plots.
-
cmap(str | Colormap, default:'viridis') –Matplotlib colormap or its name.
-
linewidth(float, default:1.0) –Element edge line width. Set to 0.0 to hide edges.
-
figsize(tuple[float, float], default:(8.0, 6.0)) –Figure size when a new figure is created.
-
colorbar(bool, default:False) –If True, adds a colorbar.
-
vmin(float | None, default:None) –Lower color limit.
-
vmax(float | None, default:None) –Upper color limit.
-
title(str | None, default:None) –Plot title.
-
ax(Axes | None, default:None) –Existing matplotlib axes to plot into.
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).
PlanarHeat¶
Bases: Heat, Planar
Planar heat conduction model.
Uses the same elements and plotting as Planar, but with a single
temperature degree of freedom per node.
Attributes:
-
nodes–Nodal coordinates with shape [n_nod, 2].
-
elements–Element connectivity with shape [n_elem, nodes_per_element].
-
material(Material | None) –Vectorized thermal material model.
-
thickness–Element thicknesses with shape [n_elem].
-
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 planar heat conduction problem.
Parameters:
-
nodes(Tensor) –Nodal coordinates with shape [n_nod, 2].
-
elements(Tensor) –Connectivity with shape [n_elem, nodes_per_element].
-
material(Material) –Thermal material model, e.g.
IsotropicConductivity2D.
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.