Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/develop' into weis
Browse files Browse the repository at this point in the history
  • Loading branch information
dzalkind committed Feb 9, 2021
2 parents b730428 + 7a26d5f commit 3454fc0
Show file tree
Hide file tree
Showing 64 changed files with 1,681 additions and 605 deletions.
8 changes: 7 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,10 @@ _build
*.outb
*.dbg

# Fortran files
# ROSCO files
*.85
*.i90
*local*

# Binaries
*.dylib
Expand All @@ -52,3 +54,7 @@ Matlab_Toolbox/*.slxc

# Exclude testing results
ROSCO_testing/results/

# Simulink/Matlab temp files
*.slxc
*.autosave
94 changes: 47 additions & 47 deletions Examples/DISCON.IN

Large diffs are not rendered by default.

Binary file modified Examples/NREL5MW_saved.p
Binary file not shown.
4 changes: 2 additions & 2 deletions Examples/ROSCO_walkthrough.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@
"from ROSCO_toolbox import utilities as ROSCO_utilities\n",
"from ROSCO_toolbox import controller as ROSCO_controller\n",
"from ROSCO_toolbox import control_interface as ROSCO_ci\n",
"from ofTools.fast_io.output_processing import output_processing\n"
"from ROSCO_toolbox.ofTools.fast_io.output_processing import output_processing\n"
]
},
{
Expand Down Expand Up @@ -648,4 +648,4 @@
},
"nbformat": 4,
"nbformat_minor": 4
}
}
9 changes: 5 additions & 4 deletions Examples/example_01.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@
from ROSCO_toolbox import turbine as ROSCO_turbine

# Load yaml file
parameter_filename = os.path.join(os.path.dirname(__file__),'NREL5MW_example.yaml')
this_dir = os.path.dirname(os.path.abspath(__file__))
parameter_filename = os.path.join(this_dir,'NREL5MW_example.yaml')
inps = yaml.safe_load(open(parameter_filename))
path_params = inps['path_params']
turbine_params = inps['turbine_params']
Expand All @@ -28,13 +29,13 @@

turbine.load_from_fast(
path_params['FAST_InputFile'],
os.path.join(os.path.dirname(__file__),path_params['FAST_directory']),
os.path.join(this_dir,path_params['FAST_directory']),
dev_branch=True,
rot_source='txt',txt_filename=os.path.join(os.path.dirname(__file__),path_params['rotor_performance_filename'])
rot_source='txt',txt_filename=os.path.join(this_dir,path_params['rotor_performance_filename'])
)

# Print some basic turbine info
print(turbine)

# Save the turbine model
turbine.save(os.path.join(os.path.dirname(__file__),'NREL5MW_saved.p'))
turbine.save(os.path.join(this_dir,'NREL5MW_saved.p'))
3 changes: 2 additions & 1 deletion Examples/example_02.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@
turbine = ROSCO_turbine.Turbine

# Load quick from python pickle
turbine = turbine.load(os.path.join(os.path.dirname(__file__),'NREL5MW_saved.p'))
this_dir = os.path.dirname(os.path.abspath(__file__))
turbine = turbine.load(os.path.join(this_dir,'NREL5MW_saved.p'))

# plot rotor performance
print('Plotting Cp data')
Expand Down
7 changes: 4 additions & 3 deletions Examples/example_03.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@
control_params = {}

# Load yaml file
parameter_filename = os.path.join(os.path.dirname(__file__),'NREL5MW_example.yaml')
this_dir = os.path.dirname(os.path.abspath(__file__))
parameter_filename = os.path.join(this_dir,'NREL5MW_example.yaml')
inps = yaml.safe_load(open(parameter_filename))
path_params = inps['path_params']
turbine_params = inps['turbine_params']
Expand All @@ -29,11 +30,11 @@
turbine = ROSCO_turbine.Turbine(turbine_params)
turbine.load_from_fast(
path_params['FAST_InputFile'],
os.path.join(os.path.dirname(__file__),path_params['FAST_directory']),
os.path.join(this_dir,path_params['FAST_directory']),
dev_branch=True,
rot_source='cc-blade',
txt_filename=None)

# Write rotor performance text file
txt_filename = os.path.join(os.path.dirname(__file__),'Cp_Ct_Cq.Ex03.txt')
txt_filename = os.path.join(this_dir,'Cp_Ct_Cq.Ex03.txt')
write_rotor_performance(turbine,txt_filename=txt_filename)
7 changes: 4 additions & 3 deletions Examples/example_04.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@
from ROSCO_toolbox.utilities import write_DISCON

# Load yaml file
parameter_filename = os.path.join(os.path.dirname(__file__),'NREL5MW_example.yaml')
this_dir = os.path.dirname(os.path.abspath(__file__))
parameter_filename = os.path.join(this_dir,'NREL5MW_example.yaml')
inps = yaml.safe_load(open(parameter_filename))
path_params = inps['path_params']
turbine_params = inps['turbine_params']
Expand All @@ -33,9 +34,9 @@
# Load turbine data from OpenFAST and rotor performance text file
turbine.load_from_fast(
path_params['FAST_InputFile'],
os.path.join(os.path.dirname(__file__),path_params['FAST_directory']),
os.path.join(this_dir,path_params['FAST_directory']),
dev_branch=True,
rot_source='txt',txt_filename=os.path.join(os.path.dirname(__file__),path_params['rotor_performance_filename'])
rot_source='txt',txt_filename=os.path.join(this_dir,path_params['rotor_performance_filename'])
)

# Tune controller
Expand Down
2 changes: 1 addition & 1 deletion Examples/example_05.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
from ROSCO_toolbox import control_interface as ROSCO_ci

# Specify controller dynamic library path and name
this_dir = os.path.dirname(__file__)
this_dir = os.path.dirname(os.path.abspath(__file__))
lib_name = os.path.join(this_dir,'../ROSCO/build/libdiscon.dylib')
param_filename = os.path.join(this_dir,'DISCON.IN')

Expand Down
12 changes: 8 additions & 4 deletions Examples/example_06.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,10 @@
from ROSCO_toolbox.utilities import write_DISCON, run_openfast
from ROSCO_toolbox import sim as ROSCO_sim

this_dir = os.path.dirname(__file__)
this_dir = os.path.dirname(os.path.abspath(__file__))

# Load yaml file
parameter_filename = os.path.join(this_dir,'NREL5MW_example.yaml')
parameter_filename = os.path.join(os.path.dirname(this_dir), 'Tune_Cases', 'IEA15MW.yaml')
inps = yaml.safe_load(open(parameter_filename))
path_params = inps['path_params']
turbine_params = inps['turbine_params']
Expand All @@ -33,7 +33,10 @@
controller = ROSCO_controller.Controller(controller_params)

# 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'])
turbine.load_from_fast(path_params['FAST_InputFile'], \
os.path.join(this_dir,path_params['FAST_directory']), \
dev_branch=True,rot_source='txt',\
txt_filename=os.path.join(this_dir,path_params['FAST_directory'],path_params['rotor_performance_filename']))

# Tune controller
controller.tune_controller(turbine)
Expand All @@ -44,7 +47,8 @@

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



Expand Down
2 changes: 1 addition & 1 deletion Examples/example_08.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
from ROSCO_toolbox.ofTools.fast_io import output_processing
import os

this_dir = os.path.dirname(__file__)
this_dir = os.path.dirname(os.path.abspath(__file__))

# Define openfast output filenames
filenames = ["../Test_Cases/NREL-5MW/NREL-5MW.outb"]
Expand Down
4 changes: 2 additions & 2 deletions Examples/example_09.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,11 @@
from ROSCO_toolbox.utilities import run_openfast
import os

this_dir = os.path.dirname(__file__)
this_dir = os.path.dirname(os.path.abspath(__file__))

# Define openfast output filenames
wind_directory = os.path.join(this_dir,'../Test_Cases/Wind/')
turbsim_infile = '90m_12mps_twr.inp'

run_openfast(wind_directory, fastcall='turbsim_sdev', fastfile=turbsim_infile, chdir=False)
run_openfast(wind_directory, fastcall='turbsim', fastfile=turbsim_infile, chdir=False)

6 changes: 3 additions & 3 deletions Examples/example_10.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,10 @@
from ROSCO_toolbox import turbine as ROSCO_turbine
from ROSCO_toolbox import controller as ROSCO_controller

rt_dir = os.path.dirname(os.path.dirname(__file__))
this_dir = os.path.dirname(os.path.abspath(__file__))

# Load yaml file
parameter_filename = os.path.join(rt_dir,'Tune_Cases/BAR.yaml')
parameter_filename = os.path.join(os.path.dirname(this_dir),'Tune_Cases/BAR.yaml')
inps = yaml.safe_load(open(parameter_filename))
path_params = inps['path_params']
turbine_params = inps['turbine_params']
Expand All @@ -34,7 +34,7 @@
turbine = ROSCO_turbine.Turbine(turbine_params)
# 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'])
turbine.load_from_fast(path_params['FAST_InputFile'], \
os.path.join(rt_dir,path_params['FAST_directory']),dev_branch=True)
os.path.join(this_dir,path_params['FAST_directory']),dev_branch=True)

# Tune controller
controller = ROSCO_controller.Controller(controller_params)
Expand Down
2 changes: 1 addition & 1 deletion Matlab_Toolbox/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,5 @@ The modules not currently implemented include:
- 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).
`runFAST.m` can be used to load the ROSCO parameters from a .IN file, using `load_ROSCO_params.m`. Add the `matlab-toolbox` [repository](https://github.com/OpenFAST/matlab-toolbox) to your matlab path.

29 changes: 29 additions & 0 deletions Matlab_Toolbox/Utilities/Af_HPF.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
function [dHPF,HPF] = Af_HPF(omega,zeta,DT,varargin)
%% Example Code
% omega = 2*pi*6; %rad/s
% HPF = tf(om^2,[1,2*zeta*omega,omega^2]);
% dHFP = c2d(LPF,DT);
%
% varargin to specify order

if isempty(varargin)
order = 2;
else
order = varargin{1};
end

if order == 2
HPF = tf([1,0,0],[1,2*zeta*omega,omega^2]);
elseif order > 2
[b,a] = butter(order,omega,'high','s');
HPF = tf(b,a);
else
HPF = tf([1,0],[1,omega]);
end

dHPF = c2d(HPF,DT,'tustin');

if 0
figure(881);
bode(HPF);
end
29 changes: 29 additions & 0 deletions Matlab_Toolbox/Utilities/Af_LPF.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
function [dLPF,LPF] = Af_LPF(omega,zeta,DT,varargin)
%% Example Code
% omega = 2*pi*6; %rad/s
% LPF = tf(om^2,[1,2*zeta*omega,omega^2]);
% dLFP = c2d(LPF,DT);
%
% varargin to specify order

if isempty(varargin)
order = 2;
else
order = varargin{1};
end

if order == 2
LPF = tf(omega^2,[1,2*zeta*omega,omega^2]);
elseif order > 2
[b,a] = butter(order,omega,'s');
LPF = tf(b,a);
else
LPF = tf(omega,[1,omega]);
end

dLPF = c2d(LPF,DT,'tustin');

if 0
figure(881);
bode(LPF);
end
Loading

0 comments on commit 3454fc0

Please sign in to comment.