Add a super-controller library target to CMake
Feature or improvement description This pull request adds a CMake target to compile the super-controller library via CMake.
Related issue, if one exists No open GitHub issue but this was discussed in this forum post: https://wind.nrel.gov/forum/wind/viewtopic.php?p=18191#p18191
Impacted areas of the software Super-controller library CMake config
Additional supporting information This has not been tested for validity in a simulation and it should be.
@hamidMech - I see the issue you opened (#909) and the changes here are what you need.
In order to compile this on your Linux machine, you can either copy the lines I've changed here into your close of OpenFAST or clone my fork with git clone https://github.com/rafmudaf/openfast -b sclib. Then, configure CMake as usual and you'll have a new target available for the Supercontroller library. The steps are:
cmake ..
make sclib
And you'll find the output in the usual spot: build/modules/supercontroller/libsclib.so.
Please report back here with the results after trying this. Thanks!
Dear Rafael, I could make to generate "libsclib.so" following your instruction. (see the first terminal output below). However, when I have tried to run Fast.Farm when supercontroller flag is "True", I got the error message as
Program received signal SIGSEGV: Segmentation fault - invalid memory reference.
Backtrace for this error:
Segmentation fault
Please find the terminal output 2 below for this error message. Could you please guide me how to solve it?
1- Terminal output for generating libsclib.so
me@tfd:~/test_ffm/OpenFAST/build$ make sclib
Scanning dependencies of target sclib
Building Fortran object modules/supercontroller/CMakeFiles/sclib.dir/src/SC_DLL.F90.o
/chalmers/users/me/test_ffm/OpenFAST/modules/supercontroller/src/SC_DLL.F90:16:0:
subroutine sc_init ( nTurbines, nInpGlobal, NumCtrl2SC, NumParamGlobal, NumParamTurbine, &
Warning: ‘dllexport’ attribute directive ignored [-Wattributes]
/chalmers/users/me/test_ffm/OpenFAST/modules/supercontroller/src/SC_DLL.F90:70:0:
subroutine sc_getInitData(nTurbines, NumParamGlobal, NumParamTurbine, ParamGlobal, ParamTurbine, &
Warning: ‘dllexport’ attribute directive ignored [-Wattributes]
/chalmers/users/me/test_ffm/OpenFAST/modules/supercontroller/src/SC_DLL.F90:134:0:
subroutine sc_calcOutputs ( t, nTurbines, nParamGlobal, paramGlobal, nParamTurbine, paramTurbine, nInpGlobal, to_SCglob, NumCtrl2SC, to_SC, &
Warning: ‘dllexport’ attribute directive ignored [-Wattributes]
/chalmers/users/me/test_ffm/OpenFAST/modules/supercontroller/src/SC_DLL.F90:208:0:
subroutine sc_updateStates ( t, nTurbines, nParamGlobal, paramGlobal, nParamTurbine, paramTurbine, nInpGlobal, to_SCglob, NumCtrl2SC, to_SC, &
Warning: ‘dllexport’ attribute directive ignored [-Wattributes]
/chalmers/users/me/test_ffm/OpenFAST/modules/supercontroller/src/SC_DLL.F90:291:0:
subroutine sc_end ( errStat, errMsg ) bind (C, NAME='sc_end')
Warning: ‘dllexport’ attribute directive ignored [-Wattributes]
Linking Fortran shared library libsclib.so
Built target sclib
2- Terminal output for running Fast.Farm with Supercontroller
me@tfd:~/test_ffm/OpenFAST/reg_tests/r-test/glue-codes/fast-farm/myTSinflow$ ../../../../../install/bin/FAST.Farm TSinflow.fstf
**************************************************************************************************
FAST.Farm
Copyright (C) 2021 National Renewable Energy Laboratory
Copyright (C) 2021 Envision Energy USA LTD
This program is licensed under Apache License Version 2.0 and comes with ABSOLUTELY NO WARRANTY.
See the "LICENSE" file distributed with this software for details.
**************************************************************************************************
FAST.Farm--128-NOTFOUND
Compile Info:
- Compiler: GCC version 8.3.0
- Architecture: 64 bit
- Precision: double
- OpenMP: No
- Date: Apr 16 2021
- Time: 16:09:48
Execution Info:
- Date: 11/03/2021
- Time: 09:45:11+0100
Heading of the FAST.Farm input file:
Sample FAST.Farm input file
Running AWAE.
Running InflowWind.
Reading a 101x35 grid (1000 m wide, 5 m to 345 m above ground) with a characteristic wind
speed of 9.243 m/s. This full-field file was generated by TurbSim (v2.00.07a-bjj, 14-Jun-2016)
on 24-Sep-2019 at 16:18:09.
Processed 2000 time steps of 10-Hz full-field data (period of 200 seconds).
Running Super Controller.
Running WakeDynamics.
Running FASTWrapper (v1.00.00, 7-Feb-2017).
Running OpenFAST.
OpenFAST input file heading:
FAST Certification Test #26: NREL 5.0 MW Baseline Wind Turbine (Onshore)
Running ElastoDyn.
Nodal outputs section of ElastoDyn input file not found or improperly formatted.
Running AeroDyn.
AD15 Nodal Outputs: Nodal output section of AeroDyn input file not found or improperly formatted.
Skipping nodal outputs.
Running InflowWind.
Running ServoDyn.
Running ServoDyn Interface for Bladed Controllers (using GNU Fortran for Linux, ).
Using legacy Bladed DLL interface.
FAST_InitializeAll:SrvD_Init:BladedInterface_Init:Error opening BLADED interface DLL. Checking
for legacy DLL.
Running OpenFAST.
OpenFAST input file heading:
FAST Certification Test #26: NREL 5.0 MW Baseline Wind Turbine (Onshore)
Running ElastoDyn.
Nodal outputs section of ElastoDyn input file not found or improperly formatted.
Running AeroDyn.
AD15 Nodal Outputs: Nodal output section of AeroDyn input file not found or improperly formatted.
Skipping nodal outputs.
Running InflowWind.
Running ServoDyn.
Running ServoDyn Interface for Bladed Controllers (using GNU Fortran for Linux, ).
Using legacy Bladed DLL interface.
FAST_InitializeAll:SrvD_Init:BladedInterface_Init:Error opening BLADED interface DLL. Checking
for legacy DLL.
Running OpenFAST.
OpenFAST input file heading:
FAST Certification Test #26: NREL 5.0 MW Baseline Wind Turbine (Onshore)
Running ElastoDyn.
Nodal outputs section of ElastoDyn input file not found or improperly formatted.
Running AeroDyn.
AD15 Nodal Outputs: Nodal output section of AeroDyn input file not found or improperly formatted.
Skipping nodal outputs.
Running InflowWind.
Running ServoDyn.
Running ServoDyn Interface for Bladed Controllers (using GNU Fortran for Linux, ).
Using legacy Bladed DLL interface.
FAST_InitializeAll:SrvD_Init:BladedInterface_Init:Error opening BLADED interface DLL. Checking
for legacy DLL.
Time: 0 of 180 seconds.
Program received signal SIGSEGV: Segmentation fault - invalid memory reference.
Backtrace for this error:
Segmentation fault
Dear @hamidMech,
Are you using the newest FAST.Farm source code from the main or dev branches of OpenFAST?
Is your DISCON controller formatted properly? There should be three super-controller arguments to DISCON, including from_SCglob and from_SC as inputs and to_SC as an output. A template of the source code at the turbine level ([i]DISCON_SC.f90[/i]) is located in the reg_tests\r-test\glue-codes\fast-farm\5MW_Baseline\ServoData\DISCON directory of the OpenFAST/FAST.Farm repository. More information on the super controller is available in the online FAST.Farm documentation on readthedocs: https://openfast.readthedocs.io/en/main/source/user/fast.farm/ModelGuidance.html#super-controller.
Best regards,
Dear Jason, I guess it was the main branch downloaded on April 2021. I have three arguments in "DISCON_SC.f90" as
SUBROUTINE DISCON ( avrSWAP, from_SC_Glob, from_SC, to_SC , aviFAIL, accINFILE, avcOUTNAME, avcMSG ) BIND (C, NAME='DISCON')
with the heading of
USE, INTRINSIC :: ISO_C_Binding
IMPLICIT NONE
#ifndef IMPLICIT_DLLEXPORT
!DEC$ ATTRIBUTES DLLEXPORT :: DISCON
!GCC$ ATTRIBUTES DLLEXPORT :: DISCON
#endif
! Passed Variables:
REAL(C_FLOAT), INTENT(IN ) :: from_SC (*) ! DATA from the supercontroller
REAL(C_FLOAT), INTENT(IN ) :: from_SC_Glob (*) ! DATA from the supercontroller
REAL(C_FLOAT), INTENT(INOUT) :: to_SC (*) ! DATA to the supercontroller
In addition, in "DISCON_SC.f90", which of the following items must be includedt?
avrSWAP(48) = 0.0 ! Demanded nacelle yaw rate
avrSWAP(48) = from_SC(1) !Set demanded nacelle yaw rate from supercontroller
Best regards, Hamid
@rafmudaf : These warning lines make me wonder if the build of the supercontroller DLL is missing the preprocessor definition IMPLICIT_DLLEXPORT on Linux:
Warning: ‘dllexport’ attribute directive ignored [-Wattributes]
/chalmers/users/me/test_ffm/OpenFAST/modules/supercontroller/src/SC_DLL.F90:70:0:
Dear @hamidMech,
Your DISCON arguments look correct. But have you built the DISCON_SC.f90 source file into an *.so file and is that the *.so file you are using?
If you are trying to use the sample super controller that prescribes yaw motion from the forum (https://wind.nrel.gov/forum/wind/viewtopic.php?f=13&t=2117&p=18310), you should use:
avrSWAP(48) = from_SC(1)
, not commented out.
Also, try upgrading to the dev branch of OpenFAST. Perhaps the PR submitted in May will fix your problem: https://github.com/OpenFAST/openfast/pull/749.
Best regards,
Dear Jason,
I have followed the instruction by Rafael (please see the first post above). Here are the steps I have done. First, I've added these lines to "OpenFAST//modules/supercontroller/CMakeLists.txt"
add_library(sclib SHARED src/SC_DLL.F90)
Then I have executed "cmake .." and then "make sclib" commands while inside the "/OpenFAST/build" directory. Then I made a copy of the generated "libsclib.so" and put into the simulation folder i.e.,
/me/test_ffm/OpenFAST/reg_tests/r-test/glue-codes/fast-farm/myTSinflow.
Below is the results in the terminal:
me@tfd:~/test_ffm/OpenFAST/build$ cmake ..
-- Enabling Fortran 2008 features
-- A library with LAPACK API found.
-- Setting system file as: src/SysGnuLinux.f90
-- Found OpenMP_C: -fopenmp
-- Found OpenMP_CXX: -fopenmp
-- Found OpenMP_Fortran: -fopenmp
-- Found OpenMP: TRUE
-- Configuring done
-- Generating done
-- Build files have been written to: /chalmers/users/me/test_ffm/OpenFAST/build
me@tfd:~/test_ffm/OpenFAST/build$ make sclib
Scanning dependencies of target sclib Building Fortran object modules/supercontroller/CMakeFiles/sclib.dir/src/SC_DLL.F90.o /chalmers/users/me/test_ffm/OpenFAST/modules/supercontroller/src/SC_DLL.F90:16:0:
subroutine sc_init ( nTurbines, nInpGlobal, NumCtrl2SC, NumParamGlobal, NumParamTurbine, &
Warning: ‘dllexport’ attribute directive ignored [-Wattributes] /chalmers/users/me/test_ffm/OpenFAST/modules/supercontroller/src/SC_DLL.F90:70:0:
subroutine sc_getInitData(nTurbines, NumParamGlobal, NumParamTurbine, ParamGlobal, ParamTurbine, &
Warning: ‘dllexport’ attribute directive ignored [-Wattributes] /chalmers/users/me/test_ffm/OpenFAST/modules/supercontroller/src/SC_DLL.F90:134:0:
subroutine sc_calcOutputs ( t, nTurbines, nParamGlobal, paramGlobal, nParamTurbine, paramTurbine, nInpGlobal, to_SCglob, NumCtrl2SC, to_SC, &
Warning: ‘dllexport’ attribute directive ignored [-Wattributes] /chalmers/users/me/test_ffm/OpenFAST/modules/supercontroller/src/SC_DLL.F90:208:0:
subroutine sc_updateStates ( t, nTurbines, nParamGlobal, paramGlobal, nParamTurbine, paramTurbine, nInpGlobal, to_SCglob, NumCtrl2SC, to_SC, &
Warning: ‘dllexport’ attribute directive ignored [-Wattributes] /chalmers/users/me/test_ffm/OpenFAST/modules/supercontroller/src/SC_DLL.F90:291:0:
subroutine sc_end ( errStat, errMsg ) bind (C, NAME='sc_end')
Warning: ‘dllexport’ attribute directive ignored [-Wattributes] Linking Fortran shared library libsclib.so Built target sclib
@hamidMech , make sure that you have also updated the individual turbine controllers that are defined in ServoDyn. These controllers have a different format when using the supercontroller, so they will need to be updated as well. @rafmudaf 's instructions are for building the supercontroller library only, not the individual turbine controller libraries.
@bjonkman , Could you please give an instruction how the individual turbine controllers (defined in ServoDyn) can be updated? In my simulation, I use "DISCON_WT1.so", "DISCON_WT2.so" and "DISCON_WT3.so" where for instance
"DISCON_WT1.so" is located at "/OpenFAST/reg_tests/r-test/glue-codes/fast-farm/5MW_Baseline/ServoData"
and they work when supercontroller flag is False in the FAST.Farm input file.
@jjonkman , Would you mean "avrSWAP(48) = from_SC(1)" or avrSWAP(58) = from_SC(1)? Does it only appear in DISCON_SC.f90? or there are in other files too? If there are n>1 (e.g., n=2) turbines, should we add "avrSWAP(49) = from_SC(2)" in DISCON_SC.f90?
Dear @hamidMech,
Oops, I meant:
avrSWAP(48) = from_SC(1)
(sorry for the typo, which I've now fixed in my post above), which should be the same for all wind turbines. The versions of the SC_DLL.f90 and DISCON_SC.f90 source files I provided in my post dated Mar 18, 2021 (updated May 10, 2021) in the FAST.Farm topic on the forum: https://wind.nrel.gov/forum/wind/viewtopic.php?f=13&t=2117 should work without modification. I've now also provided step-by-step instructions to run this working FAST.Farm example with the super controller in my post dated today (Nov 04, 2021) in that same forum topic.
Best regards,
Dear Jason, I could run FAST.Farm with the super-controller (your post dated Mar 18, 2021) including three wind turbines. Thanks for your help. I have made some harsh changes to visualize how the turbines are yawed according to the specified yaw rate. The simulation is run for 180 seconds with turbulent inflow generated by TurbSim. The changes have been made such that there is a sinusoidal yaw as:
yaw_WT_1(t)= (pi/3)sin((2pi/90)*t yaw_WT_2(t)= (pi/3)sin((1pi/90)*t yaw_WT_3(t)= 0
For this purpose, I have changed the values in "sc_dll.f90" in the below lines and re-compile it:
Line 110:
do j = 1, nTurbines ! ParamTurbine(j) = real((nTurbines-j)*.1, C_FLOAT) ParamTurbine(j) = real((nTurbines-j)*0.0349, C_FLOAT) ! Changed wrt the above line end do
Line 167:
do j = 1, nTurbines do i = 1, NumSC2Ctrl ! from_SC((j-1)*NumSC2Ctrl+i) = real(0.05 * sin(paramTurbine(j) * t)) ! The yaw is the yaw rate times the time from_SC((j-1)*NumSC2Ctrl+i) = real(1.0472 * sin(paramTurbine(j) * t)) ! Changed wrt the above line end do end do
However, when I see the results in Paraview, I cannot see any yawed motion for the turbines. it seems that the super-controller does not change the turbines' nacelle yaw according to the super-controller. Could you please help me in this case?
Here are the setting parameters that I have not changed it : nInpGlobal = 0 NumCtrl2SC = 2 NumParamGlobal = 0 NumParamTurbine = 1 NumStatesGlobal = 0 NumStatesTurbine = 0 NumSC2CtrlGlob = 0 NumSC2Ctrl = 1
Best regards, Hamid
Dear @hamidMech,
A couple comments:
- If you are not seeing any yaw motion, have you enabled your OpenFAST models to accept yaw-control signals from the DISCON DLL? I.e., have you set
YCMode= 5 andTYCOn= 0.0 s in ServoDyn and do you haveYawDOF= True in ElastoDyn? I see that I forgot this step in my step-by-step instructions on the forum, which I've now fixed. - The yaw rate amplitude you are specifying is very extreme. A yaw-rate amplitude of pi/3 rad/s is equivalent to a yaw angle amplitude of (pi/3) / (2pi/90) rad = 15 rad = 859 deg for WT1 and 1719 deg for WT2.
Best regards,
These warning lines make me wonder if the build of the supercontroller DLL is missing the preprocessor definition
IMPLICIT_DLLEXPORTon Linux:
In fact it was!