Commit 00f2ad88 authored by Alan Wai Hou Lio's avatar Alan Wai Hou Lio

spinnar lidar simulator added

parent a5012345
......@@ -373,7 +373,7 @@ begin type2_dll;
dll_subroutine_init init_regulation_advanced;
dll_subroutine_update update_regulation;
arraysizes_init 100 1;
arraysizes_update 100 100;
arraysizes_update 130 100;
begin init;
; Overall parameters
constant 1 10000; Rated power [kW]
......@@ -499,6 +499,26 @@ begin type2_dll;
mbdy state acc towertop 1 1 global only 2; Tower top y-acceleration [m/s^2]
dll inpvec 2 5; Power set-point from Matlab-interface
dll inpvec 2 6; Reset PID [-]
aero nacelle_lidar 0 0 0 30 0 120 18.67 2 100 1;
aero nacelle_lidar 0 0 0 30 18 120 18.67 2 100 2;
aero nacelle_lidar 0 0 0 30 36 120 18.67 2 100 3;
aero nacelle_lidar 0 0 0 30 54 120 18.67 2 100 4;
aero nacelle_lidar 0 0 0 30 72 120 18.67 2 100 5;
aero nacelle_lidar 0 0 0 30 90 120 18.67 2 100 6;
aero nacelle_lidar 0 0 0 30 108 120 18.67 2 100 7;
aero nacelle_lidar 0 0 0 30 126 120 18.67 2 100 8;
aero nacelle_lidar 0 0 0 30 144 120 18.67 2 100 9;
aero nacelle_lidar 0 0 0 30 162 120 18.67 2 100 10;
aero nacelle_lidar 0 0 0 30 180 120 18.67 2 100 11;
aero nacelle_lidar 0 0 0 30 198 120 18.67 2 100 12;
aero nacelle_lidar 0 0 0 30 216 120 18.67 2 100 13;
aero nacelle_lidar 0 0 0 30 234 120 18.67 2 100 14;
aero nacelle_lidar 0 0 0 30 252 120 18.67 2 100 15;
aero nacelle_lidar 0 0 0 30 270 120 18.67 2 100 16;
aero nacelle_lidar 0 0 0 30 288 120 18.67 2 100 17;
aero nacelle_lidar 0 0 0 30 306 120 18.67 2 100 18;
aero nacelle_lidar 0 0 0 30 324 120 18.67 2 100 19;
aero nacelle_lidar 0 0 0 30 342 120 18.67 2 100 20;
end output;
end type2_dll;
; ------------------------------ Matlab-HAWC2 Interface ------------
......@@ -722,8 +742,10 @@ begin output;
; Check tower clearence
dll inpvec 6 1 # Bltip tow min d [m];
; Check new dll signal
dll inpvec 2 5; Power set-point from Matlab-interface
dll inpvec 2 6; Reset PID [-]
dll inpvec 2 5 # Power set-point from Matlab-interface;
dll inpvec 2 6 # Reset PID [-];
dll inpvec 1 46 # spinner_lidar los [m/s];
dll inpvec 1 47 # LOS_num, Nacelle LiDAR Identifier [-];
end output;
;
exit;
......@@ -30,7 +30,7 @@ while time <= Tend
theta2 = 0;
theta3 = 0;
dr_update = dr; % Derate percentage (e.g. 0.7 means 70% of nominal power)
reset_pid = 0;
reset_pid = 1;
%%%%%%%%%%%%%%%%%%% Signals to HAWC2 output %%%%%%%%%%%%%%%%%
ArrayToHawc = zeros(40,1);
......
......@@ -574,7 +574,7 @@ subroutine update_regulation(array1, array2) bind(c,name='update_regulation')
!DEC$ ATTRIBUTES DLLEXPORT :: update_regulation
!GCC$ ATTRIBUTES DLLEXPORT :: update_regulation
!DEC$ END IF
real(mk), dimension(100), intent(inout) :: array1
real(mk), dimension(130), intent(inout) :: array1
real(mk), dimension(100), intent(inout) :: array2
! Input array1 must contain
!
......@@ -590,7 +590,9 @@ subroutine update_regulation(array1, array2) bind(c,name='update_regulation')
! 12: Tower top y-acceleration ; [m/s^2]
! 13: derating of power ; [-]
! 14: reset signal, PID ; [-]
!
! 15-19: Nacelle LiDAR input 1; [m/s]
! 20-24: Nacelle LiDAR input 2; [m/s]
!
! Output array2 contains
!
! 1: Generator torque reference [Nm]
......@@ -633,9 +635,10 @@ 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, counter_lidar = 0, N_beams = 20, LOS_num = 1
real(mk) GenSpeed, wsp, PitchVect(3), Pe, TT_acc(2), time, reset_pid
real(mk) ipc_pitch(3);
real(mk) :: spinnar_lidar_los, Lidar_Ts
EmergPitchStop = 0
ActiveMechBrake = 0
! Global Time from HAWC2
......@@ -726,18 +729,39 @@ subroutine update_regulation(array1, array2) bind(c,name='update_regulation')
PID_pit_var%error1_old = PID_pit_var%error1_old*0.0_mk
PID_pit_var%outset1_old = PID_pit_var%outset1_old*0.0_mk
PID_pit_var%outres1_old = PID_pit_var%outres1_old*0.0_mk
write(6,*) "Resetting PID: reaching 0.0"
! write(6,*) "Resetting PID: reaching 0.0"
endif
!
if (reset_pid .LT. 1.0_mk) then
PID_pit_var%outres = PID_pit_var%outres*reset_pid
write(6,*) "Resetting PID: active"
! write(6,*) "Resetting PID: active"
endif
else
reset_pid = 1.0_mk
endif
!
!
! Spinnar LiDAR Simulator
N_beams = 20
Lidar_Ts = 0.05_mk
if (time.gt.10.0_mk) then
counter_lidar = counter_lidar + 1;
if (counter_lidar*deltat .ge. Lidar_Ts) then
!write(6,*) "reset counter"
counter_lidar = 1
LOS_num = LOS_num + 1
endif
if (LOS_num .gt. N_beams) then
LOS_num = 1
endif
!write(6,*) counter_lidar
spinnar_lidar_los = array1(15+(LOS_num-1)*5)
else
counter_lidar = 1
spinnar_lidar_los = 0.0_mk
LOS_num = 1
endif
!
!***********************************************************************************************
! Output
!***********************************************************************************************
......@@ -790,6 +814,8 @@ subroutine update_regulation(array1, array2) bind(c,name='update_regulation')
array2(43) = dump_array(39) ! 43: Estimated Tip-speed ratio (lambda) [-]
array2(44) = dump_array(40) ! 44: Estimated rotor-effecitve wind speed [m/s]
array2(45) = Deratevar%dr ! 45: Derating percentage [-]
array2(46) = spinnar_lidar_los ! 46: Spinnar LiDAR LOS [m/s]
array2(47) = LOS_num ! 47: LOS_num, Naccelle LiDAR identifier [-]
return
end subroutine update_regulation
!**************************************************************************************************
......
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