Example #1
0
    def testAssembly(self):

        ## NREL 5MW
        fname_wt_input = test_dir + 'nrel5mw.yaml'
        fname_modeling_options = test_dir + 'modeling_options.yaml'
        fname_analysis_options = test_dir + 'analysis_options.yaml'

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

        #print(wt_opt['elastic.precomp.blade_mass'])

        self.assertAlmostEqual(wt_opt['elastic.precomp.blade_mass'][0],
                               16403.682326940743)
        self.assertAlmostEqual(wt_opt['sse.AEP'][0] * 1.e-6, 24.48408190614509)
        self.assertAlmostEqual(wt_opt['financese.lcoe'][0] * 1.e3,
                               50.2295646178)

        ## IEA 15MW
        fname_wt_input = test_dir + 'IEA-15-240-RWT.yaml'
        wt_opt, modeling_options, opt_options = run_wisdem(
            fname_wt_input, fname_modeling_options, fname_analysis_options)

        # print(wt_opt['elastic.precomp.blade_mass'])

        self.assertAlmostEqual(wt_opt['elastic.precomp.blade_mass'][0],
                               73310.0985877902)
        self.assertAlmostEqual(wt_opt['sse.AEP'][0] * 1.e-6, 78.4607793182)
        self.assertAlmostEqual(wt_opt['financese.lcoe'][0] * 1.e3,
                               68.6104283913)
Example #2
0
    def test(self):
        ## File management
        run_dir = os.path.dirname(os.path.realpath(__file__)) + os.sep
        fname_wt_input = run_dir + "../models/IEA-15-240-RWT_WISDEMieaontology4all.yaml"
        fname_analysis_options_ccblade = run_dir + "../models/modeling_options_ccblade.yaml"
        fname_analysis_options_openfast = run_dir + "../models/modeling_options_openfast.yaml"
        fname_opt_options = run_dir + "../models/analysis_options.yaml"
        folder_output = run_dir + "it_0/"
        fname_wt_output = folder_output + "/temp.yaml"

        # Run CCBlade
        wt_opt_ccblade, analysis_options_ccblade, opt_options_ccblade = run_wisdem(
            fname_wt_input,
            fname_analysis_options_ccblade,
            fname_opt_options,
        )
        np.testing.assert_allclose(wt_opt_ccblade["ccblade.CP"], 0.472391)

        # Run OpenFAST
        wt_opt_openfast, analysis_options_openfast, opt_options_openfast = run_wisdem(
            fname_wt_input,
            fname_analysis_options_openfast,
            fname_opt_options,
        )
        np.testing.assert_allclose(wt_opt_openfast["aeroelastic.Cp_out"][0],
                                   0.48262791201466426)
Example #3
0
def wisdem_cmd():
    usg_msg = "WISDEM command line launcher\n    Arguments: \n    wisdem : Starts GUI\n    wisdem input.yaml : Runs master yaml file that specifies geometry, modeling, and analysis files\n    wisdem geom.yaml modeling.yaml analysis.yaml : Runs specific geometry, modeling, and analysis files\n"

    # Look for help message
    help_flag = False
    for k in range(len(sys.argv)):
        if sys.argv[k] in ["-h", "--help"]:
            help_flag = True

    if help_flag:
        print(usg_msg)

    elif len(sys.argv) == 1:
        # Launch GUI
        guirun()

    elif len(sys.argv) == 2:
        # Grab master input file
        fyaml = sys.argv[1]
        if os.path.exists(fyaml):
            print("...Reading master input file,", fyaml)
        else:
            raise FileNotFoundError("The master input file, " + fyaml +
                                    ", cannot be found.")
        yaml_dict = load_yaml(fyaml)

        check_list = ["geometry_file", "modeling_file", "analysis_file"]
        for f in check_list:
            if not os.path.exists(yaml_dict[f]):
                raise FileNotFoundError("The " + f + " entry, " +
                                        yaml_dict[f] + ", cannot be found.")

        # Run WISDEM (also saves output)
        wt_opt, modeling_options, opt_options = run_wisdem(
            yaml_dict["geometry_file"], yaml_dict["modeling_file"],
            yaml_dict["analysis_file"])

    elif len(sys.argv) == 4:
        check_list = ["geometry", "modeling", "analysis"]
        for k, f in enumerate(sys.argv[1:]):
            if not os.path.exists(f):
                raise FileNotFoundError("The " + check_list[k] + " file, " +
                                        f + ", cannot be found.")

        # Run WISDEM (also saves output)
        wt_opt, modeling_options, opt_options = run_wisdem(
            sys.argv[1], sys.argv[2], sys.argv[3])

    else:
        # As if asked for help
        print("Unrecognized set of inputs.  Usage:")
        print(usg_msg)

    sys.exit(0)
Example #4
0
    def disable_ui_and_execute_wisdem(self):
        """
        This method disables all widgets on the UI and executes WISDEM. It
        displays message boxes depending on whether WISDEM executed
        successfully.
        """
        self.main_widget.setEnabled(False)
        self.status_label.setText("Running WISDEM")

        try:
            wt_opt, modeling_options, analysis_options = run_wisdem(
                self.geometry_filename, self.modeling_filename, self.analysis_filename
            )
        except Exception as err:
            short_error_message = f"{type(err)}: {err}. More details on command line."
            traceback.print_exc(file=sys.stdout)
            self.status_label.setText("Execution error")
            msg = QMessageBox()
            msg.setText("WISDEM execution error")
            msg.setInformativeText(short_error_message)
            msg.addButton(QMessageBox.Ok)
            msg.exec()
            self.main_widget.setEnabled(True)
        else:
            self.status_label.setText("Execution success")
            msg = QMessageBox()
            msg.setText("WISDEM executed successfully")
            msg.addButton(QMessageBox.Ok)
            msg.exec()
            self.main_widget.setEnabled(True)
Example #5
0
    def test3p4MW(self):
        ## IEA 15MW
        fname_wt_input = test_dir + "IEA-3p4-130-RWT.yaml"
        wt_opt, modeling_options, opt_options = run_wisdem(
            fname_wt_input, fname_modeling_options, fname_analysis_options
        )

        self.assertAlmostEqual(wt_opt["re.precomp.blade_mass"][0], 14555.7435212969, 1)
        self.assertAlmostEqual(wt_opt["rp.AEP"][0] * 1.0e-6, 13.7700592288, 1)
        self.assertAlmostEqual(wt_opt["financese.lcoe"][0] * 1.0e3, 36.5740341928, 1)
        self.assertAlmostEqual(wt_opt["rs.tip_pos.tip_deflection"][0], 6.5292336115, 1)
        self.assertAlmostEqual(wt_opt["towerse.z_param"][-1], 108.0, 1)
Example #6
0
    def compute(self, desvars):
        wt_opt_ccblade, analysis_options_ccblade, opt_options_ccblade = run_wisdem(
            fname_wt_input,
            fname_analysis_options_ccblade,
            fname_opt_options,
            desvars,
        )

        outputs = {}
        outputs["CP"] = wt_opt_ccblade["ccblade.CP"][0]

        return outputs
Example #7
0
    def test15MW(self):
        ## IEA 15MW
        fname_wt_input = test_dir + "IEA-15-240-RWT.yaml"
        wt_opt, modeling_options, opt_options = run_wisdem(
            fname_wt_input, fname_modeling_options, fname_analysis_options
        )

        self.assertAlmostEqual(wt_opt["re.precomp.blade_mass"][0], 73310.0985877902, 1)
        self.assertAlmostEqual(wt_opt["rp.AEP"][0] * 1.0e-6, 78.0371305939, 1)
        self.assertAlmostEqual(wt_opt["financese.lcoe"][0] * 1.0e3, 67.61437081321105, 1)
        self.assertAlmostEqual(wt_opt["rs.tip_pos.tip_deflection"][0], 22.7002324979, 1)
        self.assertAlmostEqual(wt_opt["towerse.z_param"][-1], 144.386, 1)
Example #8
0
    def test_ld_slsqp(self):
        analysis_options = load_yaml(fname_analysis_options)

        solver = "LD_SLSQP"
        analysis_options["driver"]["optimization"]["solver"] = solver
        analysis_options["driver"]["optimization"]["max_iter"] = 1

        new_fname_analysis_options = f"{fname_analysis_options.split('/')[-1].split('.')[0]}_{solver}.yaml"
        write_yaml(analysis_options, new_fname_analysis_options)

        wt_opt, modeling_options, opt_options = run_wisdem(
            fname_wt_input, fname_modeling_options, new_fname_analysis_options)
Example #9
0
    def test_cobyla(self):
        analysis_options = load_yaml(fname_analysis_options)

        solver = "COBYLA"
        analysis_options["driver"]["optimization"]["solver"] = solver
        analysis_options["driver"]["optimization"]["rhobeg"] = 0.5
        analysis_options["driver"]["optimization"]["max_iter"] = 1

        new_fname_analysis_options = f"{fname_analysis_options.split('/')[-1].split('.')[0]}_{solver}.yaml"
        write_yaml(analysis_options, new_fname_analysis_options)

        wt_opt, modeling_options, opt_options = run_wisdem(
            fname_wt_input, fname_modeling_options, new_fname_analysis_options)
Example #10
0
    def test_nelder(self):
        analysis_options = load_yaml(fname_analysis_options)

        solver = "Nelder-Mead"
        analysis_options["driver"]["optimization"]["solver"] = solver
        analysis_options["driver"]["optimization"]["adaptive"] = True
        analysis_options["driver"]["optimization"]["max_iter"] = 1

        new_fname_analysis_options = f"{fname_analysis_options.split('/')[-1].split('.')[0]}_{solver}.yaml"
        write_yaml(analysis_options, new_fname_analysis_options)

        wt_opt, modeling_options, opt_options = run_wisdem(
            fname_wt_input, fname_modeling_options, new_fname_analysis_options)
Example #11
0
    def test3p4MW(self):
        ## IEA 15MW
        fname_wt_input = test_dir + "IEA-3p4-130-RWT.yaml"
        wt_opt, modeling_options, opt_options = run_wisdem(
            fname_wt_input, fname_modeling_options, fname_analysis_options)

        self.assertAlmostEqual(wt_opt["re.precomp.blade_mass"][0],
                               14555.7435212969, 1)
        self.assertAlmostEqual(wt_opt["rp.AEP"][0] * 1.0e-6, 13.6037235499, 1)
        self.assertAlmostEqual(wt_opt["financese.lcoe"][0] * 1.0e3,
                               37.4970510481, 1)
        self.assertAlmostEqual(wt_opt["rs.tip_pos.tip_deflection"][0],
                               6.606075926116244, 1)
        self.assertAlmostEqual(wt_opt["towerse.z_param"][-1], 108.0, 3)
Example #12
0
    def test15MW(self):
        ## IEA 15MW
        fname_wt_input = test_dir + "IEA-15-240-RWT.yaml"
        wt_opt, modeling_options, opt_options = run_wisdem(
            fname_wt_input, fname_modeling_options, fname_analysis_options)

        self.assertAlmostEqual(wt_opt["re.precomp.blade_mass"][0],
                               73310.0985877902, 1)
        self.assertAlmostEqual(wt_opt["rp.AEP"][0] * 1.0e-6, 77.6585454480, 1)
        self.assertAlmostEqual(wt_opt["financese.lcoe"][0] * 1.0e3,
                               65.0620671670, 1)
        self.assertAlmostEqual(wt_opt["rs.tip_pos.tip_deflection"][0],
                               22.6934383489, 1)
        self.assertAlmostEqual(wt_opt["towerse.z_param"][-1], 144.386, 3)
Example #13
0
    def compute(self, desvars):
        wt_opt_openfast, analysis_options_openfast, opt_options_openfast = run_wisdem(
            fname_wt_input,
            fname_analysis_options_openfast,
            fname_opt_options,
            fname_wt_output,
            folder_output,
            desvars,
        )

        outputs = {}
        outputs["CP"] = wt_opt_openfast["aeroelastic.Cp"][0]

        return outputs
Example #14
0
    def test5MW(self):

        ## NREL 5MW
        fname_wt_input = test_dir + "nrel5mw.yaml"

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

        self.assertAlmostEqual(wt_opt["re.precomp.blade_mass"][0], 16403.682326940743, 2)
        self.assertAlmostEqual(wt_opt["rp.AEP"][0] * 1.0e-6, 24.0801229107, 2)
        self.assertAlmostEqual(wt_opt["financese.lcoe"][0] * 1.0e3, 50.982520869210894, 2)
        self.assertAlmostEqual(wt_opt["rs.tip_pos.tip_deflection"][0], 4.1949743155, 1)
        self.assertAlmostEqual(wt_opt["towerse.z_param"][-1], 87.6974416, 1)
Example #15
0
    def test15MW(self):
        ## IEA 15MW
        fname_wt_input = test_dir + "IEA-15-240-RWT.yaml"
        wt_opt, modeling_options, opt_options = run_wisdem(
            fname_wt_input, fname_modeling_options, fname_analysis_options)

        self.assertAlmostEqual(wt_opt["rotorse.re.precomp.blade_mass"][0],
                               69911.6542917299, 1)
        self.assertAlmostEqual(wt_opt["rotorse.rp.AEP"][0] * 1.0e-6,
                               77.9923500907, 1)
        self.assertAlmostEqual(wt_opt["financese.lcoe"][0] * 1.0e3,
                               83.6331443842, 1)
        self.assertAlmostEqual(wt_opt["rotorse.rs.tip_pos.tip_deflection"][0],
                               25.9593637967, 1)
        self.assertAlmostEqual(wt_opt["towerse.z_param"][-1], 144.386, 3)
    def test15MW(self):
        ## IEA 15MW
        fname_wt_input = test_dir + "IEA-15-240-RWT.yaml"
        wt_opt, modeling_options, opt_options = run_wisdem(
            fname_wt_input, fname_modeling_options, fname_analysis_options)

        self.assertAlmostEqual(wt_opt["rotorse.re.precomp.blade_mass"][0],
                               69911.6542917299, 1)
        self.assertAlmostEqual(wt_opt["rotorse.rp.AEP"][0] * 1.0e-6,
                               78.1221982490, 1)
        self.assertAlmostEqual(wt_opt["financese.lcoe"][0] * 1.0e3,
                               83.4955271223, 1)
        self.assertAlmostEqual(wt_opt["rotorse.rs.tip_pos.tip_deflection"][0],
                               25.2862284109, 1)
        self.assertAlmostEqual(wt_opt["towerse.z_param"][-1], 144.386, 3)
Example #17
0
    def test3p4MW(self):
        ## IEA 3.4MW
        fname_wt_input = test_dir + "IEA-3p4-130-RWT.yaml"
        wt_opt, modeling_options, opt_options = run_wisdem(
            fname_wt_input, fname_modeling_options, fname_analysis_options)

        self.assertAlmostEqual(wt_opt["rotorse.re.precomp.blade_mass"][0],
                               14555.7435212969, 1)
        self.assertAlmostEqual(wt_opt["rotorse.rp.AEP"][0] * 1.0e-6,
                               13.5747672872, 1)
        self.assertAlmostEqual(wt_opt["financese.lcoe"][0] * 1.0e3,
                               37.5717882723, 1)
        self.assertAlmostEqual(wt_opt["rotorse.rs.tip_pos.tip_deflection"][0],
                               7.3327691810, 1)
        self.assertAlmostEqual(wt_opt["towerse.z_param"][-1], 108.0, 3)
Example #18
0
    def test5MW(self):

        ## NREL 5MW
        fname_wt_input = test_dir + "nrel5mw.yaml"

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

        self.assertAlmostEqual(wt_opt["re.precomp.blade_mass"][0],
                               16403.682326940743, 2)
        self.assertAlmostEqual(wt_opt["rp.AEP"][0] * 1.0e-6, 23.8821935913, 2)
        self.assertAlmostEqual(wt_opt["financese.lcoe"][0] * 1.0e3,
                               51.6455656178, 2)
        self.assertAlmostEqual(wt_opt["rs.tip_pos.tip_deflection"][0],
                               4.2027339083, 1)
        self.assertAlmostEqual(wt_opt["towerse.z_param"][-1], 87.7, 2)
Example #19
0
    def test5MW(self):

        ## NREL 5MW
        fname_wt_input = test_dir + "nrel5mw.yaml"

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

        self.assertAlmostEqual(wt_opt["rotorse.re.precomp.blade_mass"][0],
                               16403.682326940743, 2)
        self.assertAlmostEqual(wt_opt["rotorse.rp.AEP"][0] * 1.0e-6,
                               23.8730557495, 2)
        self.assertAlmostEqual(wt_opt["financese.lcoe"][0] * 1.0e3,
                               51.6834637453, 2)
        self.assertAlmostEqual(wt_opt["rotorse.rs.tip_pos.tip_deflection"][0],
                               4.7673298062, 1)
        self.assertAlmostEqual(wt_opt["towerse.z_param"][-1], 87.7, 2)
Example #20
0
import matplotlib.pyplot as plt
from wisdem.glue_code.runWISDEM import run_wisdem
import os

show_plots = True

## File management
run_dir = os.path.dirname(os.path.realpath(__file__)) + os.sep
fname_wt_input1 = run_dir + 'blade.yaml'
fname_wt_input2 = run_dir + os.sep + 'outputs_aero' + os.sep + 'blade_out.yaml'
# fname_wt_input2        = run_dir + os.sep + 'outputs_struct' + os.sep + 'blade_out.yaml'
# fname_wt_input2        = run_dir + os.sep + 'outputs_aerostruct' + os.sep + 'blade_out.yaml'
fname_modeling_options = run_dir + 'modeling_options.yaml'
fname_analysis_options = run_dir + 'analysis_options_no_opt.yaml'

wt_opt1, modeling_options1, analysis_options1 = run_wisdem(
    fname_wt_input1, fname_modeling_options, fname_analysis_options)
wt_opt2, modeling_options2, analysis_options2 = run_wisdem(
    fname_wt_input2, fname_modeling_options, fname_analysis_options)

label1 = 'Initial'
label2 = 'Optimized'
fs = 12
extension = '.png'  # '.pdf'
color1 = 'tab:blue'
color2 = 'tab:red'
color3 = 'tab:green'

folder_output = analysis_options1['general']['folder_output']

# Twist
ftw, axtw = plt.subplots(1, 1, figsize=(5.3, 4))
Example #21
0
from wisdem.glue_code.runWISDEM import run_wisdem
from wisdem.commonse.mpi_tools import MPI
import os

## File management
run_dir = os.path.dirname(os.path.realpath(__file__)) + os.sep
# fname_wt_input         = run_dir + 'IEAonshoreWT_3.yaml'
fname_wt_input = run_dir + "IEA-15-240-RWT_WISDEMieaontology4all.yaml"
fname_modeling_options_ccblade = run_dir + "modeling_options_ccblade.yaml"
fname_modeling_options_openfast = run_dir + "modeling_options_openfast.yaml"
fname_analysis_options = run_dir + "analysis_options.yaml"
folder_output = run_dir + "it_0/"
fname_wt_output = folder_output + "temp.yaml"

# Run CCBlade
wt_opt_ccblade, analysis_options_ccblade, opt_options_ccblade = run_wisdem(
    fname_wt_input, fname_modeling_options_ccblade, fname_analysis_options)

# Run OpenFAST
wt_opt_openfast, analysis_options_openfast, opt_options_openfast = run_wisdem(
    fname_wt_input, fname_modeling_options_openfast, fname_analysis_options)

if MPI:
    rank = MPI.COMM_WORLD.Get_rank()
else:
    rank = 0

if rank == 0:
    print("Aerodynamic Cp CCblade    = " + str(wt_opt_ccblade["ccblade.CP"]))
    print("Aerodynamic Cp OpenFAST   = " +
          str(wt_opt_openfast["aeroelastic.Cp_out"]))
Example #22
0
import os

show_plots = False

## File management
mydir = os.path.dirname(os.path.realpath(__file__))  # get path to this file
fname_wt_input = mydir + os.sep + 'BAR2010_noRe_BM.yaml'
fname_modeling_options = mydir + os.sep + 'modeling_options.yaml'
fname_analysis_options = mydir + os.sep + 'analysis_options_blade.yaml'
fname_analysis_no_opt = mydir + os.sep + 'analysis_options_blade_no_opt.yaml'
folder_output = mydir + os.sep + 'output' + os.sep
fname_wt_output = folder_output + 'blade_optimized.yaml'

wt_opt1, analysis_options1, opt_options1 = run_wisdem(fname_wt_input,
                                                      fname_modeling_options,
                                                      fname_analysis_options,
                                                      fname_wt_output,
                                                      folder_output)

# Printing and plotting results
print('AEP in GWh = ' + str(wt_opt1['sse.AEP'] * 1.e-6))
print('Cp = ' + str(wt_opt1['sse.powercurve.Cp_regII']))
print('Blade mass in kg = ' + str(wt_opt1['elastic.precomp.blade_mass']))
print('Nat frequencies blades in Hz = ' +
      str(wt_opt1['rlds.frame.flap_mode_freqs']))
print('Nat frequencies blades edge in Hz = ' +
      str(wt_opt1['rlds.frame.edge_mode_freqs']))
print('Rated omega in rpm = ' + str(wt_opt1['sse.powercurve.rated_Omega']))
print('1P in Hz = ' + str(wt_opt1['sse.powercurve.rated_Omega'] / 60.))
print('3P in Hz = ' + str(wt_opt1['sse.powercurve.rated_Omega'] / 60. * 3.))
print('6P in Hz = ' + str(wt_opt1['sse.powercurve.rated_Omega'] / 60. * 6.))
Example #23
0
import os
from wisdem.glue_code.runWISDEM import run_wisdem

## File management
mydir = os.path.dirname(os.path.realpath(__file__))  # get path to this file
fname_wt_input = mydir + os.sep + 'nrel5mw.yaml'
fname_modeling_options = mydir + os.sep + 'modeling_options.yaml'
fname_analysis_options = mydir + os.sep + 'analysis_options.yaml'

wt_opt, analysis_options, opt_options = run_wisdem(fname_wt_input,
                                                   fname_modeling_options,
                                                   fname_analysis_options)
Example #24
0
def main():
    # Called only if this script is run as main.

    # ======================================================================
    # Input Information
    # ======================================================================
    parser = argparse.ArgumentParser()
    parser.add_argument(
        "input_files",
        nargs="*",
        type=str,
        help=
        "Specify the yaml filenames and pickled output filenames to be compared.",
    )
    parser.add_argument(
        "--modeling_options",
        nargs="?",
        type=str,
        default=fname_modeling_options_default,
        help="Specify the modeling options yaml.",
    )
    parser.add_argument(
        "--analysis_options",
        nargs="?",
        type=str,
        default=fname_analysis_options_default,
        help="Specify the analysis options yaml.",
    )
    parser.add_argument("--labels",
                        nargs="*",
                        type=str,
                        default=None,
                        help="Specify the labels for the yaml files.")

    args = parser.parse_args()
    input_filenames = args.input_files
    fname_modeling_options = args.modeling_options
    fname_analysis_options = args.analysis_options
    list_of_labels = args.labels

    if len(input_filenames) == 0:
        print("ERROR: Must specify either a set of yaml files or pkl files\n")
        parser.print_help(sys.stderr)
        sys.exit(1)

    if list_of_labels is None:
        list_of_labels = [f"run_{idx}" for idx in range(len(input_filenames))]

    list_of_sims = []
    for input_filename in input_filenames:
        froot = os.path.splitext(input_filename)[0]

        print()
        if os.path.exists(froot + ".yaml") and os.path.exists(froot + ".pkl"):
            # Load in saved pickle dictionary if already ran WISDEM
            print(f"Loading WISDEM data for {input_filename}.")
            wt_opt, modeling_options, analysis_options = load_wisdem(froot)

        else:
            # Run WISDEM for each yaml file to compare using the modeling and analysis options set above
            print(f"Running WISDEM for {input_filename}.")
            wt_opt, modeling_options, analysis_options = run_wisdem(
                input_filename, fname_modeling_options, fname_analysis_options)

        list_of_sims.append(wt_opt)

    run(list_of_sims, list_of_labels, modeling_options, analysis_options)
    sys.exit(0)