Skip to content

PSG: FAR's automatic Cd and Aref at zero angle of attack - #2796

Merged
sarbian merged 2 commits into
devfrom
psg/aero-zero-aoa
Nov 29, 2026
Merged

sarbian merged 2 commits into
devfrom
psg/aero-zero-aoa

Conversation

@sarbian

@sarbian sarbian commented Nov 22, 2026 •

Copy link
Copy Markdown
Contributor

Depends on #2795 (launch towers), which must be merged first: this branch is stacked on it.

Part of #2476 (audit epic, PSG)

With FAR, the automatic Cd and Aref read the vessel at zero angle of attack, as suggested in lamont-granquist's review of the estimate. Stock aerodynamics keeps the 2° (FLOW_AOA), as lamont-granquist asked in this PR's review: until PSG flies a zero-AoA gravity turn through the atmosphere, stock needs it.

Change, in PSGAeroEstimate only (+12 −10):

  • FAR is read with the airflow along the nose.
  • Stock is read as before, with the airflow 2° off the nose (Flow() renamed StockFlow(), its comment says why stock alone).

Behaviour change: with FAR the planned drag area changes by under 1 %. Stock is unchanged from #2795.

Why stock keeps the 2°: near zero angle of attack, stock drag cubes give drag linear in |α| and body lift in α|α|. At the 2° an ascent flies, the drag dominates and PSG has no lift, so leaving it out made the plan 36 % short on Kerbal X (table below, from this branch's first version, which also read stock at zero). A later α model needs a smoothed |sin α| term there: a fit in α² through the cardinal directions misses nearly all of the rise at small angles.

Tested in game (Debug build, development player; stock on the 3.2x system), before stock was put back: all three flights reached orbit, with no MechJeb exception. The stock code is now the same as #2795's (reflown below); the FAR column is this PR's code.

Stock, Kerbal X: #2795 (= this PR) Stock, Kerbal X: zero AoA (dropped) FAR, Falcon 9: this PR
Cd × Aref planned 3.189 m² 2.304 m² 3.376 m²
Drag area in flight, q/m-weighted 3.461 m² 3.579 m² 3.972 m²
Plan against flight −7.9 % −35.6 % −15.0 %
Mean angle of attack, q/m-weighted 2.2° 3.0° 3.6°
Max Q 47.0 kPa 49.2 kPa 51.8 kPa
Drag losses 122 m/s 146 m/s 37 m/s
Propellant left 373.0 LF 371.4 LF 26.209 t on board, ballast included
Orbit, km 144.8 × 145.1 144.7 × 145.0 184.0 × 185.0

The Falcon 9 was not reflown on #2795. Its flight on #2749's build, with the 2°, planned 3.397 m² and ended with 26.185 t.

Stock reflown on this PR's code (e383881, same setup): Kerbal X planned the same 3.189 m² as #2795 and flew the same, within the spread between runs. Drag area in flight 3.415 m² (plan −6.6 %), mean angle of attack 2.1°, max Q 47.0 kPa, drag losses 120 m/s, 373.6 LF left, orbit 144.4 × 145.0 km, no MechJeb exception. 0 ReSharper warnings on the changed lines.

Not tested: FAR on the final commit (its code path is the first version's, flown above), other craft, stock at 1x scale, and a craft with a launch tower on this branch.

Unit tests: 16,683 pass with CI's filter (Debug build, first version).

PSG plans with one Cd and no lift, so the table takes the airflow along the nose instead of 2 degrees off it. The frontal area comes from the same drag cube read.
@github-actions

github-actions Bot commented Nov 22, 2026 •

Copy link
Copy Markdown
Contributor

✅ Build Artifact 🚀

MechJeb2-7aba370.zip (built from e383881)

@lamont-granquist

Copy link
Copy Markdown
Collaborator

I'm digesting that finding about stock drag cubes

@lamont-granquist

Copy link
Copy Markdown
Collaborator
Compared to a real rocket, stock gets both effects backwards at small α:

drag rises too steeply (first order instead of second)
lift starts too weakly (second order instead of first)

Stock is broken--you do need the AoA there because body lift is useless at ~2 degrees and drag dominates.

Plus you've got the thick atmosphere and smaller rockets, and so drag losses are a much higher percentage of the budget.

@lamont-granquist

Copy link
Copy Markdown
Collaborator

I think the answer is that PSG needs to fly zero-AoA through the atmosphere, which I'm already planning on doing, and that makes even more sense on stock-aero-physics where that should actually be entirely optimal. So that mean-angle-of-attack is what is affecting the optimality of the Kerbal X flight. That should get driven down as close to zero as possible.

But until then, stock-aero probably needs the 2 degree hack.

Base automatically changed from psg/aero-launch-tower to dev November 23, 2026 05:08
…first

Stock's drag cubes give drag linear in |α| near zero angle of attack and body
lift only in α|α|, so at the 2° an ascent flies the drag dominates and PSG,
with no lift, needs it in the plan. FAR is read nose first.
@sarbian sarbian changed the title PSG: the automatic Cd and Aref at zero angle of attack PSG: FAR's automatic Cd and Aref at zero angle of attack Nov 29, 2026
@sarbian
sarbian merged commit f12dc54 into dev Nov 29, 2026
3 checks passed
@sarbian
sarbian deleted the psg/aero-zero-aoa branch November 29, 2026 18:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants