Skip to content

feat: expose XFOIL Type 2/3 polar modes (variable Re)#11

Merged
aeronauty-flexcompute merged 4 commits intodevfrom
feat/type2-polar-mode
Mar 23, 2026
Merged

feat: expose XFOIL Type 2/3 polar modes (variable Re)#11
aeronauty-flexcompute merged 4 commits intodevfrom
feat/type2-polar-mode

Conversation

@aeronauty-flexcompute
Copy link
Copy Markdown
Collaborator

Summary

  • Adds ReType enum (Type 1/2/3) to the Rust solver with effective_reynolds() that rescales Re each viscous iteration based on CL — matching original XFOIL Fortran behaviour
  • Threads re_type parameter through Python bindings (analyze_faithful, analyze_faithful_batch, get_bl_distribution) and the flexfoil API (solve(), polar(), bl_distribution())
  • Returns reynolds_eff in all viscous results so callers can see the effective Re used
  • Type 1 (constant Re) remains the default everywhere — no breaking changes

Requested by Ferdinand Elsner (KIT Karlsruhe) for GA-based airfoil optimisation where the operating Re depends on CL.

Usage

import flexfoil

foil = flexfoil.naca("2412")

# Type 1 (default, unchanged)
r1 = foil.solve(5.0, Re=1e6)

# Type 2: fixed Re*sqrt(CL)
r2 = foil.solve(5.0, Re=1e6, re_type=2)
print(r2.reynolds_eff)  # effective Re at converged CL

# Type 3: fixed Re*CL
r3 = foil.solve(5.0, Re=1e6, re_type=3)

# Works with polar sweeps too
polar = foil.polar(alpha=[0, 3, 5, 7, 10], Re=1e6, re_type=2)

Test plan

  • 6 Rust unit tests for effective_reynolds() (Type 1/2/3, negative CL, near-zero CL guard)
  • 10 Python binding-level tests (test_solver.py::TestReType)
  • 8 Python API-level tests (test_api.py::TestReType)
  • All 105 existing tests pass — no regressions
  • Docstrings and docs-site API reference not yet updated (planned for follow-up)

🤖 Generated with Claude Code

aeronauty and others added 4 commits March 23, 2026 12:50
Implements XFOIL polar Type 2 (fixed Re*sqrt(CL)) and Type 3
(fixed Re*CL) in the Rust solver. The effective Reynolds number is
recomputed each viscous iteration based on the current CL, matching
the original Fortran behaviour. Type 1 (constant Re) remains the default.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Threads the re_type parameter (1/2/3) through analyze_faithful,
analyze_faithful_batch, and get_bl_distribution. Returns reynolds_eff
in all result dicts so callers can see the effective Re used.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Adds re_type parameter (default 1) to solve(), polar(), and
bl_distribution(). Adds reynolds_eff field to SolveResult. All
existing behaviour is unchanged (Type 1 default).

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
18 new tests covering:
- Re_eff formula verification for Type 2 and Type 3
- Type 2 produces different CL/CD than Type 1
- Default re_type=1 matches omitted parameter
- Batch and parallel consistency
- Inviscid solve returns reynolds_eff=None
- BL distribution with Type 2

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@aeronauty-flexcompute aeronauty-flexcompute merged commit f49b17a into dev Mar 23, 2026
2 checks passed
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