Berton log-mass AUTO reformulation
Please start work on TASK-015.
TASK-015 is now In Progress and assigned to @pi.
Plan on the task:
- Review TASK-012 AUTO files, diagnostics, and TASK-013 report.
- Choose radius or log-mass as the better-conditioned cloud-size coordinate.
- Create a new episode-06 AUTO variant without overwriting TASK-012.
- Implement analytic DFDU/DFDP where practical.
- Add Python seed translation and RHS/eigenvalue cross-checks.
- Retry first-step continuation for a non-z_W0 control.
Show remaining 4 lines
- Document commands, constants, scaling, results/failures, and risks.
- Add lightweight tests for translation/artifacts/comparison.
Per project workflow, please confirm this plan or tell me to skip review, and I’ll begin implementation.
Please go ahead.
TASK-015 is complete and marked Done.
Implemented:
- New AUTO variant:
episodes/06-full-model-auto-seed-continuation/auto/berton_full_task015/ - Log-mass coordinate:
U(4)=log(m/kg), withm=exp(U4)anddlog(m)/dt=m_dot/m - Explicit derivative policy: analytic kinematic
DFDU(1,3)=1, finite-difference remaining coupled derivatives/activeDFDP - Seed translation + RHS/eigenvalue cross-check script
- Notebook, docs, curated outputs, README/index updates
- New regression tests
Show remaining 6 lines
Important result:
- Seed cross-check passes: transformed residual [REDACTED_LOCAL_PATH]
2e-13, Fortran/Python RHS diff [REDACTED_LOCAL_PATH]2.5e-16, eigenvalues match. W_a0plus/minus AUTO retry still accepts only the seed; failure is now documented as Newton/NaN/DGEBAL divergence, so robust nontrivial continuation remains unresolved.
Validation:
uv run pytest→58 passed
It sounds as though this rescaling didn't fix the problem, since the W_a0 continuation still doesn't work. Is that correct?
Yes — correct.
The TASK-015 log-mass reformulation validated the coordinate transformation and seed diagnostics, but it did not fix AUTO continuation.
What improved:
- Mass is now represented as
log(m/kg)instead of tiny/scaled raw mass. - The TASK-011 seed translates cleanly.
- RHS residuals and eigenvalues match the Python diagnostics.
What did not improve:
Show remaining 5 lines
W_a0continuation still accepted only the seed.- AUTO did not take a successful nontrivial first step.
- The failure changed from TASK-012-style minimum-step retry to more severe Newton divergence /
NaN/DGEBALdiagnostics.
So the likely issue is not just mass-coordinate scaling. It probably involves broader state/equation scaling, derivative quality, or the full 4D equilibrium formulation itself.
Is it even worth trying the H_a3 continuation in TASK-016 without doing more work on scaling?
Probably not as a serious AUTO validation attempt.
Given TASK-015:
W_a0was the easier sanity check: Python says it smoothly moves the equilibrium while staying stable.- Even that failed in AUTO after log-mass reformulation.
H_a3is the more delicate Hopf-relevant control: it changes growth/stability and likely stresses the same poorly conditioned pieces harder.- The log-mass retry produced
NaN/DGEBALdivergence, not just “almost works but step too large.”
So I would not spend TASK-016 just rerunning H_a3 on the current formulation unless the goal is only to collect a negative diagnostic artifact.
Show remaining 8 lines
Better next step before TASK-016:
- Rescale more of the state/equations, especially altitude and force/growth rows.
- Consider a reduced equilibrium AUTO system in
(z, u, log_m)withw=0, rather than full 4D ODE equilibrium. - Add stronger analytic derivatives for the force/growth balance or at least verify finite-difference Jacobian conditioning.
- Then use
W_a0as the gate: ifW_a0can’t continue, don’t trustH_a3.
Short version: H_a3 is worth trying only after another scaling/formulation pass, or as a documented expected-failure diagnostic.
A couple of ancillary questions:
- Are the next rescalings to try obvious? (They aren't to me!)
- Would it be possible to use Sympy to derive algebraic expressions for all derivatives to remove finit-difference calculations completely?
- No, the next rescalings are not obvious. I would not trust a blind “try z/10000, u/10, log-m” pass as more than exploratory.
What is obvious is the diagnostic direction:
- Inspect the Newton/Jacobian conditioning at the TASK-011 seed.
- Compare magnitudes of residual rows and Jacobian columns in the current AUTO coordinates.
- Identify whether the bad scale is:
- state scale:
z [REDACTED_LOCAL_PATH] 1e4,u,w [REDACTED_LOCAL_PATH] 1,log_m [REDACTED_LOCAL_PATH] -20 - RHS row scale: force terms
[REDACTED_LOCAL_PATH] m/s², growth termm_dot/m [REDACTED_LOCAL_PATH] s^-1 - parameter scale:
W_a0 [REDACTED_LOCAL_PATH] 1,H_a3 [REDACTED_LOCAL_PATH] 1, but effects may be tiny/indirect
Show remaining 38 lines
- non-smoothness: piecewise atmosphere/updraft/humidity interpolation,
MAX, terminal-Re fallback, root-solved geometry
Likely candidates, but not guaranteed:
- Use dimensionless state variables:
Z = (z - z_seed) / 100 mor/1000 mU = u / 1 m/sW = w / 1e-3 or 1e-2 m/smaybe, because equilibriumw=0but vertical velocity perturbation is dynamically importantM = log(m/m_seed)rather thanlog(m/kg)so the seed mass coordinate is0, not-20.6- Scale residual equations separately, e.g. multiply growth/force rows so all residual components near the seed have comparable Newton sensitivity.
- Reformulate the equilibrium problem as 3D:
- enforce
w=0 - solve only vertical force balance, horizontal force balance, and growth balance in
(z, u, log_m)or(z, u, radius) - this may be better than asking AUTO to continue the full 4D ODE equilibrium where one row is just
z' = w.
If I were doing the next task, I’d first write a Python conditioning probe that prints the transformed Jacobian, row/column norms, singular values, and suggested diagonal state/residual scalings. Then choose scalings from evidence rather than intuition.
- Sympy can help, but deriving all derivatives symbolically is probably not practical for the full model as currently written.
Reasons:
- The RHS includes piecewise-linear atmospheric profiles.
- Geometry is computed by a numerical bisection solve from mass to crystal dimensions.
- Reynolds number can use a terminal-Re fallback solve.
- There are
MAX,MERGE, branch conditions, and empirical drag/growth correlations. - Saturation vapor expressions are symbolic-friendly, but the whole RHS is not a clean closed algebraic expression.
So “use Sympy to derive the full AUTO DFDU/DFDP exactly” is probably a trap unless the model is first refactored into a smoother algebraic form.
More realistic options:
- Partial analytic derivatives: derive only the smooth local reduced equilibrium terms after freezing the active profile segment and avoiding fallback branches.
- Automatic differentiation in Python/JAX for a smoothed Python RHS, then compare against finite differences to identify bad sensitivities.
- Complex-step derivatives for smooth pieces, though branch/root-solve code may break this.
- Implicit differentiation for geometry: instead of differentiating through bisection, derive
da/dmfrom the algebraic volume relation. This is feasible and valuable. - Generate Fortran snippets only for selected smooth subexpressions, not the entire RHS.
My recommendation: before Sympy, build the 3D equilibrium formulation and conditioning probe. If that shows derivative error is the blocker, then use symbolic/analytic work surgically on geometry + growth/force balances.
Got it. Does it make sense to try the continuation on the restricted 3D system first, or is that just going to fail with the same scaling problem as the full system? It sounds as though the way forward now is to look at the 3D system, perform the scaling investigation you suggest and try the continuation in that setting again. If that sounds right to you, please make some backlog tasks to do those things.
Yes, that sounds right to me.
I’d try the restricted 3D equilibrium system first, but not blindly. It may still have scaling problems, but it removes one awkward full-ODE equilibrium row (z' = w) and lets us focus on the actual local balances:
- horizontal force balance
- vertical force balance with
w=0 - growth balance
- unknowns like
(z, u, log(m/m_seed))or(z, u, radius)
I created three backlog tasks:
Show remaining 11 lines
- TASK-018 — Diagnose scaling for restricted full-Berton 3D equilibrium system
Build the 3D residual and inspect Jacobian conditioning, row/column norms, singular values, parameter sensitivities, and branch/non-smooth risks.
- TASK-019 — Implement scaled restricted 3D AUTO continuation for
W_a0sanity check
Use TASK-018’s scalings to build a restricted 3D AUTO formulation and first test the easier W_a0 continuation.
- TASK-020 — Retry
H_a3Hopf-control continuation on scaled restricted 3D system
Only after the restricted W_a0 gate is meaningful, retry H_a3 and compare against the Python probe and failed full-4D attempts.
I also added notes to existing TASK-016/TASK-017 saying the direct full-4D retry should not be treated as meaningful until this restricted/scaled path has been investigated.
OK, please make implementation plans for those tasks. Let's create a new episode for this work, since it's no longer about the "full model".
Yes — I created the new episode and added implementation plans.
New episode:
episodes/07-restricted-equilibrium-auto/README.md- Subdirs:
auto/,docs/,notebooks/,outputs/,scripts/ - Updated
episodes/README.md
Updated backlog plans:
Show remaining 10 lines
- TASK-018 — Diagnose scaling for restricted Berton 3D equilibrium system
Now explicitly starts in episodes/07-restricted-equilibrium-auto/ and plans the residual/Jacobian conditioning investigation.
- TASK-019 — Implement scaled restricted 3D AUTO continuation for
W_a0sanity check
Plans a new 3D AUTO formulation under episode 07, gated on TASK-018 scalings.
- TASK-020 — Retry
H_a3Hopf-control continuation on scaled restricted 3D system
Plans the Hopf-control retry only after TASK-019 passes the W_a0 conditioning gate.
I also renamed TASK-018 to remove “full-model” from the title.