Skip to content

Commit

Permalink
Use generic full file paths
Browse files Browse the repository at this point in the history
  • Loading branch information
nikhar-abbas committed Feb 5, 2021
1 parent 6ef5d52 commit f072f2e
Show file tree
Hide file tree
Showing 9 changed files with 25 additions and 20 deletions.
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
7 changes: 4 additions & 3 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 = '/Users/dzalkind/Tools/ROSCO_toolbox/Tune_Cases/BAR.yaml' #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 @@ -47,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', 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
2 changes: 1 addition & 1 deletion Examples/example_09.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
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/')
Expand Down
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

0 comments on commit f072f2e

Please sign in to comment.