Skip to content

Phase 3a — Time integration + LocalNewton lowering #34

Description

@petlenz

Part of the NumSim compiler epic: #28.

Summary

Lower the Material IR's time-evolving + LNS structure into concrete generated code: replace Dt(α) = f(...) with a discrete time-stepping rule (Backward Euler default) and emit a Newton iteration loop that solves the resulting algebraic system at each call.

Scope

3a.1 — TimeIntegrationPass

  • Schemes: BackwardEuler (default), ForwardEuler, BDF2
  • Lowers Dt(α) = f(α, ε)(α_new − α_old)/dt − f(α_new, ε) = 0 using CAS's existing substitute()
  • Adds α_new and α_old as IR state-variable nodes if not already present

3a.2 — LocalNewtonLoweringPass

  • Builds residual vector R(x, ε) from each LocalNewtonSystem's residual list
  • Computes ∂R/∂x symbolically via existing tensor_differentiation
  • Emits a Newton iteration loop with:
    • Configurable convergence tolerance + max iterations
    • Residual-norm criterion (energy norm later)
    • Divergence detection (NaN check, residual growth)
    • Non-singular-Jacobian fallback (minor diagonal regularisation)
  • Line search: none initially (flagged for follow-up; see plan)

Acceptance

  • J2 plasticity recipe with StateVariable ε_p lowers through TimeIntegrationPass + LocalNewtonLoweringPass to produce a working stress update
  • At uniaxial tension, matches an analytic reference for σ within 1e-6
  • The 1D spike from Phase 1.3 is now production code (no longer throwaway)

Files affected

  • New: include/numsim_codegen/passes/TimeIntegrationPass.h
  • New: include/numsim_codegen/passes/LocalNewtonLoweringPass.h
  • Test recipes: tests/goldens/J2PlasticityFull.cpp

Dependencies

  • Phase 2 (Material IR with StateVariable, Dt, LocalNewtonSystem)

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions