Skip to content

Commit

Permalink
Merge branch 'hotfix/min_pitch'
Browse files Browse the repository at this point in the history
  • Loading branch information
nikhar-abbas committed Aug 5, 2020
2 parents bc29969 + 0a977d9 commit 4e4e3f9
Show file tree
Hide file tree
Showing 150 changed files with 68,342 additions and 316 deletions.
8 changes: 8 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -42,3 +42,11 @@ _build
.pytest_cache
examples/cp_ct_cq_lut.p

# Files Generated in Examples
Examples/DISCON.IN
Examples/*.p

# Matlab Stuff
Matlab_Toolbox/*.slxc
*.mat

2 changes: 2 additions & 0 deletions Examples/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
Cp_Ct_Cq.*.txt
*.p
83 changes: 83 additions & 0 deletions Examples/example_11.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
'''
----------- Example_11 --------------
Load a turbine, tune a controller, export linear model
-------------------------------------
In this example:
- Load a turbine from OpenFAST
- Tune a controller
- Use tuning parameters to export linear model
'''
# Python Modules
import yaml
# ROSCO toolbox modules
from ROSCO_toolbox import controller as ROSCO_controller
from ROSCO_toolbox import turbine as ROSCO_turbine
from ROSCO_toolbox import sim as ROSCO_sim
from ROSCO_toolbox import utilities as ROSCO_utilities

import numpy as np

# Load yaml file
parameter_filename = '/Users/dzalkind/Tools/ROSCO_toolbox/Tune_Cases/IEA15MW.yaml'
inps = yaml.safe_load(open(parameter_filename))
path_params = inps['path_params']
turbine_params = inps['turbine_params']
controller_params = inps['controller_params']

# Linear file output
linmod_filename = '/Users/dzalkind/Tools/matlab-toolbox/Play/IEA15MW_LinMod.dat'

# Instantiate turbine, controller, and file processing classes
turbine = ROSCO_turbine.Turbine(turbine_params)
controller = ROSCO_controller.Controller(controller_params)
file_processing = ROSCO_utilities.FileProcessing()
fast_io = ROSCO_utilities.FAST_IO()

# Load turbine data from OpenFAST and rotor performance text file
turbine.load_from_fast(path_params['FAST_InputFile'],path_params['FAST_directory'],dev_branch=True,rot_source='txt',txt_filename=path_params['rotor_performance_filename'])

# Tune controller
controller.tune_controller(turbine)

# Write Linear model parameters to text file for matlab processing
# Add to ROSCO_utilities.FileProcessing() when finished

print('Writing linear models to text file: ' + linmod_filename)

# extend gain schedule

pc_br = np.zeros(len(controller.v_below_rated))
pc_Kp = np.concatenate((pc_br,controller.pc_gain_schedule.Kp))
pc_Ki = np.concatenate((pc_br,controller.pc_gain_schedule.Ki))

vs_ar = np.zeros(len(controller.pc_gain_schedule.Kp))
vs_Kp = np.concatenate((controller.vs_gain_schedule.Kp,vs_ar))
vs_Ki = np.concatenate((controller.vs_gain_schedule.Ki,vs_ar))

with open(linmod_filename,'w') as f:
f.write('{:12}\t{:12}\t{:12}\t{:12}\t{:12}\t{:12}\t{:12}\t{:12}\t{:12}\t{:12}\t{:12}\t{:12}\n'.\
format('WindSpeed','A_om','b_theta','b_tau','b_wind','pc_Kp','pc_Ki','vs_Kp','vs_Ki','Pi_omega','Pi_theta','Pi_wind'))

for v,A,B_beta,B_tau,B_wind,pc_Kp,pc_Ki,vs_Kp,vs_Ki,Pi_omega,Pi_beta,Pi_wind in zip(controller.v,controller.A,controller.B_beta,controller.B_tau, controller.B_wind, \
pc_Kp, pc_Ki, vs_Kp, vs_Ki, \
controller.Pi_omega, controller.Pi_beta, controller.Pi_wind):
f.write('{:12.4e}\t{:12.4e}\t{:12.4e}\t{:12.4e}\t{:12.4e}\t{:12.4e}\t{:12.4e}\t{:12.4e}\t{:12.4e}\t{:12.4e}\t{:12.4e}\t{:12.4e}\n'\
.format(v,A,B_beta,B_tau,B_wind,pc_Kp,pc_Ki,vs_Kp,vs_Ki,Pi_omega,Pi_beta,Pi_wind))

print('Tower Height = {} m'.format(turbine.hubHt))
print('Platform Freq. = {} rad/s'.format(turbine.ptfm_freq))


# Write parameter input file
# param_file = 'DISCON.IN' # This must be named DISCON.IN to be seen by the compiled controller binary.
# file_processing.write_DISCON(turbine,controller,param_file=param_file, txt_filename=path_params['rotor_performance_filename'])

# Run OpenFAST
# --- May need to change fastcall if you use a non-standard command to call openfast
# fast_io.run_openfast(path_params['FAST_directory'], fastcall='openfast', fastfile=path_params['FAST_InputFile'],chdir=True)




2 changes: 1 addition & 1 deletion Matlab_Toolbox/Pl_FastPlots.m
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ function Pl_FastPlots(varargin)
plsw.PD = 1; % PD, Primary Dynamics
plsw.RO = 0; % RO, Rotor Performance Outputs
plsw.Fl1 = 0; % Fl1, Basic Floating Parameters
plsw.AF = 1; % All Floating Parameters
plsw.AF = 0; % All Floating Parameters
plsw.Twr = 0; % Twr, Turbine params with Twr Motions
plsw.Rand = 0; % Some random metrics I care about now
cases = fieldnames(plsw);
Expand Down
200 changes: 0 additions & 200 deletions Matlab_Toolbox/Post_LoadFastOut.m

This file was deleted.

65 changes: 0 additions & 65 deletions Matlab_Toolbox/Post_TestCases.m

This file was deleted.

17 changes: 17 additions & 0 deletions Matlab_Toolbox/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# Simulink Implementation of ROSCO
A simulink version of ROSCO has been created for rapid prototyping of new control ideas. The results do not exactly match results from the .DLL version of ROSCO due to the way that Simulink handles initial conditions. These differences change the wind speed estimate slightly and propogate to differences in the torque control and pitch saturation. The following modules in ROSCO have been implemented in Simulink:
- TSR tracking torque control
- PI gain-scheduled pitch control
- Setpoint smoothing control
- Extended Kalman Filter wind speed estimator
- Pitch Saturation
- Floating feedback control

The modules not currently implemented include:
- k\omega^2 torque control
- Individual pitch control
- Shutdown control
- Flap control

`runFAST.m` can be used to load the ROSCO parameters from a .IN file, using `load_ROSCO_params.m` and a more detailed version can be found in the `matlab-toolbox` [repository](https://github.com/dzalkind/matlab-toolbox/tree/master/Simulations).

Loading

0 comments on commit 4e4e3f9

Please sign in to comment.