Exemplo n.º 1
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)
Exemplo n.º 2
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)
Exemplo n.º 3
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)
Exemplo n.º 4
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)
Exemplo n.º 5
0
def read_master_file(fyaml):
    if os.path.exists(fyaml):
        print("...Reading master input file,", fyaml)
    else:
        raise FileNotFoundError("The master input file, " + fyaml +
                                ", cannot be found.")

    input_yaml = load_yaml(fyaml)

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

    return input_yaml
Exemplo n.º 6
0
def get_analysis_schema():
    wisdem_schema = load_yaml(fschema_opt_wisdem)
    weis_schema = load_yaml(fschema_opt)
    merged_schema = jsonmerge.merge(wisdem_schema, weis_schema)
    return merged_schema
Exemplo n.º 7
0
def get_modeling_schema():
    wisdem_schema = load_yaml(fschema_model_wisdem)
    weis_schema = load_yaml(fschema_model)
    weis_schema['properties']['WISDEM'].update(
        wisdem_schema['properties']['WISDEM'])
    return weis_schema
Exemplo n.º 8
0
def get_geometry_schema():
    wisdem_schema = load_yaml(fschema_geom_wisdem)
    weis_schema = load_yaml(fschema_geom)
    merged_schema = jsonmerge.merge(wisdem_schema, weis_schema)
    return merged_schema
Exemplo n.º 9
0
def load_default_geometry_yaml():
    return load_yaml(fdefaults_geom)