8.0 KiB
Optional Newton strategies: implementation and validation
The experiments start from 7a07cae. Each hypothesis has an isolated, build-configurable branch; the integration branch combines the implementations behind explicit typed policies. The default physical model, normalization, preconditioner prescription, and ordinary Newton path remain available. Central density is still an optional model specification.
Selection and ownership
Newton(options) retains its existing meaning. An expert numerical configuration can supply a third constructor argument:
namespace nl = mean_field::solver::nonlinear;
auto numerics = nl::NewtonNumerics{
nl::PolynomialEnthalpy{},
nl::GravityCurvatureCorrection{}
};
auto configuration = nl::Newton(options, nl::NormalizedResidualMetric{}, numerics);
auto solve = mean_field::solver::make(context, configuration);
auto report = solve.evaluate();
The enthalpy choices are SampledEnthalpy and PolynomialEnthalpy. Gravity choices are MonolithicGravity, GravityCurvatureCorrection, and EliminatedGravity. Their combinations are concrete C++ types. Unregistered policy types are rejected by concepts. Block identities come from the compiled equation form; mesh sizes, FE eligibility, arithmetic values, and distributed preparation generations are checked at runtime.
The context owns each prepared workspace. Numerical calls are statically dispatched; only destruction of the selected context-owned storage is erased. Workspaces are constructed when a solve selects them and are destroyed before their borrowed operator/backend dependencies. Reduced gravity recovers the outer backend prescription through GetConfiguration(); custom backends need that capability only when selecting elimination. Polynomial direction repair currently requires the normalized residual metric, because its derivative supplies the line-search slope.
1. Polynomial enthalpy feasibility
The implementation transforms the actual nodal polynomial to a tensor Bernstein representation using outward-rounded interval arithmetic. Adaptive subdivision either certifies nonnegativity, proves negativity through a negative polynomial value, or reports unresolved bounds. A negative Bernstein coefficient alone is never classified as a negative polynomial. Exact zero traces are retained algebraically.
The production adapter works in physical enthalpy coordinates; a general diagonal normalization need not preserve the polynomial encoded by normalized coefficients. It supports conforming scalar H1 hexahedral elements with the supported closed nodal tensor bases and runtime polynomial order. Unsupported spaces fail explicitly. Unsafe fast-math compilation is rejected. Gradual underflow and immutable FE spaces remain prerequisites.
An invalid or uncertifiable initial polynomial is rejected before a residual-based convergence declaration. For a valid base, a certified initial enthalpy field provides an immutable anchor. The repair family is
[ p_h(\beta)=(1-\beta)p_h+\beta(h_{\rm anchor}-h),\qquad 0\le\beta\le1. ]
Shared true DOFs and prescribed zero traces are preserved. Bernstein inequalities provide a sufficient lower bound on the repair fraction, and the full linear residual model selects a fraction within that feasible interval. The actual represented candidate is certified again after normalization and state addition. A non-descent repair fails explicitly. Backtracking uses the repaired direction's merit derivative and still evaluates the complete nonlinear residual.
This is a conservative feasible-direction method, not the solution of a constrained Newton optimization problem. It may be too restrictive or have no descent direction. It does not prove positivity of the independently represented density field. Unchanged feasible directions require one extra Jacobian action; a model-selected enthalpy repair requires three. Combining it with elimination also relifts gravity and recomputes the actual merit derivative.
2. Gravity curvature correction
Write the normalized state as retained variables u and gravity variables z, with gravity equations G(u,z). The gravity partition includes both gradient and potential equations and retains their boundary rows. Given a base x, Newton direction p, and trial y=x+alpha*p, solve
[ G_z(y),\delta z=-{G(y)-G(x)-\alpha G'(x)p}. ]
The right side removes only the nonlinear remainder. It vanishes on an affine gravity path even when the base gravity residual is nonzero; it is second order in the trial length when the operator is smooth. The base residual and Jacobian action are captured before trial preparation. The candidate inverse is refreshed before solving. Only the candidate's gravity coordinates change.
A fresh complete preparation verifies the intended gravity target and evaluates the full merit. A failed inner solve, failed preparation, or unacceptable corrected merit does not commit a state. Trial observers must publish the corrected physical and normalized vectors together. The tangent is distinct from the secant of this curved trial path.
3. Gravity elimination
The nonlinear trial path completes gravity at fixed retained variables. The initial state is also explicitly completed before defining the nonlinear convergence reference. Retained coordinates include density, enthalpy, shape, and all model specification borders; optional central-density borders remain optional.
For the partitioned Jacobian, the reduced action is
[ S=F_u-F_zG_z^{-1}G_u. ]
Right-hand-side condensation includes any remaining gravity defect, and lifting reconstructs the corresponding full correction. The retained projection of the supplied full inverse preconditions the reduced system. Every lifted outer correction must satisfy the original full normalized Jacobian residual tolerance. Candidate gravity completion is separately checked after fresh nonlinear preparation.
Tolerance-stopped inner Krylov solves approximate a linear Schur action. Flexible outer preconditioning does not make this action exact. Tight inner tolerances, directional derivative checks, and the full lifted residual gate control this limitation. Inner failure propagates explicitly. Operator actions never prepare or mutate the physical state.
The generic reference implementation restricts the full operator and supplied inverse. That preserves normalization, boundary conditions, model borders, and custom preconditioner recipes, but can do unnecessary work in non-gravity blocks. A specialized restricted inverse is a possible later performance improvement once equivalence is tested.
Interpreting reports
The complete nonlinear residual remains the merit and convergence authority. Gravity residual reduction alone does not establish a stellar equilibrium. The existing physical checker separately requires solver convergence and all eight energy/force, enthalpy/density, and quadrature-order virial measurements to pass 1e-5; it also reports local EOS, force, sign, and conservation diagnostics.
For elimination, a successful linear backend report describes the reduced system; the lifted full-system true residual is a separate diagnostic. A propagated inner failure describes the gravity subsystem. Nested gravity solve times overlap the outer reduced solve time, and backend solve time excludes some condensation/lifting work. Use complete iteration and campaign wall times for performance comparisons, not a sum of these overlapping measurements.
Reproducibility and evidence
Branches:
research/polynomial-positive-newton-20260917research/gravity-curvature-correction-20260917research/gravity-reduced-newton-20260917research/numerical-strategies-20260917(combined production integration)
The campaign runner builds a committed clean source revision, copies an immutable executable, and records source, mesh, executable, input-state, and output hashes. Serial execution keeps timing comparisons interpretable. Each new run uses a fresh output directory. Frozen probes preserve accepted buffers and verify restoration; they never certify a final physical model.
Validation results and measured limits are recorded below after execution.