Repository navigation
CasADi panel functions: polar tables as inputs, so one graph serves every deformed shape - #167
Merged
ocayon merged 1 commit intoNov 3, 2026
Conversation
On a deforming wing each panel's blended polar changes slightly every coupled iteration. The CasADi residual and panel-force functions embedded the tables as constants and were cached per table set, so a caller that re-trims deformed shapes (AWETrim's CasadiTrim) rebuilt its graph every iteration and could not afford to SX-expand it. - _casadi_newton_function(table_inputs=False) and casadi_panel_force_function(table_inputs=False): with True the functions take cl_table, cd_table, cm_table, each (n_panels, n_alpha), as extra inputs and are cached per (panel count, alpha grid, settings), not per table values. The lookup is one 1-D parametric linear interpolant on the shared grid, mapped over panels: same nodes and clamping, so the outputs equal the embedded-table ones to round-off. Omitted tables default to NaN, never to a silently zero polar. - Solver.casadi_polar_table_inputs() and casadi_stall_angle_inputs(): the current tables and stall-gate angles in the input layout. - Linear polars on one shared alpha grid only (a parametric cubic spline refits per call, ~0.1 s); other cases raise a clear ValueError. VSM's own loops keep the embedded-table functions and are unchanged: all solve outputs are bit-identical to a801b5b (4 loop types, both is_aoa_corrected settings, viscosity on/off). Expanded to SX, the table function evaluates as fast as the embedded one (+2% at 135 panels). Generated with Claude Code
Contributor
There was a problem hiding this comment.
Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota. Try requesting a review at a lower effort level.
An organization owner can choose the repository organization as the billing source for reviews requested by members with a paid Copilot license. Learn about Copilot code review billing. Review the Copilot code review billing settings.
This was referenced Nov 3, 2026
ocayon
added a commit
that referenced
this pull request
Nov 3, 2026
Land #167 on develop (polar tables as CasADi inputs)
ocayon
added a commit
that referenced
this pull request
Nov 4, 2026
Release prep v2.3.0: restore the unmerged v2.2.0 content, land #167, changelog
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Stacked on #166. The base branch is
feature/quarter-chord-xp-kernels. Retarget todeveloponce #166 is merged.Why
On a deforming wing, each panel's polar is a blend of its two section polars with geometry-dependent weights, so the tables change slightly every coupled iteration. The CasADi residual and panel-force functions embedded the tables as constants and were cached per table set. A caller that re-trims deformed shapes (AWETrim's
CasadiTrimin the aerostructural loop) therefore rebuilt its whole graph on every iteration, and could not afford to SX-expand it.What changes
Both CasADi panel functions can take the polar tables as inputs. One function then serves every shape with the same panel count and alpha grid.
New and changed signatures (
Solver)table_inputs=False(default): unchanged, the tables are embedded and the function is cached per table set. VSM's owngamma_loop_casadi_newtonkeeps using it.table_inputs=True:cl_table,cd_tableandcm_tableat the end. Rowiis panelion the shared alpha grid (panel.panel_polar_data[:, 0], rad). The outputs are unchanged.*_avgoutputs and the viscosity lift slope.ValueError:polar_interpolation="bspline": a parametric cubic spline refits its coefficients on every call, about 87 ms per evaluation;What AWETrim must change
panel_fn = vsm._casadi_newton_function(table_inputs=True)(andcasadi_panel_force_function(table_inputs=True)if used).cl_table,cd_table,cm_tableto the graph, and pass them throughpanel_fn.call({... , **tables}).update_geometry):vsm.casadi_polar_table_inputs()as those parameters;vsm.casadi_stall_angle_inputs(). Today the stall angles are fixed at build, which is only right while the tables are fixed._casadi_newton_key).Validation
Outputs unchanged:
a801b5b: 2304 arrays over 4gamma_loop_types (casadi_newton,anderson,non_linear,base) × 3 cases (V3, V3 with the viscous correction, arc wing) × bothis_aoa_correctedsettings × artificial viscosity on/off.1201f6fstill holds, at ≤ 1.5e-14.New tests (
tests/Solver/test_casadi_polar_table_inputs.py, 7):expand()works and matches;Full suite: 208 passed, 5 skipped (201 + 7 new).
Timings
Residual function, V3, artificial viscosity on, 83 alpha nodes, best of 5. Measured on a machine under other load, so trust the ratios more than the absolute values.
SX-expanded, the table-input function is as fast as the embedded one: +2 % at 135 panels, +17 % at 36.
Unexpanded MX, it is about 1.9× slower, which is why VSM's own loop keeps the embedded function.
The VSM function's own build is milliseconds either way. The 2–6 s rebuilds per coupled iteration seen in AWETrim are its full trim graph and Jacobian, which this change lets it build once.
Written by Claude, reviewed by Oriol Cayon