import NavierStokes.CorrectionState import NavierStokes.LinearWaveResidual import NavierStokes.CorrectionStepCovariance /-! # Exact full residual and its increment The 166-page Navier–Stokes paper uses cylindrical transport with frame terms in §9.1, equation (9.2) and Lemma 9.2. This module supplies the addition laws for those differential operators and their exact expansion under an update. It assembles the velocity and pressure corrections of §9.3, equation (9.7), and separates the angular mean, nonconstant angular part and stored errors as in the residual decomposition of §9.2, equations (9.3)–(9.4). It keeps both old/new transport terms and the square of the increment. The angular covariance uses the full oscillation as in §8.1, equation (8.1). Its exact update gives the cross terms and square used in the split in §9.3, equation (9.13). -/ noncomputable section namespace NavierStokes.CorrectionStep open Set WeightedClasses MeanIncrementBounds open scoped ContDiff BigOperators variable {D : Type} [NormedAddCommGroup D] [NormedSpace ℝ D] /-! ## The full differential residual, before angular averaging -/ section FullCalculus open HarmonicCalculus LinearWaveResidual /-- Exact residual of a perturbation of a fixed base, before the virtual stress and the separately retained base residual are added. -/ noncomputable def nonlinearResidual (ε : ℝ) (R : D → ℝ) (Vr Vθ Vz Vt : D → D) (B a : D → ComplexVector) (p : D → ℂ) (x : D) : ComplexVector := linearResidual ε R Vr Vθ Vz Vt B a p x + transport R Vr Vθ Vz a a x end FullCalculus section FullFields open CorrectionState HarmonicCalculus noncomputable def radialDirection (c : Context D) (n : ℕ) (x : D × ℝ) : D × ℝ := (c.operators.eR + (c.operators.radialFrequency n * c.operators.radialProfile x.1) • c.operators.vR, 0) noncomputable def axialDirection (c : Context D) (n : ℕ) (_x : D × ℝ) : D × ℝ := (c.operators.epsilon n • c.operators.eZ, 0) noncomputable def angularDirection (_x : D × ℝ) : D × ℝ := (0, 1) noncomputable def timeDirection (c : Context D) (n : ℕ) (_x : D × ℝ) : D × ℝ := (c.operators.fastCoefficient n • c.operators.vT - c.operators.epsilon n • c.operators.eT, 0) noncomputable def complexBase (c : Context D) (n : ℕ) (x : D × ℝ) : ComplexVector := ![(c.base.radial n x.1 : ℂ), (c.base.angular n x.1 : ℂ), (c.base.axial n x.1 : ℂ)] noncomputable def complexPerturbation (u : State D) (n : ℕ) (x : D × ℝ) : ComplexVector := ![(u.mean.radial n x.1 + u.oscillation n x 0 : ℝ), (u.mean.angular n x.1 + u.oscillation n x 1 : ℝ), (u.mean.axial n x.1 + u.oscillation n x 2 : ℝ)] noncomputable def complexPressure (u : State D) (n : ℕ) (x : D × ℝ) : ℂ := (u.totalPressureIncrement n x : ℝ) noncomputable def virtualDivergence (c : Context D) (n : ℕ) (x : D × ℝ) : Fin 3 → ℝ := ![0, -(c.operators.radialDiv 2 c.virtualTheta n x.1), -(c.operators.radialDiv 1 c.virtualAxial n x.1)] /-- This field uses actual Fréchet derivatives. The base flat error is restored once, alongside the negative virtual-stress divergence. -/ noncomputable def fullResidual (c : Context D) (u : State D) : Oscillation D := fun n x i => (nonlinearResidual (c.operators.epsilon n) (fun y : D × ℝ => c.operators.radius y.1) (radialDirection c n) angularDirection (axialDirection c n) (timeDirection c n) (complexBase c n) (complexPerturbation u n) (complexPressure u n) x i).re + virtualDivergence c n x i + u.errors.base n x i noncomputable def fullGoodResidual (c : Context D) (u : State D) : Oscillation D := fullResidual c u - u.errors.total noncomputable def angularMeanVector (f : Oscillation D) : MeanVector D := fun n x i => angularAverage (fun k p => f k p i) n x noncomputable def angularNonconstant (f : Oscillation D) : Oscillation D := fun n x i => f n x i - angularMeanVector f n x.1 i noncomputable def fullGoodWaveResidual (c : Context D) (u : State D) : Oscillation D := angularNonconstant (fullGoodResidual c u) theorem fullResidual_decomposition (c : Context D) (u : State D) : fullResidual c u = fun n x i => fullGoodWaveResidual c u n x i + angularMeanVector (fullGoodResidual c u) n x.1 i + u.errors.total n x i := by funext n x i simp only [fullGoodWaveResidual, angularNonconstant, fullGoodResidual, Pi.sub_apply] ring end FullFields section ActualCovariance open CorrectionState MeasureTheory def AngularContinuous (u : Oscillation D) : Prop := ∀ n x i, Continuous (fun θ : ℝ => u n (x, θ) i) omit [NormedAddCommGroup D] [NormedSpace ℝ D] in theorem AngularContinuous.add {u v : Oscillation D} (hu : AngularContinuous u) (hv : AngularContinuous v) : AngularContinuous (u + v) := fun n x i => (hu n x i).add (hv n x i) end ActualCovariance section ActualFullUpdate open CorrectionState HarmonicCalculus end ActualFullUpdate end NavierStokes.CorrectionStep