Commit 4f21b0f0 authored by gepir's avatar gepir
Browse files

some more initialization and updating of variables only with the new time step

parent 49bd7b6b
......@@ -140,9 +140,9 @@ function PID(stepno, dt, kgain, PIDvar, error)
PIDvar%error1_old = PIDvar%error1
endif
! Update the integral term
PIDvar%outset = PIDvar%outset1_old + 0.5_mk*(error + PIDvar%error1)*Kgain(2)*PIDvar%Kint*dt
PIDvar%outset = PIDvar%outset1_old + 0.5_mk*(error + PIDvar%error1_old)*Kgain(2)*PIDvar%Kint*dt
! Update proportional term
PIDvar%outpro = Kgain(1)*PIDvar%Kpro*0.5_mk*(error + PIDvar%error1)
PIDvar%outpro = Kgain(1)*PIDvar%Kpro*0.5_mk*(error + PIDvar%error1_old)
! Update differential term
PIDvar%outdif = Kgain(3)*PIDvar%Kdif*(error - PIDvar%error1_old)/dt
! Sum to up
......@@ -198,11 +198,11 @@ function PID2(stepno,dt,kgain,PIDvar,error,added_term)
PIDvar%error1_old = PIDvar%error1
endif
! Update the integral term
PIDvar%outset = PIDvar%outset1_old + 0.5_mk*dt*(Kgain(2, 1)*PIDvar%Kint(1)*(error(1) + PIDvar%error1(1))&
+Kgain(2, 2)*PIDvar%Kint(2)*(error(2) + PIDvar%error1(2)))
PIDvar%outset = PIDvar%outset1_old + 0.5_mk*dt*(Kgain(2, 1)*PIDvar%Kint(1)*(error(1) + PIDvar%error1_old(1))&
+Kgain(2, 2)*PIDvar%Kint(2)*(error(2) + PIDvar%error1_old(2)))
! Update proportional term
PIDvar%outpro = 0.5_mk*(Kgain(1, 1)*PIDvar%Kpro(1)*(error(1) + PIDvar%error1(1))&
+Kgain(1, 2)*PIDvar%Kpro(2)*(error(2) + PIDvar%error1(2)))
PIDvar%outpro = 0.5_mk*(Kgain(1, 1)*PIDvar%Kpro(1)*(error(1) + PIDvar%error1_old(1))&
+Kgain(1, 2)*PIDvar%Kpro(2)*(error(2) + PIDvar%error1_old(2)))
! Update differential term
PIDvar%outdif = (Kgain(3, 1)*PIDvar%Kdif(1)*(error(1) - PIDvar%error1_old(1)))/dt + added_term*dt
! Sum up
......
......@@ -19,7 +19,9 @@ module turbine_controller_mod
! Dynamic variables
integer :: stepno = 0, w_region = 0
logical :: newtimestep
real(mk) AddedPitchRate, PitchColRef0, GenTorqueRef0, PitchColRefOld, GenTorqueRefOld
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) GenSpeed_at_stop, GenTorque_at_stop
real(mk) excl_flag
......@@ -98,8 +100,10 @@ subroutine turbine_controller(CtrlStatus, GridFlag, GenSpeed, PitchVect, wsp, Pe
!***********************************************************************************************
! Save reference signals
!***********************************************************************************************
PitchColRefOld = PitchColRef
GenTorqueRefOld = GenTorqueRef
if (newtimestep) then
PitchColRefOld = PitchColRef
GenTorqueRefOld = GenTorqueRef
endif
return
end subroutine turbine_controller
!**************************************************************************************************
......@@ -326,25 +330,21 @@ subroutine shut_down(CtrlStatus, GenSpeed, PitchVect, wsp, GenTorqueRef, PitchCo
GenTorqueRef = 0.0_mk
end select
! Pitch seetings
if (newtimestep) then
select case(CtrlStatus)
case(1, 3, 4, 7) ! Two pitch speed stop
if (TimerShutdown2 .gt. CutoutVar%pitchdelay + CutoutVar%pitchdelay2) then
PitchColRef = min(PitchStopAng, PitchColRefOld + deltat*CutoutVar%pitchvelmax2)
elseif (TimerShutdown2 .gt. CutoutVar%pitchdelay) then
PitchColRef = min(PitchStopAng, PitchColRefOld + deltat*CutoutVar%pitchvelmax)
elseif (TimerShutdown2 .gt. 0.0_mk) then
PitchColRef = PitchColRefOld
endif
case(2, 5, 6) ! Pitch out at maximum speed
PitchColRef = min(PitchStopAng, PitchColRefOld + &
deltat*max(CutoutVar%pitchvelmax, CutoutVar%pitchvelmax2))
case(-2) ! Pitch-out before cut-in
PitchColRef = min(PitchStopAng, PitchColRefOld + deltat*CutoutVar%pitchvelmax)
end select
else
PitchColRef = PitchColRefOld
endif
select case(CtrlStatus)
case(1, 3, 4, 7) ! Two pitch speed stop
if (TimerShutdown2 .gt. CutoutVar%pitchdelay + CutoutVar%pitchdelay2) then
PitchColRef = min(PitchStopAng, PitchColRefOld + deltat*CutoutVar%pitchvelmax2)
elseif (TimerShutdown2 .gt. CutoutVar%pitchdelay) then
PitchColRef = min(PitchStopAng, PitchColRefOld + deltat*CutoutVar%pitchvelmax)
elseif (TimerShutdown2 .gt. 0.0_mk) then
PitchColRef = PitchColRefOld
endif
case(2, 5, 6) ! Pitch out at maximum speed
PitchColRef = min(PitchStopAng, PitchColRefOld + &
deltat*max(CutoutVar%pitchvelmax, CutoutVar%pitchvelmax2))
case(-2) ! Pitch-out before cut-in
PitchColRef = min(PitchStopAng, PitchColRefOld + deltat*CutoutVar%pitchvelmax)
end select
! Write into dump array
dump_array(1) = GenTorqueRef*GenSpeed
dump_array(3) = y(1)
......
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