3. PINN architecture for structural mechanics
A physics-informed neural network for structural mechanics is not a generic function approximator with a physics penalty bolted on. Its architecture is a deliberate contract between the network and the governing equations: the inputs define the domain, the outputs define the field variables, and the differentiation graph defines how the residuals are formed. Getting this contract right is the difference between a model that converges to a physically admissible solution and one that merely fits noisy data.
Coordinate Inputs and the Reference Configuration
The input layer of a structural PINN is almost always the spatial coordinate vector x = (x, y, z) in the reference (undeformed) configuration, optionally augmented with time t for transient problems. For a 2D plane-stress panel, the input dimension is 2; for a 3D solid, it is 3; for a transient beam, it is 2 (one spatial coordinate plus time). The choice of reference versus current configuration matters: if the network predicts displacement u(X) as a function of material coordinates X, the strain measure is the Green–Lagrange tensor and the equilibrium statement is written in the reference configuration. If instead the network takes spatial coordinates x, the formulation is updated-Lagrangian and the strain measure is the small-strain or Almansi tensor. Mixing the two conventions is one of the most common sources of silent errors in PINN implementations.
Input normalization is not cosmetic. Coordinates should be scaled to a unit box, for example x̂ = (x − x_min)/(x_max − x_min), so that the MLP's first-layer weights operate on O(1) values. Without this, the automatic differentiation chain produces gradients whose magnitudes differ by orders of magnitude across directions, and the optimizer stalls. A practical rule: normalize coordinates to [−1, 1] and keep the physical units in the residual assembly, not in the network input.
Outputs: Displacement First, Stress Derived
The cleanest architecture predicts the displacement field u(x) directly, with output dimension equal to the spatial dimension. Stress is then obtained by differentiating the displacement through the constitutive law. This ordering is deliberate: displacement is the primary unknown in the weak form of equilibrium, and it is the quantity that boundary conditions constrain most naturally. Predicting stress as a separate output head is possible, but it introduces an additional consistency constraint (the stress must equal C : ε(u)) that is easy to violate and hard to enforce.
For a linear elastic isotropic material, the stress follows from the strain–displacement relation and Hooke's law:
ε = 0.5 * (∇u + ∇uᵀ) # small-strain tensor
σ = λ tr(ε) I + 2μ ε # Lamé form
λ = Eν / ((1+ν)(1−2ν)), μ = E / (2(1+ν))
In a PINN, ∇u is not computed by finite differences. It is obtained by automatic differentiation of the network output with respect to its input coordinates. This is the central architectural feature that distinguishes a PINN from a surrogate model trained on stress labels.
Multilayer Perceptron Backbone
The backbone is typically a fully connected MLP with 4–8 hidden layers and 32–128 neurons per layer, using tanh or sin activations. tanh is the default because its derivatives are smooth and bounded, which keeps the second-order derivatives needed for equilibrium residuals well-behaved. ReLU is a poor choice here: its second derivative is zero almost everywhere, so the equilibrium residual collapses and the physics loss provides no gradient signal. For problems with sharp gradients or high-frequency response, sinusoidal activations (SIREN-style) or Fourier feature embeddings on the input can help, at the cost of more sensitive initialization.
Weight initialization should follow Xavier/Glorot scaling. A common failure mode is initializing with large weights, which makes the first forward pass produce saturated activations and near-zero gradients through the physics loss. Monitoring the magnitude of ∂u/∂x at initialization is a quick sanity check: it should be O(1) after normalization, not O(10⁻⁶) or O(10⁶).
Automatic Differentiation and Residual Assembly
The physics loss is built from residuals evaluated at collocation points sampled inside the domain. For static equilibrium without body forces, the residual is the divergence of stress:
r_eq = ∂σ_xx/∂x + ∂σ_xy/∂y
∂σ_xy/∂x + ∂σ_yy/∂y
Each of these terms is a second derivative of the network output with respect to the input. In PyTorch or JAX, this is expressed by nesting autograd.grad calls or using torch.autograd.grad with create_graph=True so that the first derivative remains part of the computational graph. A minimal pattern:
u = net(x) # shape (N, 2)
u_x = grad(u[:,0].sum(), x, create_graph=True)[0]
u_xx = grad(u_x[:,0].sum(), x, create_graph=True)[0]
# assemble ε, σ, then r_eq
The total loss combines the equilibrium residual, the boundary condition residual, and any data term:
L = w_eq * mean(r_eq²) + w_bc * mean(r_bc²) + w_data * mean((u − u_obs)²)
Weight balancing is critical. If w_eq is too small, the network fits data and ignores physics; if too large, it satisfies equilibrium trivially by predicting a rigid-body displacement. A practical starting point is to normalize each residual by its initial value at the first epoch, then apply a mild schedule. Adaptive schemes such as learning-rate annealing on the weights or gradient-norm balancing (NTK-based) are common in the literature and worth trying when the loss plateaus.
Architecture Summary
The figure below shows the complete data flow: coordinates enter the MLP, displacement exits, and automatic differentiation produces the strain and stress fields that feed the equilibrium and boundary residuals. The dashed path indicates that stress is not a direct network output but a derived quantity.
Practical Checks Before Training
Three checks catch most architecture-level mistakes before a long training run. First, verify that the network can represent a known analytical solution: train on a patch test (uniform strain) and confirm the equilibrium residual drops below 10⁻⁶. Second, inspect the gradient flow: if ∂L/∂θ for the first layer is more than three orders of magnitude smaller than for the last layer, the depth or activation is wrong. Third, evaluate the boundary residual separately from the equilibrium residual; if the boundary residual is small but equilibrium is not, the collocation sampling is too sparse or the weight w_eq is too low.
u and σ, introduces truncation error that masquerades as physics violation, and prevents the optimizer from seeing the true residual landscape. Always use create_graph=True for the first derivative when a second derivative is needed.
With the architecture fixed, the next step is to define the loss weighting and training schedule that turns these residuals into a convergent optimization problem. The structure described here—coordinates in, displacement out, stress and equilibrium residuals via automatic differentiation—is the foundation on which every subsequent PINN variant for structural mechanics is built.