Skip to content

AD: fix stale inflow passed to BEMT in AD_UpdateStates - #3502

Draft
andrew-platt wants to merge 1 commit into
OpenFAST:rc-5.0.1from
andrew-platt:b/AD_US_stale_wind
Draft

andrew-platt wants to merge 1 commit into
OpenFAST:rc-5.0.1from
andrew-platt:b/AD_US_stale_wind

Conversation

@andrew-platt

Copy link
Copy Markdown
Collaborator

NOT READY FOR MERGING

This PR changes many regression results. It should be one of the last PRs merged before the 5.0.1 release; baselines will be regenerated at that time.

Feature or improvement description

In AD_UpdateStates, the wind computed for each BEMT input time was written to m%Inflow(1) and never used. SetInputs read InflowInterp instead, which is set only once before the loop. Both BEMT inputs (m%BEMT_u(1) at t and m%BEMT_u(2) at t+dt) therefore got the same wind, so the BEMT/DBEMT/UA states were advanced as if the inflow did not change over the step.

There were two related problems on the same line:

  • The wind was evaluated at utimes(i) (where utimes = [t+dt, t]), but uInterp holds the node positions at BEMT_utimes(i) ([t, t+dt]). The time and the positions did not match.
  • m%Inflow(1) was overwritten, so SetInputsForAA and SetInputsForFVW (index 1) later in the routine paired u(1) with the wrong inflow.

The fix is one line: calculate the wind at BEMT_utimes(i) into InflowInterp.

-      call AD_CalcWind(utimes(i),uInterp, p%FLowField, p, m, OtherState, m%Inflow(1), ErrStat2, ErrMsg2)
+      call AD_CalcWind(BEMT_utimes(i),uInterp, p%FLowField, p, m, OtherState, InflowInterp, ErrStat2, ErrMsg2)

This puts InflowInterp back to how it was used before commit 8024b98 ("AD15: calculate wind based on u_interp instead of extrapolating"): a temporary buffer that is refilled on every pass through the loop. m%Inflow(1:2) are no longer changed in the loop.

This replaces #3480, which had the same source change plus tests that are not needed.

Related issue, if one exists

Closes #3447
Supersedes #3480

Impacted areas of the software

  • AeroDyn: AD_UpdateStates (BEMT / DBEMT / UA state updates, AeroAcoustics inputs, OLAF inputs at index 1)
  • Affects all glue codes and drivers that use AeroDyn (OpenFAST, AeroDyn driver, AeroDyn-InflowWind C binding, FAST.Farm)

Additional supporting information

  • The bug has been in every release from v4.0.0 through v5.0.0. v3.x is not affected.
  • When wind is supplied without a FlowField (AD_CalcWind returns right away when FlowField is not associated), InflowInterp stays a copy of m%Inflow(1). Both BEMT inputs keep getting u(1)'s inflow, as they do today. This PR does not change that path.
  • No new tests are added. The existing regression tests already cover this code.

Generative AI usage

Claude Code (claude-opus-5-5) was used to review the issue and #3480, make the one-line change, and draft this description. The change was reviewed by the author.

Assisted-by: Claude Code:claude-opus-5-5 [Bash] [Read] [Edit]

Test results, if applicable

Results change for cases where the wind seen by the blades varies over one DT_Aero: turbulent or time-varying wind, shear with a rotating rotor, large platform or blade motion, MHK cases with waves, and cases using AeroAcoustics or OLAF. Steady, uniform wind with little motion should not change. Regression baselines will be updated in r-test just before this PR is merged.

  • r-test branch merging required
    • check when r-test is updated

In AD_UpdateStates, the wind computed for each BEMT input time was written
to m%Inflow(1) and never read; SetInputs read InflowInterp, which was set
once before the loop. Both BEMT input slots (t and t+dt) therefore received
the same wind. The wind was also sampled at utimes(i) rather than
BEMT_utimes(i), and m%Inflow(1) was overwritten before SetInputsForAA and
SetInputsForFVW read it.

Calculate the wind at BEMT_utimes(i) into InflowInterp, restoring its role
as the per-iteration scratch buffer (regression from 8024b98).

Assisted-by: Claude Code:claude-opus-5-5 [Bash] [Read] [Edit]

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔵 Needs a closer look

Maintainers need to assess widespread regression differences from numerical forcing changes across BEMT/DBEMT/UA and AeroAcoustics/OLAF before baseline regeneration and merging.

No open issues 🎉

What changed in this PR

Fixes stale inflow in AeroDyn’s AD_UpdateStates so BEMT state updates use wind sampled at the correct time and interpolated node positions.

Changes:

  • Samples wind at BEMT_utimes(i) into InflowInterp, the buffer consumed by SetInputs.
  • Preserves the original inflow samples for downstream AeroAcoustics and OLAF inputs.

Regression baselines remain pending before merge; the no-FlowField path is unchanged.

File Description
modules/​aerodyn/​src/​AeroDyn.f90 Corrects the wind-sampling time and destination buffer in AD_UpdateStates.

Review effort: Balanced

@andrew-platt
andrew-platt marked this pull request as draft October 29, 2026 00:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants