Skip to content

[bug] RocketSolver_solve_supar hardcodes station index 2 for throat gamma_s seed, wrong for FAC problems #10

Description

@djkees

Summary
rocket.f90:896 and the identical :990 hardcode soln%eq_partials(2)%gamma_s as the throat's initial-guess seed for a Newton iteration:

else if (supar(i) >= 2.0d0) then
    ln_pinf_pe = soln%eq_partials(2)%gamma_s + 1.4d0*log(supar(i))

The literal 2 is meant to be the throat station. For IAC problems soln%throat_idx = 2, so this happens to be right — but for FAC problems soln%throat_idx = 4 (stations: 1=injector, 2=infinity, 3=combustor end, 4=throat), so eq_partials(2) in the FAC path is the infinity station, not the throat.

Reproduction

  • Interface: Fortran (RocketSolver_solve, fac=.true.)
  • rocket_test.pf:427-448 (test_rocket_fac_only_area_ratios) calls solve(..., fac=.true.) with supar=[25.0d0] (>= 2.0), hitting this exact branch with the wrong station.

Expected behavior
The throat station's gamma_s should seed the Newton iteration, via soln%eq_partials(soln%throat_idx)%gamma_s — matching the pattern already used in the analogous RocketSolver_solve_pi_p/_solve_pi_p_frozen (rocket.f90:660-661,723-724).

Actual behavior
The infinity station's gamma_s is used instead when fac=.true., incorrectly seeding the throat pressure-ratio guess.

Additional context
Impact is likely limited: this only seeds a Newton iteration's initial guess (rocket.f90:899-924, refined against area_tol=4.0d-5 over up to max_iter_area=10 steps) — a converged fixed point doesn't depend on the seed, only convergence speed/robustness does, which is presumably why the existing FAC test still passes. Not verified: whether some supar/propellant combination causes the 10-iteration cap to be hit before convergence with the bad seed (neither function warns on iteration exhaustion). Suggested fix — change soln%eq_partials(2)%gamma_s to soln%eq_partials(soln%throat_idx)%gamma_s at both sites — is mechanical and matches the file's own established pattern, but this is an initial-guess formula inside a solver iteration loop, so per CLAUDE.md it needs a maintainer's sign-off before treating as a drop-in fix.


Drafted with Claude's assistance

  • The station-index mismatch and the correct pattern used elsewhere in the same file were confirmed by direct read of rocket.f90, in the 2026-08-29 codebase sweep that originated this item.
  • Checked gh issue list on both nasa/cea and djkees/cea before filing to confirm this isn't a duplicate.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingstatus: pr-draftedA PR (draft or open) exists addressing this issue

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions