← All examples
57

Canonical Grid model

Applied mathematics - Engineering what-if

A dimensionless nonlinear spring: change load, inspect the residual and explain the local compliance.

Scale
Small
Source
applied-math-equilibrium.grid
Length
19 lines
Collection
Advanced language
Level
Intermediate
Runtime
Portable
applied-math-equilibrium.grid
Get Grid
MODEL "Applied mathematics - Engineering what-if"
DESCRIPTION "A dimensionless nonlinear spring: change load, inspect the residual and explain the local compliance."
TAGS "applied-mathematics", "engineering", "scenarios"

# Inputs: the bracket covers the intended nonnegative loads.
input Load = 2
  VALIDATE BETWEEN 0 AND 30

# One equilibrium solve and one explicitly reported local derivative.
output Displacement = ROOT((position) => position^3 + position - Load, 0, 3, 1e-12, 100)
output StiffnessReport = DERIVATIVE.REPORT((position) => position^3 + position, Displacement)

# Outputs: compliance follows implicit differentiation at this simple root.
output Residual = Displacement^3 + Displacement - Load
output Compliance = 1 / StiffnessReport.value
output Verified = ABS(Residual) < 1e-9
output Interpretation = "Compliance is the local displacement change per unit load; it is not a finite-load extrapolation."

END MODEL