Nonlinear mass matrices and selected time derivatives (v1.3.1) ================================================================= .. important:: This chapter describes the **v1.3.1 nonlinear time-mass correction** (issue #34, merged PR #33). It is **not part of the immutable v1.3.0 release**. Users must explicitly declare differentiated states in models requiring partial nonlinear time derivatives; a version update does not infer the physics. Distinguish a state-dependent mass from a product derivative -------------------------------------------------------------- Consider the Saint-Venant momentum equation with state variables :math:`h` (height) and :math:`p` (momentum). One typical weak term is .. math:: \int_\Omega h\,\partial_t p\cdot\Phi\,\mathrm{d}x. In the GetFEM Generic Weak-Form Language (GWFL), the primitive ``h * p . Test_p`` depends on **both** state variables. Its complete Gateaux derivative is .. math:: D(hp)[\dot h,\dot p] = p\dot h+h\dot p, so the nonlinear ``dt=True`` brick below models a **time derivative of the product**, not merely the derivative of momentum: .. code-block:: python S.Brick("M_p", "h * p . Test_p", [1], dt=True, linear=False, position="flow") SCRIMP v1.3.0 already implements the correct nonlinear Newton Jacobian of that **old implemented residual**. This does **not** make the old residual physically correct when the PDE requires only :math:`h\partial_t p`. Declare the differentiated state explicitly ------------------------------------------- If your mathematical equation is :math:`h\partial_t p`, use: .. code-block:: python S.Brick("M_p", "h * p . Test_p", [1], dt=True, linear=False, position="flow", dt_variables=("p",)) The ``dt_variables`` sequence names **dynamic state unknowns**, not the test function or the coefficient fields. For example, ``dt_variables=("p",)`` differentiates only momentum in time while the height still modulates the mass and contributes to the nonlinear Jacobian. Choosing the differential state cannot be deduced in general from ``Test_p``. The option is valid for **nonlinear, implicit** ``dt=True``, ``position="flow"`` bricks. Use a tuple or list of distinct state names. If omitted, the previous complete-primitive semantics are intentionally preserved for backward compatibility. **Upgrading SCRIMP does not automatically rewrite existing models.** Jacobian convention ------------------- For each weak primitive :math:`Q_b(z)`, let :math:`P_b` be the projector onto the selected temporal FE coefficients. SCRIMP assembles a nonlinear mass action .. math:: F_{\mathrm{mass}}(z,\dot z) = \sum_b DQ_b(z)\,P_b\dot z. The corresponding Newton linearization with PETSc TS shift :math:`\sigma = \partial \dot z / \partial z` is .. math:: J_{\mathrm{mass}}v = \sigma\sum_b DQ_b(z)P_bv + \sum_b D^2Q_b(z)[v,P_b\dot z]. **The Hessian term must retain variation with respect to *all* state variables**, including ``h``. In the simple case .. math:: F_{\mathrm{mass}}(h,p,\dot h,\dot p)=h\dot p, the derivative with respect to ``h`` equals ``pdot``; it must not disappear when suppressing the spurious ``p*hdot`` term. The implementation uses native GetFEM tangents for the mass columns and the full contracted Hessian in the selected time direction. Physical meaning and numerical validation ----------------------------------------- The fix was tested on a minimal GetFEM/PETSc nonlinear-mass example with MPI1/MPI2, the complete inviscid Saint-Venant example (1,246 degrees of freedom), and genuine BDF2 physical time integration with MPI parity and temporal refinement. In the **separate** viscous rotating boundary-controlled research model at :math:`T=12`, the maximum energy-balance residual decreased by about 546x (open loop) and 1,310x (closed loop) at fixed spatial and temporal discretizations. These are **measured numerical diagnostics**, not a general proof of exact energy conservation. In particular, a corrected Crank--Nicolson run can have nonzero energy defects from time-dependent boundary controls and numerical quadrature. Further spatial refinement and long-time physical studies are required for publication claims. See the exhaustive native acceptance record ``docs/NONLINEAR_DT_PARTIAL_MASS.md``, the proposed patch release gate ``docs/V131_NONLINEAR_DT_RELEASE_GATE.md``, and `GitHub issue #34 `_.