CMPSTheory & Implementation Manual
NeuralFlow Physics-Constrained Objectives and Jacobian Metrics
LIKUA HomeManual Home

NeuralFlow Physics-Constrained Objectives and Jacobian Metrics

Not a data-fit loss. The central NeuralFlow training signal is built from the CMPS finite-volume conservation imbalance. In this chapter \(\mathbf B\) is the assembled vector of net flux/source imbalance per cell, not an error relative to a stored target solution.

Residual and solver-matrix convention

Define the exact residual Jacobian of the active differentiated assembly as

\[\mathbf J_B=\frac{\partial\mathbf B}{\partial\mathbf q}.\]

The current CMPS implicit matrix uses the opposite sign,

\[\mathbf A_{solv}\approx-\mathbf J_B.\]

This distinction removes the apparent sign ambiguity in the transpose-Jacobian training path.

Physical gradient injected into the recurrent GNO

For

\[J_{phys}=\frac12\mathbf B^T\mathbf W\mathbf B,\]

with frozen \(\mathbf W\),

\[\nabla_{\mathbf q}J_{phys}=\mathbf J_B^T\mathbf W\mathbf B\approx-\mathbf A_{solv}^T\mathbf W\mathbf B.\]

CMPS computes the transpose-matrix action and applies the minus sign once when building the external final-state gradient. Reverse-mode differentiation through the recurrent GNO then maps that state gradient to \(\nabla_\theta J_{phys}\).

Unweighted physical objective

\[J=\frac1{2N}\mathbf B^T\mathbf B,\qquad \mathbf W\mathbf B=\frac1N\mathbf B.\]

The division by active cell count makes the basic physical-loss scale approximately mesh-size independent.

Residual-hotspot weighting

For

\[r_i=\|\mathbf B_i\|_2,\qquad \bar r=\frac1N\sum_i r_i,\]

the bounded hotspot factor is

\[a_i=\operatorname{clamp}\!\left(1+\beta\frac{r_i}{\max(\bar r,\epsilon)},1,a_{max}\right).\]

Then

\[J=\frac1{2N}\sum_i a_i\mathbf B_i^T\mathbf B_i,\qquad (\mathbf W\mathbf B)_i=\frac{a_i}{N}\mathbf B_i.\]

In the normalized-score hotspot mode, equation-wise block RMS values are used only to build the difficulty score. The transpose-Jacobian path still receives the original physical residual components multiplied by the hotspot factor.

Frozen reduced pressure-velocity metric

For a residual block \(\mathbf b=[\mathbf b_m,b_p,b_T]^T\), define

\[d=\theta\rho C_p+\rho_T,\]
\[\mathbf z_m=\frac{\mathbf b_m-\mathbf u b_p}{\rho},\]
\[\xi=b_T-\mathbf u\cdot\mathbf b_m+|\mathbf u|^2b_p,\]
\[z_p=\frac{(\rho_TH+\rho C_p)b_p-\rho_T\xi}{d},\qquad z_T=\frac{\theta\xi-(\theta H-1)b_p}{d}.\]

With \(\mathbf z=\mathbf T^{-1}\mathbf b\),

\[J_i=\frac12\|\mathbf T_i^{-1}\mathbf B_i\|_2^2,\qquad (\mathbf W\mathbf B)_i=\mathbf T_i^{-T}\mathbf T_i^{-1}\mathbf B_i.\]

Primitive-scaled hotspot metric

The current default physical-loss mode adds primitive correction scales

\[U_i=u_{ref,i},\qquad P_i=\rho_iU_i^2,\qquad \Theta_i=T_i\frac{\gamma_i-1}{\gamma_i}\frac{P_i}{p_i},\]
\[\mathbf S_i=\operatorname{diag}(U_i,\ldots,U_i,P_i,\Theta_i).\]

The local score and weighted objective are

\[r_i=\|\mathbf S_i^{-1}\mathbf T_i^{-1}\mathbf B_i\|_2,\]
\[J_i=\frac12a_i\|\mathbf S_i^{-1}\mathbf T_i^{-1}\mathbf B_i\|_2^2,\]
\[(\mathbf W\mathbf B)_i=a_i\mathbf T_i^{-T}\mathbf S_i^{-2}\mathbf T_i^{-1}\mathbf B_i.\]

Regularized complete frozen-Jacobian correction metric

At an accepted reference state let

\[\mathbf A=-\frac{\partial\mathbf B}{\partial\mathbf q},\qquad \mathbf S=\operatorname{diag}(\text{physical primitive correction scales}).\]

Construct

\[\mathbf K=\mathbf A\mathbf S^2\mathbf A^T,\qquad \mathbf D=\operatorname{blkdiag}(\mathbf K),\]
\[\mathbf D_\delta=\mathbf D+\delta\operatorname{diag}(\mathbf D),\qquad \mathbf G=\mathbf K+\mu\mathbf D_\delta.\]

The metric is

\[J=\frac{1+\mu}{2N}\mathbf B^T\mathbf G^{-1}\mathbf B,\qquad \mathbf W\mathbf B=\frac{1+\mu}{N}\mathbf G^{-1}\mathbf B.\]

With cell-block factorization \(\mathbf D_\delta=\mathbf L\mathbf L^T\), the equilibrated system is

\[[\mathbf L^{-1}\mathbf K\mathbf L^{-T}+\mu\mathbf I]\mathbf z=\mathbf L^{-1}\mathbf B,\qquad \mathbf y=\mathbf L^{-T}\mathbf z.\]

The metric solve is accepted only when its a-posteriori error estimate satisfies the configured tolerance.

Physical scales for the complete frozen metric

When explicit scales are not supplied, the reference velocity can be resolved from supported physical boundary data using an area-weighted RMS:

\[U_c=\sqrt{\frac{\sum_fA_fU_f^2}{\sum_fA_f}}.\]

With static thermodynamic boundary data,

\[\rho_c=\frac{\sum_fA_f\rho_f}{\sum_fA_f},\qquad C_{p,c}=\frac{\sum_fA_fC_{p,f}}{\sum_fA_f},\]
\[P_c=\rho_cU_c^2,\qquad T_c=\frac{U_c^2}{C_{p,c}}.\]

Frozen local Jacobian row-Gram metric

The local approximation retains all owner/neighbor Jacobian blocks in a given residual row:

\[\mathbf D_i=\sum_j\mathbf A_{ij}\mathbf S_j^2\mathbf A_{ij}^T,\qquad \mathbf D_{i,\delta}=\mathbf D_i+\delta\operatorname{diag}(\mathbf D_i).\]

The objective is

\[J=\frac{\gamma}{2N}\sum_i\mathbf B_i^T\mathbf D_{i,\delta}^{-1}\mathbf B_i,\qquad (\mathbf W\mathbf B)_i=\frac{\gamma}{N}\mathbf D_{i,\delta}^{-1}\mathbf B_i.\]

The frozen scalar \(\gamma\) is selected so that the dimensionless state-gradient RMS matches the reference primitive-scaled metric at the accepted anchor.

Default physical-metric controls

The default mode is the primitive-scaled hotspot metric with

\[\beta_{hot}=1,\qquad a_{max}=20.\]

For the complete frozen-correction metric, the default controls include

\[\kappa_{target}=10^4,\qquad \varepsilon_{lin}=10^{-10},\qquad N_{lin,max}=500,\qquad \varepsilon_{sol,max}=10^{-5}.\]

Current metric restrictions

The frozen-Jacobian metrics currently use the steady spatial Jacobian in the learned-training path; transient physical-time Jacobian terms are not included. Frozen metric data are tied to the accepted reference/anchor and must be rebuilt when case-defining physics or that anchor changes.

Implemented NeuralFlow physical objectives

ModePurpose
UnweightedDirect finite-volume residual Euclidean norm.
Reduced pressure-velocity metricLocal preconditioning-aware residual transformation.
Residual hotspotAmplifies locally difficult cells.
Normalized-score hotspotNormalizes the difficulty score while retaining physical residual components in the gradient path.
Primitive-scaled hotspotPreconditioning- and primitive-authority-aware local metric; current default.
Regularized frozen correctionComplete frozen spatial-Jacobian operator metric.
Frozen local row-GramCell-local operator metric assembled from the block row of the frozen Jacobian.

Interpretation as learned nonlinear solution

All of these objectives ask the same fundamental question: does the recurrent NeuralFlow update move the current CMPS state toward finite-volume physical consistency? They differ only in how the imbalance is scaled or conditioned before its gradient is injected through the recurrent GNO. None requires NeuralFlow to imitate a stored completed CFD field.