Displacement and Reaction Forces

Implemented in: mlpg_solver.py (post-processing stage), results.py (TimestepResult)

1. Displacement Extraction

After solving the linear system K u = f, the solution vector uflat has length 2N, interleaved as:

uflat = [ux,0, uy,0, ux,1, uy,1, …, ux,N−1, uy,N−1]

This vector is reshaped to a (N, 3) array by extracting:

displacement[i] = [uflat[2i], uflat[2i+1], 0]

The third component is always zero because the analysis is planar (2D model): no out-of-plane displacement is computed. This ensures compatibility with the 3D data model used by the rest of the GearMaster framework (which uses (N, 3) displacement arrays throughout).

Units: Displacements are in millimetres (mm), consistent with the model coordinate system and the Young's modulus in MPa (N/mm²).

2. Reaction Forces

Reaction forces at constrained nodes are computed as the residual of the assembled system:

R = K u − f

For unconstrained (free) nodes, Ri ≈ 0 within solver tolerance. For constrained nodes (those belonging to a GM_Joint with fixed DOFs), Ri gives the force that the support exerts on the structure (equal and opposite to the applied reaction).

In the direct-substitution BC method, the rows of K corresponding to constrained DOFs are replaced with unit rows (K_{ii} = 1, K_{ij} = 0, j ≠ i). The reaction forces are therefore computed before BC enforcement, using the original (unmodified) stiffness product Ku at constrained DOFs.

Units: Reaction forces are in Newtons (N).

3. TimestepResult Data Model

Both arrays are stored in a TimestepResult object (one per solved load step):

AttributeTypeShapeDescription
displacementnp.ndarray(N, 3)Nodal displacements [ux, uy, 0] in mm
reaction_forcesnp.ndarray(N, 3)Nodal reaction forces [Rx, Ry, 0] in N
timestep_indexint—Load step index (0 for static)
timefloat—Pseudo-time (0.0 for static)
metadatadict—Solver diagnostics (solve_time, converged, …)

The convenience property TimestepResult.max_displacement_magnitude() returns maxi |ui|, useful for solution quality checks.