Commit 3a9d90cf authored by gepir's avatar gepir
Browse files

Further initializations. Made the reference torque and pitch values global...

Further initializations. Made the reference torque and pitch values global variables so that the 'old' values can be updated at the beginning of the next time step. Made sure that the controller can be called twice in the very first time step without treating it as an iteration.
parent 20d4c807
......@@ -10,6 +10,7 @@ module dtu_we_controller
integer CtrlStatus
real(mk) dump_array(50)
real(mk) time_old
logical repeated
contains
!**************************************************************************************************
subroutine init_regulation(array1, array2) bind(c, name='init_regulation')
......@@ -278,6 +279,7 @@ subroutine init_regulation(array1, array2) bind(c, name='init_regulation')
! Initiate the dynamic variables
stepno = 0
time_old = 0.0_mk
repeated=.FALSE.
AddedPitchRate = 0.0_mk
PitchAngles=0.0_mk
AveragedMeanPitchAngles=0.0_mk
......@@ -429,7 +431,6 @@ subroutine update_regulation(array1, array2) bind(c,name='update_regulation')
! Local variables
integer GridFlag, EmergPitchStop, ActiveMechBrake
real(mk) GenSpeed, wsp, PitchVect(3), Pe, TT_acc(2), time
real(mk) GenTorqueRef, PitchColRef
EmergPitchStop = 0
ActiveMechBrake = 0
! Time
......@@ -437,11 +438,18 @@ 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.
endif
if (time .gt. time_old) then
deltat = time - time_old
time_old = time
stepno = stepno + 1
newtimestep = .TRUE.
PitchColRefOld = PitchColRef
GenTorqueRefOld = GenTorqueRef
else
newtimestep = .FALSE.
endif
......
......@@ -19,9 +19,15 @@ module turbine_controller_mod
! Dynamic variables
integer :: stepno = 0, w_region = 0
real(mk) AddedPitchRate, PitchColRef0, GenTorqueRef0
real(mk) :: PitchColRefOld=0.0_mk
real(mk) :: GenTorqueRefOld=0.0_mk
real(mk) TimerGenCutin, TimerStartup, TimerExcl, TimerShutdown, TimerShutdown2
real(mk) :: PitchColRef = 0.0_mk
real(mk) :: GenTorqueRef = 0.0_mk
real(mk) :: PitchColRefOld = 0.0_mk
real(mk) :: GenTorqueRefOld = 0.0_mk
real(mk) :: TimerGenCutin = 0.0_mk
real(mk) :: TimerStartup = 0.0_mk
real(mk) :: TimerExcl = 0.0_mk
real(mk) :: TimerShutdown = 0.0_mk
real(mk) :: TimerShutdown2 = 0.0_mk
real(mk) GenSpeed_at_stop, GenTorque_at_stop
real(mk) excl_flag
real(mk)::outmax_old=0.0_mk,outmin_old=0.0_mk
......@@ -68,13 +74,6 @@ subroutine turbine_controller(CtrlStatus, GridFlag, GenSpeed, PitchVect, wsp, Pe
real(mk), intent(out) :: PitchColRef ! Reference collective pitch [rad].
real(mk) TTAcc
!***********************************************************************************************
! Save reference signals
!***********************************************************************************************
if (newtimestep) then
PitchColRefOld = PitchColRef
GenTorqueRefOld = GenTorqueRef
endif
!***********************************************************************************************
! Wind turbine monitoring
!***********************************************************************************************
TTAcc = dsqrt(TTAccVect(1)**2 + TTAccVect(2)**2)
......
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