Commit b0234aa5 authored by famen's avatar famen
Browse files

updated the CMakeLists.txt

cleaned up old files
parent 89672ef3
Pipeline #16406 passed with stage
in 32 seconds
cmake_minimum_required (VERSION 3.0)
#Creating the project
project(dtu_we_controller.dll LANGUAGES Fortran)
# Creating the project
project(DTUWEC LANGUAGES Fortran)
# message(${CMAKE_SOURCE_DIR})
# Adding all source files in ./source directory
#file(GLOB_RECURSE SRC *.f90)
set(ROOT_DIR ${CMAKE_CURRENT_SOURCE_DIR})
set(MODSRC_DIR ${CMAKE_CURRENT_SOURCE_DIR}/src/modules)
set(IPCSRC_DIR ${CMAKE_CURRENT_SOURCE_DIR}/src/individual_pitch_controller)
set(DTUWEC_SRC_DIR ${CMAKE_CURRENT_SOURCE_DIR}/src/dtu_we_controller)
set(BLADED_SRC_DIR ${CMAKE_CURRENT_SOURCE_DIR}/src/dtu_we_controller_bladed)
set(FLAP_SRC_DIR ${CMAKE_CURRENT_SOURCE_DIR}/src/flap_controller_individual_aep_u_f)
set(BUILD_TYPE SHARED)
set(LIB static)
message("Configuring DTU WEC source files: " ${DTUWEC_SRC_DIR})
add_subdirectory(${DTUWEC_SRC_DIR})
message("Configuring Bladed Interface source files: " ${BLADED_SRC_DIR})
add_subdirectory(${BLADED_SRC_DIR})
#set(LIB_TYPE STATIC)
message("Configuring Individual Pitch Controller source files: " ${IPCSRC_DIR})
add_subdirectory(${IPCSRC_DIR})
message("Configuring flap controller source files: " ${FLAP_SRC_DIR})
add_subdirectory(${FLAP_SRC_DIR})
# Adding all source files in ./source directory
# file(GLOB_RECURSE SRC *.f90)
# set(LIB_TYPE STATIC)
include(${CMAKE_CURRENT_SOURCE_DIR}/utils/ci/CMakeListsFortranLibrary.txt)
# include(${CMAKE_CURRENT_SOURCE_DIR}/utils/ci/CMakeListsFortranLibrary.txt)
[![pipeline status](https://gitlab.windenergy.dtu.dk/OpenLAC/BasicDTUController/badges/master/pipeline.svg)](https://gitlab.windenergy.dtu.dk/OpenLAC/BasicDTUController/commits/master)
# Basic DTU Wind Energy controller
# DTU Wind Energy Controller (DTUWEC)
## Introduction
The scope of this project is to provide a basic open-source open-access controller that can be used by the community as a reference.
The scope of this project is to provide an open-source open-access controller that can be used by the wind energy community as a reference. The DTU Wind Energy Controller (DTUWEC) is designed for pitch-regulated variable-speed wind turbines. It is built for high fidelity in-house aero-elastic simulation software (HAWC2). An interface to DNV-GL Bladed and OpenFAST is also provided for using DTUWEC with Bladed or OpenFAST. The controller features both partial and full load operation capabilities as well as switching mechanisms ensuring smooth transition between the two modes of operation. The partial load controller is based on a classical $`K\Omega^2`$ strategy or on a proportional-integral controller to track optimal tip speed ratio. The full load controller is also based on classical proportional-integral control theory. It also includes drivetrain and tower dampers, rotor speed exclusion zone control, de-rating control, wind speed estimation and filters on the feedback signal.
The basic DTU Wind Energy controller is designed for pitch-regulated variable speed wind turbines.
The controller features both partial and full load operation capabilities as well as switching mechanisms ensuring smooth transition between the two modes of operation. The partial load controller is based on a classical K Omega**2 strategy or on a proportional-integral controller to track constant tip speed ratio. The full load controllers is also based on classical proportional-integral control theory. The controller also includes drivetrain and tower dampers, a rotor speed exclusion zone, and filters on the feedback signal.
Blade pitch servo and generator models are not included in this controller. They can be found in the project [ServoAndUtilities](https://github.com/DTUWindEnergy/ServosAndUtilities).
The DTUWEC also includes individual pitch control (IPC), individual flap control and cyclic flap control as separated DLLs.
Blade pitch servo, generator models, flap servo, mechanical brake are not included in this repository. They can be found in the project [ServoAndUtilities](https://github.com/DTUWindEnergy/ServosAndUtilities).
## Compatibility
The repository includes Visual Studio project (for Windows) and Makefiles (for Linux) to create DLLs to interface the controller to HAWC2 and Bladed.
The controller is written in Fortran and it is compatible with Intel and GFortran compilers. It can be compiled both on Windows and Linux.
The project uses CMake to generate standard build files (e.g., makefiles on Linux/Mac OS and projects/solution files on Windows Visual studio) which could be used in the usual way.
The repository includes Visual Studio solution (for Windows) and CMakeLists.txt (for both Windows and Linux) to create DLLs to be used by HAWC2, Bladed and openFAST.
The controller is written in Fortran and it is compatible with Intel and GFortran compilers. It can be compiled both on Windows (32bit and 64bit) and Linux.
## Compilation
- For compilation in Windows (as a dll), use the Visual Studio Solution or Project files provided (*.sln, *.vfproj)
- For compilation in Unix (as a so file), go to the /src subfolder and type `make FC=compiler`. Where 'compiler' should be replaced by an already installed compiler (e.g. ifort, mpif90).
## Documentation
The documentation can be found [here](http://dtuwindenergy.github.io/BasicDTUController/index.html).
The documentation is written in [Sphinx](http://sphinx-doc.org/) and can be built by typing:
$ cd docs
$ make html
The documentations requires the [Fortran Sphynx](https://github.com/VACUMM/sphinx-fortran) extension that can be pip installed by typing:
$ pip install sphinx-fortran
## License
The Basic DTU Wind Energy controller is distributed under the [GNU General Public License v3.0](http://en.wikipedia.org/wiki/GNU_General_Public_License).
## References
When using the Basic DTU Wind Energy controller, please refer to the following publications:
* Hansen, MH & Henriksen, LC 2013, Basic DTU Wind Energy controller. DTU Wind Energy. DTU Wind Energy E, no. 0028 [link](http://orbit.dtu.dk/en/publications/basic-dtu-wind-energy-controller(ff8123f8-55d2-4907-af7f-2fa139987c33).html)
### Windows: Visual Studio 2019 only + Intel Fortran (WIP)
- Install Microsoft Visual Studio Community 2019 and Intel Parallel Studio XE 2019 Update 5 Composer Edition for Fortran Windows Integration for Microsoft Visual Studio
- Use the Visual Studio Solution or Project files (*.sln, *.vfproj) which will be provided in the future.
### Windows: Visual Studio 2019 with CMake + Intel Fortran
- Install Microsoft Visual Studio Community 2019 and Intel Parallel Studio XE 2019 Update 5 Composer Edition for Fortran Windows Integration for Microsoft Visual Studio
- Install C++ CMake tools for Windows from (https://docs.microsoft.com/en-us/cpp/build/cmake-projects-in-visual-studio?view=vs-2019). Alternative, you could also install CMake from (https://cmake.org/download/). The minimum required CMake version is 3.12.4.
- Create a "build" directory inside the toplevel of your local repository directory. (e.g. C:\Users\xxx\BasicDTUController\)
```
>> mkdir build
```
- Going to your build directory.
```
>> cd build
```
- For 32-bit, in build folder run (make sure cmake command is inside your user environment PATH):
```
>> cmake .. -G "Visual Studio 16 2019" -A Win32
```
- For 64-bit, in build folder run:
```
>> cmake .. -G "Visual Studio 16 2019" -A x64
```
- Now, a Visual Studio Solution file has been created and you could either use the following command to build the projects or open it with you Visual Studio IDE and build the projects as usual;
```
devenv DTUWEC.sln /Build
```
### Windows: CMake + GNU Fortran (gfortran)
- Install CMake from (https://cmake.org/download/). The minimum required CMake version is 3.12.4.
- Install [MinGW] (https://osdn.net/projects/mingw/releases/). Currently, MinGW offers only a 32-bit GNU Compiler Collection (GCC) including gfortran. One can also install MinGW-w64 through [MSYS2](https://www.msys2.org/). It offers a 64-bit GNU Compiler Collection (GCC) including gfortran. It should also be able to compile DTUWEC, but it has not been tested.
- Make sure both CMake and MinGW are inside your user environment PATH;
- Create a "build" directory inside the toplevel of your local repository directory. (e.g. C:\Users\xxx\BasicDTUController\)
```
>> mkdir build
```
- Going to your build directory.
```
>> cd build
```
- In the build folder run the following command to build the code
```
>> cmake .. -G "MinGW Makefiles" -D CMAKE_Fortran_COMPILER="gfortran" -D CMAKE_BUILD_TYPE="release"
>> mingw32-make
```
### Linux/Mac: CMake + GNU Fortran (gfortran) (WIP)
- Install CMake and gfortran (e.g. in Ubuntu). The minimum required CMake version is 3.12.4.
```
$ sudo apt-get install cmake
$ cmake -- version
cmake version 3.17.2
$ sudo apt-get install gfortran
```
- Create a "build" directory inside the toplevel of your local repository directory. (e.g. /home/xxx/BasicDTUController/)
```
$ mkdir build
```
- Going to your build directory.
```
$ cd build
```
- In the build folder run the following command to build the code
```
$ cmake .. -DCMAKE_Fortran_COMPILER="gfortran"
$ make
```
.PHONY: all
all: dtu_we_controller dtu_we_controller_bladed flap_controller_cyclic flap_controller_individual_aep_u_f
.PHONY: dtu_we_controller
dtu_we_controller:
make -C dtu_we_controller
.PHONY: dtu_we_controller_bladed
dtu_we_controller_bladed:
make -C dtu_we_controller_bladed
.PHONY: flap_controller_cyclic
flap_controller_cyclic:
make -C flap_controller_cyclic
.PHONY: flap_controller_individual_aep_u_f
flap_controller_individual_aep_u_f:
make -C flap_controller_individual_aep_u_f
.PHONY: clean
clean:
make -C dtu_we_controller clean
make -C dtu_we_controller_bladed clean
make -C flap_controller_cyclic clean
make -C flap_controller_individual_aep_u_f clean
\ No newline at end of file
MODULE BuildInfo
IMPLICIT NONE
!
type tbuildinfo
character*255 :: git_tag = ""
character*255 :: builder = ""
character*255 :: computer_name = ""
character*255 :: build_time = ""
character*255 :: build_date = ""
end type
!
CONTAINS
!
SUBROUTINE BuildInfo_initialise(b)
type (tbuildinfo) :: b
!
include 'version.inc'
END SUBROUTINE
!
SUBROUTINE BuildInfo_echo(b,fin)
type (tbuildinfo) :: b
integer, optional :: fin
integer :: fid
!
if (present(fin)) then
fid = fin
else
fid = 6 ! use stdout if not specified in input
endif
!
WRITE(fid,*) "***********************************************************************"
WRITE(fid,*) "* Build information for HAWC2MB.exe (GIT)"
!DEC$ IF DEFINED(_WIN32)
!DEC$ IF DEFINED(_M_X64)
WRITE(fid,*) "* WINDOWS 64-bit"
!DEC$ ELSE
WRITE(fid,*) "* WINDOWS 32-bit"
!DEC$ ENDIF
!DEC$ ENDIF
!DEC$ IF DEFINED(_DEBUG)
WRITE(fid,*) "* DEBUG version"
!DEC$ ENDIF
!DEC$ IF DEFINED(CLUSTER)
WRITE(fid,*) "* CLUSTER version"
!DEC$ ENDIF
WRITE(fid,*) "***********************************************************************"
WRITE(fid,*) "* GIT-TAG = ", trim(b%git_tag)
WRITE(fid,*) "* BUILDER = ", trim(b%builder)
WRITE(fid,*) "* COMPUTER_NAME = ", trim(b%computer_name)
WRITE(fid,*) "* BUILD_TIME = ", trim(b%build_time)
WRITE(fid,*) "* BUILD_DATE = ", trim(b%build_date)
WRITE(fid,*) "***********************************************************************"
!
END SUBROUTINE
!
END MODULE
# Set the project name
project(dtu_we_controller LANGUAGES Fortran)
message("Configuring Subproject: " ${PROJECT_NAME})
message("Root Directory is: " ${ROOT_DIR})
# set source code
set(SRC_DIR ${CMAKE_CURRENT_SOURCE_DIR})
set(DTUWEC_SRC_DIR ${SRC_DIR})
# set(SRC ${DTUWEC_SRC_DIR}/dtu_we_controller_fcns.f90
# turbine_controller.f90
# safety_system.f90
# )
file(GLOB_RECURSE MODSRC "${ROOT_DIR}/src/modules/global_constants.f90"
"${ROOT_DIR}/src/modules/global_variables.f90"
"${ROOT_DIR}/src/modules/misc_mod.f90"
"${ROOT_DIR}/src/modules/user_defined_types.f90")
file(GLOB_RECURSE SRC "${SRC_DIR}/dtu_we_controller.f90"
"${SRC_DIR}/dtu_we_controller_fcns.f90"
"${SRC_DIR}/turbine_controller.f90"
"${SRC_DIR}/safety_system.f90"
)
list (APPEND SRC ${MODSRC})
# add_library(turbine_controller_lib
# ${MODSRC}
# dtu_we_controller_fcns.f90
# turbine_controller.f90
# safety_system.f90
# )
# target_compile_options(turbine_controller_lib PRIVATE
# -cpp;
# -fcray-pointer;
# -ffree-form;
# -ffree-line-length-none;
# )
include(${ROOT_DIR}/utils/cmake/CMakeLists.txt)
message("Including the utils: " "${ROOT_DIR}/utils/cmake/CMakeLists.txt")
# target_link_libraries(${PROJECT_NAME} turbine_controller_lib)
include ../config.mk
.PHONY: all
all: dtu_we_controller
.PHONY: clean
clean:
rm -f dtu_we_controller.so *.mod *.o
.PHONY: dtu_we_controller
dtu_we_controller: dtu_we_controller.so
dtu_we_controller.o: dtu_we_controller_fcns.o turbine_controller.o safety_system.o write_version.o
dtu_we_controller_fcns.o: misc_mod.o
dtu_we_controller.so: dtu_we_controller.o dtu_we_controller_fcns.o turbine_controller.o safety_system.o write_version.o misc_mod.o
$(FC) $(LFLAGS) $^ -o $@
LIBRARY dtu_we_controller.dll
EXPORTS
init_regulation
init_regulation_advanced
update_regulation
module dtu_we_controller
! program dtu_we_controller
!
! Main module of the Basic DTU Wind Energy Controller. Interface for HAWC2.
!
use dtu_we_controller_fcns
use turbine_controller_mod
! use dtu_we_controller_fcns
use BuildInfo
use safety_system_mod
use write_version_mod
use dll_utils
use iso_c_binding
! use misc_mod
implicit none
! integer CtrlStatus
......@@ -17,6 +20,7 @@ contains
subroutine init_regulation(array1, array2) bind(c, name='init_regulation')
!DEC$ IF .NOT. DEFINED(__LINUX__)
!DEC$ ATTRIBUTES DLLEXPORT :: init_regulation
!GCC$ ATTRIBUTES DLLEXPORT :: init_regulation
!DEC$ END IF
real(mk), dimension(100), intent(inout) :: array1
real(mk), dimension(1), intent(inout) :: array2
......@@ -25,8 +29,9 @@ subroutine init_regulation(array1, array2) bind(c, name='init_regulation')
character(len=32) text32
real(mk) minimum_pitch_angle
logical findes
call write_textversion
write(6, *) trim(adjustl(TextVersion))
call echo_version()
! Input array1 must contain
! Overall parameters
! constant 1 ; Rated power [kW]
......@@ -297,6 +302,7 @@ subroutine init_regulation_advanced(array1, array2) bind(c,name='init_regulation
use dtu_we_controller_fcns
!DEC$ IF .NOT. DEFINED(__LINUX__)
!DEC$ ATTRIBUTES DLLEXPORT::init_regulation_advanced
!GCC$ ATTRIBUTES DLLEXPORT::init_regulation_advanced
!DEC$ END IF
real(mk), dimension(100), intent(inout) :: array1
real(mk), dimension(1) , intent(inout) :: array2
......@@ -308,7 +314,8 @@ subroutine init_regulation_advanced(array1, array2) bind(c,name='init_regulation
! character(128) :: fullName = ''
! character(50),dimension(3) :: strMsg
logical :: err = .false.
logical :: DEBUG_Flag = .true.
logical :: DEBUG_Flag = .false.
integer(C_INTPTR_T) :: pdll
! integer :: iostatus
! character(len=:), allocatable, dimension(3) :: strMsg
! real(mk), pointer :: p1=>null();
......@@ -325,12 +332,12 @@ subroutine init_regulation_advanced(array1, array2) bind(c,name='init_regulation
! constant 60 ; Damping of notch filter [-] (Default 0.01 used if zero)
! constant 61 ; Phase lag of damper [s] => max 40*dt (Default 0 used if zero)
! Fore-aft Tower mode damper
! constant 62 ; Frequency of BP filter [Hz] (Default 10 used if zero)\\
! constant 63 ; Frequency of notch fiter [Hz] (Default 10 used if zero)\\
! constant 64 ; Damping of BP filter [-] (Default 0.02 used if zero)\\
! constant 65 ; Damping of notch filter [-] (Default 0.01 used if zero)\\
! constant 66 ; Gain of damper [-] (Default 0 used if zero)\\
! constant 67 ; Phase lag of damper [s] => max 40*dt (Default 0 used if zero)\\
! constant 62 ; Frequency of BP filter [Hz] (Default 10 used if zero)
! constant 63 ; Frequency of notch fiter [Hz] (Default 10 used if zero)
! constant 64 ; Damping of BP filter [-] (Default 0.02 used if zero)
! constant 65 ; Damping of notch filter [-] (Default 0.01 used if zero)
! constant 66 ; Gain of damper [-] (Default 0 used if zero)
! constant 67 ; Phase lag of damper [s] => max 40*dt (Default 0 used if zero)
! constant 68 ; Time constant of 1st order filter on PWR used for fore-aft Tower mode damper GS [Hz] (Default 10 used if zero)
! constant 69 ; Lower PWR limit used for fore-aft Tower mode damper GS [-] (Default 0 used if zero)
! constant 70 ; Upper PWR limit used for fore-aft Tower mode damper GS [-] (Default 0 used if zero)
......@@ -502,7 +509,6 @@ subroutine init_regulation_advanced(array1, array2) bind(c,name='init_regulation
call readAdditionalCtrlParameter(pAdditionalCtrlParamFile,downRegulationData,CpData,err)
if(err) then
close(pAdditionalCtrlParamFile%fileID)
! close(controllerOutput%fileID)
stop
else
close(pAdditionalCtrlParamFile%fileID)
......@@ -511,10 +517,16 @@ subroutine init_regulation_advanced(array1, array2) bind(c,name='init_regulation
endif
! This is only for debugging
write(6,*) "Type2_dll initialization is successed!!"
write(6,*) "Controller dll initialization is successed!!"
if(DEBUG_Flag) then
write(*,*) array1(100)
write(*,*) "Press 'c' to continue, 'q' to Quit the code."
! pdll = loaddll('./control/cyclic_pitch_controller.dll',0)
! if(pdll == 0) then
! write(*,*) " DLL NOT loaded. "
! endif
write(*,*) "Press 'c' to continue the simulation, 'q' to Quit the simulation."
read(*,*) str
if(str == 'q') then
stop
......@@ -526,10 +538,11 @@ subroutine init_regulation_advanced(array1, array2) bind(c,name='init_regulation
return
end subroutine init_regulation_advanced
!**************************************************************************************************
subroutine initstring(istring)
implicit none
subroutine initstring(istring) bind(c,name='initstring')
! implicit none
!DEC$ IF .NOT. DEFINED(__LINUX__)
!DEC$ ATTRIBUTES DLLEXPORT, C, ALIAS:'initstring'::initstring
!DEC$ ATTRIBUTES DLLEXPORT :: initstring
!GCC$ ATTRIBUTES DLLEXPORT :: initstring
!DEC$ END IF
! Declare the subroutine input arguments
integer(1) :: istring(*)
......@@ -550,7 +563,7 @@ end subroutine initstring
!**************************************************************************************************
subroutine update_regulation(array1, array2) bind(c,name='update_regulation')
!
use turbine_controller_mod
! Controller interface.
! - sets DLL inputs/outputs.
! - sets controller timers.
......@@ -558,6 +571,7 @@ subroutine update_regulation(array1, array2) bind(c,name='update_regulation')
!
!DEC$ IF .NOT. DEFINED(__LINUX__)
!DEC$ ATTRIBUTES DLLEXPORT :: update_regulation
!GCC$ ATTRIBUTES DLLEXPORT :: update_regulation
!DEC$ END IF
real(mk), dimension(100), intent(inout) :: array1
real(mk), dimension(100), intent(inout) :: array2
......@@ -569,13 +583,13 @@ subroutine update_regulation(array1, array2) bind(c,name='update_regulation')
! 4: constraint bearing2 pitch2 1 only 1 [rad]
! 5: constraint bearing2 pitch3 1 only 1 [rad]
! 6-8: wind free_wind 1 0.0 0.0 hub height [m/s] global coords at hub height
! 9: elec. power ; [W]
! 10: grid flag ; [1=no grid,0=grid]
! 11: Tower top x-acceleration ; [m/s^2]
! 12: Tower top y-acceleration ; [m/s^2]
! 13: dll type2_dll individual_pitch_controller inpvec 1;
! 14: dll type2_dll individual_pitch_controller inpvec 2;
! 15: dll type2_dll individual_pitch_controller inpvec 3;
! 9: elec. power ; [W]
! 10: grid flag ; [1=no grid,0=grid]
! 11: Tower top x-acceleration ; [m/s^2]
! 12: Tower top y-acceleration ; [m/s^2]
! 13: dll type2_dll individual_pitch_controller inpvec 1; [rad] only needed if using individual pitch control
! 14: dll type2_dll individual_pitch_controller inpvec 2; [rad] only needed if using individual pitch control
! 15: dll type2_dll individual_pitch_controller inpvec 3; [rad] only needed if using individual pitch control
!
! Output array2 contains
!
......@@ -619,7 +633,7 @@ subroutine update_regulation(array1, array2) bind(c,name='update_regulation')
! 39: Power coefficient at the derated operational point [-]
! Local variables
integer GridFlag, EmergPitchStop, ActiveMechBrake
integer GridFlag, EmergPitchStop, ActiveMechBrake
real(mk) GenSpeed, wsp, PitchVect(3), Pe, TT_acc(2), time
real(mk) ipc_pitch(3);
EmergPitchStop = 0
......@@ -629,7 +643,6 @@ subroutine update_regulation(array1, array2) bind(c,name='update_regulation')
!***********************************************************************************************
! Increment time step (may actually not be necessary in type2 DLLs)
!***********************************************************************************************
!somehow the controller gets called twice in the very first time step...
! if ((time==deltat).AND. (repeated==.FALSE.)) then
! time_old=0.0_mk
! repeated=.TRUE.
......@@ -664,7 +677,7 @@ subroutine update_regulation(array1, array2) bind(c,name='update_regulation')
TT_acc(1) = array1(11)
TT_acc(2) = array1(12)
!
! cyclic pitch angles ref. signal read in from individual pitch controller type2dll
! individual pitch angles ref. signal read in from individual pitch controller type2dll
ipc_pitch(1:3) = array1(13:15)
!***********************************************************************************************
! Safety system
......@@ -700,13 +713,14 @@ subroutine update_regulation(array1, array2) bind(c,name='update_regulation')
!***********************************************************************************************
! Output
!***********************************************************************************************
array2( 1) = GenTorqueRef/GearRatio ! 1: Generator torque reference [Nm]
array2( 2) = PitchColRef + ipc_pitch(1) ! 2: Pitch angle reference of blade 1 [rad]
array2( 3) = PitchColRef + ipc_pitch(2) ! 3: Pitch angle reference of blade 2 [rad]
array2( 4) = PitchColRef + ipc_pitch(3) ! 4: Pitch angle reference of blade 3 [rad]
!array2( 2) = PitchColRef ! 2: Pitch angle reference of blade 1 [rad]
!array2( 3) = PitchColRef ! 3: Pitch angle reference of blade 2 [rad]
!array2( 4) = PitchColRef ! 4: Pitch angle reference of blade 3 [rad]
!array2( 2) = PitchColRef ! 2: Pitch angle reference of blade 1 [rad]
!array2( 3) = PitchColRef ! 3: Pitch angle reference of blade 2 [rad]
!array2( 4) = PitchColRef ! 4: Pitch angle reference of blade 3 [rad]
array2( 5) = dump_array(1) ! 5: Power reference [W]
array2( 6) = dump_array(2) ! 6: Filtered wind speed [m/s]
array2( 7) = dump_array(3) ! 7: Filtered rotor speed [rad/s]
......
//Signatures from Module dtu_we_controller_mod
//subroutine init_regulation(array1, array2) bind(c, name='init_regulation')
void init_regulation(double* array1, double* array2);
//subroutine init_regulation_advanced(array1, array2) bind(c,name='init_regulation_advanced')
void init_regulation_advanced(double* array1, double* array2);
//subroutine update_regulation(array1, array2) bind(c,name='update_regulation')
void update_regulation(double* array1, double* array2);
......@@ -11,7 +11,7 @@
<Tool Name="VFMidlTool" SuppressStartupBanner="true"/>
<Tool Name="VFCustomBuildTool"/>
<Tool Name="VFPreLinkEventTool"/>
<Tool Name="VFPreBuildEventTool" CommandLine="version.bat"/>
<Tool Name="VFPreBuildEventTool"/>
<Tool Name="VFPostBuildEventTool" CommandLine="del &quot;$(ProjectDir)$(OutDir)\version.res&quot;"/>
<Tool Name="VFManifestTool" SuppressStartupBanner="true"/></Configuration>
<Configuration Name="Release|Win32" OutputDirectory="$(PlatformName)\$(ConfigurationName)" IntermediateDirectory="$(PlatformName)\$(ConfigurationName)" DeleteExtensionsOnClean="*.cod;*__genmod.*;*.obj;*.mod;*.pdb;*.asm;*.lst;*.map;*.dyn;*.dpi;*.tmp;*.log;*.ilk;*.exe;*.lib;$(TargetPath);*.htm" ConfigurationType="typeDynamicLibrary">
......
......@@ -85,7 +85,8 @@ end function
!**************************************************************************************************
function PID(stepno, dt, kgain, PIDvar, error)
! PID controller with one input.
! PID controller with one input. Used for generator torque controller and
! tower fore-aft damper
integer stepno
real(mk) PID, dt, kgain(3), error
type(Tpidvar) PIDvar
......@@ -231,6 +232,22 @@ subroutine damper(stepno, dt, x, filters, y, x_filt)
end subroutine damper
!**************************************************************************************************
!**************************************************************************************************
subroutine damper_twr(stepno, dt, x, filters, y, x_filt)
! Tower fore-aft damper based on notch filter, and a gain.
type(Tdamper), intent(in) :: filters
integer stepno
real(mk), intent(in) :: x
real(mk), intent(out) :: y, x_filt
real(mk) dt
! x_filt = bandpassfilt(dt, stepno, filters%bandpass, x)
x_filt = notch2orderfilt(dt, stepno, filters%notch, x)
! x_filt = timedelay(dt, stepno, filters%delay, filters%Td, x_filt)
y = filters%gain*x_filt
end subroutine damper_twr
!**************************************************************************************************
subroutine writeErrorMsg(controlDataFile,message)
Type (TcontrolFile), pointer :: controlDataFile
character*(*), dimension(3), intent(in) :: message
......@@ -371,7 +388,7 @@ subroutine getwords(line,words,controlDataFile)
cont=.false.
do while (cont==.false.)
do while (cont.eqv..false.)
cont=.true.
words%wordArray(:)=''
line=trim(adjustl(line))
......@@ -381,7 +398,7 @@ subroutine getwords(line,words,controlDataFile)
out=.false.
if (endp>1) then
do while (out==.false.)
do while (out.eqv..false.)
blankpos=index(line(first:endp),blank)
tabpos =index(line(first:endp),tab)
commapos=index(line(first:endp),comma)
......@@ -473,64 +490,67 @@ subroutine getwords(line,words,controlDataFile)
return
end subroutine getwords
!**************************************************************************************************
subroutine type2_dll_input(ctrl_input_file,outvec) bind(c, name='type2_dll_input')
!DEC$ IF .NOT. DEFINED(__LINUX__)
!DEC$ ATTRIBUTES DLLEXPORT :: type2_dll_input
!DEC$ END IF
! passed in variables
type(TcontrolFile), pointer :: ctrl_input_file
Real*8, dimension(:), intent(out) :: outvec
! loacl variables
Type (Tline) :: line
Type (Tword) :: words