Skip to content

Commit

Permalink
Fix more paths
Browse files Browse the repository at this point in the history
  • Loading branch information
dzalkind committed Jan 3, 2024
1 parent f87751a commit 25900db
Show file tree
Hide file tree
Showing 23 changed files with 64 additions and 59 deletions.
2 changes: 1 addition & 1 deletion Examples/02_ccblade.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
turbine = ROSCO_turbine.Turbine(turbine_params)
turbine.load_from_fast(
path_params['FAST_InputFile'],
os.path.join(this_dir,path_params['FAST_directory']),
os.path.join(tune_dir,path_params['FAST_directory']),
rot_source='cc-blade',
txt_filename=None)

Expand Down
6 changes: 3 additions & 3 deletions Examples/04_simple_sim.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,11 +43,11 @@
os.makedirs(example_out_dir)

if platform.system() == 'Windows':
lib_name = os.path.join(this_dir, '../ROSCO/build/libdiscon.dll')
lib_name = os.path.join(this_dir, '../rosco/controller/build/libdiscon.dll')
elif platform.system() == 'Darwin':
lib_name = os.path.join(this_dir, '../ROSCO/build/libdiscon.dylib')
lib_name = os.path.join(this_dir, '../rosco/controller/build/libdiscon.dylib')
else:
lib_name = os.path.join(this_dir, '../ROSCO/build/libdiscon.so')
lib_name = os.path.join(this_dir, '../rosco/controller/build/libdiscon.so')

# # Load turbine model from saved pickle
turbine = ROSCO_turbine.Turbine
Expand Down
4 changes: 2 additions & 2 deletions Examples/07_openfast_outputs.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
- Trim the time series
- Plot some available channels
Note: need to run openfast model in '../Test_Cases/5MW_Land_DLL_WTurb/' to plot
Note: need to run openfast model in 'Test_Cases/5MW_Land_DLL_WTurb/' to plot
'''

# Python Modules
Expand All @@ -24,7 +24,7 @@
os.makedirs(example_out_dir)

# Define openfast output filenames
filenames = ["../Test_Cases/IEA-15-240-RWT-UMaineSemi/IEA-15-240-RWT-UMaineSemi.outb"]
filenames = ["Test_Cases/IEA-15-240-RWT-UMaineSemi/IEA-15-240-RWT-UMaineSemi.outb"]
# ---- Note: Could load and plot multiple cases, textfiles, and binaries...
# filenames = ["../Test_Cases/NREL-5MW/NREL-5MW.outb",
# "../Test_Cases/NREL-5MW/NREL-5MW_ex8.outb"]
Expand Down
2 changes: 1 addition & 1 deletion Examples/08_run_turbsim.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
this_dir = os.path.dirname(os.path.abspath(__file__))

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

run_openfast(wind_directory, fastcall='turbsim',
Expand Down
5 changes: 3 additions & 2 deletions Examples/09_distributed_aero.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,10 @@


this_dir = os.path.dirname(os.path.abspath(__file__))
tune_dir = os.path.join(this_dir,'Tune_Cases')

# Load yaml file
parameter_filename = os.path.join(os.path.dirname(this_dir),'Tune_Cases/BAR.yaml')
parameter_filename = os.path.join(tune_dir,'BAR.yaml')
inps = load_rosco_yaml(parameter_filename)
path_params = inps['path_params']
turbine_params = inps['turbine_params']
Expand All @@ -36,7 +37,7 @@
turbine = ROSCO_turbine.Turbine(turbine_params)
turbine.load_from_fast(
path_params['FAST_InputFile'],
os.path.join(this_dir,path_params['FAST_directory'])
os.path.join(tune_dir,path_params['FAST_directory'])
)

# Tune controller
Expand Down
13 changes: 8 additions & 5 deletions Examples/10_linear_params.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,16 +19,20 @@

import numpy as np

this_dir = os.path.dirname(os.path.abspath(__file__))
tune_dir = os.path.join(this_dir,'Tune_Cases')

# Load yaml file
parameter_filename = os.path.join( os.path.dirname( os.path.dirname( os.path.realpath(__file__) )),
'Tune_Cases', 'IEA15MW.yaml')
parameter_filename = os.path.join( tune_dir, 'IEA15MW.yaml')
inps = load_rosco_yaml(parameter_filename)
path_params = inps['path_params']
turbine_params = inps['turbine_params']
controller_params = inps['controller_params']

# Linear file output
this_dir = os.path.dirname(os.path.abspath(__file__))


os.path.join(this_dir,path_params['FAST_directory'])
example_out_dir = os.path.join(this_dir,'examples_out')
if not os.path.isdir(example_out_dir):
os.makedirs(example_out_dir)
Expand All @@ -40,10 +44,9 @@
controller = ROSCO_controller.Controller(controller_params)

# Load turbine data from OpenFAST and rotor performance text file
tune_dir = os.path.join(this_dir,'Tune_Cases')
turbine.load_from_fast(
path_params['FAST_InputFile'],
os.path.join(this_dir,path_params['FAST_directory']),
os.path.join(tune_dir,path_params['FAST_directory']),
rot_source='txt',
txt_filename=os.path.join(tune_dir,path_params['rotor_performance_filename'])
)
Expand Down
4 changes: 2 additions & 2 deletions Examples/11_robust_tuning.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ def run_example():
# Shorthand directories
this_dir = os.path.dirname(os.path.abspath(__file__))
tune_dir = os.path.join(this_dir, 'Tune_Cases')
test_dir = os.path.join(this_dir, '../Test_Cases')
test_dir = os.path.join(this_dir, 'Test_Cases')

# ROSCO options
parameter_filename = os.path.join(tune_dir, 'IEA15MW_robust.yaml')
Expand Down Expand Up @@ -81,7 +81,7 @@ def run_example():
options['path_options'] = path_options
options['opt_options'] = opt_options

options['linturb_options']['linfile_path'] = os.path.join(this_dir, options['linturb_options']['linfile_path'])
options['linturb_options']['linfile_path'] = os.path.join(tune_dir, options['linturb_options']['linfile_path'])

# Run robust scheduling
sd = rsched_driver(options)
Expand Down
3 changes: 1 addition & 2 deletions Examples/12_tune_ipc.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,11 @@ def main():
run_dir = os.path.join(example_out_dir, example_name)

# Load yaml file (Open Loop Case)
parameter_filename = os.path.join(rosco_dir,'Tune_Cases/NREL2p8.yaml')
parameter_filename = os.path.join(this_dir,'Tune_Cases/NREL2p8.yaml')

case_inputs = {}
case_inputs[('ServoDyn','Ptch_Cntrl')] = {'vals': [1], 'group': 0}
case_inputs[('DISCON_in','IPC_SatMode')] = {'vals': [0,1,2,3], 'group': 1}



# simulation set up
Expand Down
12 changes: 7 additions & 5 deletions Examples/14_open_loop_control.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,14 +28,16 @@


this_dir = os.path.dirname(os.path.abspath(__file__))
tune_dir = os.path.join(this_dir,'Tune_Cases')

rosco_dir = os.path.dirname(this_dir)
example_out_dir = os.path.join(this_dir,'examples_out')
example_out_dir = os.path.join(this_dir,'examples_out')
if not os.path.isdir(example_out_dir):
os.makedirs(example_out_dir)

# Load yaml file (Open Loop Case)
parameter_filename = os.path.join(rosco_dir,'Tune_Cases/IEA15MW_OL.yaml')
parameter_filename = os.path.join(tune_dir, 'IEA15MW_OL.yaml')

inps = load_rosco_yaml(parameter_filename)
path_params = inps['path_params']
Expand Down Expand Up @@ -75,9 +77,9 @@

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

# Tune controller
controller.tune_controller(turbine)
Expand All @@ -103,7 +105,7 @@
discon_vt = ROSCO_utilities.DISCON_dict(
turbine,
controller,
txt_filename=os.path.join(this_dir,path_params['FAST_directory'],path_params['rotor_performance_filename'])
txt_filename=os.path.join(tune_dir,path_params['FAST_directory'],path_params['rotor_performance_filename'])
)
for discon_input in discon_vt:
case_inputs[('DISCON_in',discon_input)] = {'vals': [discon_vt[discon_input]], 'group': 0}
Expand All @@ -124,7 +126,7 @@
# Run FAST cases
fastBatch = runFAST_pywrapper_batch()

fastBatch.FAST_directory = os.path.realpath(os.path.join(rosco_dir,'Tune_Cases',path_params['FAST_directory']))
fastBatch.FAST_directory = os.path.realpath(os.path.join(tune_dir,path_params['FAST_directory']))
fastBatch.FAST_InputFile = path_params['FAST_InputFile']
fastBatch.channels = channels
fastBatch.FAST_runDirectory = run_dir
Expand Down
2 changes: 1 addition & 1 deletion Examples/15_pass_through.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ def main():
# Simulation config
r = run_FAST_ROSCO()

parameter_filename = os.path.join(rosco_dir,'Tune_Cases/NREL5MW_PassThrough.yaml')
parameter_filename = os.path.join(this_dir,'Tune_Cases/NREL5MW_PassThrough.yaml')
run_dir = os.path.join(example_out_dir,'15_PassThrough')
os.makedirs(run_dir,exist_ok=True)

Expand Down
10 changes: 5 additions & 5 deletions Examples/16_external_dll.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,11 @@
os.makedirs(example_out_dir,exist_ok=True)

if platform.system() == 'Windows':
lib_name = os.path.realpath(os.path.join(this_dir, '../ROSCO/build/libdiscon.dll'))
lib_name = os.path.realpath(os.path.join(this_dir, '../rosco/controller/build/libdiscon.dll'))
elif platform.system() == 'Darwin':
lib_name = os.path.realpath(os.path.join(this_dir, '../ROSCO/build/libdiscon.dylib'))
lib_name = os.path.realpath(os.path.join(this_dir, '../rosco/controller/build/libdiscon.dylib'))
else:
lib_name = os.path.realpath(os.path.join(this_dir, '../ROSCO/build/libdiscon.so'))
lib_name = os.path.realpath(os.path.join(this_dir, '../rosco/controller/build/libdiscon.so'))


def main():
Expand All @@ -36,15 +36,15 @@ def main():


# Ensure external control paths are okay
parameter_filename = os.path.join(rosco_dir,'Tune_Cases/IEA15MW_ExtInterface.yaml')
parameter_filename = os.path.join(this_dir,'Tune_Cases/IEA15MW_ExtInterface.yaml')
run_dir = os.path.join(example_out_dir,'16_ExtInterface')
os.makedirs(run_dir,exist_ok=True)

# Set DLL file and DISCON input dynamically (hard-coded in yaml)
controller_params = {}
controller_params['DISCON'] = {}
controller_params['DISCON']['DLL_FileName'] = copy_lib
controller_params['DISCON']['DLL_InFile'] = os.path.join(rosco_dir,'Test_Cases/NREL-5MW/DISCON.IN')
controller_params['DISCON']['DLL_InFile'] = os.path.join(this_dir,'Test_Cases/NREL-5MW/DISCON.IN')
controller_params['DISCON']['DLL_ProcName'] = 'DISCON'

# simulation set up
Expand Down
2 changes: 1 addition & 1 deletion Examples/18_pitch_offsets.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
def main():

# Input yaml and output directory
parameter_filename = os.path.join(rosco_dir,'Tune_Cases/IEA15MW.yaml')
parameter_filename = os.path.join(this_dir,'Tune_Cases/IEA15MW.yaml')
run_dir = os.path.join(example_out_dir,'18_PitchFaults')
os.makedirs(run_dir,exist_ok=True)

Expand Down
2 changes: 1 addition & 1 deletion Examples/19_update_discon_version.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ def main():
old_discon_filename = os.path.join(this_dir,'example_inputs','DISCON_v2.2.0.IN') # An IEA-15MW input

# Tuning yaml can be anything, does not have to correspond to old discon
tuning_yaml = os.path.join(rosco_dir,'Tune_Cases','NREL5MW.yaml') # dummy for now
tuning_yaml = os.path.join(this_dir,'Tune_Cases','NREL5MW.yaml') # dummy for now
update_discon_version(
old_discon_filename,
tuning_yaml,
Expand Down
10 changes: 5 additions & 5 deletions Examples/20_active_wake_control.py
Original file line number Diff line number Diff line change
Expand Up @@ -170,22 +170,22 @@
os.makedirs(example_out_dir,exist_ok=True)

if platform.system() == 'Windows':
lib_name = os.path.realpath(os.path.join(this_dir, '../ROSCO/build/libdiscon.dll'))
lib_name = os.path.realpath(os.path.join(this_dir, '../rosco/controller/build/libdiscon.dll'))
elif platform.system() == 'Darwin':
lib_name = os.path.realpath(os.path.join(this_dir, '../ROSCO/build/libdiscon.dylib'))
lib_name = os.path.realpath(os.path.join(this_dir, '../rosco/controller/build/libdiscon.dylib'))
else:
lib_name = os.path.realpath(os.path.join(this_dir, '../ROSCO/build/libdiscon.so'))
lib_name = os.path.realpath(os.path.join(this_dir, '../rosco/controller/build/libdiscon.so'))


def main():

# Input yaml and output directory
parameter_filename = os.path.join(rosco_dir,'Tune_Cases/NREL2p8.yaml') # will be dummy and overwritten with SNL DISCON params
parameter_filename = os.path.join(this_dir,'Tune_Cases/NREL2p8.yaml') # will be dummy and overwritten with SNL DISCON params
run_dir = os.path.join(example_out_dir,'20_active_wake_control/all_cases')
os.makedirs(run_dir,exist_ok=True)

# Read all DISCON inputs
rosco_vt = read_DISCON(os.path.join(rosco_dir,'Test_Cases','NREL_2p8_127/NREL-2p8-127_DISCON.IN'))
rosco_vt = read_DISCON(os.path.join(this_dir,'Test_Cases','NREL_2p8_127/NREL-2p8-127_DISCON.IN'))

# Apply all discon variables as case inputs
control_base_case = {}
Expand Down
6 changes: 3 additions & 3 deletions Examples/21_optional_inputs.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,11 @@ def main():

# Set up rosco_dll
if platform.system() == 'Windows':
rosco_dll = os.path.join(rosco_dir, 'ROSCO/build/libdiscon.dll')
rosco_dll = os.path.join(rosco_dir, 'rosco/controller/build/libdiscon.dll')
elif platform.system() == 'Darwin':
rosco_dll = os.path.join(rosco_dir, 'ROSCO/build/libdiscon.dylib')
rosco_dll = os.path.join(rosco_dir, 'rosco/controller/build/libdiscon.dylib')
else:
rosco_dll = os.path.join(rosco_dir, 'ROSCO/build/libdiscon.so')
rosco_dll = os.path.join(rosco_dir, 'rosco/controller/build/libdiscon.so')

# Load turbine model from saved pickle
turbine = ROSCO_turbine.Turbine
Expand Down
4 changes: 2 additions & 2 deletions Examples/22_cable_control.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
def main():

# Input yaml and output directory
parameter_filename = os.path.join(rosco_dir,'Tune_Cases/IEA15MW_cable.yaml')
parameter_filename = os.path.join(this_dir,'Tune_Cases/IEA15MW_cable.yaml')
run_dir = os.path.join(example_out_dir,'22_cable_control')
os.makedirs(run_dir,exist_ok=True)

Expand All @@ -49,7 +49,7 @@ def main():
# Change inputs programatically, read first
reader = InputReader_OpenFAST()
reader.FAST_InputFile = path_params['FAST_InputFile']
reader.FAST_directory = os.path.join(rosco_dir,'Tune_Cases',path_params['FAST_directory'])
reader.FAST_directory = os.path.join(this_dir,'Tune_Cases',path_params['FAST_directory'])
reader.execute()

# Set control line mapping (ChannelID -> Line(s))
Expand Down
4 changes: 2 additions & 2 deletions Examples/23_structural_control.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@
def main():

# Input yaml and output directory
parameter_filename = os.path.join(rosco_dir,'Tune_Cases/IEA15MW_ballast.yaml')
parameter_filename = os.path.join(this_dir,'Tune_Cases/IEA15MW_ballast.yaml')
run_dir = os.path.join(example_out_dir,'23_structural_control')
os.makedirs(run_dir,exist_ok=True)

Expand All @@ -57,7 +57,7 @@ def main():
# Change inputs programatically, read first
reader = InputReader_OpenFAST()
reader.FAST_InputFile = path_params['FAST_InputFile']
reader.FAST_directory = os.path.join(rosco_dir,'Tune_Cases',path_params['FAST_directory'])
reader.FAST_directory = os.path.join(this_dir,'Tune_Cases',path_params['FAST_directory'])
# reader.FAST_directory = '/Users/dzalkind/Tools/ROSCO1/Test_Cases/ptfm_control_archive/IEA-15-240-RWT-UMaineSemi_ballast'
reader.execute()

Expand Down
8 changes: 4 additions & 4 deletions Examples/24_floating_feedback.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,17 +34,17 @@
os.makedirs(example_out_dir,exist_ok=True)

if platform.system() == 'Windows':
lib_name = os.path.realpath(os.path.join(this_dir, '../ROSCO/build/libdiscon.dll'))
lib_name = os.path.realpath(os.path.join(this_dir, '../rosco/controller/build/libdiscon.dll'))
elif platform.system() == 'Darwin':
lib_name = os.path.realpath(os.path.join(this_dir, '../ROSCO/build/libdiscon.dylib'))
lib_name = os.path.realpath(os.path.join(this_dir, '../rosco/controller/build/libdiscon.dylib'))
else:
lib_name = os.path.realpath(os.path.join(this_dir, '../ROSCO/build/libdiscon.so'))
lib_name = os.path.realpath(os.path.join(this_dir, '../rosco/controller/build/libdiscon.so'))


def main():

# Input yaml and output directory
parameter_filename = os.path.join(rosco_dir,'Tune_Cases/IEA15MW.yaml')
parameter_filename = os.path.join(this_dir,'Tune_Cases/IEA15MW.yaml')
run_dir = os.path.join(example_out_dir,'24_floating_feedback')
os.makedirs(run_dir,exist_ok=True)

Expand Down
8 changes: 4 additions & 4 deletions Examples/25_rotor_position_control.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,17 +23,17 @@
os.makedirs(example_out_dir,exist_ok=True)

if platform.system() == 'Windows':
lib_name = os.path.realpath(os.path.join(this_dir, '../ROSCO/build/libdiscon.dll'))
lib_name = os.path.realpath(os.path.join(this_dir, '../rosco/controller/build/libdiscon.dll'))
elif platform.system() == 'Darwin':
lib_name = os.path.realpath(os.path.join(this_dir, '../ROSCO/build/libdiscon.dylib'))
lib_name = os.path.realpath(os.path.join(this_dir, '../rosco/controller/build/libdiscon.dylib'))
else:
lib_name = os.path.realpath(os.path.join(this_dir, '../ROSCO/build/libdiscon.so'))
lib_name = os.path.realpath(os.path.join(this_dir, '../rosco/controller/build/libdiscon.so'))

def main():


# Set up paths
parameter_filename = os.path.join(rosco_dir,'Tune_Cases/NREL2p8.yaml')
parameter_filename = os.path.join(this_dir,'Tune_Cases/NREL2p8.yaml')
run_dir = os.path.join(example_out_dir,'25_rotor_position_control')
os.makedirs(run_dir,exist_ok=True)

Expand Down
2 changes: 1 addition & 1 deletion Examples/26_marine_hydro.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
def main():

# Input yaml and output directory
parameter_filename = os.path.join(rosco_dir,'Tune_Cases/RM1_MHK.yaml')
parameter_filename = os.path.join(this_dir,'Tune_Cases/RM1_MHK.yaml')
run_dir = os.path.join(example_out_dir,'26_MHK/0_baseline')
os.makedirs(run_dir,exist_ok=True)

Expand Down
Loading

0 comments on commit 25900db

Please sign in to comment.