Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed-Pitch Torque Control in Region 3 #347

Open
wants to merge 267 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
267 commits
Select commit Hold shift + click to select a range
0575d75
Re-organize AWC pitch contribution, before actuator
dzalkind Jan 23, 2023
974e271
Separate contribution to PitCom from mode calculation
dzalkind Jan 23, 2023
515da17
Make AWC_complexangle a LocalVar for logging
dzalkind Jan 23, 2023
be28641
Allow PA_Mode 1 (#213)
dzalkind Jan 25, 2023
e554c1d
IPC Saturation Fix [RAAW] (#210)
dzalkind Jan 26, 2023
c51ed30
Removed duplicate pitch assignment and removed MinPitch mods for AWC
ndevelder Jan 27, 2023
3155b63
Add script for updating DISCON versions (#214)
dzalkind Feb 2, 2023
0c0e466
Fixes to readsetparams and awc location
ndevelder Feb 3, 2023
20c9c9d
Adding NREL 2.8 127 for AWC testing
ndevelder Feb 3, 2023
a1cf97b
Rename examples (#215)
dzalkind Feb 7, 2023
42525a9
V270 prep (#218)
dzalkind Feb 10, 2023
f5c3c1e
Add case generation updates
dzalkind Feb 10, 2023
a471783
Add initial AWC example, needs OF3.4
dzalkind Feb 10, 2023
2f941e3
Merge remote-tracking branch 'upstream/main' into develop
dzalkind Feb 10, 2023
d05ef6c
Merge branch 'develop' into rosco_awc_merge
dzalkind Feb 10, 2023
80bd691
Add AWC_Mode and move AWC into subroutine
dzalkind Feb 10, 2023
b102b34
Update example to point to correct inputs
dzalkind Feb 10, 2023
5c5333b
Remove LocalVar%PC_MinPit = CntrPar%PC_MinPit, breaking setpoint smoo…
dzalkind Feb 10, 2023
da46fac
Set min pitch for AWC
dzalkind Feb 10, 2023
cc4080d
Tidy up input additions
dzalkind Feb 10, 2023
1201a66
Update other DISCONs
dzalkind Feb 10, 2023
1693602
Add AWC to toolbox schema
dzalkind Feb 10, 2023
2bb0176
Tidy example
dzalkind Feb 10, 2023
d93d443
Update AWC example with instructions/theory
ndevelder Feb 14, 2023
3c40565
Formatting fixes
ndevelder Feb 14, 2023
83022e5
Prep for more modes
dzalkind Feb 15, 2023
a7d3303
Merge remote-tracking branch 'upstream/main' into develop
dzalkind Feb 15, 2023
f6d061f
Update 20_active_wake_control.py
kbrown1snl Feb 16, 2023
1824f99
Fix units in schema
dzalkind Feb 16, 2023
cabbb2a
Merge pull request #1 from kbrown1snl/patch-1
ndevelder Feb 17, 2023
de16ecd
Test all AWC cases in example 20
dzalkind Feb 17, 2023
de3a6fe
Tidy up DISCON file writing
dzalkind Feb 17, 2023
87b3f09
Revert setup directory
dzalkind Feb 17, 2023
46e7168
Update 20_active_wake_control.py
kbrown1snl Feb 22, 2023
32dc9fd
Update NREL-2p8-127_DISCON.IN
kbrown1snl Feb 24, 2023
ae5090b
Update Controllers.f90
kbrown1snl Feb 24, 2023
5c878ad
Update ROSCO_Types.f90
kbrown1snl Feb 24, 2023
baaa8db
Update ReadSetParameters.f90
kbrown1snl Feb 24, 2023
b141c4e
Update 20_active_wake_control.py
kbrown1snl Feb 24, 2023
826ca01
Update toolbox_schema.yaml
kbrown1snl Feb 24, 2023
797e554
Update utilities.py
kbrown1snl Feb 24, 2023
ff0ce39
Update rosco_types.yaml
kbrown1snl Feb 24, 2023
3bc2185
Added NREL-developed AWC-implementation
jfrederik-nrel Feb 27, 2023
687b760
Undo unintentional changes to wrie_registry.py
jfrederik-nrel Feb 28, 2023
70d5771
Fix file writing in AWC section
dzalkind Feb 28, 2023
b24f07b
Merge remote-tracking branch 'upstream/develop' into awc
dzalkind Feb 28, 2023
a9ec14e
Update all DISCONs
dzalkind Feb 28, 2023
4604ebb
Add 20_awc to test_examples
dzalkind Feb 28, 2023
b17f350
Add 2.8 to update_discons, regenerate DISCON
dzalkind Feb 28, 2023
b2fdfbc
Update AWC_Mode descriptions
dzalkind Feb 28, 2023
e899600
Updated Coleman Transformation based AWC
jfrederik-nrel Mar 7, 2023
1ccc1b3
Platform control and Optional Inputs (#227)
dzalkind Mar 7, 2023
87cde8c
Merge remote-tracking branch 'upstream/develop' into awc
dzalkind Mar 7, 2023
8ea0a4c
Merge remote-tracking branch 'jfred/AWC_NREL' into awc
dzalkind Mar 7, 2023
daf77e9
Merge remote-tracking branch 'ndev/rosco_awc_merge' into awc
dzalkind Mar 7, 2023
ca7c44d
Tidy print statements, file writing
dzalkind Mar 7, 2023
4e2a778
Remove duplicate PF_Offsets input read
dzalkind Mar 7, 2023
74c7fcb
Rename methods in readme
dzalkind Mar 7, 2023
e4d7ec2
Tidy input writing, remove `future` references
dzalkind Mar 7, 2023
4194da4
Force AWC_n into int
dzalkind Mar 8, 2023
c1e4be7
Force AWC_n into int better
dzalkind Mar 8, 2023
5e75601
Make AWC_n a list, too
dzalkind Mar 8, 2023
de8d228
Fix input file writing, force into int in write_array
dzalkind Mar 8, 2023
e1379de
Run ROSCO_testing from anywhere
dzalkind Mar 8, 2023
2947b4f
Dylib -> so in Test_Cases
dzalkind Mar 8, 2023
cae3f17
Updated AWC input parameters.
jfrederik-nrel Mar 15, 2023
bd4d7d5
Added checks for AWC inputs.
jfrederik-nrel Mar 16, 2023
1e25c88
Fixed bug in added AWC input checks.
jfrederik-nrel Mar 16, 2023
50f4191
Update error message
dzalkind Mar 20, 2023
50bd08c
Tidy up IPC, allow AWC and IPC with warning
dzalkind Mar 20, 2023
e02379d
Remove AWC references from IPC
dzalkind Mar 20, 2023
3851a6b
Remove lingering comment
dzalkind Mar 20, 2023
9d7e18d
Tidy file writing
dzalkind Mar 20, 2023
7f12c9c
Clean up comments
dzalkind Mar 20, 2023
8e4cf8b
Allow more than 99 local variables in dbg2
dzalkind Mar 20, 2023
bc33417
Update api_change.rst
jfrederik-nrel Mar 20, 2023
17ce1a5
Merge remote-tracking branch 'jfred/patch-1' into awc
dzalkind Mar 20, 2023
728c61d
Update 20_active_wake_control.py
kbrown1snl Mar 27, 2023
820aa66
Merge pull request #2 from kbrown1snl/patch-2
dzalkind Mar 27, 2023
90c4041
Add optimized NREL2p8 controller input
dzalkind Mar 30, 2023
5afb385
Parallelize output processing
dzalkind Apr 3, 2023
fbb44c4
Add IPC gain to NREL2p8
dzalkind Apr 3, 2023
fe24704
Merge remote-tracking branch 'upstream/develop' into power_ref_tracking
dzalkind Apr 3, 2023
52e3708
Finish merge with inputs and registry
dzalkind Apr 3, 2023
1e38c90
Update IPC example for testing sat modes
dzalkind Apr 3, 2023
e49f383
Add latest plot_FAST notebook
dzalkind Apr 3, 2023
9e5fd58
Add PRC example
dzalkind Apr 3, 2023
f1037ec
Merge remote-tracking branch 'origin/awc' into power_ref_tracking
dzalkind Apr 3, 2023
099532b
Finish merge with awc inputs and registry
dzalkind Apr 3, 2023
5a7046f
Active Wake Control (#230)
dzalkind Apr 3, 2023
8a39f3c
Update example with ramp, reference
dzalkind Apr 3, 2023
7669419
Merge remote-tracking branch 'upstream/develop' into power_ref_tracking
dzalkind Apr 3, 2023
de15e52
Various bug fixes (#233)
dzalkind Apr 4, 2023
ac14b17
Init PC_RefSpeed if no PRC
dzalkind Apr 5, 2023
60b366d
Revert openfast changes
dzalkind Apr 5, 2023
24bded0
Add note about offset
dzalkind Apr 5, 2023
585e2c8
Open loop platform control (#236)
dzalkind Apr 10, 2023
339ad53
Tidy example output
dzalkind Apr 10, 2023
79426f7
Increment version number
dzalkind Apr 10, 2023
90357a2
Merge remote-tracking branch 'upstream/develop' into power_ref_tracking
dzalkind Apr 20, 2023
12f8fdb
Merge remote-tracking branch 'upstream/main' into develop
dzalkind Jun 8, 2023
5fd97e2
Increment version number
dzalkind Jun 8, 2023
e5b1af5
Yaw Rate Bug Fix (#239)
dzalkind Jun 9, 2023
c701f67
OpenFAST 3.5.0 (#246)
dzalkind Jul 10, 2023
2f069da
Floating Feedback Gain Scheduling (#241)
alandwright Jul 20, 2023
9de385b
Merge remote-tracking branch 'upstream/develop' into power_ref_tracking
dzalkind Jul 24, 2023
d9547dd
Fix relative Cp filepaths
dzalkind Jul 24, 2023
178217b
Regenerate registry, inputs
dzalkind Jul 24, 2023
c641b54
Rotor Position Control (#255)
dzalkind Aug 4, 2023
31332d9
Update .readthedocs.yaml to remove use of 'system_packages' as it is …
abhineet-gupta Aug 9, 2023
63bcb0d
Extend ROSCO for MHK (#257)
AthulKrishnaSundarrajan Sep 19, 2023
716b2e4
Merge remote-tracking branch 'upstream/develop' into power_ref_tracking
dzalkind Sep 22, 2023
b27629b
Rename power ref example
dzalkind Sep 22, 2023
ea55560
Shorten PRC example
dzalkind Sep 22, 2023
b5eb5c0
Use updated DISCON writing functions for PRC inputs
dzalkind Sep 22, 2023
24052dc
Revert run_FAST cases
dzalkind Sep 25, 2023
3092e38
Tidy example documentation, output
dzalkind Sep 25, 2023
b817a5c
Bring back new VS_ControlMode that merge lost
dzalkind Sep 25, 2023
38f27de
Add LPF on WSE for speed selection, use gen speed rather than rotor
dzalkind Sep 26, 2023
d9a31fb
Document API changes
dzalkind Sep 26, 2023
32292e5
Bring back saturation of torque reference speed
dzalkind Sep 26, 2023
3b0bde0
Update PRC example with PRC_GenSpeeds
dzalkind Sep 26, 2023
e75baa2
Remove pCrunch notebook
dzalkind Sep 27, 2023
989ce5b
Merge pull request #170 from dzalkind/power_ref_tracking
abhineet-gupta Sep 27, 2023
2c76747
Increase max file unit (#253)
dzalkind Oct 6, 2023
b66cd11
Add types to scalars (#264)
rthedin Oct 17, 2023
0e80094
Update api_change.rst formatting
dzalkind Oct 17, 2023
f2a624d
Update .readthedocs.yaml with build.os
dzalkind Oct 17, 2023
6f1ccfa
Update .readthedocs.yaml with other build options
dzalkind Oct 17, 2023
80973fe
Update .readthedocs.yaml with python 3.9
dzalkind Oct 17, 2023
04d3f52
Update .readthedocs.yaml with new python version
dzalkind Oct 17, 2023
c479034
Update .readthedocs.yaml with another python version
dzalkind Oct 17, 2023
328d29e
Update .readthedocs.yaml with version key
dzalkind Oct 17, 2023
8693d4b
Update .readthedocs.yaml
dzalkind Oct 17, 2023
dd01047
Update .readthedocs.yaml remove old python version
dzalkind Oct 17, 2023
a610e55
Better Open Loop Control Error Catching (#273)
dzalkind Oct 27, 2023
c75738e
Modified ZeroMQ interface to include pitch offsets (#261)
mvanv Nov 6, 2023
1961f95
Merged upstream/develop
Mar 27, 2024
6ceb155
Add initial torque/speed power controllers
dzalkind Mar 27, 2024
3a5c59a
Add power control via pitch
dzalkind Mar 28, 2024
0ddbf0d
Merge remote-tracking branch 'upstream/develop' into develop
May 8, 2024
f846f17
Initial implementation of fixed blade pitch control for MHK turbines.…
May 9, 2024
748d975
Remove extra test_cases
dzalkind May 10, 2024
2787ff9
Expanded test script and made cc-blade Cp surface generation extend t…
May 10, 2024
c15e869
Merged and regenerated rotor performance in the right place
May 10, 2024
32ecfc8
updated DISCONs
May 10, 2024
8c57a31
Remove extra RefSpd localvars
dzalkind May 10, 2024
4c1202c
Merge remote-tracking branch 'ds/r3-fixed-pitch' into r3-fixed-pitch
dzalkind May 10, 2024
de4f6a7
Added overspeed config option and expanded Cp surface again
May 10, 2024
ae07303
Add constants for various VS_Control modes
dzalkind May 10, 2024
2df9e54
Regen registry
dzalkind May 10, 2024
8eab998
Cleaned up fixed pitch example script
May 10, 2024
38e28cf
Merge remote-tracking branch 'ds/r3-fixed-pitch' into r3-fixed-pitch
dzalkind May 10, 2024
1008cc6
Added comments to fixed pitch controller tuning, rearranged torque co…
May 13, 2024
25001e0
Finished renaming FBP variables and VS ref speed filter
May 13, 2024
822b731
Regenerated DISCONs
May 13, 2024
e639706
Merge remote-tracking branch 'ds/r3-fixed-pitch' into r3-fixed-pitch
dzalkind May 15, 2024
7726f0d
Disable the pitch controller at the DISCON level
dzalkind May 15, 2024
01121e2
Working on overspeed operating schedule, still not yet giving stable …
May 15, 2024
be58bbb
Merge branch 'r3-fixed-pitch' of https://github.com/dstockhouse/ROSCO…
May 15, 2024
ab7a1f8
Update .readthedocs.yaml
dzalkind Jun 14, 2024
7870a01
Implement open loop PRC inputs
dzalkind Jun 14, 2024
b8559fa
Add ZMQ PRC inputs, defaults in wfc setpoints
dzalkind Jun 14, 2024
7546879
Update to latest scipy functions
dzalkind Jul 1, 2024
86cf9f6
Update max_torque_rates
dzalkind Jul 1, 2024
105dc45
Switch constants to integers
dzalkind Jul 2, 2024
c9895f6
Merge remote-tracking branch 'origin/fix_scipy' into power_control
dzalkind Jul 2, 2024
8b62b85
Let R_Speed affect below rated ref speed (based on TSR)
dzalkind Jul 2, 2024
ed1522a
Merge branch 'main' into docs
dzalkind Jul 12, 2024
a83e4bb
Docs: Fix small bug in docs that caused errors with links
abhineet-gupta Jul 12, 2024
3cc17b3
Add open loop control with wind speed breakpoints
dzalkind Jul 12, 2024
a2255a1
Add checks for power control
dzalkind Jul 12, 2024
102286d
Considerable cahnges to fixed-blade-pitch (FBP) operation for marine …
Jul 25, 2024
541fe81
Start using automatic documentation for examples (#371)
abhineet-gupta Aug 9, 2024
df133ee
Added autodocumentation template for all examples
abhineet-gupta Aug 10, 2024
ead419d
Merge remote-tracking branch 'upstream/develop' into develop
Aug 15, 2024
f0debea
Merged branch upstream/develop
Aug 15, 2024
6216972
Fixed bug in FBP control with VS_RefSpd turning to NaN if GenTq ever …
Aug 21, 2024
ce1b0eb
Revised usage of generator and gearbox efficiencies in toolbox contro…
Aug 22, 2024
b12e499
Re-enable previous PRC_Mode
dzalkind Sep 3, 2024
0b569e4
Update 5MW yamls for constant power
dzalkind Sep 3, 2024
a24f157
Edit comments
dzalkind Sep 3, 2024
c5c2920
Merge remote-tracking branch 'origin/develop' into power_control
dzalkind Sep 3, 2024
860182d
Merge remote-tracking branch 'origin/docs' into power_control
dzalkind Sep 3, 2024
9456ef2
Check for IPC openfast flag when using AWC
dzalkind Sep 3, 2024
87f681e
Merge remote-tracking branch 'origin/main' into power_control
dzalkind Sep 3, 2024
9124f93
Update discons
dzalkind Sep 3, 2024
44703b6
Modified comments related to GBoxEff in rng2K calculation
Sep 5, 2024
3327225
Fix GB and gen efficiencies
dzalkind Sep 5, 2024
552a434
Merge remote-tracking branch 'origin/develop' into vbf
dzalkind Sep 5, 2024
27476f9
Allow updating of Ind_BldPitch from int to array
dzalkind Sep 9, 2024
ac73dde
Remove print statement
dzalkind Sep 10, 2024
bdc1c3e
Add power control example
dzalkind Sep 10, 2024
5eb81de
Fix issue where PRC_Mode 2 was not setting PC_RefSpeed_PRC
dzalkind Sep 10, 2024
008c154
Add offset to sine_timeseries
dzalkind Sep 10, 2024
5c94207
Clean up power control example
dzalkind Sep 10, 2024
d77ba20
Restructured some controller code related to saturation, attempted to…
Sep 18, 2024
6d79062
Added more precise calculation of Cp-optimizing pitch and updated the…
Sep 18, 2024
2ec41dd
Disable WSE automatically outside normal operation
dzalkind Sep 27, 2024
302a6ba
Fix OL_BP_FiltFreq input writing
dzalkind Sep 27, 2024
0c0e423
Check breakpoints of open loop control against maxima
dzalkind Sep 27, 2024
f249520
Account for rating command in setpoint smoother
dzalkind Sep 27, 2024
90ccdd8
Set up PRC demos and documentation
dzalkind Sep 27, 2024
26fe47c
Elaborate old PRC documentation
dzalkind Sep 27, 2024
82413fc
Update some example documentation
dzalkind Sep 27, 2024
d1021ff
Update example list in docs
dzalkind Sep 27, 2024
b450185
Fix old open loop nomenclature
dzalkind Sep 27, 2024
7882913
Fix error message in ol control
dzalkind Sep 30, 2024
ee2b46a
Configure PRC example for CI
dzalkind Sep 30, 2024
8b304cf
Add docs images
dzalkind Sep 30, 2024
aa1694d
Add a note about building docs
dzalkind Sep 30, 2024
8778c79
Fix global variables in Example 17a and 17b
abhineet-gupta Sep 30, 2024
b0aa0e4
Merge remote-tracking branch 'origin/docs' into docs
dzalkind Oct 3, 2024
16551d0
Merge remote-tracking branch 'origin/docs' into power_control
dzalkind Oct 3, 2024
f075c80
Try numpy<2.0
dzalkind Oct 3, 2024
4486d7a
Fixed bug where TRA_LastRefSpd was set to a generator speed not the L…
BenClaytonARUP Oct 3, 2024
e6cc03a
Merge remote-tracking branch 'origin/docs' into power_control
dzalkind Oct 3, 2024
ca57895
Merge remote-tracking branch 'origin/vbf' into power_control
dzalkind Oct 3, 2024
7a958ac
Merge remote-tracking branch 'origin/develop' into power_control
dzalkind Oct 3, 2024
4055eeb
Document PRC API changes
dzalkind Oct 3, 2024
914ea41
Merge branch 'power_control' into r3-fixed-pitch
dzalkind Oct 3, 2024
7bb60d4
Merge remote-tracking branch 'origin/develop' into r3-fixed-pitch
dzalkind Oct 25, 2024
849dcfd
Regenerate DISCONs
dzalkind Oct 25, 2024
f39b6e4
Regenerate Types/IO
dzalkind Oct 25, 2024
e51ff1f
Fix VS_MaxTq logic
dzalkind Oct 28, 2024
91bea8c
Tidy PC_State logic
dzalkind Oct 28, 2024
80a0117
Sync vs ref and wse filters
dzalkind Nov 12, 2024
6f29db0
Regenerate discons
dzalkind Nov 15, 2024
b60e925
Tidy up DISCON formatting
dzalkind Nov 15, 2024
33a3a36
Tidy up some code comments
dzalkind Nov 15, 2024
8be8713
Rename example
dzalkind Nov 15, 2024
ed159ed
Add F_VSRefSpdCornerFreq to minimal DISCON inputs, it's required
dzalkind Nov 15, 2024
aa34445
Start documentation of fixed pitch example
dzalkind Nov 15, 2024
f69d11a
Let user specify configuration of controller in fixed pitch example
dzalkind Nov 15, 2024
e755276
Update max torque limit logic
dzalkind Dec 5, 2024
05c4f37
Add checks on fixed blade pitch control and other modes
dzalkind Dec 5, 2024
7390267
Add fixed pitch control example docs
dzalkind Dec 5, 2024
c1d32f2
Update images in ex 30 docs
dzalkind Dec 5, 2024
daf36bc
Add mpi_tools to rosco
dzalkind Dec 4, 2024
8ae616d
Merge remote-tracking branch 'origin/develop' into r3-fixed-pitch
dzalkind Dec 10, 2024
fd29747
Merge remote-tracking branch 'origin/develop' into r3-fixed-pitch
dzalkind Dec 13, 2024
3900637
Finish merge: regen discons, registry
dzalkind Dec 13, 2024
2b00bbb
Rename fixed pitch example, add to tests
dzalkind Dec 13, 2024
395c681
Fix typo in example test
dzalkind Dec 13, 2024
fa51fab
Use WSE filter as default ref speed filter, Check updated discon
dzalkind Dec 27, 2024
840fa79
Tidy imports
dzalkind Dec 27, 2024
8891a86
Increment ROSCO version
dzalkind Dec 27, 2024
fa1aa7e
Do not set default wind_case_fcn
dzalkind Jan 3, 2025
8671afa
Set up ex31 to simulate each config easily
dzalkind Jan 3, 2025
334e94c
Simplify save_dir
dzalkind Jan 3, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 20 additions & 1 deletion Examples/19_update_discon_version.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@
"""

import os
import shutil
from rosco import discon_lib_path
from rosco.toolbox import control_interface as ROSCO_ci
from rosco.toolbox.tune import update_discon_version

def main():
Expand All @@ -16,11 +19,27 @@ def main():

# Tuning yaml can be anything, does not have to correspond to old discon
tuning_yaml = os.path.join(this_dir,'Tune_Cases','NREL5MW.yaml') # dummy for now
new_discon = os.path.join(this_dir,'examples_out','18_UPDATED_DISCON.IN')
update_discon_version(
old_discon_filename,
tuning_yaml,
os.path.join(this_dir,'examples_out','18_UPDATED_DISCON.IN')
new_discon
)

# Try using updated DISCON

shutil.copyfile(
os.path.join(this_dir,'example_inputs','Cp_Ct_Cq.IEA15MW.txt'),
os.path.join(this_dir,'examples_out','Cp_Ct_Cq.IEA15MW.txt')
) # Copy Cp table for testing

controller_int = ROSCO_ci.ControllerInterface(
discon_lib_path,
param_filename=new_discon,
sim_name='sim1')
controller_int.kill_discon()

assert(controller_int.aviFAIL.value == 0)

if __name__ == "__main__":
main()
2 changes: 0 additions & 2 deletions Examples/21_optional_inputs.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,7 @@
import os
from rosco import discon_lib_path
from rosco.toolbox import control_interface as ROSCO_ci
#from rosco.toolbox import sim as ROSCO_sim
from rosco.toolbox import turbine as ROSCO_turbine
#import numpy as np

def main():#directories
this_dir = os.path.dirname(os.path.abspath(__file__))
Expand Down
234 changes: 234 additions & 0 deletions Examples/31_fixed_pitch_mhk.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,234 @@
'''
30_fixed_pitch_mhk
------------------

This example demonstrates the fixed-pitch control of a marine hydrodkinetic (MHK) turbine.

There are several ways to control the power output of a turbine in above-rated conditions.
In this example we demonstrate the following control configurations:

#. Constant power underspeed (should be the default)
#. Constant power overspeed
#. Linear increasing power
#. Linear increasing power, leveling out
#. Generic numeric function
#. Constant power overspeed, nonlinear lookup table control

The desired power curves of each configuration are as follows:

.. image:: ../images/30_fixed_pitch_mhk_sched.png

In the first case, the reference generator speed is decreased (underspeed) to maintain a constant rated power above rated.
To slow down the generator, a higher torque must be used:

.. image:: ../images/30_fixed_pitch_mhk_sim.png



'''

# Copying images, from docs/:
# cp ../Examples/examples_out/30_fixed_pitch_mhk_sched.png images/
# cp ../Examples/examples_out/30_fixed_pitch_mhk_sim.png images/

import os
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
from rosco.toolbox import controller as ROSCO_controller
from rosco.toolbox import turbine as ROSCO_turbine
from rosco.toolbox import utilities as ROSCO_utilities
from rosco.toolbox.utilities import write_DISCON
from rosco.toolbox.inputs.validation import load_rosco_yaml
import matplotlib.pyplot as plt
import numpy as np



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

def main():

FULL_TEST = False # Run a full test locally (True) or a shorter one for CI
sim_config = 1 # Choose which simulation configuration (1-6)

# Input yaml and output directory
parameter_filename = os.path.join(this_dir, 'Tune_Cases/RM1_MHK_FBP.yaml')
tune_dir = os.path.dirname(parameter_filename)

inps = load_rosco_yaml(parameter_filename)
path_params = inps['path_params']
turbine_params = inps['turbine_params']
controller_params = inps['controller_params']

# Instantiate turbine, controller, and file processing classes
turbine = ROSCO_turbine.Turbine(turbine_params)
controller = ROSCO_controller.Controller(controller_params)

# Load turbine data from OpenFAST and rotor performance text file
cp_filename = os.path.join(tune_dir, path_params['rotor_performance_filename'])
turbine.load_from_fast(
path_params['FAST_InputFile'],
os.path.join(tune_dir, path_params['FAST_directory']),
rot_source='txt', txt_filename= cp_filename
)


### Tune controller cases
# Constant power underspeed (should be the default)
controller_params_1 = controller_params.copy()
controller_params_1['VS_FBP'] = 3 # Power reference
controller_params_1['VS_FBP_speed_mode'] = 0
controller_params_1['VS_FBP_U'] = [2.0, 4.0]
controller_params_1['VS_FBP_P'] = [1.0, 1.0]
controller_1 = ROSCO_controller.Controller(controller_params_1)
controller_1.tune_controller(turbine)

# Constant power overspeed
controller_params_2 = controller_params.copy()
controller_params_2['VS_FBP'] = 2 # Switch to WSE reference
controller_params_2['VS_FBP_speed_mode'] = 1
controller_params_2['VS_FBP_U'] = [2.0, 4.0]
controller_params_2['VS_FBP_P'] = [1.0, 1.0]
controller_2 = ROSCO_controller.Controller(controller_params_2)
controller_2.tune_controller(turbine)

# Linear increasing power
controller_params_3 = controller_params.copy()
controller_params_3['VS_FBP_speed_mode'] = 0
controller_params_2['VS_FBP_U'] = [2.0, 4.0]
controller_params_3['VS_FBP_P'] = [1.0, 2.0]
controller_3 = ROSCO_controller.Controller(controller_params_3)
controller_3.tune_controller(turbine)

# Linear increasing power, leveling out
controller_params_4 = controller_params.copy()
controller_params_4['VS_FBP_U'] = [2.0, 3.0]
controller_params_4['VS_FBP_P'] = [1.0, 2.0]
controller_4 = ROSCO_controller.Controller(controller_params_4)
controller_4.tune_controller(turbine)

# Generic numeric function
controller_params_5 = controller_params.copy()
controller_params_5['VS_FBP'] = 2 # WSE reference
controller_params_5['VS_FBP_U'] = [2.0, 2.2, 2.4, 2.6, 2.8, 3.0, 3.2, 3.4, 3.6, 3.8, 4.0]
controller_params_5['VS_FBP_P'] = [1.0, 1.3, 1.6, 1.8, 1.9, 2.0, 1.9, 1.8, 1.7, 1.6, 1.5]
controller_5 = ROSCO_controller.Controller(controller_params_5)
controller_5.tune_controller(turbine)

# Constant power overspeed, nonlinear lookup table control
controller_params_6 = controller_params.copy()
controller_params_6['VS_FBP'] = 1 # Constant power overspeed
controller_params_6['VS_FBP_speed_mode'] = 1
controller_params_6['VS_FBP_U'] = [2.0, 4.0]
controller_params_6['VS_FBP_P'] = [1.0, 1.0]
controller_params_6['VS_ControlMode'] = 1
controller_6 = ROSCO_controller.Controller(controller_params_6)
controller_6.tune_controller(turbine)


plot_labels = ['Constant Power Underspeed', 'Constant Power Overspeed', 'Linear Increasing Power', 'Increasing Leveled Power', 'Generic User-Defined']
fig, axs = plt.subplots(3,1)
axs[0].plot(controller_1.v, controller_1.power_op, label=plot_labels[0])
axs[0].plot(controller_2.v, controller_2.power_op, label=plot_labels[1], linestyle='--')
axs[0].plot(controller_3.v, controller_3.power_op, label=plot_labels[2])
axs[0].plot(controller_4.v, controller_4.power_op, label=plot_labels[3])
axs[0].plot(controller_5.v, controller_5.power_op, label=plot_labels[4])
axs[0].set_ylabel('Gen Power [W]')
axs[1].plot(controller_1.v, controller_1.omega_gen_op, label=plot_labels[0])
axs[1].plot(controller_2.v, controller_2.omega_gen_op, label=plot_labels[1], linestyle='--')
axs[1].plot(controller_3.v, controller_3.omega_gen_op, label=plot_labels[2])
axs[1].plot(controller_4.v, controller_4.omega_gen_op, label=plot_labels[3])
axs[1].plot(controller_5.v, controller_5.omega_gen_op, label=plot_labels[4])
axs[1].set_ylabel('Gen Speed [rad/s]')
axs[2].plot(controller_1.v, controller_1.tau_op, label=plot_labels[0])
axs[2].plot(controller_2.v, controller_2.tau_op, label=plot_labels[1], linestyle='--')
axs[2].plot(controller_3.v, controller_3.tau_op, label=plot_labels[2])
axs[2].plot(controller_4.v, controller_4.tau_op, label=plot_labels[3])
axs[2].plot(controller_5.v, controller_5.tau_op, label=plot_labels[4])
axs[2].set_ylabel('Gen Torque [N m]')
axs[2].set_xlabel('Flow Speed [m/s]')
axs[0].legend(loc='upper left', bbox_to_anchor=(.2, 2.35))

fig.align_ylabels()
plt.subplots_adjust(hspace=0.5)


if False:
plt.show()
else:
fig_fname = os.path.join(example_out_dir, '30_fixed_pitch_mhk_sched.png')
print('Saving figure ' + fig_fname)
plt.savefig(fig_fname,bbox_inches='tight',)

# Write parameter input file for constant power underspeed controller
run_dir = os.path.join(example_out_dir, f'31_MHK/{sim_config}_config')
os.makedirs(run_dir,exist_ok=True)

# simulation set up
if FULL_TEST:
TMax = 60
else:
TMax = 5

all_controller_params = [
controller_params_1,
controller_params_2,
controller_params_3,
controller_params_4,
controller_params_5,
controller_params_6,
]

if sim_config in range(1,len(all_controller_params)+1):
controller_params = all_controller_params[sim_config-1]
else:
raise Exception(f'Invalid sim_config of {sim_config}. Note the 1-indexing.')

r = run_FAST_ROSCO()
r.tuning_yaml = parameter_filename
r.wind_case_fcn = cl.power_curve
r.wind_case_opts = {
'U': [3.0],
'TMax': TMax,
}
r.case_inputs = {}
r.controller_params = controller_params
r.save_dir = run_dir
r.rosco_dir = rosco_dir

r.run_FAST()

op = output_processing.output_processing()
fast_out = op.load_fast_out([os.path.join(run_dir,'RM1_MHK_FBP/power_curve/base/RM1_MHK_FBP_0.out')], tmin=0)
fig, axs = plt.subplots(4,1)
axs[0].plot(fast_out[0]['Time'], fast_out[0]['Wind1VelX'], label='Constant Power Underspeed')
axs[0].set_ylabel('Flow Speed [m/s]',rotation=0, labelpad=50)
axs[1].plot(fast_out[0]['Time'], fast_out[0]['GenSpeed'] * 2*np.pi/60, label='Constant Power Underspeed')
axs[1].set_ylabel('Gen Speed [rad/s]',rotation=0, labelpad=50)
axs[2].plot(fast_out[0]['Time'], fast_out[0]['GenTq'] * 1e3, label='Constant Power Underspeed')
axs[2].set_ylabel('Gen Torque [N m]',rotation=0, labelpad=50)
axs[3].plot(fast_out[0]['Time'], fast_out[0]['GenPwr'] * 1e3, label='Constant Power Underspeed')
axs[3].set_ylabel('Gen Power [W]',rotation=0, labelpad=50)
axs[3].set_xlabel('Time [s]')

plt.subplots_adjust(hspace=0.5)
fig.align_ylabels()


# TODO: Compare result to desired operating schedule

if False:
plt.show()
else:
fig_fname = os.path.join(example_out_dir, '30_fixed_pitch_mhk_sim.png')
print('Saving figure ' + fig_fname)
plt.savefig(fig_fname, bbox_inches='tight')


if __name__=="__main__":
main()
Loading
Loading