OpenFAST / openfast

Main repository for the NREL-supported OpenFAST whole-turbine and FAST.Farm wind farm simulation codes.
http://openfast.readthedocs.io
Apache License 2.0
691 stars 458 forks source link

Segmentation in FAST.Farm with OLAF (AD15) #1391

Open andrew-platt opened 1 year ago

andrew-platt commented 1 year ago

Bug description Running a multi-turbine FAST.Farm simulation with OLAF enabled in AD15 results in a segmentation fault. This was reported on the forum (https://forums.nrel.gov/t/fvw-for-multiple-turbines-in-openfast-fast-farm/4303/3).

To Reproduce Steps to reproduce the behavior:

  1. Compile in debug
  2. Run TSinflow FAST.Farm regression case with OLAF enabled
  3. The following error occurs (reported by forum user)

Program received signal SIGSEGV: Segmentation fault - invalid memory reference. ==2629== Invalid read of size 8 ==2629== at 0x6C96D7: fastwrapper_MOD_fwrap_calcoutput (FASTWrapper.f90:591) ==2629== by 0x6E0735: __fastwrapper_MOD_fwrap_t0 (FASTWrapper.f90:511) ==2629== by 0x44452F: fast_farm_subs_MOD_farm_initialco (FAST_Farm_Subs.f90:2050) ==2629== by 0x79CE6E: MAIN __ (FAST_Farm.f90:109) ==2629== by 0x79D13C: main (FAST_Farm.f90:28) ==2629== Address 0x0 is not stack’d, malloc’d or (recently) free’d

Line 591 of FASTWrapper.f90 is:

y%D_rotor = 2.0_ReKi * maxval(m%Turbine%AD%m%rotors(1)%BEMT_u(indx)%rLocal)

This corresponds to line 601 in dev: https://github.com/OpenFAST/openfast/blob/dev/glue-codes/fast-farm/src/FASTWrapper.f90#L601

Root Cause When OLAF is enabled AD15, BEMT is not used. Therefore, the BEMT_u array is not allocated, and neither is the rLocal contained in it.

When OLAF was added to OpenFAST, testing with FAST.Farm was apparently not done as this would have been noticed then.

Additional concerns and fix The rLocal array from BEMT contains the radius of blade nodes in the disk plane from the center of a flat rotor disk projection. The y%D_rotor value calculated from it isused in the WakeDynamics module, which may have some assumptions on how this calculation is done.

Two possible fixes:

  1. use the rotor diameter calculated at initialization
  2. Calculate the rotor diameter from a flat disk projection in OLAF as it is calculated in BEMT

However, there may be some additional assumptions in the WakeDynamics module that are not valid for OLAF -- this will need to be checked.

OpenFAST Version Any version of OpenFAST that includes OLAF will likely trigger this bug.

jjonkman commented 1 year ago

Thanks, @andrew-platt.

I agree that FASTWrapper needs to pass the instantaneous rotor diameter (projected along a flat disk representing the rotor plane) from OpenFAST to FAST.Farm for use by WakeDynamics. This and other variables that need to be transferred from OpenFAST to FAST.Farm are listed in the Outputs section of the FASTWrapper registry file: https://github.com/OpenFAST/openfast/blob/dev/glue-codes/fast-farm/src/FASTWrapper_Registry.txt. We should ensure all of these variables are calculated properly when OLAF is enabled as well.