Skip to content

feat: same optimizer and terminal for both solvers - #8

Merged
Filettus-newkeyboard merged 1 commit into
fix/messages-robustnessfrom
feat/optimizer-parity
Sep 23, 2026
Merged

Filettus-newkeyboard merged 1 commit into
fix/messages-robustnessfrom
feat/optimizer-parity

Conversation

@PSamuele

Copy link
Copy Markdown
Contributor

What

  • New naca_core/optimization.py with the logic shared by both optimizers (limits, Genetic Algorithm + SLSQP, bounding box, terminal table). Each solver only defines the analysis and the score.
  • The XFOIL optimizer now uses the same Genetic Algorithm + SLSQP search as the in-house one. SLSQP finite-difference step: 2e-3 for XFOIL, 1e-4 for the in-house solver. XFOIL prints Cl with 4 decimals: with a step of 1e-4 the gradient in p and t was zero and SLSQP stopped at Cl 0.8123 for a target of 0.8.
  • XFOIL not converging at the target angle is a failed evaluation (a Cl computed at another angle is not a valid result). The * flag is gone.
  • Timeouts are shown as Timeout in the table instead of a [WARNING] line.
  • New prompt Enter random seed [default: random]. The seed used is printed and saved in the CSV; entering it again repeats the run exactly.
  • Bounding box: same rule in both solvers. An airfoil taller than the box is not analysed (OUT in the BB column) and gets a penalty that grows with the excess height.
  • Same table (Eval | m | p | t | Cl | Cd | BB | Score) and same PHASE 1/2/3 headers in both programs.
  • m, p, t limits defined once. NACA 2412 is always included in the initial Genetic Algorithm population.
  • XFOIL analyses the same points as the panel method, so the number of panels chosen by the user applies to both solvers.

Bug found: PANE was never executed

The airfoil file passed to XFOIL had no name line. After LOAD, XFOIL asks for a name and took the next line of the script (PANE) as the answer. XFOIL therefore always analysed the points generated by the code (199 in the optimizer) and never re-paneled.
Now the file has a name line and PANE is removed. Validation values are identical to before, on both Windows and Linux, which confirms that PANE never ran.

Open question: random or fixed initial population?

Default is random, with the seed printed so that any run can be repeated.
Reason: with the current in-house objective (only Cl = target) many airfoils are valid. With the same input, previous runs returned NACA 3307, 2520, 2511, 2220 and 2518. A fixed population would always return the same airfoil: it would hide the problem without solving it.
When the objective becomes "minimum Cd at the given Cl" (next PR), the solution should be unique and a fixed default seed could make sense. To be decided together.

Verified

  • Baseline 24/24.
  • Windows: the XFOIL optimizer reaches Cl 0.8005 (target 0.8) in 102 iterations, 90 s, with 1 timeout and 2 failed evaluations handled in the table. Before: Cl 0.8123 after 24 iterations.
  • Windows: the in-house run repeated with the same seed (136031) returns the same airfoil.
  • Windows and Linux: validation values unchanged.

Not changed

Objective: the XFOIL optimizer still only penalizes Cd above the maximum. Minimising Cd (and the "maximum Cl with Cd limit" mode) is the next PR.

Depends on

#7 (base branch: fix/messages-robustness).

@Filettus-newkeyboard

Copy link
Copy Markdown
Contributor

Finsico di sistemare i pool domani mattima. Ti chiedo una conferma su questo: "Pane" è un comando che il codice dà a Xfoil relativo al numero di pannelli? Era ciò che faceva non coincidere il numero di pannelli nei due casi?

@PSamuele

Copy link
Copy Markdown
Contributor Author

Finsico di sistemare i pool domani mattima. Ti chiedo una conferma su questo: "Pane" è un comando che il codice dà a Xfoil relativo al numero di pannelli? Era ciò che faceva non coincidere il numero di pannelli nei due casi?

Sì, PANE è il comando con cui XFOIL ripannella il profilo, usando i parametri di PPAR (di default 160 nodi). Il codice lo mandava, ma non veniva mai eseguito: il file di coordinate che scrivevamo per XFOIL non aveva la riga del nome, quindi dopo LOAD XFOIL chiedeva "Enter airfoil name" e si prendeva la riga successiva dello script, cioè proprio PANE, come nome del profilo. Si vede nell'output di XFOIL: compare Enter airfoil name e non compare mai Paneling parameters used.

Quindi XFOIL analizzava sempre i punti che gli passavamo noi. Il disallineamento però non veniva da PANE: veniva dal fatto che l'ottimizzatore generava il profilo con il valore di default della funzione di geometria, cioè 199 punti, ignorando il numero di pannelli scelto dall'utente, che invece il panel method in-house usava.

Ora il file ha la riga del nome, PANE è stato tolto, e la geometria passata a XFOIL è costruita con il numero di pannelli inserito dall'utente: i due solutori vedono gli stessi identici punti. La conferma è che i 24 valori della validazione sono rimasti identici a prima, sia su Windows sia su Linux: se XFOIL avesse davvero ripannellato prima, togliere PANE li avrebbe cambiati.

@Filettus-newkeyboard
Filettus-newkeyboard merged commit 042effa into fix/messages-robustness Sep 23, 2026
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