Skip to content

Commit

Permalink
Various Bug Fixes (#376)
Browse files Browse the repository at this point in the history
* Update .readthedocs.yaml

* Docs: Fix small bug in docs that caused errors with links

* Start using automatic documentation for examples (#371)

* Added autodocumentation template for all examples

* Check for IPC openfast flag when using AWC

* Fix GB and gen efficiencies
GB efficiency reduces LSS to HSS
GEN reduces HSS to generator electrical output
We apply the GenTq at the HSS

* Allow updating of Ind_BldPitch from int to array

* Add a note about building docs

* Fix global variables in Example 17a and 17b

* Try numpy<2.0

* Fixed bug where TRA_LastRefSpd was set to a generator speed not the LSS speed (#381)

* Check for Ind_BldPitch in original_vt

---------

Co-authored-by: AbhineetGupta <abhineet.gupta@nrel.gov>
Co-authored-by: Ben Clayton <55184924+BenClaytonARUP@users.noreply.github.com>
  • Loading branch information
3 people authored Oct 11, 2024
1 parent fca5163 commit fc65032
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 6 deletions.
2 changes: 1 addition & 1 deletion rosco/controller/src/ControllerBlocks.f90
Original file line number Diff line number Diff line change
Expand Up @@ -490,7 +490,7 @@ SUBROUTINE RefSpeedExclusion(LocalVar, CntrPar, objInst, DebugVar)
LocalVar%TRA_LastRefSpd = CntrPar%TRA_ExclSpeed - CntrPar%TRA_ExclBand / 2
ENDIF
ELSE
LocalVar%TRA_LastRefSpd = LocalVar%VS_RefSpd
LocalVar%TRA_LastRefSpd = VS_RefSpeed_LSS
END IF
END IF

Expand Down
7 changes: 6 additions & 1 deletion rosco/controller/src/ReadSetParameters.f90
Original file line number Diff line number Diff line change
Expand Up @@ -229,7 +229,7 @@ SUBROUTINE SetParameters(avrSWAP, accINFILE, size_avcMSG, CntrPar, LocalVar, obj
ENDIF
LocalVar%VS_LastGenTrq = LocalVar%GenTq
LocalVar%VS_MaxTq = CntrPar%VS_MaxTq
LocalVar%VS_GenPwr = LocalVar%GenTq * LocalVar%GenSpeed
LocalVar%VS_GenPwr = LocalVar%GenTq * LocalVar%GenSpeed * CntrPar%VS_GenEff/100.0

! Initialize variables
LocalVar%CC_DesiredL = 0
Expand Down Expand Up @@ -1499,6 +1499,11 @@ SUBROUTINE CheckInputs(LocalVar, CntrPar, avrSWAP, ErrVar, size_avcMSG)
ErrVar%ErrMsg = 'Pitch offset fault enabled (PF_Mode = 1), but Ptch_Cntrl in ServoDyn has a value of 0. Set it to 1 for individual pitch control.'
ENDIF

IF (NINT(avrSWAP(28)) == 0 .AND. (CntrPar%AWC_Mode > 1)) THEN
ErrVar%aviFAIL = -1
ErrVar%ErrMsg = 'AWC enabled, but Ptch_Cntrl in ServoDyn has a value of 0. Set it to 1 for individual pitch control.'
ENDIF

! DT
IF (LocalVar%DT <= 0.0) THEN
ErrVar%aviFAIL = -1
Expand Down
10 changes: 8 additions & 2 deletions rosco/toolbox/controller.py
Original file line number Diff line number Diff line change
Expand Up @@ -325,8 +325,14 @@ def tune_controller(self, turbine):
self.vs_gain_schedule.second_order_PI(self.zeta_vs, self.omega_vs,A_vs,B_tau[0:len(v_below_rated)],linearize=False,v=v_below_rated)

# -- Find K for Komega_g^2 --
self.vs_rgn2K = (pi*rho*R**5.0 * turbine.Cp.max * turbine.GBoxEff/100 * turbine.GenEff/100) / \
(2.0 * turbine.Cp.TSR_opt**3 * Ng**3) * self.controller_params['rgn2k_factor']
# Careful handling of different efficiencies
# P_lss = 1/2 * Cp * rho * pi * R^5 / (TSR^3 * Ng^3)
# P_hss = GBoxEff * P_lss = tau_gen * omega_gen = K * omega_gen^3
# P_gen = GenEff * P_hss
# Generator efficiency is not included in K here, but gearbox efficiency is
# Note that this differs from the
self.vs_rgn2K = (pi*rho*R**5.0 * turbine.Cp.max * turbine.GBoxEff/100) / (2.0 * turbine.Cp.TSR_opt**3 * Ng**3) * self.controller_params['rgn2k_factor']

self.vs_refspd = min(turbine.TSR_operational * turbine.v_rated/R, turbine.rated_rotor_speed) * Ng

# -- Define some setpoints --
Expand Down
3 changes: 1 addition & 2 deletions rosco/toolbox/sim.py
Original file line number Diff line number Diff line change
Expand Up @@ -113,8 +113,7 @@ def sim_ws_series(self, t_array, ws_array, rotor_rpm_init=10, init_pitch=0.0,
# Update the turbine state
# -- 1DOF model: rotor speed and generator speed (scaled by Ng)
aero_torque[i] = 0.5 * self.turbine.rho * (np.pi * R**3) * (cp/tsr) * ws**2
rot_speed[i] = rot_speed[i-1] + (dt/self.turbine.J)*(aero_torque[i]
* self.turbine.GenEff/100 - self.turbine.Ng * gen_torque[i-1])
rot_speed[i] = rot_speed[i-1] + (dt/self.turbine.J)*(aero_torque[i] - self.turbine.Ng * gen_torque[i-1] / (self.turbine.GBoxEff/100))
gen_speed[i] = rot_speed[i] * self.turbine.Ng
# -- Simple nacelle model
nac_yawerr[i] = wd - nac_yaw[i-1]
Expand Down
4 changes: 4 additions & 0 deletions rosco/toolbox/tune.py
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,10 @@ def update_discon_version(file,tuning_yaml,new_discon_filename):
if original_vt['F_NotchType'] == 2 or original_vt['F_NotchType'] == 3:
new_discon['F_TwrTopNotch_N'] = 1
new_discon['F_TwrTopNotch_Ind'] = [1]

# OL blade pitch changed to array
if ('Ind_BldPitch' in original_vt) and (not hasattr(original_vt['Ind_BldPitch'],'__len__')):
new_discon['Ind_BldPitch'] = [original_vt['Ind_BldPitch']] * 3


# Make the DISCON
Expand Down

0 comments on commit fc65032

Please sign in to comment.