Skip to content

Commit

Permalink
Merge pull request #338 from WISDEM/examples
Browse files Browse the repository at this point in the history
Tidying up WEIS Examples
  • Loading branch information
gbarter authored Jan 10, 2025
2 parents 9e8d970 + 218dd5b commit 3ae7464
Show file tree
Hide file tree
Showing 53 changed files with 24,134 additions and 131 deletions.
12 changes: 11 additions & 1 deletion .github/workflows/run_exhaustive_examples.yml
Original file line number Diff line number Diff line change
Expand Up @@ -102,8 +102,18 @@ jobs:
# python dac_driver.py

# Run scripts within design of experiments folder
- name: Run examples design of experiments
- name: Run OpenFAST design of experiments
run: |
cd examples/09_design_of_experiments
mpiexec -n 2 --bind-to core python DOE_openfast.py
python postprocess_results.py
- name: Run RAFT design of experiments
run: |
cd examples/09_design_of_experiments
mpiexec -n 2 python DOE_raft.py
- name: Run parallel script with RAFT
run: |
cd examples/17_IEA22_Optimization
mpiexec -n 2 python driver_weis_raft_opt.py

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import os
from rosco.toolbox.ofTools.fast_io.update_discons import update_discons


weis_dir = os.path.dirname(os.path.dirname(os.path.dirname(os.path.dirname(__file__))))
iea15_dir = os.path.join(weis_dir,'examples/01_aeroelasticse/OpenFAST_models/IEA-15-240-RWT/')

Expand Down
57 changes: 3 additions & 54 deletions examples/02_run_openfast_cases/modeling_options_sm.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -23,54 +23,8 @@ Level3: # Options for WEIS fidelity level 3 = nonlinear time domain
regulation_trajectory: IEA-15-240-RWT-outputs.yaml
openfast_file: IEA-15-240-RWT-UMaineSemi.fst
openfast_dir: ../01_aeroelasticse/OpenFAST_models/IEA-15-240-RWT/IEA-15-240-RWT-UMaineSemi
simulation:
DT: 0.0125
CompElast: 1
CompInflow: 1
CompAero: 2
CompServo: 1
CompHydro: 1
CompSub: 0
CompMooring: 3
CompIce: 0
OutFileFmt: 3
linearization:
Linearize: False
ElastoDyn:
FlapDOF1: True
FlapDOF2: True
EdgeDOF: True
TeetDOF: False
DrTrDOF: False
GenDOF: True
YawDOF: False
TwFADOF1 : True
TwFADOF2 : True
TwSSDOF1 : True
TwSSDOF2 : True
PtfmSgDOF: True
PtfmSwDOF: True
PtfmHvDOF: True
PtfmRDOF : True
PtfmPDOF : True
PtfmYDOF : False
TwrNodes: 50
HydroDyn:
WaveSeed1: 123456789
WaveSeed2: 1011121314
AddBLin3: [0.0, 0.0, 4389794.6, 0.0, 0.0, 0.0]
WaveMod: 2
WaveTMax: 850
WvLowCOff: 0.111527
WvHiCOff: 0.783827
WvSumQTF: True
RdtnMod: 1
PotMod: 1
DiffQTF: 0
PotFile: ../01_aeroelasticse/OpenFAST_models/IEA-15-240-RWT/IEA-15-240-RWT-UMaineSemi/HydroData/IEA-15-240-RWT-UMaineSemi

InflowWind:
RefHt: 150.0
AeroDyn:
WakeMod: 2

ROSCO:
flag: True
Expand All @@ -91,7 +45,7 @@ ROSCO:
Kp_float: -10
linmodel_tuning:
type: robust #'robust or simulation'
linfile_path: ../../ROSCO/Test_Cases/IEA-15-240-RWT-UMaineSemi/linearizations
linfile_path: ../01_aeroelasticse/OpenFAST_models/IEA-15-240-RWT/IEA-15-240-RWT-UMaineSemi/linearizations
lintune_outpath: rs_outfiles
load_parallel: True
stability_margin: 0.1
Expand All @@ -108,8 +62,3 @@ DLC_driver:
n_seeds: 1
analysis_time: 1.0
transient_time: 1.0
turbulent_wind:
HubHt: 140
GridHeight: 220
GridWidth: 220
# AnalysisTime: 5.
11 changes: 8 additions & 3 deletions examples/02_run_openfast_cases/weis_driver_sm.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,11 @@
fname_modeling_options = os.path.join(run_dir, "modeling_options_sm.yaml")
fname_analysis_options = os.path.join(run_dir, "analysis_options_sm.yaml")

wt_opt, modeling_options, opt_options = weis_main(fname_wt_input,
fname_modeling_options,
fname_analysis_options)
def run():

wt_opt, modeling_options, opt_options = weis_main(fname_wt_input,
fname_modeling_options,
fname_analysis_options)

if __name__=="__main__":
run()
2 changes: 1 addition & 1 deletion examples/09_design_of_experiments/DOE_openfast.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
run_dir = os.path.dirname( os.path.realpath(__file__) ) + os.sep
fname_wt_input = os.path.join(run_dir, "..", "00_setup", "ref_turbines", "IEA-15-240-RWT_VolturnUS-S.yaml")
fname_modeling_options = os.path.join(run_dir, "..", "06_IEA-15-240-RWT", "modeling_options_umaine_semi.yaml")
fname_analysis_options = os.path.join(run_dir, "analysis_options.yaml")
fname_analysis_options = os.path.join(run_dir, "analysis_options_openfast.yaml")

wt_opt, modeling_options, opt_options = weis_main(fname_wt_input,
fname_modeling_options,
Expand Down
24 changes: 24 additions & 0 deletions examples/09_design_of_experiments/DOE_raft.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
"""
This example shows how to use the Design of Experiments (DOE) driver within
WEIS including OpenFAST.
Specifically, the DOE driver helps sample the design space of a problem, allowing
you to perform parameter sweeps or random samples of design variables. This is
useful for better understanding a design space, especially prior to running optimization.
The DOE driver is not an optimizer, but simply runs the cases prescribed.
Check out the `driver` section within the `analysis_options.yaml` for the
DOE driver settings.
"""

import os
from weis import weis_main

## File management
run_dir = os.path.dirname( os.path.realpath(__file__) ) + os.sep
fname_wt_input = os.path.join(run_dir, "..", "00_setup", "ref_turbines", "IEA-15-240-RWT_VolturnUS-S.yaml")
fname_modeling_options = os.path.join(run_dir, "..", "15_RAFT_Studies", "modeling_options_umaine_semi.yaml")
fname_analysis_options = os.path.join(run_dir, "analysis_options_raft.yaml")

wt_opt, modeling_options, opt_options = weis_main(fname_wt_input,
fname_modeling_options,
fname_analysis_options)
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
general:
folder_output: outputs
fname_output: doe_output
folder_output: outputs/OpenFAST_DOE
fname_output: OpenFAST_DOE
design_variables:
blade:
aero_shape:
Expand Down
81 changes: 81 additions & 0 deletions examples/09_design_of_experiments/analysis_options_raft.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
general:
folder_output: outputs/RAFT_DOE
fname_output: refturb_output


design_variables:
# control:
# servo:
# pitch_control:
# omega:
# flag: True
# min: 0.1
# max: 0.5

floating:
joints:
flag: True
z_coordinate:
- names: [main_keel, col1_keel, col2_keel, col3_keel]
lower_bound: -40.0
upper_bound: -15.0
r_coordinate:
- names: [col1_keel, col1_freeboard, col2_keel, col2_freeboard, col3_keel, col3_freeboard]
lower_bound: 38.8125
upper_bound: 64.6875
members:
flag: True
groups:
- names: [column1,column2,column3]
diameter:
lower_bound: 9.375
upper_bound: 15.625
constant: True
thickness:
lower_bound: 0.05
upper_bound: 0.25
constant: True
# - names: [Y_pontoon_lower1, Y_pontoon_lower2, Y_pontoon_lower3]
# diameter:
# lower_bound: 7.5
# upper_bound: 12.5



constraints:
control:
rotor_overspeed:
flag: True
min: 0.0
max: 0.25
Max_PtfmPitch:
flag: True
max: 5.5
Std_PtfmPitch:
flag: False
max: 2.
Max_Offset:
flag: True
max: 30.
floating:
stress:
flag: True
global_buckling:
flag: True
shell_buckling:
flag: True

merit_figure: platform_mass # Merit figure of the optimization problem. The options are 'AEP' - 'LCOE' - 'Cp' - 'blade_mass' - 'blade_tip_deflection'


driver:
design_of_experiments:
flag: True # Flag to enable design of experiments
run_parallel: True # Flag to run using parallel processing
generator: Uniform # Type of input generator. (Uniform)
num_samples: 20 # number of samples for (Uniform only)

recorder:
flag: True # Flag to activate OpenMDAO recorder
file_name: log_opt.sql # Name of OpenMDAO recorder
includes: ['*raft*','*floating*','*platform*']
2 changes: 1 addition & 1 deletion examples/09_design_of_experiments/postprocess_results.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ def load_OMsql(log):

# sql outfile directory
run_dir = os.path.dirname(os.path.realpath(__file__))
output_dir = os.path.join(run_dir, "outputs")
output_dir = os.path.join(run_dir, "outputs/OpenFAST_DOE")
doe_logs = glob.glob(os.path.join(output_dir,"log_opt.sql*"))
if len(doe_logs) < 1:
raise FileExistsError("No output logs to post process!")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,8 @@ driver:
tol: 1.e-3 # Optimality tolerance
max_major_iter: 2 # Maximum number of major design iterations (SNOPT)
max_minor_iter: 100 # Maximum number of minor design iterations (SNOPT)
max_iter: 100 # Maximum number of iterations (SLSQP)
maxiter: 100 # Maximum number of iterations (SLSQP)
max_iter: 2 # Maximum number of iterations (SLSQP)
maxiter: 2 # Maximum number of iterations (SLSQP)
solver: LN_COBYLA # Optimization solver. Other options are 'SLSQP' - 'CONMIN'
step_size: 1.e-3 # Step size for finite differencing
form: forward # Finite differencing mode, either forward or central
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -121,8 +121,8 @@ driver:
optimization:
flag: True # Flag to enable optimization
tol: 1.e-3 # Optimality tolerance
maxiter: 100 # Maximum number of iterations (NLopt)
max_iter: 1000 # Maximum number of iterations (SLSQP)
maxiter: 2 # Maximum number of iterations (NLopt)
max_iter: 2 # Maximum number of iterations (SLSQP)
solver: LN_COBYLA # Optimization solver. Other options are 'SLSQP' - 'CONMIN'
penalty_exponent: 2.0 # constraint penalty exponent
# penalty_parameter: 2.0 # constraint penalty exponent
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -121,11 +121,11 @@ driver:
optimization:
flag: True # Flag to enable optimization
tol: 1.e-6 # Optimality tolerance
max_iter: 100 # Maximum number of iterations (SLSQP)
maxiter: 100 # Maximum number of iterations (NLopt)
maxgen: 100 # Maximum number of generations (DE)
max_iter: 2 # Maximum number of iterations (SLSQP)
maxiter: 2 # Maximum number of iterations (NLopt)
maxgen: 2 # Maximum number of generations (DE)
# maxtime: 3420
solver: LN_COBYLA # Optimization solver. Other options are 'SLSQP' - 'CONMIN'
solver: SLSQP # Optimization solver. Other options are 'SLSQP' - 'CONMIN'

recorder:
flag: True # Flag to activate OpenMDAO recorder
Expand Down
23 changes: 3 additions & 20 deletions examples/17_IEA22_Optimization/driver_weis_openfast_opt.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,25 +10,8 @@
fname_modeling_options = os.path.join(run_dir, "modeling_options_openfast.yaml")
fname_analysis_options = os.path.join(run_dir, "analysis_options_of_ptfm_opt.yaml")

# Change optimizer and output folder
optimizer = sys.argv[1]
# optimizer = "SLSQP"
print(f"Optimizer: {optimizer}")
wt_opt, modeling_options, opt_options = weis_main(fname_wt_input,
fname_modeling_options,
fname_analysis_options)

analysis_override = {}
analysis_override["general"] = {}
analysis_override["general"]["folder_output"] = f"17_IEA22_OptStudies/of_{optimizer}"
analysis_override["driver"] = {}
analysis_override["driver"]["optimization"] = {}
analysis_override["driver"]["optimization"]["solver"] = optimizer

wt_opt, modeling_options, analysis_options = weis_main(
fname_wt_input,
fname_modeling_options,
fname_analysis_options,
analysis_override=analysis_override
)

print("Tower mass (kg) =", wt_opt["towerse.tower_mass"])
print("Floating platform mass (kg) =", wt_opt["floatingse.platform_mass"])

7 changes: 4 additions & 3 deletions examples/17_IEA22_Optimization/driver_weis_raft_opt.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@
fname_modeling_options = os.path.join(run_dir, "modeling_options_raft.yaml")
fname_analysis_options = os.path.join(run_dir, "analysis_options_raft_ptfm_opt.yaml")

wt_opt, modeling_options, analysis_options = weis_main(fname_wt_input, fname_modeling_options, fname_analysis_options)
wt_opt, modeling_options, opt_options = weis_main(fname_wt_input,
fname_modeling_options,
fname_analysis_options)


print("Tower mass (kg) =", wt_opt["towerse.tower_mass"])
print("Floating platform mass (kg) =", wt_opt["floatingse.platform_mass"])
Loading

0 comments on commit 3ae7464

Please sign in to comment.