Skip to content

Commit

Permalink
Automate write file
Browse files Browse the repository at this point in the history
  • Loading branch information
nikhar-abbas committed Oct 2, 2019
1 parent 9e4e3e8 commit 9b65600
Showing 1 changed file with 40 additions and 40 deletions.
80 changes: 40 additions & 40 deletions WTC_toolbox/controller.py
Original file line number Diff line number Diff line change
Expand Up @@ -299,7 +299,7 @@ class containing
file.write('1 ! PS_Mode - Peak shaving mode {0: no peak shaving, 1: implement peak shaving}\n')
file.write('\n')
file.write('!------- FILTERS ----------------------------------------------------------\n')
file.write('1.570796326 ! F_LPFCornerFreq - Corner frequency (-3dB point) in the low-pass filters, [Hz]\n') # this needs to be included as an input file
file.write('{} ! F_LPFCornerFreq - Corner frequency (-3dB point) in the low-pass filters, [Hz]\n'.format(str(turbine.omega_dt))) # this needs to be included as an input file
file.write('0 ! F_LPFDamping - Damping coefficient [used only when F_FilterType = 2]\n')
file.write('0 ! F_NotchCornerFreq - Natural frequency of the notch filter, [rad/s]\n')
file.write('0 0 ! F_NotchBetaNumDen - Two notch damping values (numerator and denominator, resp) - determines the width and depth of the notch, [-]\n')
Expand All @@ -312,73 +312,73 @@ class containing
file.write('{} ! PC_GS_KI - Gain-schedule table: pitch controller ki gains\n'.format(str(controller.pc_gain_schedule.Ki).strip('[]').replace('\n','')))
file.write('{} ! PC_GS_KD - Gain-schedule table: pitch controller kd gains\n'.format(str(np.zeros(len(controller.pitch_op_pc))).strip('[]').replace('\n','')))
file.write('{} ! PC_GS_TF - Gain-schedule table: pitch controller tf gains (derivative filter)\n'.format(str(np.zeros(len(controller.pitch_op_pc))).strip('[]').replace('\n','')))
file.write('1.5707 ! PC_MaxPit - Maximum physical pitch limit, [rad].\n')
file.write('-0.087266 ! PC_MinPit - Minimum physical pitch limit, [rad].\n')
file.write('{} ! PC_MaxPit - Maximum physical pitch limit, [rad].\n'.format(str(turbine.PC_MaxPit)))
file.write('{} ! PC_MinPit - Minimum physical pitch limit, [rad].\n'.format(str(turbine.PC_MinPit)))
file.write('0.13962 ! PC_MaxRat - Maximum pitch rate (in absolute value) in pitch controller, [rad/s].\n')
file.write('-0.13962 ! PC_MinRat - Minimum pitch rate (in absolute value) in pitch controller, [rad/s].\n')
file.write('122.90957 ! PC_RefSpd - Desired (reference) HSS speed for pitch controller, [rad/s].\n')
file.write('{} ! PC_RefSpd - Desired (reference) HSS speed for pitch controller, [rad/s].\n'.format(str(turbine.RRspeed*turbine.Ng)))
file.write('0.0 ! PC_FinePit - Record 5: Below-rated pitch angle set-point, [rad]\n')
file.write('0.003490658 ! PC_Switch - Angle above lowest minimum pitch angle for switch, [rad]\n')
file.write('0 ! Z_EnableSine - Enable/disable sine pitch excitation, used to validate for dynamic induction control, will be removed later, [-]\n')
file.write('0.0349066 ! Z_PitchAmplitude - Amplitude of sine pitch excitation, [rad]\n')
file.write('0 ! Z_PitchFrequency - Frequency of sine pitch excitation, [rad/s]\n')
file.write('\n')
file.write('!------- INDIVIDUAL PITCH CONTROL -----------------------------------------\n')
file.write('0.087266 ! IPC_IntSat - Integrator saturation (maximum signal amplitude contribution to pitch from IPC), [rad]\n')
file.write('1E-8 0 ! IPC_KI - Integral gain for the individual pitch controller: first parameter for 1P reductions, second for 2P reductions, [-]\n')
file.write('0.436332313 0 ! IPC_aziOffset - Phase offset added to the azimuth angle for the individual pitch controller, [rad]. \n')
file.write('2.5 ! IPC_CornerFreqAct - Corner frequency of the first-order actuators model, to induce a phase lag in the IPC signal {0: Disable}, [rad/s]\n')
file.write('0.0 ! IPC_IntSat - Integrator saturation (maximum signal amplitude contribution to pitch from IPC), [rad]\n')
file.write('0.0 0.0 ! IPC_KI - Integral gain for the individual pitch controller: first parameter for 1P reductions, second for 2P reductions, [-]\n')
file.write('0.0 0.0 ! IPC_aziOffset - Phase offset added to the azimuth angle for the individual pitch controller, [rad]. \n')
file.write('0.0 ! IPC_CornerFreqAct - Corner frequency of the first-order actuators model, to induce a phase lag in the IPC signal {0: Disable}, [rad/s]\n')
file.write('\n')
file.write('!------- VS TORQUE CONTROL ------------------------------------------------\n')
file.write('0.944 ! VS_GenEff - Generator efficiency mechanical power -> electrical power, [should match the efficiency defined in the generator properties!], [-]\n')
file.write('43093.55 ! VS_ArSatTq - Above rated generator torque PI control saturation, [Nm]\n')
file.write('{} ! VS_GenEff - Generator efficiency mechanical power -> electrical power, [should match the efficiency defined in the generator properties!], [-]\n'.format(str(turbine.GenEff)))
file.write('{} ! VS_ArSatTq - Above rated generator torque PI control saturation, [Nm]\n'.format(str(turbine.RatedTorque)))
file.write('150000.0 ! VS_MaxRat - Maximum torque rate (in absolute value) in torque controller, [Nm/s].\n')
file.write('48000.00 ! VS_MaxTq - Maximum generator torque in Region 3 (HSS side), [Nm].\n')
file.write('{} ! VS_MaxTq - Maximum generator torque in Region 3 (HSS side), [Nm].\n'.format(str(turbine.RatedTorque*1.1)))
file.write('0.0 ! VS_MinTq - Minimum generator (HSS side), [Nm].\n')
file.write('91.2109 ! VS_MinOMSpd - Optimal mode minimum speed, cut-in speed towards optimal mode gain path, [rad/s]\n')
file.write('2.33228 ! VS_Rgn2K - Generator torque constant in Region 2 (HSS side), [N-m/(rad/s)^2]\n')
file.write('5.0E+06 ! VS_RtPwr - Wind turbine rated power [W]\n')
file.write('43093.55 ! VS_RtTq - Rated torque, [Nm].\n')
file.write('120.113 ! VS_RefSpd - Rated generator speed [rad/s]\n')
file.write('0.0 ! VS_MinOMSpd - Optimal mode minimum speed, cut-in speed towards optimal mode gain path, [rad/s]\n')
file.write('0.0 ! VS_Rgn2K - Generator torque constant in Region 2 (HSS side), [N-m/(rad/s)^2]\n')
file.write('{} ! VS_RtPwr - Wind turbine rated power [W]\n'.format(str(turbine.RatedPower)))
file.write('{} ! VS_RtTq - Rated torque, [Nm].\n'.format(str(turbine.RatedTorque)))
file.write('{} ! VS_RefSpd - Rated generator speed [rad/s]\n'.format(str(turbine.RRspeed*turbine.Ng)))
file.write('1 ! VS_n - Number of generator PI torque controller gains\n')
file.write('-835 ! 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')
file.write('-164 ! 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')
file.write('{} ! 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(str(controller.vs_gain_schedule.Kp[-1])))
file.write('{} ! 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(str(controller.vs_gain_schedule.Ki[-1])))
file.write('\n')
file.write('!------- SETPOINT SMOOTHER ---------------------------------------------\n')
file.write('30 ! SS_VSGainBias - Variable speed torque controller gain bias, [(rad/s)/rad].\n')
file.write('0.001 ! SS_PCGainBias - Collective pitch controller gain bias, [(rad/s)/Nm].\n')
file.write('\n')
file.write('!------- WIND SPEED ESTIMATOR ---------------------------------------------\n')
file.write('63.0 ! WE_BladeRadius - Blade length [m]\n')
file.write('{} ! WE_BladeRadius - Blade length [m]\n'.format(str(turbine.RotorRad)))
file.write('4 ! WE_CP_n - Amount of parameters in the Cp array\n')
file.write('14.571319658214513 42.809556250371465 2.456512501523107 0.003127994078720 ! WE_CP - Parameters that define the parameterized CP(lambda) function\n')
file.write('20 ! WE_Gamma - Adaption gain of the wind speed estimator algorithm [m/rad]\n')
file.write('97 ! WE_GearboxRatio - Gearbox ratio [>=1], [-]\n')
file.write('4.0469564E+07 ! WE_Jtot - Total drivetrain inertia, including blades, hub and casted generator inertia to LSS, [kg m^2]\n')
file.write('0.0 0.0 0.0 0.0 ! WE_CP - Parameters that define the parameterized CP(lambda) function\n')
file.write('0.0 ! WE_Gamma - Adaption gain of the wind speed estimator algorithm [m/rad]\n')
file.write('{} ! WE_GearboxRatio - Gearbox ratio [>=1], [-]\n'.format(str(turbine.Ng)))
file.write('{} ! WE_Jtot - Total drivetrain inertia, including blades, hub and casted generator inertia to LSS, [kg m^2]\n'.format(str(turbine.J)))
file.write('1.225 ! WE_RhoAir - Air density, [kg m^-3]\n')
file.write('"../5MW_Baseline/Cp_Ct_Cq.txt" ! PerfFileName - File containing rotor performance tables (Cp,Ct,Cq)\n')
file.write('320 40 ! 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')
file.write('23 ! WE_FOPoles_N - Number of first-order system poles used in EKF\n')
file.write('3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 ! WE_FOPoles_v - Wind speeds corresponding to first-order system poles [m/s]\n')
file.write('-0.0203 -0.0270 -0.0338 -0.0405 -0.0473 -0.0540 -0.0608 -0.0675 -0.0743 -0.0671 -0.0939 -0.1257 -0.1601 -0.1973 -0.2364 -0.2783 -0.3223 -0.3678 -0.4153 -0.4632 -0.5122 -0.5629 -0.6194 ! WE_FOPoles - First order system poles\n')
file.write('"Cp_Ct_Cq.txt" ! PerfFileName - File containing rotor performance tables (Cp,Ct,Cq)\n')
file.write('{} {} ! 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(str(len(turbine.Cp.pitch_initial_rad)),str(len(turbine.Cp.TSR_initial))))
file.write('{} ! WE_FOPoles_N - Number of first-order system poles used in EKF\n'.format(str(len(controller.A))))
file.write('{} ! WE_FOPoles_v - Wind speeds corresponding to first-order system poles [m/s]\n'.format(str(controller.v).strip('[]').replace('\n','')))
file.write('{} ! WE_FOPoles - First order system poles\n'.format(str(controller.A).strip('[]').replace('\n','')))
file.write('\n')
file.write('!------- YAW CONTROL ------------------------------------------------------\n')
file.write('1.745329252 ! Y_ErrThresh - Yaw error threshold. Turbine begins to yaw when it passes this. [rad^2 s]\n')
file.write('0.17453 ! Y_IPC_IntSat - Integrator saturation (maximum signal amplitude contribution to pitch from yaw-by-IPC), [rad]\n')
file.write('0.0 ! Y_ErrThresh - Yaw error threshold. Turbine begins to yaw when it passes this. [rad^2 s]\n')
file.write('0.0 ! Y_IPC_IntSat - Integrator saturation (maximum signal amplitude contribution to pitch from yaw-by-IPC), [rad]\n')
file.write('1 ! Y_IPC_n - Number of controller gains (yaw-by-IPC)\n')
file.write('-0.064 ! Y_IPC_KP - Yaw-by-IPC proportional controller gain Kp\n')
file.write('-0.0008 ! Y_IPC_KI - Yaw-by-IPC integral controller gain Ki\n')
file.write('0.6283185 ! Y_IPC_omegaLP - Low-pass filter corner frequency for the Yaw-by-IPC controller to filtering the yaw alignment error, [rad/s].\n')
file.write('1.0 ! Y_IPC_zetaLP - Low-pass filter damping factor for the Yaw-by-IPC controller to filtering the yaw alignment error, [-].\n')
file.write('0.00000 ! Y_MErrSet - Yaw alignment error, set point [rad]\n')
file.write('1.0 ! Y_omegaLPFast - Corner frequency fast low pass filter, 1.0 [Hz]\n')
file.write('0.016667 ! Y_omegaLPSlow - Corner frequency slow low pass filter, 1/60 [Hz]\n')
file.write('0.0034906 ! Y_Rate - Yaw rate [rad/s]\n')
file.write('0.0 ! Y_IPC_KP - Yaw-by-IPC proportional controller gain Kp\n')
file.write('0.0 ! Y_IPC_KI - Yaw-by-IPC integral controller gain Ki\n')
file.write('0.0 ! Y_IPC_omegaLP - Low-pass filter corner frequency for the Yaw-by-IPC controller to filtering the yaw alignment error, [rad/s].\n')
file.write('0.0 ! Y_IPC_zetaLP - Low-pass filter damping factor for the Yaw-by-IPC controller to filtering the yaw alignment error, [-].\n')
file.write('0.0 ! Y_MErrSet - Yaw alignment error, set point [rad]\n')
file.write('0.0 ! Y_omegaLPFast - Corner frequency fast low pass filter, 1.0 [Hz]\n')
file.write('0.0 ! Y_omegaLPSlow - Corner frequency slow low pass filter, 1/60 [Hz]\n')
file.write('0.0 ! Y_Rate - Yaw rate [rad/s]\n')
file.write('\n')
file.write('!------- TOWER FORE-AFT DAMPING -------------------------------------------\n')
file.write('-1 ! FA_KI - Integral gain for the fore-aft tower damper controller, -1 = off / >0 = on [rad s/m] - !NJA - Make this a flag\n')
file.write('0.1 ! FA_HPF_CornerFreq - Corner frequency (-3dB point) in the high-pass filter on the fore-aft acceleration signal [rad/s]\n')
file.write('0.087266 ! FA_IntSat - Integrator saturation (maximum signal amplitude contribution to pitch from FA damper), [rad]\n')
file.write('0.0 ! FA_HPF_CornerFreq - Corner frequency (-3dB point) in the high-pass filter on the fore-aft acceleration signal [rad/s]\n')
file.write('0.0 ! FA_IntSat - Integrator saturation (maximum signal amplitude contribution to pitch from FA damper), [rad]\n')
file.write('\n')
file.write('!------- PEAK SHAVING -------------------------------------------\n')
file.write('{} ! 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.pitch_min)))
Expand Down

0 comments on commit 9b65600

Please sign in to comment.