Commit ee92e08e authored by famen's avatar famen
Browse files

implemented a interface to the C code controller used in the DHI Lab FoWT test;

updated the submodule utils hash code to the latest master
add build folder to the git ignore list.
parent e6160f57
Pipeline #22437 passed with stage
in 3 minutes and 56 seconds
......@@ -11,3 +11,5 @@ __pycache__/
/src/dtu_we_controller/Win32
/src/dtu_we_controller_bladed/Win32
/version.h
build_vs17/
build_DHI_vs17/
......@@ -6,6 +6,7 @@ The scope of this project is to provide an open-source open-access controller th
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).
A Working in progress (WIP) version of the user manual can be found [here](https://gitlab.windenergy.dtu.dk/OpenLAC/BasicDTUControllerReport):
## Compatibility
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.
......@@ -28,15 +29,15 @@ $ git submodule update --init --recursive
## Compilation
### Windows: Visual Studio 2019 only + Intel Fortran (WIP)
### Windows: Visual Studio 2017/2019 + Intel Fortran compiler (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
- Install Microsoft Visual Studio Community 2017 or 2019 and Intel Parallel Studio XE 2019 Update 5 Composer Edition for Fortran Windows Integration for Microsoft Visual Studio
- A pre generated Visual Studio Solution file (*.sln) will be provided in the future.
### Windows: Visual Studio 2019 with CMake + Intel Fortran
### Windows: Visual Studio 2017/2019 with CMake + Intel Fortran compiler
- 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 Microsoft Visual Studio Community 2017 or 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\)
......@@ -47,16 +48,25 @@ $ git submodule update --init --recursive
```
>> cd build
```
- For 32-bit, in build folder run (make sure cmake command is inside your user environment PATH):
- For Visual Studio 2019, 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:
- For Visual Studio 2019, 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;
- For Visual Studio 2017, 32-bit, in build folder run (make sure cmake command is inside your user environment PATH):
```
>> cmake .. -G "Visual Studio 15 2017" -A Win32
```
- For Visual Studio 2017, 64-bit, in build folder run:
```
>> cmake .. -G "Visual Studio 15 2017" -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 the generated solution file (DTUWEC.sln) with you Visual Studio IDE and build the projects as usual;
```
devenv DTUWEC.sln /Build
```
......
......@@ -4,6 +4,7 @@
solvertype 1; (newmark)
on_no_convergence continue;
convergence_limits 1000 1 1e-07;
logfile ./log/DTU_10MW_RWT.log;
begin newmark;
deltat 0.01;
end newmark;
......@@ -360,13 +361,16 @@
;
begin type2_dll;
name dtu_we_controller;
filename ./dtu_we_controller.dll;
dll_subroutine_init init_regulation_advanced;
filename C:\Users\famen\repos_BasicDTUController\build_DHI_vs17\src\dtu_we_controller\Debug\dtu_we_controller.dll;
; filename ./dtu_we_controller.dll;
; dll_subroutine_init init_regulation_advanced;
dll_subroutine_init init_external_ctrl_dll;
dll_subroutine_update update_regulation;
arraysizes_init 100 1;
arraysizes_update 100 100;
; used in down regulation control strategies and wind speed estimation
init_string ./control/additional_control_parameters.txt;
; used in down regulation control strategies, wind speed estimation or 3rd party controller dll
; init_string ./control/additional_control_parameters.txt;
init_string ./control/libFloatStep_DHI_FoWTCtrl.dll;
begin init;
; Overall parameters
constant 1 10000; Rated power [kW]
......@@ -466,7 +470,7 @@
constant 73 0; Max low-pass filtered tower top acceleration level before initiating safety system alarm (shut-down) [m/s^2] (Default 1.1 x input 46 used if zero)
constant 74 0; Time constant of 1st order filter on tower top acceleration [1/1P] (Default 1 used if zero)
; Pitch deviation monitor parameters
constant 75 1005020; Parameters for pitch deviation monitoring. The format is 1,nnn,mmm
constant 75 0; Parameters for pitch deviation monitoring. The format is 1,nnn,mmm
; where 'nnn' [s] is the period of the moving average and 'mmm' is threshold of the deviation [0.1 deg] (functionality is inactive if value $<$ 1,000,000)
; Gear ratio
constant 76 0; Gear ratio used for the calculation of the LSS rotational speeds and the HSS generator torque reference [-] (Default 1 if zero)
......@@ -477,6 +481,22 @@
constant 79 0; Derate strategy. 0 = No Derating, 1 = constant rotation, 2 = max rotation 3 = min ct
constant 80 100; Derate percentage (eg. 70 means 70% of nominal power
constant 81 0.0; Moment of inertia of the rotor
; Floating additional control loop
constant 82 11.4; Rated wind speed (Only used when constant 79 = 3 OR constant 95 = 0)
constant 83 1.0; Gain for the loop mapping from tower velocity to blade pitch [rad/(m/s)]
constant 84 0.0; Gain for the loop mapping from tower velocity to GenTorque [Nm/(m/s)]
constant 85 10.0; Time to switch on the floating control loop [s]
constant 86 0.0; Frequency of LP filter [Hz] (Default 0 if filter not used)
constant 87 0.7; Damping ratio of LP filter [-]
constant 88 0.0; Frequency of BP filter [Hz] (Default 0 if filter not used)
constant 89 0.02; Damping ratio of BP filter [-] (Default 0.02)
constant 90 0.0; Time constant of BP filter [s] (Default 0)
cosntant 91 0.0; Coefficient of linear term in gain scheduling for tower-pitch loop, KK1 [1/(m/s)];
; Kgain * (1 + KK1 *abs(WSPfilt - WSPrated) + KK2 * abs(WSPfilt - WSPrated)**2)
constant 92 0.0; Coefficient of quadratic term in gain scheduling for tower-pitch loop, KK2 [1/(m/s)^2];
cosntant 93 0.0; Coefficient of linear term in gain scheduling for tower-genTorq loop, KK1 [1/(m/s)];
constant 94 0.0; Coefficient of quadratic term in gain scheduling for tower-genTorq loop, KK2 [1/(m/s)^2];
constant 95 1.0; Choice of gain-scheduling variable (0: WSPfilt, 1:Pitch angle (Default))
end init;
;
begin output;
......@@ -488,8 +508,12 @@
wind free_wind 1 0 0 -119; Global coordinates at hub height
dll inpvec 2 2; Elec. power from generator servo .dll
dll inpvec 2 8; Grid state flag from generator servo .dll
mbdy state acc towertop 1 1 global only 1; Tower top x-acceleration [m/s^2]
mbdy state acc towertop 1 1 global only 2; Tower top y-acceleration [m/s^2]
mbdy state acc towertop 1 1 global only 2; Tower top x-acceleration [m/s^2]
mbdy state acc towertop 1 1 global only 1; Tower top y-acceleration [m/s^2]
general constant 0; IPC
general constant 0; IPC
general constant 0; IPC
mbdy state vel towertop 1 1 global only 2;
end output;
end type2_dll;
;
......@@ -608,7 +632,7 @@
;----------------------------------------------------------------------------------------------------------------------------------------------------------------
;
begin output;
filename ./tmp/minimal;
filename ./res/DTU_10MW_RWT;
data_format hawc_binary;
buffer 1;
;
......@@ -633,10 +657,10 @@
mbdy momentvec blade2 13 1 local # blade 2 50% local e coo;
mbdy momentvec blade3 13 1 local # blade 3 50% local e coo;
; Displacements and accellerations
mbdy state pos tower 10 1 global only 1 # tower top fa displ;
mbdy state pos tower 10 1 global only 2 # tower top ss displ;
mbdy state acc tower 10 1 global only 1 # tower top fa acc;
mbdy state acc tower 10 1 global only 2 # tower top ss acc;
mbdy state pos tower 10 1 global only 2 # tower top fa displ;
mbdy state pos tower 10 1 global only 1 # tower top ss displ;
mbdy state acc tower 10 1 global only 2 # tower top fa acc;
mbdy state acc tower 10 1 global only 1 # tower top ss acc;
;
mbdy state pos blade1 26 1 blade1 # blade 1 tip pos;
mbdy state pos blade2 26 1 blade2 # blade 2 tip pos;
......@@ -697,6 +721,14 @@
dll inpvec 4 3 # pitch 3 [rad];
; Check tower clearence
dll inpvec 5 1 # bltip tow min d [m];
; Tower fore-aft velocity
mbdy state vel towertop 1 1 global only 2 # tower top fa vel;
; Floating
mbdy state vel towertop 1 1 global only 2 # tower top fa vel;
dll inpvec 1 45 # switch factor;
dll inpvec 1 46 # filtered tower-top fore-aft velocity;
dll inpvec 1 47 # GenTorq from the floating loop;
dll inpvec 1 48 # Pitch from the floating loop;
end output;
;
exit;
\ No newline at end of file
......@@ -17,6 +17,7 @@ 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"
"${SRC_DIR}/floating_controller.f90"
)
list (APPEND SRC ${MODSRC})
......
This diff is collapsed.
......@@ -1162,7 +1162,7 @@ function AeroTorqEstimator( GenTorqueRef, GenSpeed, WindEstvar,deltat)
WindEstvar%est_Qa = est_Qa
return
end function AeroTorqEstimator
!
function GradDesc(estQ, GenSpeed, PitchMean, WindEstvar,Cptable)
! In the current version, gearbox ratio is omitted
implicit none
......
module floating_controller_mod
!
! Module contains functions for floating controller used by DTU Wind Energy Controller
!
use user_defined_types
use global_variables
use misc_mod
implicit none
!**************************************************************************************************
contains
!**************************************************************************************************
! (TO-DO)function tower_velocity_calcuation()
!
!
!
subroutine floating_controller(CtrlStatus, time, Floatingvar, TTfa_vel, wsp, Pitch_addition, GenTorque_addition,dump_array)
implicit none
real(mk) switchfactor, TTfa_vel_filt, y(2), WSPfilt, GSvar
real(mk), intent(in) :: TTfa_vel, wsp , time
real(mk), intent(out):: Pitch_addition, GenTorque_addition
real(mk) :: region
type(TFloatingvar), intent(inout) :: Floatingvar
integer, intent(in) :: CtrlStatus
real(mk), intent(in) :: dump_array(50)
!******************
! switching
!******************
switchingvar%tau = 5.0_mk ! turning on the floating loop gradually
if (CtrlStatus.eq.0 .and. time .gt. Floatingvar%time_on) then
switchfactor=1.d0
else
switchfactor=0.d0
endif
Floatingvar%switchfactor=lowpass1orderfilt(deltat,stepno,switchingvar,switchfactor)
!!******************
! filtering tower signal
!!! Low-pass filter
if (float2orderlpfvar%f0 .gt. 0) then
y = lowpass2orderfilt(deltat, stepno, float2orderlpfvar, TTfa_vel)
else
y = TTfa_vel
endif
!!! Band-pass filter
if (float2orderbpfvar%f0 .gt.0) then
y = bandpassfilt(deltat, stepno, float2orderbpfvar, TTfa_vel)
else
y = TTfa_vel
endif
TTfa_vel_filt = y(1)
!!******************
! filterd wind speed for gain-scheduling
WSPfilt = lowpass1orderfilt(deltat, stepno, wspfirstordervar, wsp)
if (Floatingvar%GSmode .gt. 0.0_mk) then
Floatingvar%GSvar = abs(WSPfilt - Floatingvar%RatedWindSpeed)
else
Floatingvar%GSvar = PitchColRef
endif
!!******************
! Main Loop
! Tower-pitch loop
if ((abs(Floatingvar%TPgain) .gt. 0.0_mk).and.(time.gt.20.0_mk)) then
region = switchfactor*dump_array(10)
call towerV_pitch(Pitch_addition,TTfa_vel_filt*region,Floatingvar) ! only active in above-rated
endif
! Tower-genTorq loop
if ((abs(Floatingvar%TGgain) .gt. 0.0_mk).and.(time.gt.20.0_mk)) then
region = switchfactor*dump_array(10)
call towerV_genTorq(GenTorque_addition,TTfa_vel_filt*region,Floatingvar)
endif
! for output
Floatingvar%switchfactor = switchfactor
Floatingvar%TTfa_vel_filt = TTfa_vel_filt
end subroutine floating_controller
!
! additional loop maping the tower fore-aft velocity to pitch
subroutine towerV_pitch(Pitch_addition,TTfa_vel,Floatingvar)
implicit none
real(mk), intent(in) :: TTfa_vel
real(mk), intent(inout) :: Pitch_addition
type(TFloatingvar), intent(in) :: Floatingvar
real(mk) :: GSvar, GSvalue
! main
GSvar = Floatingvar%GSvar
GSvalue = 1+Floatingvar%KK1_tp*GSvar + Floatingvar%KK2_tp*GSvar**2
Pitch_addition = Floatingvar%TPgain*GSvalue*TTfa_vel
return
end subroutine towerV_pitch
! additional loop maping the tower fore-aft velocity to genTorque
subroutine towerV_genTorq(GenTorque_addition,TTfa_vel,Floatingvar)
implicit none
real(mk), intent(in) :: TTfa_vel
real(mk), intent(inout) :: GenTorque_addition
type(TFloatingvar), intent(in) :: Floatingvar
real(mk) :: GSvar, GSvalue
! main
GSvar = Floatingvar%GSvar
GSvalue = 1+Floatingvar%KK1_tq*GSvar + Floatingvar%KK2_tq*GSvar**2
GenTorque_addition = Floatingvar%TGgain *GSvalue * TTfa_vel
return
end subroutine towerV_genTorq
end module floating_controller_mod
......@@ -145,7 +145,7 @@ subroutine normal_operation(GenSpeed, PitchVect, wsp, Pe, TTfa_acc, GenTorqueRef
x = switch_spline(P_filt, TTfa_PWR_lower*PeRated, TTfa_PWR_upper*PeRated)
PitchColRef = min(max(PitchColRef + theta_dam_ref*x, PID_pit_var%outmin), PID_pit_var%outmax)
! call log_info('pitch_twr_damper-ref: ',theta_dam_ref)
!
!***********************************************************************************************
! Calculate the estimated aerodynamic torque
!***********************************************************************************************
......@@ -813,7 +813,7 @@ subroutine pitchcontroller(GenSpeedFilt, dGenSpeed_dtFilt, PitchMeanFilt, PeFilt
! Gainscheduling according to dQaero/dOmega
aero_damp = 1.0_mk + PitchGSVar%invkk1_speed*PitchMeanFilt + &
PitchGSVar%invkk2_speed*PitchMeanFilt**2
PID_pit_var%kpro(1) = PID_pit_var%kpro(1) + PitchGSVar%kp_speed*aero_damp
PID_pit_var%kpro(1) = PID_pit_var%kpro_init(1) + PitchGSVar%kp_speed*aero_damp
!-----------------------------------------------------------------------------------------------
! Compute PID feedback to pitch demand
!-----------------------------------------------------------------------------------------------
......@@ -872,7 +872,7 @@ subroutine individualpitchcontroller(GenSpeedFilt, dGenSpeed_dtFilt, PitchMeanFi
! Gainscheduling according to dQaero/dOmega
aero_damp = 1.0_mk + PitchGSVar%invkk1_speed*PitchMeanFilt + &
PitchGSVar%invkk2_speed*PitchMeanFilt**2
PID_pit_var%kpro(1) = PID_pit_var%kpro(1) + PitchGSVar%kp_speed*aero_damp
PID_pit_var%kpro(1) = PID_pit_var%kpro_init(1) + PitchGSVar%kp_speed*aero_damp
!-----------------------------------------------------------------------------------------------
! Compute PID feedback to pitch demand
!-----------------------------------------------------------------------------------------------
......
......@@ -20,6 +20,7 @@ file(GLOB_RECURSE SRC "${BLADED_INTERFACE_SRC_DIR}/dtu_we_controller_bladed.f90"
"${DTUWEC_SRC_DIR}/dtu_we_controller_fcns.f90"
"${DTUWEC_SRC_DIR}/turbine_controller.f90"
"${DTUWEC_SRC_DIR}/safety_system.f90"
"${DTUWEC_SRC_DIR}/floating_controller.f90"
)
list (APPEND SRC ${MODSRC})
......
......@@ -48,6 +48,8 @@ module global_variables
integer :: CountPitchDeviation=0
real(mk) :: lambdaAtMinCt = 0.0_mk, pitchAtMinCt = 0.0_mk, minCt = 0.0_mk
real(mk) :: CpAtMinCt = 0.0_mk
real(mk) :: GenTorque_addition = 0.0_mk
real(mk) :: Pitch_addition = 0.0_mk
!
! Variables with user defined Types
!
......@@ -72,6 +74,12 @@ module global_variables
type(TWindEstvar), save :: WindEstvar
type(Twpdata), save :: OPdatavar
type(Texclzone), save :: ExcluZone
!
! Define variables for floating control
type(TFloatingvar), save :: Floatingvar
type(Tfirstordervar), save :: switchingvar
type(Tlowpass2order), save :: float2orderlpfvar
type(Tbandpassfilt), save :: float2orderbpfvar
! defined global variables for down regulation control strategy
type(TdownRegulationData), save :: downRegulationData
......@@ -81,6 +89,9 @@ module global_variables
type(TCpData), save :: CpData
type(TcontrolFile), pointer :: pCtrlInputFile
! define global avariables for external 3rd party DLLs
Type (Tdll), save :: external_dll
!**************************************************************************************************
end module global_variables
......
module user_defined_types
use global_constants
use iso_c_binding
implicit none
! =============================================================================
......@@ -51,7 +52,7 @@ module user_defined_types
! Blade pitch PID data type
type Tpid2var
real(mk) Kpro(2),Kdif(2),Kint(2),outmin,outmax,velmax,error1(2),outset1,outres1
real(mk) Kpro(2),Kdif(2),Kint(2),outmin,outmax,velmax,error1(2),outset1,outres1, Kpro_init(2)
integer :: stepno1 = 0
real(mk) outset,outpro,outdif,error1_old(2),outset1_old,outres1_old,outres
end type Tpid2var
......@@ -102,6 +103,22 @@ module user_defined_types
type TWindEstvar
real(mk) :: J, est_Qa , sum_err, xhat ,P , Q , R, Kp, Ki, radius
end type
! Floating
type TFloatingvar
real(mk) :: TPgain = 0.0_mk
real(mk) :: TGgain = 0.0_mk
real(mk) :: time_on = 0.0_mk
real(mk) :: KK1_tp = 0.0_mk ! gain-scheduling for tower-pitch loop
real(mk) :: KK2_tp = 0.0_mk
real(mk) :: KK1_tq = 0.0_mk ! gain-scheduling for tower-genTorq loop
real(mk) :: KK2_tq = 0.0_mk
real(mk) :: RatedWindSpeed = 11.4_mk
real(mk) :: GSmode = 1.0_mk
real(mk) :: GSvar = 0.0_mk
real(mk) :: switchfactor = 0.0_mk
real(mk) :: TTfa_vel_filt = 0.0_mk
end type
! MIN CT control data type
type TdownRegulationData
......@@ -177,4 +194,28 @@ module user_defined_types
integer :: length
end type Tstring
! DLL data type
Type Tdll
integer (C_INTPTR_T) :: p_dll ! integer pointer to DLL
#if defined __GFORTRAN__
type(C_FUNPTR) :: p_func ! integer pointer to DLL subroutine discon
#elif defined __INTEL_COMPILER
integer (C_INTPTR_T) :: p_func ! integer pointer to DLL subroutine discon
#endif
character*256 :: filename=''
character*256 :: infile =''
character*256 :: outfile=''
character*256 :: func_name=''
real(4),dimension(32) :: avrSWAP=0.0 ! The swap array, used to pass data to, and receive data from, the DLL controller.
integer(c_int) :: is_shutdown
integer(c_int) :: hawc2_status
integer :: istep_hawc2
integer :: istep_controller !
real*8 :: aero_power
real*8 :: elec_power
real*8 :: efficiency
real*8 :: time_step = 0.d0 ! time step used in simulation [s]
end Type Tdll
end module user_defined_types
\ No newline at end of file
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment