Physics Models

Physics models define material behavior and element-level computations for finite element analysis.

Available Physics Models

Base Class

class pyFANTOM.physics._physx.Physx[source]

Bases: object

Base class for physics models in pyFANTOM.

Abstract interface defining methods all physics implementations must provide. Physics models compute element-level quantities (stiffness matrices, areas/volumes, etc.).

K(x0s)[source]

Compute element stiffness/conductivity matrix from nodal coordinates

locals(x0s)[source]

Compute local matrices [D, B, …] for post-processing (stress, strain, etc.)

volume(x0s)[source]

Compute element area (2D) or volume (3D)

neumann(x0s)[source]

Compute Neumann boundary contribution (not yet implemented)

Notes

All methods accept: - Single element: x0s shape (n_nodes_per_element, spatial_dim) - Batch: x0s shape (n_elements, n_nodes_per_element, spatial_dim)

Subclasses must implement all abstract methods.

Examples

>>> from pyFANTOM import LinearElasticity
>>> physics = LinearElasticity(E=200e9, nu=0.3)
>>> K = physics.K(element_nodes)  # Shape: (dof, dof)
__init__()[source]
K(x0s)[source]
locals(x0s)[source]
volume(x0s)[source]
neumann(x0s)[source]

Detailed Documentation

class pyFANTOM.physics.LinearElasticity.LinearElasticity(E=1.0, nu=0.3333333333333333, thickness=1.0, type='PlaneStress')[source]

Bases: Physx

Linear isotropic elasticity physics model.

Implements small-deformation elasticity for 2D (plane stress/strain) and 3D solid mechanics. Computes element stiffness matrices, B-matrices, and D-matrices for triangles, quads, tets, and hexes.

Parameters:
  • E (float, optional) – Young’s modulus (default: 1.0)

  • nu (float, optional) – Poisson’s ratio (default: 1/3)

  • thickness (float, optional) – Thickness for 2D elements (default: 1.0)

  • type (str, optional) – ‘2D formulation: ‘PlaneStress’ or ‘PlaneStrain’ (default: ‘PlaneStress’)

E

Young’s modulus

Type:

float

nu

Poisson’s ratio

Type:

float

thickness

Element thickness

Type:

float

type

0 for plane stress, 1 for plane strain

Type:

int

K(x0s)[source]

Compute element stiffness matrix from nodal coordinates

locals(x0s)[source]

Compute [D, B, …] matrices for strain/stress calculations

volume(x0s)[source]

Compute element area (2D) or volume (3D)

Notes

Supported Elements: - 2D: 3-node triangles, 4-node quads - 3D: 4-node tetrahedra, 8-node hexahedra

Plane Stress vs Plane Strain: - Plane Stress: σ_z = 0 (thin plates) - Plane Strain: ε_z = 0 (thick sections, extrusions)

Constitutive Matrix D: - Relates stress to strain: σ = D @ ε - Plane stress: D_11 = E/(1-ν²) - Plane strain: D_11 = E(1-ν)/[(1+ν)(1-2ν)]

B-Matrix: - Strain-displacement operator: ε = B @ u - Shape: (3, n_dof) for 2D, (6, n_dof) for 3D

Examples

>>> from pyFANTOM import LinearElasticity
>>> # Aluminum properties
>>> physics = LinearElasticity(E=70e9, nu=0.33, type='PlaneStress')
>>>
>>> # Steel 3D
>>> physics_3d = LinearElasticity(E=200e9, nu=0.3)
>>>
>>> # Use with mesh
>>> from pyFANTOM.CPU import StructuredMesh2D
>>> mesh = StructuredMesh2D(nx=64, ny=32, lx=2.0, ly=1.0, physics=physics)
__init__(E=1.0, nu=0.3333333333333333, thickness=1.0, type='PlaneStress')[source]
K(x0s)[source]
locals(x0s)[source]
volume(x0s)[source]
neumann(x0s)[source]
class pyFANTOM.physics.NLElasticity.NLElasticity(E=1.0, nu=0.3333333333333333, thickness=1.0, type='PlaneStress')[source]

Bases: Physx

Geometrically nonlinear elasticity for large deformations.

Implements finite strain elasticity with St. Venant-Kirchhoff material model. For large displacement problems where linear elasticity is insufficient.

Parameters:
  • E (float, optional) – Young’s modulus (default: 1.0)

  • nu (float, optional) – Poisson’s ratio (default: 1/3)

  • thickness (float, optional) – Thickness for 2D elements (default: 1.0)

  • type (str, optional) – ‘2D formulation: ‘PlaneStress’ or ‘PlaneStrain’ (default: ‘PlaneStress’)

K(x0s)[source]

Initial stiffness matrix (linear)

KTan(x0s, xs, rho)[source]

Tangent stiffness matrix at current configuration

Notes

  • Use case: Large deformations, geometric nonlinearity

  • Solver: Requires NLFiniteElement with Newton-Raphson

  • Elements: Currently supports 4-node quads only

  • Material: St. Venant-Kirchhoff (simple hyperelastic)

  • Limitations: Not suitable for very large strains (>20%)

Examples

>>> from pyFANTOM import NLElasticity
>>> physics = NLElasticity(E=1.0, nu=0.3)
>>> # Use with NLFiniteElement and NLUniformStiffnessKernel
__init__(E=1.0, nu=0.3333333333333333, thickness=1.0, type='PlaneStress')[source]
K(x0s)[source]
KTan(x0s, xs, rho)[source]
locals(x0s)[source]
volume(x0s)[source]
neumann(x0s)[source]
stressCurrent()[source]
stressLastSolved()[source]
set_stressCurrent(stress) None[source]
set_stressLastSolved(stress) None[source]
class pyFANTOM.physics.SteadyHeatTransfer.SteadyHeatTransfer(k=1.0, thickness=1.0)[source]

Bases: Physx

Steady-state heat conduction physics.

Implements Fourier heat conduction for thermal topology optimization. Governed by ∇·(k∇T) = Q where T is temperature, k is conductivity, Q is heat source.

Parameters:
  • k (float, optional) – Thermal conductivity (default: 1.0)

  • thickness (float, optional) – Thickness for 2D elements (default: 1.0)

k

Thermal conductivity

Type:

float

thickness

Element thickness

Type:

float

K(x0s)[source]

Compute element conductivity matrix (analogous to stiffness)

locals(x0s)[source]

Compute gradient operator and conductivity matrix

volume(x0s)[source]

Compute element area/volume

Notes

  • Use case: Heat sink design, thermal management

  • DOF: 1 per node (temperature)

  • BCs: Dirichlet (fixed temperature), Neumann (heat flux)

  • Elements: Triangles, quads, tets, hexes

  • FEA formulation: K @ T = Q (identical structure to elasticity)

Examples

>>> from pyFANTOM import SteadyHeatTransfer
>>> physics = SteadyHeatTransfer(k=200, thickness=0.01)  # Aluminum
>>> mesh = StructuredMesh2D(nx=64, ny=64, lx=0.1, ly=0.1, physics=physics)
__init__(k=1.0, thickness=1.0)[source]
K(x0s)[source]
locals(x0s)[source]
volume(x0s)[source]
neumann(x0s)[source]