Skip to content

Commit

Permalink
Merge pull request WISDEM#34 from nikhar-abbas/f/DISCON_cleanup
Browse files Browse the repository at this point in the history
DISCON Cleanup
  • Loading branch information
nikhar-abbas committed Feb 5, 2021
2 parents bd13c02 + df28b09 commit c8e3f77
Showing 1 changed file with 13 additions and 13 deletions.
26 changes: 13 additions & 13 deletions ROSCO_toolbox/utilities.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ def write_DISCON(turbine, controller, param_file='DISCON.IN', txt_filename='Cp_C
file.write('\n')
file.write('!------- FILTERS ----------------------------------------------------------\n')
file.write('{:<13.5f} ! F_LPFCornerFreq - Corner frequency (-3dB point) in the low-pass filters, [rad/s]\n'.format(turbine.bld_edgewise_freq * 1/4))
file.write('{:<13.5f} ! F_LPFDamping - Damping coefficient [used only when F_FilterType = 2]\n'.format(controller.F_LPFDamping))
file.write('{:<13.5f} ! F_LPFDamping - Damping coefficient {{used only when F_FilterType = 2}} [-]\n'.format(controller.F_LPFDamping))
file.write('{:<13.5f} ! F_NotchCornerFreq - Natural frequency of the notch filter, [rad/s]\n'.format(turbine.twr_freq))
file.write('{:<10.5f}{:<9.5f} ! F_NotchBetaNumDen - Two notch damping values (numerator and denominator, resp) - determines the width and depth of the notch, [-]\n'.format(0.0,0.25))
file.write('{:<014.5f} ! F_SSCornerFreq - Corner frequency (-3dB point) in the first order low pass filter for the setpoint smoother, [rad/s].\n'.format(controller.ss_cornerfreq))
Expand All @@ -89,9 +89,9 @@ def write_DISCON(turbine, controller, param_file='DISCON.IN', txt_filename='Cp_C
file.write('\n')
file.write('!------- BLADE PITCH CONTROL ----------------------------------------------\n')
file.write('{:<11d} ! PC_GS_n - Amount of gain-scheduling table entries\n'.format(len(controller.pitch_op_pc)))
file.write('{} ! PC_GS_angles - Gain-schedule table: pitch angles\n'.format(''.join('{:<4.6f} '.format(controller.pitch_op_pc[i]) for i in range(len(controller.pitch_op_pc)))))
file.write('{} ! PC_GS_KP - Gain-schedule table: pitch controller kp gains\n'.format(''.join('{:<4.6f} '.format(controller.pc_gain_schedule.Kp[i]) for i in range(len(controller.pc_gain_schedule.Kp)))))
file.write('{} ! PC_GS_KI - Gain-schedule table: pitch controller ki gains\n'.format(''.join('{:<4.6f} '.format(controller.pc_gain_schedule.Ki[i]) for i in range(len(controller.pc_gain_schedule.Ki)))))
file.write('{} ! PC_GS_angles - Gain-schedule table: pitch angles [rad].\n'.format(''.join('{:<4.6f} '.format(controller.pitch_op_pc[i]) for i in range(len(controller.pitch_op_pc)))))
file.write('{} ! PC_GS_KP - Gain-schedule table: pitch controller kp gains [s].\n'.format(''.join('{:<4.6f} '.format(controller.pc_gain_schedule.Kp[i]) for i in range(len(controller.pc_gain_schedule.Kp)))))
file.write('{} ! PC_GS_KI - Gain-schedule table: pitch controller ki gains [-].\n'.format(''.join('{:<4.6f} '.format(controller.pc_gain_schedule.Ki[i]) for i in range(len(controller.pc_gain_schedule.Ki)))))
file.write('{} ! PC_GS_KD - Gain-schedule table: pitch controller kd gains\n'.format(''.join('{:<1.1f} '.format(0.0) for i in range(len(controller.pc_gain_schedule.Ki)))))
file.write('{} ! PC_GS_TF - Gain-schedule table: pitch controller tf gains (derivative filter)\n'.format(''.join('{:<1.1f} '.format(0.0) for i in range(len(controller.pc_gain_schedule.Ki)))))
file.write('{:<014.5f} ! PC_MaxPit - Maximum physical pitch limit, [rad].\n'.format(controller.max_pitch))
Expand All @@ -115,13 +115,13 @@ def write_DISCON(turbine, controller, param_file='DISCON.IN', txt_filename='Cp_C
file.write('{:<014.5f} ! VS_MaxTq - Maximum generator torque in Region 3 (HSS side), [Nm].\n'.format(turbine.max_torque))
file.write('{:<014.5f} ! VS_MinTq - Minimum generator (HSS side), [Nm].\n'.format(0.0))
file.write('{:<014.5f} ! VS_MinOMSpd - Optimal mode minimum speed, cut-in speed towards optimal mode gain path, [rad/s]\n'.format(controller.vs_minspd))
file.write('{:<014.5f} ! VS_Rgn2K - Generator torque constant in Region 2 (HSS side), [N-m/(rad/s)^2]\n'.format(controller.vs_rgn2K))
file.write('{:<014.5f} ! VS_Rgn2K - Generator torque constant in Region 2 (HSS side), [Nm/(rad/s)^2]\n'.format(controller.vs_rgn2K))
file.write('{:<014.5f} ! VS_RtPwr - Wind turbine rated power [W]\n'.format(turbine.rated_power))
file.write('{:<014.5f} ! VS_RtTq - Rated torque, [Nm].\n'.format(turbine.rated_torque))
file.write('{:<014.5f} ! VS_RefSpd - Rated generator speed [rad/s]\n'.format(controller.vs_refspd))
file.write('{:<11d} ! VS_n - Number of generator PI torque controller gains\n'.format(1))
file.write('{:<014.5f} ! VS_KP - Proportional gain for generator PI torque controller [1/(rad/s) Nm]. (Only used in the transitional 2.5 region if VS_ControlMode =/ 2)\n'.format(controller.vs_gain_schedule.Kp[-1]))
file.write('{:<014.5f} ! VS_KI - Integral gain for generator PI torque controller [1/rad Nm]. (Only used in the transitional 2.5 region if VS_ControlMode =/ 2)\n'.format(controller.vs_gain_schedule.Ki[-1]))
file.write('{:<014.5f} ! VS_KP - Proportional gain for generator PI torque controller [-]. (Only used in the transitional 2.5 region if VS_ControlMode =/ 2)\n'.format(controller.vs_gain_schedule.Kp[-1]))
file.write('{:<014.5f} ! VS_KI - Integral gain for generator PI torque controller [s]. (Only used in the transitional 2.5 region if VS_ControlMode =/ 2)\n'.format(controller.vs_gain_schedule.Ki[-1]))
file.write('{:<13.2f} ! VS_TSRopt - Power-maximizing region 2 tip-speed-ratio [rad].\n'.format(turbine.TSR_operational))
file.write('\n')
file.write('!------- SETPOINT SMOOTHER ---------------------------------------------\n')
Expand All @@ -139,8 +139,8 @@ def write_DISCON(turbine, controller, param_file='DISCON.IN', txt_filename='Cp_C
file.write( '"{}" ! PerfFileName - File containing rotor performance tables (Cp,Ct,Cq)\n'.format(txt_filename))
file.write('{:<7d} {:<10d} ! PerfTableSize - Size of rotor performance tables, first number refers to number of blade pitch angles, second number referse to number of tip-speed ratios\n'.format(len(turbine.Cp.pitch_initial_rad),len(turbine.Cp.TSR_initial)))
file.write('{:<11d} ! WE_FOPoles_N - Number of first-order system poles used in EKF\n'.format(len(controller.A)))
file.write('{} ! WE_FOPoles_v - Wind speeds corresponding to first-order system poles [m/s]\n'.format(''.join('{:<4.2f} '.format(controller.v[i]) for i in range(len(controller.v)))))
file.write('{} ! WE_FOPoles - First order system poles\n'.format(''.join('{:<10.8f} '.format(controller.A[i]) for i in range(len(controller.A)))))
file.write('{} ! WE_FOPoles_v - Wind speeds corresponding to first-order system poles [m/s]\n'.format(''.join('{:<4.4f} '.format(controller.v[i]) for i in range(len(controller.v)))))
file.write('{} ! WE_FOPoles - First order system poles [1/s]\n'.format(''.join('{:<10.8f} '.format(controller.A[i]) for i in range(len(controller.A)))))
file.write('\n')
file.write('!------- YAW CONTROL ------------------------------------------------------\n')
file.write('{:<13.1f} ! Y_ErrThresh - Yaw error threshold. Turbine begins to yaw when it passes this. [rad^2 s]\n'.format(0.0))
Expand All @@ -151,8 +151,8 @@ def write_DISCON(turbine, controller, param_file='DISCON.IN', txt_filename='Cp_C
file.write('{:<13.1f} ! Y_IPC_omegaLP - Low-pass filter corner frequency for the Yaw-by-IPC controller to filtering the yaw alignment error, [rad/s].\n'.format(0.0))
file.write('{:<13.1f} ! Y_IPC_zetaLP - Low-pass filter damping factor for the Yaw-by-IPC controller to filtering the yaw alignment error, [-].\n'.format(0.0))
file.write('{:<13.1f} ! Y_MErrSet - Yaw alignment error, set point [rad]\n'.format(0.0))
file.write('{:<13.1f} ! Y_omegaLPFast - Corner frequency fast low pass filter, 1.0 [Hz]\n'.format(0.0))
file.write('{:<13.1f} ! Y_omegaLPSlow - Corner frequency slow low pass filter, 1/60 [Hz]\n'.format(0.0))
file.write('{:<13.1f} ! Y_omegaLPFast - Corner frequency fast low pass filter, 1.0 [rad/s]\n'.format(0.0))
file.write('{:<13.1f} ! Y_omegaLPSlow - Corner frequency slow low pass filter, 1/60 [rad/s]\n'.format(0.0))
file.write('{:<13.1f} ! Y_Rate - Yaw rate [rad/s]\n'.format(0.0))
file.write('\n')
file.write('!------- TOWER FORE-AFT DAMPING -------------------------------------------\n')
Expand All @@ -162,7 +162,7 @@ def write_DISCON(turbine, controller, param_file='DISCON.IN', txt_filename='Cp_C
file.write('\n')
file.write('!------- MINIMUM PITCH SATURATION -------------------------------------------\n')
file.write('{:<11d} ! PS_BldPitchMin_N - Number of values in minimum blade pitch lookup table (should equal number of values in PS_WindSpeeds and PS_BldPitchMin)\n'.format(len(controller.ps_min_bld_pitch)))
file.write('{} ! PS_WindSpeeds - Wind speeds corresponding to minimum blade pitch angles [m/s]\n'.format(''.join('{:<4.2f} '.format(controller.v[i]) for i in range(len(controller.v)))))
file.write('{} ! PS_WindSpeeds - Wind speeds corresponding to minimum blade pitch angles [m/s]\n'.format(''.join('{:<4.4f} '.format(controller.v[i]) for i in range(len(controller.v)))))
file.write('{} ! PS_BldPitchMin - Minimum blade pitch angles [rad]\n'.format(''.join('{:<10.8f} '.format(controller.ps_min_bld_pitch[i]) for i in range(len(controller.ps_min_bld_pitch)))))
file.write('\n')
file.write('!------- SHUTDOWN -----------------------------------------------------------\n')
Expand All @@ -175,7 +175,7 @@ def write_DISCON(turbine, controller, param_file='DISCON.IN', txt_filename='Cp_C
file.write('!------- FLAP ACTUATION -----------------------------------------------------\n')
file.write('{:<014.5f} ! Flp_Angle - Initial or steady state flap angle [rad]\n'.format(controller.flp_angle))
file.write('{:<014.8e} ! Flp_Kp - Blade root bending moment proportional gain for flap control [s]\n'.format(controller.Kp_flap[-1]))
file.write('{:<014.8e} ! Flp_Ki - Flap displacement integral gain for flap control [s]\n'.format(controller.Ki_flap[-1]))
file.write('{:<014.8e} ! Flp_Ki - Flap displacement integral gain for flap control [-]\n'.format(controller.Ki_flap[-1]))
file.write('{:<014.5f} ! Flp_MaxPit - Maximum (and minimum) flap pitch angle [rad]'.format(controller.flp_maxpit))
file.close()

Expand Down

0 comments on commit c8e3f77

Please sign in to comment.