# Two-section wing parametric performance plan

## Decision

Treat a two-section wing as one continuous, piecewise-linear lifting surface. Keep the inner and outer section geometry explicit through every aerodynamic calculation. A single equivalent taper or sweep may be reported as a reference value, but must not be used as the primary solver geometry.

## Canonical reference geometry

For one semispan, let the inner and outer panel spans be `p1` and `p2`, and let the root, kink, and tip chords be `c0`, `c1`, and `c2`.

- Full-wing area: `S = p1(c0 + c1) + p2(c1 + c2)`.
- Full span: `b = 2(p1 + p2)`.
- Aspect ratio: `AR = b^2 / S`.
- Section taper ratios: `lambdaInner = c1/c0`, `lambdaOuter = c2/c1`.
- Overall reference taper: `lambdaOverall = c2/c0`. Report it, but do not substitute it for the two section tapers in aerodynamic analysis.
- Geometric mean aerodynamic chord: `MAC = 2[p1(c0^2 + c0 c1 + c1^2) + p2(c1^2 + c1 c2 + c2^2)] / (3S)`.
- Inner and outer quarter-chord sweeps are calculated from each section's actual root and tip quarter-chord points.
- An overall geometric quarter-chord sweep may be reported from the root-to-tip quarter-chord line, but the aerodynamic solver must use the kinked quarter-chord geometry.
- Locate the geometric MAC reference point by integrating the local quarter-chord position and chord weighting across both panels. Do not reuse the single-trapezoid MAC-location formula.

`Wing.S`, `Wing.b`, `Wing.AR`, `Wing.MAC`, and the canonical reference coordinates must be the only reference values consumed by downstream performance, stability, loads, and structural modules. Section properties remain available for strip and panel calculations.

## Recommended aerodynamic method

Implement a symmetric low-speed vortex-lattice method (VLM) over the actual two-section planform.

1. Tessellate each semispan section independently, with a shared row at the kink. Use cosine spacing spanwise and at least 4 chordwise panels for normal analysis.
2. Place bound vortices at quarter chord, control points at three-quarter chord, and extend a wake downstream.
3. Solve circulation for at least two small angles of attack in the linear range.
4. Integrate panel forces and moments using total `S`, full `b`, and geometric `MAC` as reference dimensions.
5. Derive `CL_alpha`, span loading, induced drag, Oswald/span efficiency, pitching-moment slope, and aerodynamic center. With an explicitly documented moment sign convention, obtain aerodynamic center from the lift and pitching-moment slopes.
6. Apply a Prandtl-Glauert correction only inside its documented subsonic range. Keep incompressible results available for comparison.
7. Treat stall, separation, vortex lift, wave drag, and maximum lift as separate empirical or higher-fidelity models. Do not imply that linear VLM predicts them.

## Parametric analysis interface

- Add a collapsible `Wing Performance` panel below the geometry workspace.
- Inputs: Mach, altitude/density, speed or dynamic pressure, angle-of-attack range, aircraft weight, parasite-drag estimate, and lattice resolution.
- Outputs: total area, span, AR, inner/outer/overall taper, inner/outer/geometric quarter-chord sweep, MAC and its reference location, aerodynamic center, `CL_alpha`, `CL(alpha)`, `CDi(CL)`, span efficiency, span loading, estimated stall speed when a user-supplied `CLmax` exists, and basic drag-polar/required-power curves when parasite drag is supplied.
- Parametric sweeps: inner/outer span, sweep, taper, kink location, twist, and airfoil lift-curve slope. Keep total area or span fixed when selected by the user.
- Run the lattice solve in a Web Worker, cache geometry matrices, debounce slider changes, and show convergence with lattice refinement.
- Clearly label geometric, VLM-derived, and user/empirical results.

## Validation gates

1. Geometry unit tests for area, AR, MAC, MAC reference point, and both quarter-chord sweeps.
2. Continuity tests at the kink: matching chord, coincident vertices, no duplicate/zero-area panels.
3. A one-section equivalence test: a two-section wing with identical sweeps and a collinear taper must reproduce the existing trapezoidal-wing geometry.
4. Compare rectangular and elliptic-reference wings with classical lifting-line trends.
5. Compare swept/tapered cases with NACA TN 1491 trends for lift-curve slope, induced drag, and aerodynamic-center movement.
6. Lattice-convergence tests and invariance to harmless section-boundary placement.
7. Verify every downstream module reads canonical total-wing reference values rather than an individual panel area.
8. Preserve JSON backward compatibility and add optional analysis settings/results under a versioned `DesignerAnalysis` object.

## Primary open references

- NACA TR 751, *The Mean Aerodynamic Chord and the Aerodynamic Center of a Tapered Wing*: https://ntrs.nasa.gov/citations/19930091829
- NACA TN 1491, *Theoretical Additional Span Loading Characteristics of Wings with Arbitrary Sweep, Aspect Ratio, and Taper Ratio*: https://ntrs.nasa.gov/citations/19930082544
- NASA SP-405, *Vortex-Lattice Utilization*: https://ntrs.nasa.gov/citations/19760021075
- NASA CR-2865, *A Generalized Vortex Lattice Method for Subsonic and Supersonic Flow Applications*: https://ntrs.nasa.gov/citations/19780008059
- NASA TP-2269, *Wing Planform Effects at Supersonic Speeds for an Advanced Fighter Configuration*: https://ntrs.nasa.gov/citations/19840012418

## Implementation prompt

Implement section-aware parametric wing performance analysis in `TOOLS/AircraftDesigner.html` and `TOOLS/JavaScripts/AircraftDesigner/AircraftDesigner.js`, using this plan as the acceptance-test basis.

Treat a two-section wing as one continuous piecewise-linear lifting surface. Do not reduce it to a single equivalent trapezoid for aerodynamic calculations. Preserve one-section behavior and existing JET JSON compatibility.

### Canonical geometry

1. Create a pure canonical wing-reference calculation shared by all downstream modules.
2. For semispan panel lengths `p1`, `p2` and root/kink/tip chords `c0`, `c1`, `c2`, enforce:
   - `S_inner = p1(c0+c1)`
   - `S_outer = p2(c1+c2)`
   - `S = S_inner + S_outer`
   - `b = 2(p1+p2)`
   - `AR = b^2/S`
   - `MAC = 2[p1(c0^2+c0c1+c1^2)+p2(c1^2+c1c2+c2^2)]/(3S)`
3. Calculate section quarter-chord sweeps from the actual section endpoint quarter-chord coordinates. Report a root-to-tip quarter-chord sweep only as a geometric reference.
4. Preserve and report `lambdaInner=c1/c0`, `lambdaOuter=c2/c1`, and `lambdaOverall=c2/c0`. Never use `lambdaOverall` in place of the two section tapers in the solver.
5. Integrate the local chord and quarter-chord geometry to obtain the geometric MAC reference location. Keep this geometric reference distinct from the solver-derived aerodynamic center.
6. Audit every performance, stability, load, control-surface, and structural consumer in this tool. All whole-wing coefficients and dimensional results must use canonical total `S`, full `b`, and piecewise `MAC`; strip or panel calculations may use local section geometry.

### Low-speed aerodynamic solver

1. Add a self-contained symmetric vortex-lattice method over the actual kinked planform. Use no network dependencies. If computation is moved off the UI thread, create a Blob-backed Web Worker so the HTML remains standalone.
2. Tessellate the inner and outer sections separately with a single shared kink row, cosine spanwise spacing, configurable spanwise resolution, and at least four chordwise panels at normal resolution.
3. Use quarter-chord bound vortices, three-quarter-chord control points, a documented wake model, and an explicitly documented force/moment sign convention.
4. Solve at two or more small angles of attack and return `CL_alpha`, `Cm_alpha`, `CL(alpha)`, circulation/span loading, induced drag, and span efficiency. Calculate aerodynamic center from the lift and pitching-moment slopes using the declared sign convention.
5. Add optional Prandtl-Glauert correction only within a clearly stated subsonic validity range and retain the incompressible result for comparison.
6. Do not use linear VLM to claim stall angle, `CLmax`, separated vortex lift, transonic/wave drag, or post-stall behavior. Stall-speed results require a user-supplied or separately modeled `CLmax`; total drag and power results require parasite-drag inputs.

### Parametric interface

1. Add a collapsible `Wing Performance` panel below the geometry workspace.
2. Inputs: Mach, density/altitude, speed or dynamic pressure, angle-of-attack range, aircraft weight, user `CLmax`, parasite-drag estimate, and lattice resolution.
3. Outputs: inner/outer/total area, span, AR, all three taper values, inner/outer/reference quarter-chord sweeps, MAC and geometric reference coordinates, aerodynamic center, `CL_alpha`, `CL(alpha)`, `CDi(CL)`, span efficiency, span loading, and conditionally available stall-speed and drag/power results.
4. Add parametric sweeps for inner/outer span, kink location, inner/outer sweep, inner/outer taper, twist, and section lift-curve slope. Let the user choose constraints such as fixed total area or fixed span.
5. Debounce slider changes, cache influence matrices by geometry and lattice settings, avoid full 3D redraws during solver-only changes, and show convergence versus lattice refinement.
6. Label every result as geometric, VLM-derived, or user/empirical.

### Data, regression, and delivery

1. Store optional settings and results in a versioned `DesignerAnalysis` object. Loading older JSON must produce sensible defaults; disabling a wing must not leave stale analysis results.
2. Add tests for exact area, AR, piecewise MAC, reference locations, section sweeps, kink continuity, and finite solver outputs.
3. Add a one-section equivalence case: identical section sweeps and a collinear chord progression must reproduce the one-section geometry and closely match its aerodynamic results.
4. Add rectangular-wing and elliptic-loading trend checks plus swept/tapered trend comparisons with NACA TN 1491.
5. Add lattice-convergence, no-NaN, no-zero-area-panel, symmetry, and harmless-kink-location invariance tests.
6. Keep `TOOLS/AircraftDesigner.html` standalone by synchronizing the complete JavaScript source copy into the HTML. Increment the visible tool version and date, preserve unrelated user changes, and report every edited file and test result.
7. Retain the existing `Analysis approach…` popup, update its displayed values from the canonical geometry helper, and clearly indicate which solver stages are active versus planned.

Use these primary references as validation and methodology guidance: NACA TR 751, NACA TN 1491, NASA SP-405, NASA CR-2865, and NASA TP-2269, linked above.