Skip to content

Fix region-3 thrust shaving unpacking for numpy >= 2.5 - #737

Merged
gbarter merged 4 commits into
NLRWindSystems:masterfrom
dzalkind:fix/thrust-shaving-numpy25
Sep 29, 2026
Merged

gbarter merged 4 commits into
NLRWindSystems:masterfrom
dzalkind:fix/thrust-shaving-numpy25

Conversation

@dzalkind

Copy link
Copy Markdown
Contributor

Fix region-3 peak thrust shaving crash on numpy >= 2.5

Summary

ComputePowerCurve.compute() fails on numpy >= 2.5 when peak thrust shaving re-solves a region-3 point:

ValueError: ... ComputePowerCurve: Error calling compute(), setting an array element with a sequence.

In the if peak_thrust_shaving and T[i] >= max_T: branch, the output of ccblade.evaluate was unpacked with myout[key]. That put shape-(1,) arrays into the scalar slots P_aero[i], T[i], and so on. Numpy has warned about this since 1.25, and 2.5 raises an error. Every other unpacking in the function already uses myout[key][0].

We found this in WEIS CI (iea22_raft_opt_driver, with thrust_shaving_coeff: 0.8). It only failed on Windows/Python 3.12, because whether this branch runs depends on the path the optimizer takes. NLRWindSystems/WEIS#478 pins numpy<2.5 until a WISDEM release includes this fix.

Changes

  • rotor_power.py: use myout[key][0] in the region-3 thrust-shaving unpacking.
  • rotor_power.py: make scaling_thrust a scalar (0.1*float(myout["T"][0])). ccblade.evaluate flattens its inputs, so scalar arguments still return shape-(1,) arrays.
  • New test testRegulationTrajectory_PeakShavingRegion3. It uses the NREL 5MW test data with an 80 m/s tip-speed limit and peak_thrust_shaving=0.5, which reaches this branch; no existing test does. The test treats numpy's "Conversion of an array with ndim > 0" warning as an error, so it also fails on numpy < 2.5 if this comes back.
  • Once this is released, the numpy<2.5 pin in Speed up CI conda solve WEIS#478 can be removed.

Audit of wisdem/rotorse/

I found no other cases:

  • Search: no float() or scalar casts on unindexed inputs[...]. All other unpackings of evaluate() results already use [0]
  • Input sweep: I ran 64 thrust-shaving input combinations with the ndim warning as an error. Only this branch failed.

Testing

Environment wisdem/test/test_rotorse/
numpy 2.5.3, Python 3.13 20 passed
numpy 2.4.3, Python 3.13, ndim warning as error 20 passed

The new test fails on the old code under both numpy versions and passes with the fix.

Known issue (not addressed here)

With peak_thrust_shaving=0.5, the rated-point solve doesn't converge. The point at rated_V stays at
full thrust and 5 MW, and the next feww rated power. This happens withoutthis change too.

🤖 Generated with Claude Code

The peak thrust shaving branch in ComputePowerCurve assigned shape-(1,)
ccblade outputs into scalar array slots, which numpy 2.5 turns from a
DeprecationWarning into an error. Index with [0] as the other unpackings
do, and make scaling_thrust a scalar.

Add a regression test that reaches this branch and treats numpy's ndim
conversion warning as an error so it also fails on older numpy.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@dzalkind

Copy link
Copy Markdown
Contributor Author

I fixed the issue with the mac compilers here if you want me to pull in the same fix: NatLabRockies/ROSCO@8d95127

dzalkind and others added 3 commits September 24, 2026 13:21
OpenMDAO 3.45.1 changed Autoscaler.get_bounds_scaling() to return a
name-keyed BoundMap instead of a (lower, upper, equals) tuple, and
represents unbounded directions as None or +/-inf rather than the now
deprecated INF_BOUND sentinel. Read bounds from the BoundMap, following
OpenMDAO's ScipyOptimizeDriver, and drop the INF_BOUND import.

Also check double-sided constraints per element; previously the
bounds array was overwritten by its first element inside the loop.

OpenMDAO 3.45.1 also looks for the renamed 'pydoe' package instead of
'pyDOE3' for its DOE and GA drivers, so add it as a dependency.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@gbarter
gbarter merged commit bc964be into NLRWindSystems:master Sep 29, 2026
18 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