示例#1
0
def run_PC_sweep(omega, zeta=1.0):
    # Process inputs, single (omega, zeta) or multiple?

    # Turbine inputs
    iec = CaseGen_IEC()
    iec.Turbine_Class = 'I'  # Wind class I, II, III, IV
    iec.Turbulence_Class = 'B'  # Turbulence class 'A', 'B', or 'C'
    iec.D = 240.  # Rotor diameter to size the wind grid
    iec.z_hub = 150.  # Hub height to size the wind grid
    cut_in = 3.  # Cut in wind speed
    cut_out = 25.  # Cut out wind speed
    n_ws = 3  # Number of wind speed bins
    TMax = 800.  # Length of wind grids and OpenFAST simulations, suggested 720 s
    Vrated = 10.59  # Rated wind speed
    Ttrans = max([
        0., TMax - 60.
    ])  # Start of the transient for DLC with a transient, e.g. DLC 1.4
    TStart = max([0., TMax - 600.
                  ])  # Start of the recording of the channels of OpenFAST
    iec.cores = 1
    iec.overwrite = False

    # Initial conditions to start the OpenFAST runs
    u_ref = np.arange(3., 26.)  # Wind speed
    pitch_ref = [
        0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 1.5058525323662666,
        5.253759185225932, 7.50413344606208, 9.310153958810268,
        10.8972969450052, 12.412247669440042, 13.883219268525659,
        15.252012626933068, 16.53735488246438, 17.76456777500061,
        18.953261878035104, 20.11055307762722, 21.238680277668898,
        22.30705111326602, 23.455462501156205
    ]  # Pitch values in deg
    omega_ref = [
        2.019140272160114, 2.8047214918577925, 3.594541645994511,
        4.359025795823625, 5.1123509774611025, 5.855691196288371,
        6.589281196735111, 7.312788026081227, 7.514186181824161,
        7.54665511646938, 7.573823812448151, 7.600476033113538,
        7.630243938880304, 7.638301051122195, 7.622050377183605,
        7.612285710588359, 7.60743945212863, 7.605865650155881,
        7.605792924227456, 7.6062185247519825, 7.607153933765292,
        7.613179734210654, 7.606737845170748
    ]  # Rotor speeds in rpm
    iec.init_cond = {}
    iec.init_cond[("ElastoDyn", "RotSpeed")] = {'U': u_ref}
    iec.init_cond[("ElastoDyn", "RotSpeed")]['val'] = omega_ref
    iec.init_cond[("ElastoDyn", "BlPitch1")] = {'U': u_ref}
    iec.init_cond[("ElastoDyn", "BlPitch1")]['val'] = pitch_ref
    iec.init_cond[("ElastoDyn", "BlPitch2")] = iec.init_cond[("ElastoDyn",
                                                              "BlPitch1")]
    iec.init_cond[("ElastoDyn", "BlPitch3")] = iec.init_cond[("ElastoDyn",
                                                              "BlPitch1")]
    iec.init_cond[("HydroDyn", "WaveHs")] = {
        'U': [3, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 25, 40, 50]
    }
    iec.init_cond[("HydroDyn", "WaveHs")]['val'] = [
        1.101917033, 1.101917033, 1.179052649, 1.315715154, 1.536867124,
        1.835816514, 2.187994638, 2.598127096, 3.061304068, 3.617035443,
        4.027470219, 4.51580671, 4.51580671, 6.98, 10.7
    ]
    iec.init_cond[("HydroDyn", "WaveTp")] = {
        'U': [3, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 25, 40, 50]
    }
    iec.init_cond[("HydroDyn", "WaveTp")]['val'] = [
        8.515382435, 8.515382435, 8.310063688, 8.006300889, 7.6514231,
        7.440581338, 7.460834063, 7.643300307, 8.046899942, 8.521314105,
        8.987021024, 9.451641026, 9.451641026, 11.7, 14.2
    ]
    iec.init_cond[("HydroDyn", "PtfmSurge")] = {'U': [3., 15., 25.]}
    iec.init_cond[("HydroDyn", "PtfmSurge")]['val'] = [4., 15., 10.]
    iec.init_cond[("HydroDyn", "PtfmPitch")] = {'U': [3., 15., 25.]}
    iec.init_cond[("HydroDyn", "PtfmPitch")]['val'] = [-1., 3., 1.3]
    iec.init_cond[("HydroDyn", "PtfmHeave")] = {'U': [3., 25.]}
    iec.init_cond[("HydroDyn", "PtfmHeave")]['val'] = [0.5, 0.5]

    # DLC inputs
    if False:
        wind_speeds = np.linspace(int(cut_in), int(cut_out), int(n_ws))
        iec.dlc_inputs = {}
        iec.dlc_inputs['DLC'] = [1.1, 1.3, 1.4, 1.5, 5.1, 6.1, 6.3]
        iec.dlc_inputs['U'] = [
            wind_speeds, wind_speeds, [Vrated - 2., Vrated, Vrated + 2.],
            wind_speeds, [Vrated - 2., Vrated, Vrated + 2., cut_out], [], []
        ]
        iec.dlc_inputs['Seeds'] = [[1], [1], [], [], [1], [1], [1]]
        # iec.dlc_inputs['Seeds'] = [range(1,7), range(1,7),[],[], range(1,7), range(1,7), range(1,7)]
        iec.dlc_inputs['Yaw'] = [[], [], [], [], [], [], []]
    else:
        wind_speeds = [18]
        iec.dlc_inputs = {}
        iec.dlc_inputs['DLC'] = [1.1]
        iec.dlc_inputs['U'] = [wind_speeds]
        iec.dlc_inputs['Seeds'] = [[1]]
        # iec.dlc_inputs['Seeds'] = [range(1,7), range(1,7),[],[], range(1,7), range(1,7), range(1,7)]
        iec.dlc_inputs['Yaw'] = [[]]

    iec.PC_MaxRat = 2.
    iec.TStart = Ttrans
    iec.TMax = TMax  # wind file length
    iec.transient_dir_change = 'both'  # '+','-','both': sign for transient events in EDC, EWS
    iec.transient_shear_orientation = 'both'  # 'v','h','both': vertical or horizontal shear for EWS
    iec.wind_dir = 'outputs/wind'
    # Management of parallelization
    # not using for now, copy from run_DLC.py if needed later
    iec.parallel_windfile_gen = True
    iec.cores = 4

    iec.run_dir = 'outputs/iea15mw/PC_sweep_play'

    # Run case generator / wind file writing
    case_inputs = {}
    case_inputs[("Fst", "TMax")] = {'vals': [TMax], 'group': 0}
    case_inputs[("Fst", "TStart")] = {'vals': [TStart], 'group': 0}
    # case_inputs[("Fst","DT_Out")]            = {'vals':[0.01], 'group':0}  #0.005
    case_inputs[("Fst", "OutFileFmt")] = {'vals': [2], 'group': 0}
    case_inputs[("Fst", "CompHydro")] = {'vals': [1], 'group': 0}
    case_inputs[("Fst", "CompSub")] = {'vals': [0], 'group': 0}
    case_inputs[("InflowWind", "WindType")] = {'vals': [1], 'group': 0}
    case_inputs[("ElastoDyn", "TwFADOF1")] = {'vals': ["True"], 'group': 0}
    case_inputs[("ElastoDyn", "TwFADOF2")] = {'vals': ["True"], 'group': 0}
    case_inputs[("ElastoDyn", "TwSSDOF1")] = {'vals': ["True"], 'group': 0}
    case_inputs[("ElastoDyn", "TwSSDOF2")] = {'vals': ["True"], 'group': 0}
    case_inputs[("ElastoDyn", "FlapDOF1")] = {'vals': ["True"], 'group': 0}
    case_inputs[("ElastoDyn", "FlapDOF2")] = {'vals': ["True"], 'group': 0}
    case_inputs[("ElastoDyn", "EdgeDOF")] = {'vals': ["True"], 'group': 0}
    case_inputs[("ElastoDyn", "DrTrDOF")] = {'vals': ["False"], 'group': 0}
    case_inputs[("ElastoDyn", "GenDOF")] = {'vals': ["True"], 'group': 0}
    case_inputs[("ElastoDyn", "YawDOF")] = {'vals': ["False"], 'group': 0}
    case_inputs[("ElastoDyn", "PtfmSgDOF")] = {'vals': ["True"], 'group': 0}
    case_inputs[("ElastoDyn", "PtfmSwDOF")] = {'vals': ["True"], 'group': 0}
    case_inputs[("ElastoDyn", "PtfmHvDOF")] = {'vals': ["True"], 'group': 0}
    case_inputs[("ElastoDyn", "PtfmRDOF")] = {'vals': ["True"], 'group': 0}
    case_inputs[("ElastoDyn", "PtfmPDOF")] = {'vals': ["True"], 'group': 0}
    case_inputs[("ElastoDyn", "PtfmYDOF")] = {'vals': ["True"], 'group': 0}
    case_inputs[("ServoDyn", "PCMode")] = {'vals': [5], 'group': 0}
    case_inputs[("ServoDyn", "VSContrl")] = {'vals': [5], 'group': 0}
    run_dir1 = os.path.dirname(
        os.path.dirname(os.path.dirname(os.path.realpath(__file__)))) + os.sep
    if platform.system() == 'Windows':
        path2dll = os.path.join(run_dir1, 'local/lib/libdiscon.dll')
    elif platform.system() == 'Darwin':
        path2dll = os.path.join(run_dir1, 'local/lib/libdiscon.dylib')
    else:
        path2dll = os.path.join(run_dir1, 'local/lib/libdiscon.so')

    case_inputs[("ServoDyn", "DLL_FileName")] = {
        'vals': [path2dll],
        'group': 0
    }
    case_inputs[("AeroDyn15", "TwrAero")] = {'vals': ["True"], 'group': 0}
    case_inputs[("AeroDyn15", "TwrPotent")] = {'vals': [1], 'group': 0}
    case_inputs[("AeroDyn15", "TwrShadow")] = {'vals': [1], 'group': 0}
    case_inputs[("HydroDyn", "WaveMod")] = {'vals': [2], 'group': 0}
    case_inputs[("HydroDyn", "WvDiffQTF")] = {'vals': ["False"], 'group': 0}
    channels = {}
    for var in [
            "TipDxc1", "TipDyc1", "TipDzc1", "TipDxb1", "TipDyb1", "TipDxc2",
            "TipDyc2", "TipDzc2", "TipDxb2", "TipDyb2", "TipDxc3", "TipDyc3",
            "TipDzc3", "TipDxb3", "TipDyb3", "RootMxc1", "RootMyc1",
            "RootMzc1", "RootMxb1", "RootMyb1", "RootMxc2", "RootMyc2",
            "RootMzc2", "RootMxb2", "RootMyb2", "RootMxc3", "RootMyc3",
            "RootMzc3", "RootMxb3", "RootMyb3", "TwrBsMxt", "TwrBsMyt",
            "TwrBsMzt", "GenPwr", "GenTq", "RotThrust", "RtAeroCp", "RtAeroCt",
            "RotSpeed", "BldPitch1", "TTDspSS", "TTDspFA", "NacYaw",
            "Wind1VelX", "Wind1VelY", "Wind1VelZ", "LSSTipMxa", "LSSTipMya",
            "LSSTipMza", "LSSTipMxs", "LSSTipMys", "LSSTipMzs", "LSShftFys",
            "LSShftFzs", "TipRDxr", "TipRDyr", "TipRDzr"
    ]:
        channels[var] = True

    # mass sweep
    # case_inputs[("ElastoDyn","PtfmMass")] = {'vals': (1.7838E+07*np.array([.7,.8,.9,1,1.1,1.2,1.3])).tolist(), 'group':3}
    # case_inputs[("ElastoDyn","PtfmRIner")] = {'vals':(1.2507E+10*np.array([.7,.8,.9,1,1.1,1.2,1.3])).tolist(), 'group':3}
    # case_inputs[("ElastoDyn","PtfmPIner")] = {'vals':(1.2507E+10*np.array([.7,.8,.9,1,1.1,1.2,1.3])).tolist(), 'group':3}
    # case_inputs[("ElastoDyn","PtfmYIner")] = {'vals':(2.3667E+10*np.array([.7,.8,.9,1,1.1,1.2,1.3])).tolist(), 'group':3}

    # controller params

    # load default params
    print('here')
    rt_dir = os.path.join(
        os.path.dirname(
            os.path.dirname(os.path.dirname(os.path.realpath(__file__)))),
        'ROSCO_toolbox')
    rt_dir = '/Users/dzalkind/Tools/ROSCO_toolbox'
    weis_dir = os.path.join(rt_dir, 'Tune_Cases')
    control_param_yaml = os.path.join(rt_dir, 'Tune_Cases', 'IEA15MW.yaml')
    inps = yaml.safe_load(open(control_param_yaml))
    path_params = inps['path_params']
    turbine_params = inps['turbine_params']
    controller_params = inps['controller_params']

    # make default controller, turbine objects for ROSCO_toolbox
    turbine = ROSCO_turbine.Turbine(turbine_params)
    turbine.load_from_fast(path_params['FAST_InputFile'],
                           os.path.join(rt_dir, path_params['FAST_directory']),
                           dev_branch=True)

    controller = ROSCO_controller.Controller(controller_params)

    # tune default controller
    controller.tune_controller(turbine)

    # check if inputs are lists
    if not isinstance(omega, list):
        omega = [omega]
    if not isinstance(zeta, list):
        zeta = [zeta]

    # Loop through and make PI gains
    pc_kp = []
    pc_ki = []
    omega_zeta = []  # flattened (omega,zeta) pairs
    for o in omega:
        for z in zeta:
            controller.omega_pc = o
            controller.zeta_pc = z
            controller.tune_controller(turbine)
            pc_kp.append(controller.pc_gain_schedule.Kp.tolist())
            pc_ki.append(controller.pc_gain_schedule.Ki.tolist())
            omega_zeta.append((o, z))

    # add control gains to case_list
    case_inputs[('DISCON_in', 'PC_GS_KP')] = {'vals': pc_kp, 'group': 3}
    case_inputs[('DISCON_in', 'PC_GS_KI')] = {'vals': pc_ki, 'group': 3}

    iec.case_name_base = 'pc_play'

    # generate cases
    case_list, case_name_list, dlc_list = iec.execute(case_inputs=case_inputs)

    #for var in var_out+[var_x]:

    # Run FAST cases
    fastBatch = runFAST_pywrapper_batch(FAST_ver='OpenFAST', dev_branch=True)

    # Monopile
    # fastBatch.FAST_InputFile    = 'IEA-15-240-RWT-Monopile.fst'   # FAST input file (ext=.fst)
    # run_dir2                    = os.path.dirname( os.path.dirname( os.path.realpath(__file__) ) ) + os.sep
    # fastBatch.FAST_directory    = os.path.join(run_dir2, 'OpenFAST_models/IEA-15-240-RWT/IEA-15-240-RWT-Monopile')   # Path to fst directory files
    fastBatch.channels = channels
    # fastBatch.FAST_runDirectory = iec.run_dir
    fastBatch.case_list = case_list
    fastBatch.case_name_list = case_name_list
    fastBatch.debug_level = 2

    # if MPI:
    #     fastBatch.run_mpi(comm_map_down)
    # else:
    #     fastBatch.run_serial()

    # U-Maine semi-sub
    fastBatch.FAST_InputFile = 'IEA-15-240-RWT-UMaineSemi.fst'  # FAST input file (ext=.fst)
    run_dir2 = os.path.dirname(os.path.realpath(__file__)) + os.sep
    fastBatch.FAST_directory = os.path.join(
        run_dir2, 'OpenFAST_models', 'IEA-15-240-RWT',
        'IEA-15-240-RWT-UMaineSemi')  # Path to fst directory files
    fastBatch.FAST_runDirectory = iec.run_dir
    if True:
        fastBatch.run_multi(cores=4)
    else:
        fastBatch.run_serial()
示例#2
0
# Analysis time
if floating:
    TMax = 900
else:
    TMax = 660

# Turbine definition
Turbine_Class = 'I'  # I, II, III, IV
Turbulence_Class = 'A'
D = 126.
z_hub = 90

# ================== THE ACTION ==================
# Initialize iec
iec = CaseGen_IEC()
# Turbine Data
iec.init_cond = {}  # can leave as {} if data not available
iec.init_cond[("ElastoDyn", "RotSpeed")] = {
    'U': [
        3., 4., 5., 6., 7., 8., 9., 10., 11., 12., 13., 14., 15., 16., 17.,
        18., 19., 20., 21., 22., 23., 24., 25
    ]
}
iec.init_cond[("ElastoDyn", "RotSpeed")]['val'] = [
    6.972, 7.183, 7.506, 7.942, 8.469, 9.156, 10.296, 11.431, 11.89, 12.1,
    12.1, 12.1, 12.1, 12.1, 12.1, 12.1, 12.1, 12.1, 12.1, 12.1, 12.1, 12.1,
    12.1
]
iec.init_cond[("ElastoDyn", "BlPitch1")] = {
    'U': [
示例#3
0
    def test_run(self):
        # Turbine inputs
        iec = CaseGen_IEC()
        iec.Turbine_Class = "I"  # Wind class I, II, III, IV
        iec.Turbulence_Class = "B"  # Turbulence class 'A', 'B', or 'C'
        iec.D = 240.0  # Rotor diameter to size the wind grid
        iec.z_hub = 150.0  # Hub height to size the wind grid
        cut_in = 3.0  # Cut in wind speed
        cut_out = 25.0  # Cut out wind speed
        n_ws = 2  # Number of wind speed bins
        TMax = 0.05  # Length of wind grids and OpenFAST simulations, suggested 720 s
        Vrated = 10.59  # Rated wind speed
        Ttrans = max([
            0.0, TMax - 60.0
        ])  # Start of the transient for DLC with a transient, e.g. DLC 1.4
        TStart = max([0.0, TMax - 600.0
                      ])  # Start of the recording of the channels of OpenFAST

        # Initial conditions to start the OpenFAST runs
        u_ref = np.arange(8.0, 10.0)  # Wind speed
        pitch_ref = [0.0, 0.5]  # Pitch values in deg
        omega_ref = [5.5, 6.0]  # Rotor speeds in rpm
        iec.init_cond = {}
        iec.init_cond[("ElastoDyn", "RotSpeed")] = {"U": u_ref}
        iec.init_cond[("ElastoDyn", "RotSpeed")]["val"] = omega_ref
        iec.init_cond[("ElastoDyn", "BlPitch1")] = {"U": u_ref}
        iec.init_cond[("ElastoDyn", "BlPitch1")]["val"] = pitch_ref
        iec.init_cond[("ElastoDyn", "BlPitch2")] = iec.init_cond[("ElastoDyn",
                                                                  "BlPitch1")]
        iec.init_cond[("ElastoDyn", "BlPitch3")] = iec.init_cond[("ElastoDyn",
                                                                  "BlPitch1")]
        iec.init_cond[("HydroDyn", "WaveHs")] = {"U": [3, 4]}
        iec.init_cond[("HydroDyn", "WaveHs")]["val"] = [
            1.101917033,
            1.101917033,
        ]
        iec.init_cond[("HydroDyn", "WaveTp")] = {"U": [3, 4]}
        iec.init_cond[("HydroDyn", "WaveTp")]["val"] = [
            8.515382435,
            8.515382435,
        ]
        iec.init_cond[("HydroDyn", "PtfmSurge")] = {"U": [3.0, 15.0, 25.0]}
        iec.init_cond[("HydroDyn", "PtfmSurge")]["val"] = [4.0, 15.0, 10.0]
        iec.init_cond[("HydroDyn", "PtfmPitch")] = {"U": [3.0, 15.0, 25.0]}
        iec.init_cond[("HydroDyn", "PtfmPitch")]["val"] = [-1.0, 3.0, 1.3]
        iec.init_cond[("HydroDyn", "PtfmHeave")] = {"U": [3.0, 25.0]}
        iec.init_cond[("HydroDyn", "PtfmHeave")]["val"] = [0.5, 0.5]

        # DLC inputs
        wind_speeds = np.linspace(int(cut_in), int(cut_out), int(n_ws))
        iec.dlc_inputs = {}
        iec.dlc_inputs["DLC"] = [1.1]  # , 1.3, 1.4, 1.5, 5.1, 6.1, 6.3]
        iec.dlc_inputs["U"] = [
            wind_speeds,
            # wind_speeds,
            # [Vrated - 2.0, Vrated, Vrated + 2.0],
            # wind_speeds,
            # [Vrated - 2.0, Vrated, Vrated + 2.0, cut_out],
            # [],
            # [],
        ]
        iec.dlc_inputs["Seeds"] = [[1], [1], [], [], [1], [1], [1]]
        # iec.dlc_inputs['Seeds'] = [range(1,7), range(1,7),[],[], range(1,7), range(1,7), range(1,7)]
        iec.dlc_inputs["Yaw"] = [[], [], [], [], [], [], []]
        iec.PC_MaxRat = 2.0

        iec.TStart = Ttrans
        iec.TMax = TMax  # wind file length
        iec.transient_dir_change = (
            "both"  # '+','-','both': sign for transient events in EDC, EWS
        )
        iec.transient_shear_orientation = (
            "both"  # 'v','h','both': vertical or horizontal shear for EWS
        )

        # Naming, file management, etc
        iec.wind_dir = "outputs/wind"
        iec.case_name_base = "iea15mw"
        iec.cores = 1

        iec.debug_level = 2
        iec.parallel_windfile_gen = False
        iec.mpi_run = False
        iec.run_dir = "outputs/iea15mw"

        # Run case generator / wind file writing
        case_inputs = {}
        case_inputs[("Fst", "TMax")] = {"vals": [TMax], "group": 0}
        case_inputs[("Fst", "TStart")] = {"vals": [TStart], "group": 0}
        case_inputs[("Fst", "DT")] = {"vals": [0.005], "group": 0}
        case_inputs[("Fst", "DT_Out")] = {"vals": [0.01], "group": 0}  # 0.005
        case_inputs[("Fst", "OutFileFmt")] = {"vals": [2], "group": 0}
        case_inputs[("Fst", "CompHydro")] = {"vals": [1], "group": 0}
        case_inputs[("Fst", "CompSub")] = {"vals": [0], "group": 0}
        case_inputs[("InflowWind", "WindType")] = {"vals": [1], "group": 0}
        case_inputs[("ElastoDyn", "TwFADOF1")] = {"vals": ["True"], "group": 0}
        case_inputs[("ElastoDyn", "TwFADOF2")] = {"vals": ["True"], "group": 0}
        case_inputs[("ElastoDyn", "TwSSDOF1")] = {"vals": ["True"], "group": 0}
        case_inputs[("ElastoDyn", "TwSSDOF2")] = {"vals": ["True"], "group": 0}
        case_inputs[("ElastoDyn", "FlapDOF1")] = {"vals": ["True"], "group": 0}
        case_inputs[("ElastoDyn", "FlapDOF2")] = {"vals": ["True"], "group": 0}
        case_inputs[("ElastoDyn", "EdgeDOF")] = {"vals": ["True"], "group": 0}
        case_inputs[("ElastoDyn", "DrTrDOF")] = {"vals": ["False"], "group": 0}
        case_inputs[("ElastoDyn", "GenDOF")] = {"vals": ["True"], "group": 0}
        case_inputs[("ElastoDyn", "YawDOF")] = {"vals": ["False"], "group": 0}
        case_inputs[("ElastoDyn", "PtfmSgDOF")] = {
            "vals": ["False"],
            "group": 0
        }
        case_inputs[("ElastoDyn", "PtfmSwDOF")] = {
            "vals": ["False"],
            "group": 0
        }
        case_inputs[("ElastoDyn", "PtfmHvDOF")] = {
            "vals": ["False"],
            "group": 0
        }
        case_inputs[("ElastoDyn", "PtfmRDOF")] = {
            "vals": ["False"],
            "group": 0
        }
        case_inputs[("ElastoDyn", "PtfmPDOF")] = {
            "vals": ["False"],
            "group": 0
        }
        case_inputs[("ElastoDyn", "PtfmYDOF")] = {
            "vals": ["False"],
            "group": 0
        }
        case_inputs[("ServoDyn", "PCMode")] = {"vals": [5], "group": 0}
        case_inputs[("ServoDyn", "VSContrl")] = {"vals": [5], "group": 0}
        run_dir1 = (os.path.dirname(
            os.path.dirname(
                os.path.dirname(os.path.dirname(os.path.realpath(__file__)))))
                    + os.sep)
        if platform.system() == "Windows":
            path2dll = os.path.join(run_dir1, "local/lib/libdiscon.dll")
        elif platform.system() == "Darwin":
            path2dll = os.path.join(run_dir1, "local/lib/libdiscon.dylib")
        else:
            path2dll = os.path.join(run_dir1, "local/lib/libdiscon.so")

        case_inputs[("ServoDyn", "DLL_FileName")] = {
            "vals": [path2dll],
            "group": 0
        }
        case_inputs[("AeroDyn15", "TwrAero")] = {"vals": ["True"], "group": 0}
        case_inputs[("AeroDyn15", "TwrPotent")] = {"vals": [1], "group": 0}
        case_inputs[("AeroDyn15", "TwrShadow")] = {
            "vals": ["True"],
            "group": 0
        }
        case_inputs[("Fst", "CompHydro")] = {"vals": [1], "group": 0}
        case_inputs[("HydroDyn", "WaveMod")] = {"vals": [2], "group": 0}
        case_inputs[("HydroDyn", "WvDiffQTF")] = {
            "vals": ["False"],
            "group": 0
        }
        channels = {}
        for var in [
                "TipDxc1",
                "TipDyc1",
                "TipDzc1",
                "TipDxb1",
                "TipDyb1",
                "TipDxc2",
                "TipDyc2",
                "TipDzc2",
                "TipDxb2",
                "TipDyb2",
                "TipDxc3",
                "TipDyc3",
                "TipDzc3",
                "TipDxb3",
                "TipDyb3",
                "RootMxc1",
                "RootMyc1",
                "RootMzc1",
                "RootMxb1",
                "RootMyb1",
                "RootMxc2",
                "RootMyc2",
                "RootMzc2",
                "RootMxb2",
                "RootMyb2",
                "RootMxc3",
                "RootMyc3",
                "RootMzc3",
                "RootMxb3",
                "RootMyb3",
                "TwrBsMxt",
                "TwrBsMyt",
                "TwrBsMzt",
                "GenPwr",
                "GenTq",
                "RotThrust",
                "RtAeroCp",
                "RtAeroCt",
                "RotSpeed",
                "BldPitch1",
                "BldPitch2",
                "BldPitch3",
                "TTDspSS",
                "TTDspFA",
                "NacYaw",
                # "Wind1VelX",
                # "Wind1VelY",
                # "Wind1VelZ",
                "LSSTipMxa",
                "LSSTipMya",
                "LSSTipMza",
                "LSSTipMxs",
                "LSSTipMys",
                "LSSTipMzs",
                "LSShftFys",
                "LSShftFzs",
                "TipRDxr",
                "TipRDyr",
                "TipRDzr",
        ]:
            channels[var] = True

        case_list, case_name_list, dlc_list = iec.execute(
            case_inputs=case_inputs)

        # for var in var_out+[var_x]:

        # Run FAST cases
        fastBatch = runFAST_pywrapper_batch(FAST_ver="OpenFAST",
                                            dev_branch=True,
                                            post=FAST_IO_timeseries)

        # Monopile
        fastBatch.FAST_InputFile = (
            "IEA-15-240-RWT-Monopile.fst"  # FAST input file (ext=.fst)
        )
        run_dir2 = (os.path.dirname(
            os.path.dirname(
                os.path.dirname(os.path.dirname(
                    os.path.realpath(__file__))))) + os.sep + "examples" +
                    os.sep + "01_aeroelasticse" + os.sep)
        fastBatch.FAST_directory = os.path.join(
            run_dir2, "OpenFAST_models", "IEA-15-240-RWT",
            "IEA-15-240-RWT-Monopile")  # Path to fst directory files
        fastBatch.channels = channels
        fastBatch.FAST_runDirectory = iec.run_dir
        fastBatch.case_list = case_list
        fastBatch.case_name_list = case_name_list
        fastBatch.debug_level = 2
        fastBatch.keep_time = True

        _, _, _, out = fastBatch.run_serial()

        train = False
        keys_to_skip = []
        #keys_to_skip = [
        #    "Wind1VelX",
        #    "Wind1VelY",
        #    "Wind1VelZ",
        #    "Wave1Elev",
        #]

        compare_regression_values(
            out,
            "DLC_regression_values_1.pkl",
            directory=this_file_dir,
            tol=1e-1,
            train=train,
            keys_to_skip=keys_to_skip,
        )

        # U-Maine semi-sub
        fastBatch.FAST_InputFile = (
            "IEA-15-240-RWT-UMaineSemi.fst"  # FAST input file (ext=.fst)
        )
        fastBatch.FAST_directory = os.path.join(
            run_dir2, "OpenFAST_models", "IEA-15-240-RWT",
            "IEA-15-240-RWT-UMaineSemi")  # Path to fst directory files

        _, _, _, out = fastBatch.run_serial()

        compare_regression_values(
            out,
            "DLC_regression_values_2.pkl",
            directory=this_file_dir,
            tol=1e-1,
            train=train,
            keys_to_skip=keys_to_skip,
        )
from weis.aeroelasticse.runFAST_pywrapper import runFAST_pywrapper, runFAST_pywrapper_batch
from weis.aeroelasticse.CaseGen_IEC       import CaseGen_IEC
from wisdem.commonse.mpi_tools              import MPI
import sys

eagle = True

if MPI:
    from wisdem.commonse.mpi_tools import map_comm_heirarchical, subprocessor_loop, subprocessor_stop
    if eagle:
        comm_map_down, comm_map_up, color_map = map_comm_heirarchical(1, 246)
    else:
        comm_map_down, comm_map_up, color_map = map_comm_heirarchical(1, 3)


iec = CaseGen_IEC()
iec.Turbine_Class = 'III' # I, II, III, IV
iec.Turbulence_Class = 'A'
iec.D = 206.
iec.z_hub = 140.
TMax   = 720.
Vrated = 8.3
Ttrans = TMax - 60.
TStart = max([0., TMax - 600.])

# Turbine Data
iec.init_cond = {} # can leave as {} if data not available
iec.init_cond[("ElastoDyn","RotSpeed")] = {'U':[3., 5., 7., 8.3, 25.]}
iec.init_cond[("ElastoDyn","RotSpeed")]['val'] = [2.92, 4.88, 6.81, 7.835, 7.88]
iec.init_cond[("ElastoDyn","BlPitch1")] = {'U':[3., 8.2,  9., 11.,  13.,  15.,  17., 19., 21., 23., 25]}
iec.init_cond[("ElastoDyn","BlPitch1")]['val'] = [0., 0., 2.93, 8.76, 12.01, 14.82, 17.37, 19.73, 21.96, 24.08, 26.10]
示例#5
0
"""

Example script to run the DLCs in OpenFAST

"""

from weis.aeroelasticse.runFAST_pywrapper   import runFAST_pywrapper, runFAST_pywrapper_batch
from weis.aeroelasticse.CaseGen_IEC         import CaseGen_IEC
from wisdem.commonse.mpi_tools              import MPI
import sys, os, platform
import numpy as np

# Turbine inputs
iec = CaseGen_IEC()
iec.Turbine_Class       = 'I'   # Wind class I, II, III, IV
iec.Turbulence_Class    = 'B'   # Turbulence class 'A', 'B', or 'C'
iec.D                   = 240.  # Rotor diameter to size the wind grid
iec.z_hub               = 150.  # Hub height to size the wind grid
cut_in                  = 3.    # Cut in wind speed
cut_out                 = 25.   # Cut out wind speed
n_ws                    = 3    # Number of wind speed bins
TMax                    = 1.    # Length of wind grids and OpenFAST simulations, suggested 720 s
Vrated                  = 10.59 # Rated wind speed
Ttrans                  = max([0., TMax - 60.])  # Start of the transient for DLC with a transient, e.g. DLC 1.4
TStart                  = max([0., TMax - 600.]) # Start of the recording of the channels of OpenFAST

# Initial conditions to start the OpenFAST runs
u_ref     = np.arange(3.,26.) # Wind speed
pitch_ref = [0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 1.5058525323662666, 5.253759185225932, 7.50413344606208, 9.310153958810268, 10.8972969450052, 12.412247669440042, 13.883219268525659, 15.252012626933068, 16.53735488246438, 17.76456777500061, 18.953261878035104, 20.11055307762722, 21.238680277668898, 22.30705111326602, 23.455462501156205] # Pitch values in deg
omega_ref = [2.019140272160114, 2.8047214918577925, 3.594541645994511, 4.359025795823625, 5.1123509774611025, 5.855691196288371, 6.589281196735111, 7.312788026081227, 7.514186181824161, 7.54665511646938, 7.573823812448151, 7.600476033113538, 7.630243938880304, 7.638301051122195, 7.622050377183605, 7.612285710588359, 7.60743945212863, 7.605865650155881, 7.605792924227456, 7.6062185247519825, 7.607153933765292, 7.613179734210654, 7.606737845170748] # Rotor speeds in rpm
iec.init_cond = {}
示例#6
0
def RotorSE_DAC_rated(fst_vt,
                      runDir,
                      namebase,
                      TMax,
                      turbine_class,
                      turbulence_class,
                      Vrated,
                      U_init=[],
                      Omega_init=[],
                      pitch_init=[],
                      Turbsim_exe='',
                      debug_level=0,
                      cores=0,
                      mpi_run=False,
                      mpi_comm_map_down=[]):
    # Default Runtime
    T = 630.  # 600.
    TStart = 0.  #0.  # 30.

    # Overwrite for testing
    if TMax < T:
        T = TMax
        TStart = 0.

    iec = CaseGen_IEC()
    iec.TMax = T
    iec.init_cond[("ElastoDyn", "RotSpeed")] = {'U': U_init}
    iec.init_cond[("ElastoDyn", "RotSpeed")]['val'] = [
        0.95 * omega_i for omega_i in Omega_init
    ]
    iec.init_cond[("ElastoDyn", "BlPitch1")] = {'U': U_init}
    iec.init_cond[("ElastoDyn", "BlPitch1")]['val'] = pitch_init
    iec.init_cond[("ElastoDyn", "BlPitch2")] = iec.init_cond[("ElastoDyn",
                                                              "BlPitch1")]
    iec.init_cond[("ElastoDyn", "BlPitch3")] = iec.init_cond[("ElastoDyn",
                                                              "BlPitch1")]

    iec.Turbine_Class = turbine_class
    iec.Turbulence_Class = turbulence_class
    iec.D = fst_vt['ElastoDyn']['TipRad'] * 2.
    iec.z_hub = fst_vt['InflowWind']['RefHt']

    iec.dlc_inputs = {}
    iec.dlc_inputs['DLC'] = [1.1]  # [1.1]
    # iec.dlc_inputs['U'] = [[U]]
    iec.dlc_inputs['U'] = [list(Vrated + np.arange(0, 10, 2))]
    # iec.dlc_inputs['Seeds'] = [[1]]
    iec.dlc_inputs['Seeds'] = [[
        13428, 1524
    ]]  # nothing special about these seeds, randomly generated
    iec.dlc_inputs['Yaw'] = [[]]
    iec.transient_dir_change = '-'  # '+','-','both': sign for transient events in EDC, EWS
    iec.transient_shear_orientation = 'v'  # 'v','h','both': vertical or horizontal shear for EWS
    iec.TMax = 5.

    iec.wind_dir = runDir
    iec.case_name_base = namebase
    iec.Turbsim_exe = Turbsim_exe
    iec.debug_level = debug_level
    iec.cores = cores
    iec.run_dir = runDir
    # iec.overwrite = True
    iec.overwrite = False
    if cores > 1:
        iec.parallel_windfile_gen = True
    else:
        iec.parallel_windfile_gen = False

    # mpi_run = False
    if mpi_run:
        iec.mpi_run = mpi_run
        iec.comm_map_down = mpi_comm_map_down

    case_inputs = {}
    case_inputs[("Fst", "TMax")] = {'vals': [T], 'group': 0}
    case_inputs[("Fst", "TStart")] = {'vals': [TStart], 'group': 0}
    case_inputs[("Fst", "OutFileFmt")] = {'vals': [3], 'group': 0}

    case_inputs[("ElastoDyn", "YawDOF")] = {'vals': ['False'], 'group': 0}
    case_inputs[("ElastoDyn", "FlapDOF1")] = {'vals': ['True'], 'group': 0}
    case_inputs[("ElastoDyn", "FlapDOF2")] = {'vals': ['True'], 'group': 0}
    case_inputs[("ElastoDyn", "EdgeDOF")] = {
        'vals': ['False'],
        'group': 0
    }  # <<< set to FALSE for now
    case_inputs[("ElastoDyn", "DrTrDOF")] = {'vals': ['False'], 'group': 0}
    case_inputs[("ElastoDyn", "GenDOF")] = {'vals': ['True'], 'group': 0}
    case_inputs[("ElastoDyn", "TwFADOF1")] = {'vals': ['False'], 'group': 0}
    case_inputs[("ElastoDyn", "TwFADOF2")] = {'vals': ['False'], 'group': 0}
    case_inputs[("ElastoDyn", "TwSSDOF1")] = {'vals': ['False'], 'group': 0}
    case_inputs[("ElastoDyn", "TwSSDOF2")] = {'vals': ['False'], 'group': 0}

    case_inputs[("ServoDyn", "PCMode")] = {'vals': [5], 'group': 0}
    case_inputs[("ServoDyn", "VSContrl")] = {'vals': [5], 'group': 0}
    case_inputs[("ServoDyn", "YCMode")] = {'vals': [0], 'group': 0}

    case_inputs[("AeroDyn15", "WakeMod")] = {'vals': [1], 'group': 0}
    case_inputs[("AeroDyn15", "AFAeroMod")] = {'vals': [2], 'group': 0}
    case_inputs[("AeroDyn15", "TwrPotent")] = {'vals': [0], 'group': 0}
    case_inputs[("AeroDyn15", "TwrShadow")] = {'vals': ['False'], 'group': 0}
    case_inputs[("AeroDyn15", "TwrAero")] = {'vals': ['False'], 'group': 0}

    case_inputs[("AeroDyn15", "SkewMod")] = {'vals': [2], 'group': 0}
    case_inputs[("AeroDyn15", "TipLoss")] = {'vals': ['True'], 'group': 0}
    case_inputs[("AeroDyn15", "HubLoss")] = {'vals': ['True'], 'group': 0}
    # case_inputs[("AeroDyn15","TanInd")]      = {'vals':['True'], 'group':0}
    # case_inputs[("AeroDyn15","AIDrag")]      = {'vals':['True'], 'group':0}
    # case_inputs[("AeroDyn15","TIDrag")]      = {'vals':['True'], 'group':0}
    # case_inputs[("AeroDyn15","IndToler")]    = {'vals':[1.e-5], 'group':0}
    # case_inputs[("AeroDyn15","MaxIter")]     = {'vals':[5000], 'group':0}
    case_inputs[("AeroDyn15", "UseBlCm")] = {'vals': ['True'], 'group': 0}

    case_list, case_name_list = iec.execute(case_inputs=case_inputs)

    channels = [
        "TipDxc1", "TipDyc1", "TipDzc1", "TipDxc2", "TipDyc2", "TipDzc2",
        "TipDxc3", "TipDyc3", "TipDzc3", "Azimuth"
    ]
    channels += [
        "RootMxc1", "RootMyc1", "RootMzc1", "RootMxc2", "RootMyc2", "RootMzc2",
        "RootMxc3", "RootMyc3", "RootMzc3"
    ]
    channels += [
        "RootFxc1", "RootFyc1", "RootFzc1", "RootFxc2", "RootFyc2", "RootFzc2",
        "RootFxc3", "RootFyc3", "RootFzc3"
    ]
    channels += ["RtAeroCp", "RotTorq", "RotThrust", "RotSpeed", "NacYaw"]

    channels += [
        "B1N1Fx", "B1N2Fx", "B1N3Fx", "B1N4Fx", "B1N5Fx", "B1N6Fx", "B1N7Fx",
        "B1N8Fx", "B1N9Fx"
    ]
    channels += [
        "B1N1Fy", "B1N2Fy", "B1N3Fy", "B1N4Fy", "B1N5Fy", "B1N6Fy", "B1N7Fy",
        "B1N8Fy", "B1N9Fy"
    ]

    channels += ["Wind1VelX", "Wind1VelY", "Wind1VelZ"]
    channels += ["BLFLAP1", "BLFLAP2", "BLFLAP3"]

    return case_list, case_name_list, channels
示例#7
0
def RotorSE_DLC_1_4_Rated(fst_vt,
                          runDir,
                          namebase,
                          TMax,
                          turbine_class,
                          turbulence_class,
                          Vrated,
                          U_init=[],
                          Omega_init=[],
                          pitch_init=[],
                          Turbsim_exe=''):

    # Default Runtime
    T = 60.
    TStart = 30.
    # TStart = 0.

    # Overwrite for testing
    if TMax < T:
        T = TMax
        TStart = 0.

    iec = CaseGen_IEC()
    iec.init_cond[("ElastoDyn", "RotSpeed")] = {'U': U_init}
    iec.init_cond[("ElastoDyn", "RotSpeed")]['val'] = Omega_init
    iec.init_cond[("ElastoDyn", "BlPitch1")] = {'U': U_init}
    iec.init_cond[("ElastoDyn", "BlPitch1")]['val'] = pitch_init
    iec.init_cond[("ElastoDyn", "BlPitch2")] = iec.init_cond[("ElastoDyn",
                                                              "BlPitch1")]
    iec.init_cond[("ElastoDyn", "BlPitch3")] = iec.init_cond[("ElastoDyn",
                                                              "BlPitch1")]
    iec.Turbine_Class = turbine_class
    iec.Turbulence_Class = turbulence_class
    iec.D = fst_vt['ElastoDyn']['TipRad'] * 2.
    iec.z_hub = fst_vt['InflowWind']['RefHt']

    iec.dlc_inputs = {}
    iec.dlc_inputs['DLC'] = [1.4]
    iec.dlc_inputs['U'] = [[Vrated]]
    iec.dlc_inputs['Seeds'] = [[]]
    iec.dlc_inputs['Yaw'] = [[]]
    iec.transient_dir_change = '-'  # '+','-','both': sign for transient events in EDC, EWS
    iec.transient_shear_orientation = 'v'  # 'v','h','both': vertical or horizontal shear for EWS

    iec.wind_dir = runDir
    iec.case_name_base = namebase + '_gust'
    iec.Turbsim_exe = ''
    iec.debug_level = 0
    iec.parallel_windfile_gen = False
    iec.run_dir = runDir

    case_inputs = {}
    case_inputs[("Fst", "TMax")] = {'vals': [T], 'group': 0}
    case_inputs[("Fst", "TStart")] = {'vals': [TStart], 'group': 0}
    case_inputs[("Fst", "OutFileFmt")] = {'vals': [2], 'group': 0}

    case_inputs[("ElastoDyn", "YawDOF")] = {'vals': ['True'], 'group': 0}
    case_inputs[("ElastoDyn", "FlapDOF1")] = {'vals': ['True'], 'group': 0}
    case_inputs[("ElastoDyn", "FlapDOF2")] = {'vals': ['True'], 'group': 0}
    case_inputs[("ElastoDyn", "EdgeDOF")] = {'vals': ['True'], 'group': 0}
    case_inputs[("ElastoDyn", "DrTrDOF")] = {'vals': ['False'], 'group': 0}
    case_inputs[("ElastoDyn", "GenDOF")] = {'vals': ['True'], 'group': 0}
    case_inputs[("ElastoDyn", "TwFADOF1")] = {'vals': ['False'], 'group': 0}
    case_inputs[("ElastoDyn", "TwFADOF2")] = {'vals': ['False'], 'group': 0}
    case_inputs[("ElastoDyn", "TwSSDOF1")] = {'vals': ['False'], 'group': 0}
    case_inputs[("ElastoDyn", "TwSSDOF2")] = {'vals': ['False'], 'group': 0}

    case_inputs[("ServoDyn", "PCMode")] = {'vals': [5], 'group': 0}
    case_inputs[("ServoDyn", "VSContrl")] = {'vals': [5], 'group': 0}
    case_inputs[("ServoDyn", "YCMode")] = {'vals': [5], 'group': 0}

    case_inputs[("AeroDyn15", "WakeMod")] = {'vals': [1], 'group': 0}
    case_inputs[("AeroDyn15", "AFAeroMod")] = {'vals': [2], 'group': 0}
    case_inputs[("AeroDyn15", "TwrPotent")] = {'vals': [0], 'group': 0}
    case_inputs[("AeroDyn15", "TwrShadow")] = {'vals': ['False'], 'group': 0}
    case_inputs[("AeroDyn15", "TwrAero")] = {'vals': ['False'], 'group': 0}

    case_inputs[("AeroDyn15", "SkewMod")] = {'vals': [1], 'group': 0}
    case_inputs[("AeroDyn15", "TipLoss")] = {'vals': ['True'], 'group': 0}
    case_inputs[("AeroDyn15", "HubLoss")] = {'vals': ['True'], 'group': 0}
    case_inputs[("AeroDyn15", "TanInd")] = {'vals': ['True'], 'group': 0}
    case_inputs[("AeroDyn15", "AIDrag")] = {'vals': ['True'], 'group': 0}
    case_inputs[("AeroDyn15", "TIDrag")] = {'vals': ['True'], 'group': 0}
    case_inputs[("AeroDyn15", "IndToler")] = {'vals': [1.e-5], 'group': 0}
    case_inputs[("AeroDyn15", "MaxIter")] = {'vals': [5000], 'group': 0}
    case_inputs[("AeroDyn15", "UseBlCm")] = {'vals': ['True'], 'group': 0}

    case_list, case_name_list = iec.execute(case_inputs=case_inputs)

    channels = [
        "TipDxc1", "TipDyc1", "TipDzc1", "TipDxc2", "TipDyc2", "TipDzc2",
        "TipDxc3", "TipDyc3", "TipDzc3"
    ]
    channels += [
        "RootMxc1", "RootMyc1", "RootMzc1", "RootMxc2", "RootMyc2", "RootMzc2",
        "RootMxc3", "RootMyc3", "RootMzc3"
    ]
    channels += [
        "RootFxc1", "RootFyc1", "RootFzc1", "RootFxc2", "RootFyc2", "RootFzc2",
        "RootFxc3", "RootFyc3", "RootFzc3"
    ]
    channels += ["RtAeroCp", "RotTorq", "RotThrust", "RotSpeed", "NacYaw"]

    channels += [
        "B1N1Fx", "B1N2Fx", "B1N3Fx", "B1N4Fx", "B1N5Fx", "B1N6Fx", "B1N7Fx",
        "B1N8Fx", "B1N9Fx"
    ]
    channels += [
        "B1N1Fy", "B1N2Fy", "B1N3Fy", "B1N4Fy", "B1N5Fy", "B1N6Fy", "B1N7Fy",
        "B1N8Fy", "B1N9Fy"
    ]

    return case_list, case_name_list, channels