FLOWFarm.jl Integration#182
Open
BTV25 wants to merge 21 commits into
Open
Conversation
cfrontin
self-requested a review
March 19, 2026 20:24
cfrontin
requested changes
Apr 2, 2026
cfrontin
left a comment
Collaborator
There was a problem hiding this comment.
overall, this looks pretty good! let's fight through some of the architecture stuff and try to clean up. one thing I was noticing fairly consistently is that there is a lot of complex and potentially over-engineered (possibly AI produced?) code and we should make sure to keep it as simple and clean as possible. FWIW, I'm fine w/ AI-supported code but I do demand a tight leash with it: a human somewhere needs to know what every single line does and why it's necessary.
distance_point_to_polygon_ray_casting and distance_multi_point_to_multi_polygon_ray_casting hardcoded jnp.float32 for turbine points and polygon vertices, despite jax_enable_x64=True being set in boundary.py. At km-scale site coordinates, float32 quantization noise gets amplified through the s=700 smooth_max/ smooth_min sharpness, producing O(0.1-1) errors in boundary_distances gradients vs FD. Switch both casts to float64.
…ositions _initial_turbine_positions() previously calibrated the sparse Jacobian pattern and per-wind-state deficit_thresholds against a synthetic, rotated (20 deg) grid layout unrelated to the real config-specified turbine layout. Near power-curve kinks (cut-in, near-rated, cut-out), the synthetic layout could produce an exactly-zero calibration jacobian (unwaked front row, every other row uniformly wake-clipped below cut-in), pinning threshold=Inf for that wind state forever -- even though the real layout has genuine nonzero x/y sensitivity there. Confirmed directly against the live model and reproduced standalone in pure FLOWFarm/Julia (hybridfarm repo: FarmSetup/test_sparse_threshold_bug.jl). Now jitters the actual config layout (layout.x_turbines/y_turbines + a small seeded random offset) instead of the unrelated synthetic grid, falling back to the old synthetic-grid behavior only when no explicit layout coordinates are available. Also adds set_check_partial_options overrides for x_turbines/y_turbines (step=0.01 m) in FLOWFarmBatchPower.setup_partials, matching the existing yaw_turbines override -- large FD steps used by ad hoc check_partials calls can cross power-curve kinks and produce large apparent errors that are FD truncation artifacts, not analytic errors. Verified: plant.wind.wind.ard_sub_prob now passes check_partials at max_rel=3.95e-06 in the full hybrid_farm.py model (was failing before). Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
OpenMDAO layout component that takes x_turbines_in/y_turbines_in as inputs (rather than reading fixed positions from modeling_options), so an outer IVC can drive turbine coordinates through the SubmodelComp boundary for gradient-based optimization. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
jax/jaxlib 0.9.0.1 crashes (SIGSEGV) inside _slice_transpose_fancy when computing second-order check_grads through distance_point_to_polygon_ray_casting (test_geometry.py). Reproduced directly; the function itself uses only ordinary slicing/vstack, so this is a jaxlib bug/incompatibility on this platform, not an Ard code defect. Confirmed jax 0.9.2 (same minor line) fixes it; verified no regression via test_derivatives.py (50/50) and a full hybrid_farm.py run (identical LCOH 2.102418).
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.
Added FLOWFarm.jl as an aero model. Added integration tests. Added a README specific to FLOWFarm.jl and Julia setup. I attempted to keep the integration as noninvasive as possible, focusing on the fact that Ard should still run without Julia as long as the FLOWFarm model is not being used.
I created a working example that imitates example 01 but just uses the FLOWFarm model.