Skip to content

Commit

Permalink
Shutdown (#394)
Browse files Browse the repository at this point in the history
* Shutdown: Add framework for more shutdown modes

* shutdown: add a working shutdown model, needs more polish

* shutdown: add torque control to shutdown and other small changes

* shutdown: Run rosco controller registry to add shutdown variables

* Shutdown: Fix registry to solve build issue

* Shutdown: Add separate shutdown variable for pitch

* Shutdown: Modify DISCON.IN files for test cases

* Shutdown: Fix utilities.py to remove unknown character

* Shutdown: Fix issue where SD_MaxPit was named SD_MaxPitch in some places and reduce default SD_MaxTorqueRate

* Shutdown: Fix DISCON.IN files in example_inputs

* Shutdown: Set defaults values SD_MaxPitchRate and SD_MaxTorqeRate based on turbine properties

* Shutdown: Fix DISCON.IN files in Test_Cases

* Shutdown: Convert some filtered signals to local variables

* Shutdown: Add comments and minor code edit

* Shutdown: Use wrapping for filtering nacelle vane signal

* Shutdown: Remove optional shutdown inputs from minimal_discon.in

* Shutdown: Set defaults for various shutdown parameters

* Shutdown: Cleanup

* Shutdown: Specify defaults for shutdown parameters in toolbox

* Shutdown: Add example 30_shutdown.py to regression test list

* Shutdown: Correced the unit of SD_MaxYawError from rad to deg

* Shutdown: Run update_rosco_discons.py to update the DISCON.IN files in Examples/Test_Cases

* Add mpi_tools to rosco

* Shutdown: Add SD_TimeActivate to enable delaying activate of shutdown

* Shutdown: Add docstring to example 30_shutdown and remove time mode of shutdown

* Shutdown: Add example 30 documentation to docs

* Shutdown: Fix unit of SD_TimeActivate in toolbox

* Shutdown: Fix some bugs in shutdown logic

* Shutdown: Add images in docs for example 30_shutdown

* Shutdown: Run update_rosco_discons.py

* Shutdown: quick edit in example 30_shutdown

* Fix duplicated main call

* Change some minor formatting

---------

Co-authored-by: dzalkind <[email protected]>
  • Loading branch information
abhineet-gupta and dzalkind authored Dec 13, 2024
1 parent da03e56 commit 938e4f1
Show file tree
Hide file tree
Showing 29 changed files with 801 additions and 209 deletions.
3 changes: 0 additions & 3 deletions Examples/04_simple_sim.py
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,3 @@ def main():
if __name__ == "__main__":
main()

if __name__=='__main__':
main()

123 changes: 123 additions & 0 deletions Examples/30_shutdown.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,123 @@
"""
30_shutdown
----------------
This example demonstrates turbine shutdown using collective blade pitch threshold mode.
ROSCO allows for four shutdown trigger options:
- collective blade pitch exceeds a threshold
- yaw error exceeds a threshold
- generator speed exceeds a threshold
- Shutdown at a predefined time
Pitch Threshold Demo
````````````````````
The following plot demonstrates turbine shutdown when blade pitch exceeds a threshold of 30 degrees.
This shutdown mode can provide protection against high wind speeds.
.. image:: ../images/30_shutdown_pitch_demo.png
Yaw Error Threshold Demo
````````````````````````
The following plot demonstrates turbine shutdown when turbine yaw error pitch exceeds a threshold of 25 degrees.
This demonstration uses the extreme coherent gust with direction change wind inflow used in DLC 1.4.
.. image:: ../images/30_shutdown_yaw_demo.png
Generator Speed Threshold Demo
``````````````````````````````
The following plot demonstrates turbine shutdown when generator speed exceeds a threshold of 8.5 rpm.
This also compares the use of :code:`SD_TimeActive` to enable shutdown at 0 seconds and 10 seconds.
.. image:: ../images/30_shutdown_gen_demo.png
Time Demo
`````````
The following plot demonstrates turbine shutdown at 20 second time.
.. image:: ../images/30_shutdown_time_demo.png
"""

import os
import numpy as np
import matplotlib.pyplot as plt
from rosco.toolbox.ofTools.case_gen.run_FAST import run_FAST_ROSCO
from rosco.toolbox.ofTools.case_gen import CaseLibrary as cl
from rosco.toolbox.ofTools.fast_io import output_processing

rpm2RadSec = 2.0 * (np.pi) / 60.0
deg2rad = np.pi/180.0

# directories
this_dir = os.path.dirname(os.path.abspath(__file__))
example_out_dir = os.path.join(this_dir, "examples_out")
os.makedirs(example_out_dir, exist_ok=True)


def main():
# Input yaml and output directory
parameter_filename = os.path.join(this_dir, "Tune_Cases/IEA15MW.yaml")

# Set DISCON input dynamically through yaml/dict
controller_params = {}
controller_params["DISCON"] = {}
controller_params["DISCON"]["Echo"] = 1
controller_params["LoggingLevel"] = 3
controller_params["SD_Mode"] = 1
controller_params["DISCON"]["SD_EnablePitch"] = 1
controller_params["DISCON"]["SD_MaxPit"] = 30*deg2rad
controller_params["DISCON"]["SD_MaxPitchRate"] = 0.0348
controller_params["DISCON"]["SD_MaxTorqueRate"] = 4500000

# simulation set up
r = run_FAST_ROSCO()
r.tuning_yaml = parameter_filename
r.case_inputs = {}

# Disable floating DOFs for clarity
r.case_inputs[("ElastoDyn", "PtfmSgDOF")] = {"vals": ["False"], "group": 0}
r.case_inputs[("ElastoDyn", "PtfmSwDOF")] = {"vals": ["False"], "group": 0}
r.case_inputs[("ElastoDyn", "PtfmHvDOF")] = {"vals": ["False"], "group": 0}
r.case_inputs[("ElastoDyn", "PtfmRDOF")] = {"vals": ["False"], "group": 0}
r.case_inputs[("ElastoDyn", "PtfmPDOF")] = {"vals": ["False"], "group": 0}
r.case_inputs[("ElastoDyn", "PtfmYDOF")] = {"vals": ["False"], "group": 0}


t_max = 80

run_dir = os.path.join(example_out_dir, "30_shutdown_demo/1_pitch")

# Wind case
r.wind_case_fcn = cl.ramp
r.wind_case_opts = {
"U_start": 25,
"U_end": 50,
"t_start": 0,
"t_end": t_max,
}
r.case_inputs[("ElastoDyn", "BlPitch1")] = {"vals": [20.0], "group": 0}
r.case_inputs[("ElastoDyn", "BlPitch2")] = {"vals": [20.0], "group": 0}
r.case_inputs[("ElastoDyn", "BlPitch3")] = {"vals": [20.0], "group": 0}
r.case_inputs[("ElastoDyn", "RotSpeed")] = {"vals": [10.0], "group": 0}

# Run simulation
os.makedirs(run_dir, exist_ok=True)
r.controller_params = controller_params
r.save_dir = run_dir
r.run_FAST()

# Plot output
outfile = [os.path.join(run_dir, "IEA15MW", "ramp", "base", "IEA15MW_0.outb")]
cases = {}
cases["Baseline"] = ["Wind1VelX", "BldPitch1", "GenTq", "RotSpeed", "GenPwr"]
fast_out = output_processing.output_processing()
fastout = fast_out.load_fast_out(outfile)
fast_out.plot_fast_out(cases=cases, showplot=False)

plt.savefig(os.path.join(example_out_dir, "30_shutdown.png"))


if __name__ == "__main__":
main()
23 changes: 18 additions & 5 deletions Examples/Test_Cases/BAR_10/BAR_10_DISCON.IN
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
! Controller parameter input file for the BAR_10 wind turbine
! - File written using ROSCO version 2.9.4 controller tuning logic on 09/03/24
! - File written using ROSCO version 2.9.4 controller tuning logic on 12/11/24

!------- SIMULATION CONTROL ------------------------------------------------------------
1 ! LoggingLevel - {0: write no debug files, 1: write standard output .dbg-file, 2: LoggingLevel 1 + ROSCO LocalVars (.dbg2) 3: LoggingLevel 2 + complete avrSWAP-array (.dbg3)}
Expand All @@ -18,7 +18,7 @@
0 ! PRC_Mode - Power reference tracking mode{0: power control disabled, 1: lookup table from wind speed to generator speed setpoints, 2: change speed, torque, pitch to control power}
2 ! WE_Mode - Wind speed estimator mode {0: One-second low pass filtered hub height wind speed, 1: Immersion and Invariance Estimator, 2: Extended Kalman Filter}
1 ! PS_Mode - Pitch saturation mode {0: no pitch saturation, 1: implement pitch saturation}
0 ! SD_Mode - Shutdown mode {0: no shutdown procedure, 1: pitch to max pitch at shutdown}
0 ! SD_Mode - Shutdown mode {0: no shutdown procedure, 1: shutdown enabled}
0 ! Fl_Mode - Floating specific feedback mode {0: no nacelle velocity feedback, 1: feed back translational velocity, 2: feed back rotational veloicty}
0 ! TD_Mode - Tower damper mode (0- no tower damper, 1- feed back translational nacelle accelleration to pitch angle
0 ! TRA_Mode - Tower resonance avoidance mode (0- no tower resonsnace avoidance, 1- use torque control setpoints to avoid a specific frequency
Expand Down Expand Up @@ -81,7 +81,7 @@
70282.09458000 ! VS_MaxTq - Maximum generator torque in Region 3 (HSS side), [Nm].
0.000000000000 ! VS_MinTq - Minimum generator torque (HSS side), [Nm].
27.49717000000 ! VS_MinOMSpd - Minimum generator speed [rad/s]
11.20801000000 ! VS_Rgn2K - Generator torque constant in Region 2 (HSS side). Only used in VS_ControlMode = 1,3
11.43674000000 ! VS_Rgn2K - Generator torque constant in Region 2 (HSS side). Only used in VS_ControlMode = 1,3
5000000.000000 ! VS_RtPwr - Wind turbine rated power [W]
63892.81326000 ! VS_RtTq - Rated torque, [Nm].
75.83317000000 ! VS_RefSpd - Rated generator speed [rad/s]
Expand Down Expand Up @@ -145,8 +145,21 @@
-0.015 -0.015 -0.015 -0.015 -0.015 -0.015 -0.015 -0.015 -0.015 -0.015 -0.015 -0.015 -0.015 -0.015 -0.015 -0.015 -0.015 -0.015 -0.015 -0.015 -0.015 -0.015 -0.015 -0.015 -0.012 0.000 0.011 0.020 0.029 0.041 0.056 0.069 0.082 0.095 0.108 0.120 0.132 0.143 0.155 0.166 0.178 0.189 0.200 0.211 0.222 0.232 0.243 0.254 0.264 0.274 0.285 0.295 0.305 0.315 0.325 0.335 0.344 0.354 0.364 0.373 ! PS_BldPitchMin - Minimum blade pitch angles [rad]

!------- SHUTDOWN -----------------------------------------------------------
0.698100000000 ! SD_MaxPit - Maximum blade pitch angle to initiate shutdown, [rad]
0.418880000000 ! SD_CornerFreq - Cutoff Frequency for first order low-pass filter for blade pitch angle, [rad/s]
0 ! SD_TimeActivate - Time to acitvate shutdown modes, [s]
0 ! SD_EnablePitch - Shutdown when collective blade pitch exceeds a threshold, [-]
0 ! SD_EnableYawError - Shutdown when yaw error exceeds a threshold, [-]
0 ! SD_EnableGenSpeed - Shutdown when generator speed exceeds a threshold, [-]
0 ! SD_EnableTime - Shutdown at a predefined time, [-]
0.698100000000 ! SD_MaxPit - Maximum blade pitch angle to initiate shutdown, [rad]
0.418880000000 ! SD_PitchCornerFreq - Cutoff Frequency for first order low-pass filter for blade pitch angle for shutdown, [rad/s]
30.00000000000 ! SD_MaxYawError - Maximum yaw error to initiate shutdown, [deg]
0.418880000000 ! SD_YawErrorCornerFreq - Cutoff Frequency for first order low-pass filter for yaw error for shutdown, [rad/s]
10.00000000000 ! SD_MaxGenSpd - Maximum generator speed to initiate shutdown, [rad/s]
0.418880000000 ! SD_GenSpdCornerFreq - Cutoff Frequency for first order low-pass filter for generator speed for shutdown, [rad/s]
9999.000000000 ! SD_Time - Shutdown time, [s]
1 ! SD_Method - Shutdown method {1: Reduce generator torque and increase blade pitch}, [-]
62000.00000000 ! SD_MaxTorqueRate - Maximum torque rate for shutdown, [Nm/s]
2.000000000000 ! SD_MaxPitchRate - Maximum pitch rate used for shutdown, [rad/s]

!------- Floating -----------------------------------------------------------
1 ! Fl_n - Number of Fl_Kp gains in gain scheduling, optional with default of 1
Expand Down
23 changes: 18 additions & 5 deletions Examples/Test_Cases/IEA-15-240-RWT-UMaineSemi/DISCON-UMaineSemi.IN
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
! Controller parameter input file for the IEA-15-240-RWT-UMaineSemi wind turbine
! - File written using ROSCO version 2.9.4 controller tuning logic on 09/03/24
! - File written using ROSCO version 2.9.4 controller tuning logic on 12/11/24

!------- SIMULATION CONTROL ------------------------------------------------------------
2 ! LoggingLevel - {0: write no debug files, 1: write standard output .dbg-file, 2: LoggingLevel 1 + ROSCO LocalVars (.dbg2) 3: LoggingLevel 2 + complete avrSWAP-array (.dbg3)}
Expand All @@ -18,7 +18,7 @@
0 ! PRC_Mode - Power reference tracking mode{0: power control disabled, 1: lookup table from wind speed to generator speed setpoints, 2: change speed, torque, pitch to control power}
2 ! WE_Mode - Wind speed estimator mode {0: One-second low pass filtered hub height wind speed, 1: Immersion and Invariance Estimator, 2: Extended Kalman Filter}
1 ! PS_Mode - Pitch saturation mode {0: no pitch saturation, 1: implement pitch saturation}
0 ! SD_Mode - Shutdown mode {0: no shutdown procedure, 1: pitch to max pitch at shutdown}
0 ! SD_Mode - Shutdown mode {0: no shutdown procedure, 1: shutdown enabled}
2 ! Fl_Mode - Floating specific feedback mode {0: no nacelle velocity feedback, 1: feed back translational velocity, 2: feed back rotational veloicty}
0 ! TD_Mode - Tower damper mode (0- no tower damper, 1- feed back translational nacelle accelleration to pitch angle
0 ! TRA_Mode - Tower resonance avoidance mode (0- no tower resonsnace avoidance, 1- use torque control setpoints to avoid a specific frequency
Expand Down Expand Up @@ -81,7 +81,7 @@
21765444.21450 ! VS_MaxTq - Maximum generator torque in Region 3 (HSS side), [Nm].
0.000000000000 ! VS_MinTq - Minimum generator torque (HSS side), [Nm].
0.523600000000 ! VS_MinOMSpd - Minimum generator speed [rad/s]
32413847.90763 ! VS_Rgn2K - Generator torque constant in Region 2 (HSS side). Only used in VS_ControlMode = 1,3
33850461.49341 ! VS_Rgn2K - Generator torque constant in Region 2 (HSS side). Only used in VS_ControlMode = 1,3
15000000.00000 ! VS_RtPwr - Wind turbine rated power [W]
19786767.46773 ! VS_RtTq - Rated torque, [Nm].
0.791680000000 ! VS_RefSpd - Rated generator speed [rad/s]
Expand Down Expand Up @@ -145,8 +145,21 @@
0.060 0.060 0.060 0.060 0.060 0.060 0.056 0.052 0.047 0.041 0.036 0.029 0.022 0.015 0.008 0.001 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.006 0.021 0.033 0.044 0.053 0.064 0.074 0.084 0.093 0.103 0.112 0.121 0.130 0.138 0.147 0.155 0.163 0.172 0.180 0.188 0.196 0.203 0.211 0.219 0.227 0.234 0.242 0.250 0.257 0.265 0.272 0.279 0.287 0.294 0.301 ! PS_BldPitchMin - Minimum blade pitch angles [rad]

!------- SHUTDOWN -----------------------------------------------------------
0.698100000000 ! SD_MaxPit - Maximum blade pitch angle to initiate shutdown, [rad]
0.418880000000 ! SD_CornerFreq - Cutoff Frequency for first order low-pass filter for blade pitch angle, [rad/s]
0 ! SD_TimeActivate - Time to acitvate shutdown modes, [s]
0 ! SD_EnablePitch - Shutdown when collective blade pitch exceeds a threshold, [-]
0 ! SD_EnableYawError - Shutdown when yaw error exceeds a threshold, [-]
0 ! SD_EnableGenSpeed - Shutdown when generator speed exceeds a threshold, [-]
0 ! SD_EnableTime - Shutdown at a predefined time, [-]
0.698100000000 ! SD_MaxPit - Maximum blade pitch angle to initiate shutdown, [rad]
0.418880000000 ! SD_PitchCornerFreq - Cutoff Frequency for first order low-pass filter for blade pitch angle for shutdown, [rad/s]
30.00000000000 ! SD_MaxYawError - Maximum yaw error to initiate shutdown, [deg]
0.418880000000 ! SD_YawErrorCornerFreq - Cutoff Frequency for first order low-pass filter for yaw error for shutdown, [rad/s]
10.00000000000 ! SD_MaxGenSpd - Maximum generator speed to initiate shutdown, [rad/s]
0.418880000000 ! SD_GenSpdCornerFreq - Cutoff Frequency for first order low-pass filter for generator speed for shutdown, [rad/s]
9999.000000000 ! SD_Time - Shutdown time, [s]
1 ! SD_Method - Shutdown method {1: Reduce generator torque and increase blade pitch}, [-]
4500000.000000 ! SD_MaxTorqueRate - Maximum torque rate for shutdown, [Nm/s]
0.034900000000 ! SD_MaxPitchRate - Maximum pitch rate used for shutdown, [rad/s]

!------- Floating -----------------------------------------------------------
1 ! Fl_n - Number of Fl_Kp gains in gain scheduling, optional with default of 1
Expand Down
23 changes: 18 additions & 5 deletions Examples/Test_Cases/MHK_RM1/MHK_RM1_DISCON.IN
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
! Controller parameter input file for the MHK_RM1_Floating wind turbine
! - File written using ROSCO version 2.9.4 controller tuning logic on 09/03/24
! - File written using ROSCO version 2.9.4 controller tuning logic on 12/11/24

!------- SIMULATION CONTROL ------------------------------------------------------------
2 ! LoggingLevel - {0: write no debug files, 1: write standard output .dbg-file, 2: LoggingLevel 1 + ROSCO LocalVars (.dbg2) 3: LoggingLevel 2 + complete avrSWAP-array (.dbg3)}
Expand All @@ -18,7 +18,7 @@
0 ! PRC_Mode - Power reference tracking mode{0: power control disabled, 1: lookup table from wind speed to generator speed setpoints, 2: change speed, torque, pitch to control power}
0 ! WE_Mode - Wind speed estimator mode {0: One-second low pass filtered hub height wind speed, 1: Immersion and Invariance Estimator, 2: Extended Kalman Filter}
0 ! PS_Mode - Pitch saturation mode {0: no pitch saturation, 1: implement pitch saturation}
0 ! SD_Mode - Shutdown mode {0: no shutdown procedure, 1: pitch to max pitch at shutdown}
0 ! SD_Mode - Shutdown mode {0: no shutdown procedure, 1: shutdown enabled}
1 ! Fl_Mode - Floating specific feedback mode {0: no nacelle velocity feedback, 1: feed back translational velocity, 2: feed back rotational veloicty}
0 ! TD_Mode - Tower damper mode (0- no tower damper, 1- feed back translational nacelle accelleration to pitch angle
0 ! TRA_Mode - Tower resonance avoidance mode (0- no tower resonsnace avoidance, 1- use torque control setpoints to avoid a specific frequency
Expand Down Expand Up @@ -81,7 +81,7 @@
12450.50344000 ! VS_MaxTq - Maximum generator torque in Region 3 (HSS side), [Nm].
0.000000000000 ! VS_MinTq - Minimum generator torque (HSS side), [Nm].
19.00309000000 ! VS_MinOMSpd - Minimum generator speed [rad/s]
1.142870000000 ! VS_Rgn2K - Generator torque constant in Region 2 (HSS side). Only used in VS_ControlMode = 1,3
1.210670000000 ! VS_Rgn2K - Generator torque constant in Region 2 (HSS side). Only used in VS_ControlMode = 1,3
500000.0000000 ! VS_RtPwr - Wind turbine rated power [W]
8300.335630000 ! VS_RtTq - Rated torque, [Nm].
63.81200000000 ! VS_RefSpd - Rated generator speed [rad/s]
Expand Down Expand Up @@ -145,8 +145,21 @@
0.001 0.001 0.001 0.001 0.001 0.001 0.001 0.001 0.001 0.001 0.001 0.001 0.001 0.001 0.001 0.001 0.001 0.001 0.001 0.001 0.001 0.001 0.001 0.001 0.001 0.001 0.001 0.001 0.001 0.001 0.001 0.001 0.001 0.001 0.001 0.001 0.001 0.001 0.001 0.001 0.001 0.001 0.001 0.001 0.001 0.001 0.001 0.001 0.001 0.001 0.001 0.001 0.001 0.001 0.001 0.001 0.001 0.001 0.001 0.001 ! PS_BldPitchMin - Minimum blade pitch angles [rad]

!------- SHUTDOWN -----------------------------------------------------------
0.436300000000 ! SD_MaxPit - Maximum blade pitch angle to initiate shutdown, [rad]
0.418880000000 ! SD_CornerFreq - Cutoff Frequency for first order low-pass filter for blade pitch angle, [rad/s]
0 ! SD_TimeActivate - Time to acitvate shutdown modes, [s]
0 ! SD_EnablePitch - Shutdown when collective blade pitch exceeds a threshold, [-]
0 ! SD_EnableYawError - Shutdown when yaw error exceeds a threshold, [-]
0 ! SD_EnableGenSpeed - Shutdown when generator speed exceeds a threshold, [-]
0 ! SD_EnableTime - Shutdown at a predefined time, [-]
0.698100000000 ! SD_MaxPit - Maximum blade pitch angle to initiate shutdown, [rad]
0.418880000000 ! SD_PitchCornerFreq - Cutoff Frequency for first order low-pass filter for blade pitch angle for shutdown, [rad/s]
30.00000000000 ! SD_MaxYawError - Maximum yaw error to initiate shutdown, [deg]
0.418880000000 ! SD_YawErrorCornerFreq - Cutoff Frequency for first order low-pass filter for yaw error for shutdown, [rad/s]
10.00000000000 ! SD_MaxGenSpd - Maximum generator speed to initiate shutdown, [rad/s]
0.418880000000 ! SD_GenSpdCornerFreq - Cutoff Frequency for first order low-pass filter for generator speed for shutdown, [rad/s]
9999.000000000 ! SD_Time - Shutdown time, [s]
1 ! SD_Method - Shutdown method {1: Reduce generator torque and increase blade pitch}, [-]
7800.000000000 ! SD_MaxTorqueRate - Maximum torque rate for shutdown, [Nm/s]
0.174500000000 ! SD_MaxPitchRate - Maximum pitch rate used for shutdown, [rad/s]

!------- Floating -----------------------------------------------------------
1 ! Fl_n - Number of Fl_Kp gains in gain scheduling, optional with default of 1
Expand Down
Loading

0 comments on commit 938e4f1

Please sign in to comment.