Exemplo n.º 1
0
case_inputs[("ServoDyn","PCMode")]      = {'vals':[5], 'group':0}
case_inputs[("ServoDyn","VSContrl")]    = {'vals':[5], 'group':0}
case_inputs[("InflowWind","WindType")]  = {'vals':[1], 'group':0}
case_inputs[("InflowWind","HWindSpeed")]= {'vals': wind_speeds, 'group': 1}
case_inputs[("Fst","OutFileFmt")]       = {'vals':[0], 'group':0}
case_inputs[("ElastoDyn","RotSpeed")]   = {'vals': omega_init, 'group': 1}
case_inputs[("ElastoDyn","BlPitch1")]   = {'vals': pitch_init, 'group': 1}
case_inputs[("ElastoDyn","BlPitch2")]   = case_inputs[("ElastoDyn","BlPitch1")]
case_inputs[("ElastoDyn","BlPitch3")]   = case_inputs[("ElastoDyn","BlPitch1")]

# Find the controller
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}

# Generate the matrix of cases
case_list, case_name_list = CaseGen_General(case_inputs, dir_matrix=fastBatch.FAST_runDirectory, namebase='iea15mw')

fastBatch.case_list = case_list
fastBatch.case_name_list = case_name_list

# Run OpenFAST, either serially or sequentially
if n_cores == 1:
    fastBatch.run_serial()
else:
    fastBatch.run_multi(n_cores)
Exemplo n.º 2
0
            tsdata = tsr()  ## actually runs turbsim
            ptsm.write(tsdata, tsinput, fname=tsoutname)

        # here we provide the means to link turbsim to fast:
        self.tswind_file = tsoutname
        self.tswind_dir = run_dir

if __name__ == "__main__":

    case_inputs = {}
    case_inputs[("TMax")] = {'vals':[10.], 'group':0}
    case_inputs[("Vhub")] = {'vals':[10., 11., 12.], 'group':1}
    case_inputs[("Rho")] = {'vals':[.2, .25, .3], 'group':1}
    case_inputs[("RandSeed1")] = {'vals':[123,234], 'group':2}
    case_list, case_names = CaseGen_General(case_inputs, dir_matrix='', namebase='pyTurbsim_testing')

    filedict = {
        'ts_dir':"/Users/pgraf/work/wese/templates/turbsim/xloads/",
        'ts_file':"TurbSim.inp",
        'run_dir':"test_run_dir"}

    for idx in range(len(case_list)):
        case = case_list[idx]
        case_name = case_names[idx]
        pyturb = pyTurbsim_wrapper(filedict, case, case_name) # initialize runner with case variable inputs
        pyturb.ny = 20 # example of changing an attribute
        pyturb.execute() # run

        case['tswind_file'] = pyturb.tswind_file
        case['tswind_dir'] = pyturb.tswind_dir
Exemplo n.º 3
0
    def runFAST_steady(self):
        """ 
        Run batch of steady state cases for initial conditions, in serial or in parallel
        TODO: determine whether we can skip this step
        """

        self.FAST_runDirectory = self.FAST_steadyDirectory

        case_inputs = {}
        case_inputs[("Fst", "TMax")] = {'vals': [self.TMax], 'group': 0}
        case_inputs[("InflowWind", "WindType")] = {'vals': [1], 'group': 0}
        case_inputs[("Fst", "OutFileFmt")] = {'vals': [2], 'group': 0}

        # Wind Speeds
        case_inputs[("InflowWind", "HWindSpeed")] = {
            'vals': self.WindSpeeds,
            'group': 1
        }

        if platform.system() == 'Windows':
            path2dll = os.path.join(self.weis_dir, 'local/lib/libdiscon.dll')
        elif platform.system() == 'Darwin':
            path2dll = os.path.join(self.weis_dir, 'local/lib/libdiscon.dylib')
        else:
            path2dll = os.path.join(self.weis_dir, 'local/lib/libdiscon.so')

        case_inputs[("ServoDyn", "DLL_FileName")] = {
            'vals': [path2dll],
            '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

        self.channels = channels

        # # Initial Conditions: less important, trying to find them here
        # case_inputs[("ElastoDyn","RotSpeed")] = {'vals':[7.55], 'group':0}
        # case_inputs[("ElastoDyn","BlPitch1")] = {'vals':[3.823], 'group':0}
        # case_inputs[("ElastoDyn","BlPitch2")] = case_inputs[("ElastoDyn","BlPitch1")]
        # case_inputs[("ElastoDyn","BlPitch3")] = case_inputs[("ElastoDyn","BlPitch1")]

        case_list, case_name_list = CaseGen_General(
            case_inputs,
            dir_matrix=self.FAST_steadyDirectory,
            namebase='steady')

        self.case_list = case_list
        self.case_name_list = case_name_list

        outfiles = glob.glob(
            os.path.join(self.FAST_steadyDirectory, 'steady*.outb'))

        if self.overwrite or (len(outfiles) != len(
                self.WindSpeeds)):  # if the steady output files are all there
            if self.parallel:
                self.run_multi(self.cores)
            else:
                self.run_serial()
Exemplo n.º 4
0
    def execute(self, case_inputs={}):

        case_list_all = {}
        dlc_all = []

        for i, dlc in enumerate(self.dlc_inputs['DLC']):
            case_inputs_i = copy.deepcopy(case_inputs)

            # DLC specific variable changes
            if dlc in [1.1, 1.2, 5.1]:
                IEC_WindType = 'NTM'
                alpha = 0.2
                iecwind = pyIECWind_turb()
                TMax = 630.

            elif dlc in [1.3, 6.1, 6.3]:
                if self.Turbine_Class == 'I':
                    x = 1
                elif self.Turbine_Class == 'II':
                    x = 2
                elif self.Turbine_Class == 'III':
                    x = 3
                else:
                    exit(
                        'Class of the WT is needed for the ETM wind, but it is currently not set to neither 1,2 or 3.'
                    )
                IEC_WindType = '%uETM' % x
                alpha = 0.11
                iecwind = pyIECWind_turb()
                TMax = 630.

            elif dlc == 1.4:
                IEC_WindType = 'ECD'
                alpha = 0.2
                iecwind = pyIECWind_extreme()
                TMax = 90.

            elif dlc == 1.5:
                IEC_WindType = 'EWS'
                alpha = 0.2
                iecwind = pyIECWind_extreme()
                TMax = 90.

            # Windfile generation setup
            if self.TMax == 0.:
                iecwind.AnalysisTime = TMax
                iecwind.TF = TMax
            else:
                iecwind.AnalysisTime = self.TMax
                iecwind.TF = self.TMax

            iecwind.TStart = self.TStart
            iecwind.Turbine_Class = self.Turbine_Class
            iecwind.Turbulence_Class = self.Turbulence_Class
            iecwind.IEC_WindType = IEC_WindType
            iecwind.dir_change = self.transient_dir_change
            iecwind.shear_orient = self.transient_shear_orientation
            iecwind.z_hub = self.z_hub
            iecwind.D = self.D
            iecwind.PLExp = alpha

            iecwind.outdir = self.wind_dir
            iecwind.case_name = self.case_name_base
            iecwind.Turbsim_exe = self.Turbsim_exe
            iecwind.debug_level = self.debug_level
            iecwind.overwrite = self.overwrite

            # Set DLC specific settings
            iecwind_ex = pyIECWind_extreme()
            iecwind_ex.Turbine_Class = self.Turbine_Class
            iecwind_ex.Turbulence_Class = self.Turbulence_Class
            iecwind_ex.z_hub = self.z_hub
            iecwind_ex.setup()
            _, V_e50, V_e1, V_50, V_1 = iecwind_ex.EWM(0.)

            if dlc == 5.1:
                case_inputs_i[("ServoDyn", "TPitManS1")] = {
                    'vals': [self.TStart],
                    'group': 0
                }
                case_inputs_i[("ServoDyn", "TPitManS2")] = {
                    'vals': [self.TStart],
                    'group': 0
                }
                case_inputs_i[("ServoDyn", "TPitManS3")] = {
                    'vals': [self.TStart],
                    'group': 0
                }
                case_inputs_i[("ServoDyn", "PitManRat1")] = {
                    'vals': [self.PC_MaxRat],
                    'group': 0
                }
                case_inputs_i[("ServoDyn", "PitManRat2")] = {
                    'vals': [self.PC_MaxRat],
                    'group': 0
                }
                case_inputs_i[("ServoDyn", "PitManRat3")] = {
                    'vals': [self.PC_MaxRat],
                    'group': 0
                }
                case_inputs_i[("ServoDyn", "BlPitchF1")] = {
                    'vals': [90.],
                    'group': 0
                }
                case_inputs_i[("ServoDyn", "BlPitchF2")] = {
                    'vals': [90.],
                    'group': 0
                }
                case_inputs_i[("ServoDyn", "BlPitchF3")] = {
                    'vals': [90.],
                    'group': 0
                }
                case_inputs_i[("ServoDyn", "GenTiStp")] = {
                    'vals': ["True"],
                    'group': 0
                }
                case_inputs_i[("ServoDyn", "TimGenOf")] = {
                    'vals': [self.TStart],
                    'group': 0
                }
            else:
                case_inputs_i[("ServoDyn", "TPitManS1")] = {
                    'vals': [9999.9],
                    'group': 0
                }
                case_inputs_i[("ServoDyn", "TPitManS2")] = {
                    'vals': [9999.9],
                    'group': 0
                }
                case_inputs_i[("ServoDyn", "TPitManS3")] = {
                    'vals': [9999.9],
                    'group': 0
                }
                case_inputs_i[("ServoDyn", "PitManRat1")] = {
                    'vals': [2.],
                    'group': 0
                }
                case_inputs_i[("ServoDyn", "PitManRat2")] = {
                    'vals': [2.],
                    'group': 0
                }
                case_inputs_i[("ServoDyn", "PitManRat3")] = {
                    'vals': [2.],
                    'group': 0
                }
                case_inputs_i[("ServoDyn", "BlPitchF1")] = {
                    'vals': [0.],
                    'group': 0
                }
                case_inputs_i[("ServoDyn", "BlPitchF2")] = {
                    'vals': [0.],
                    'group': 0
                }
                case_inputs_i[("ServoDyn", "BlPitchF3")] = {
                    'vals': [0.],
                    'group': 0
                }
                case_inputs_i[("ServoDyn", "GenTiStp")] = {
                    'vals': ["False"],
                    'group': 0
                }
                case_inputs_i[("ServoDyn", "TimGenOf")] = {
                    'vals': [9999.9],
                    'group': 0
                }

            if dlc == 6.1:
                self.dlc_inputs['U'][i] = [V_50]
                self.dlc_inputs['Yaw'][i] = [-8., 8.]
                case_inputs_i[("ElastoDyn", "GenDOF")] = {
                    'vals': ["False"],
                    'group': 0
                }
                case_inputs_i[("ElastoDyn", "YawDOF")] = {
                    'vals': ["False"],
                    'group': 0
                }
                case_inputs_i[("ElastoDyn", "RotSpeed")] = {
                    'vals': [0.],
                    'group': 0
                }
                case_inputs_i[("ElastoDyn", "BlPitch1")] = {
                    'vals': [90.],
                    'group': 0
                }
                case_inputs_i[("ElastoDyn", "BlPitch2")] = {
                    'vals': [90.],
                    'group': 0
                }
                case_inputs_i[("ElastoDyn", "BlPitch3")] = {
                    'vals': [90.],
                    'group': 0
                }
                case_inputs_i[("ServoDyn", "PCMode")] = {
                    'vals': [0],
                    'group': 0
                }
                case_inputs_i[("AeroDyn15", "AFAeroMod")] = {
                    'vals': [1],
                    'group': 0
                }
            elif dlc == 6.3:
                self.dlc_inputs['U'][i] = [V_1]
                self.dlc_inputs['Yaw'][i] = [-20., 20.]
                case_inputs_i[("ElastoDyn", "GenDOF")] = {
                    'vals': ["False"],
                    'group': 0
                }
                case_inputs_i[("ElastoDyn", "YawDOF")] = {
                    'vals': ["False"],
                    'group': 0
                }
                case_inputs_i[("ElastoDyn", "RotSpeed")] = {
                    'vals': [0.],
                    'group': 0
                }
                case_inputs_i[("ElastoDyn", "BlPitch1")] = {
                    'vals': [90.],
                    'group': 0
                }
                case_inputs_i[("ElastoDyn", "BlPitch2")] = {
                    'vals': [90.],
                    'group': 0
                }
                case_inputs_i[("ElastoDyn", "BlPitch3")] = {
                    'vals': [90.],
                    'group': 0
                }
                case_inputs_i[("ServoDyn", "PCMode")] = {
                    'vals': [0],
                    'group': 0
                }
                case_inputs_i[("AeroDyn15", "AFAeroMod")] = {
                    'vals': [1],
                    'group': 0
                }
            else:
                self.dlc_inputs['Yaw'][i] = [0.]
                case_inputs_i[("ServoDyn", "PCMode")] = {
                    'vals': [5],
                    'group': 0
                }
                case_inputs_i[("AeroDyn15", "AFAeroMod")] = {
                    'vals': [2],
                    'group': 0
                }
                case_inputs_i[("ElastoDyn", "GenDOF")] = {
                    'vals': ["True"],
                    'group': 0
                }
                case_inputs_i[("ElastoDyn", "YawDOF")] = {
                    'vals': ["True"],
                    'group': 0
                }

            # Matrix combining N dlc variables that affect wind file generation
            # Done so a single loop can be used for generating wind files in parallel instead of using nested loops
            var_list = ['U', 'Seeds']
            group_len = []
            change_vars = []
            change_vals = []
            for var in var_list:
                if len(self.dlc_inputs[var][i]) > 0:
                    group_len.append(len(self.dlc_inputs[var][i]))
                    change_vars.append(var)
                    change_vals.append(self.dlc_inputs[var][i])
            group_idx = [range(n) for n in group_len]
            matrix_idx = list(itertools.product(*group_idx))
            matrix_group_idx = [
                np.where([
                    group_i == group_j for group_j in range(0, len(group_len))
                ])[0].tolist() for group_i in range(0, len(group_len))
            ]
            matrix_out = []
            for idx, row in enumerate(matrix_idx):
                row_out = [None] * len(change_vars)
                for j, val in enumerate(row):
                    for g in matrix_group_idx[j]:
                        row_out[g] = change_vals[g][val]
                matrix_out.append(row_out)
            matrix_out = np.asarray(matrix_out)

            # change seed manually to not mess up indexing above, 600
            if self.uniqueSeeds and dlc in [1.1, 1.2, 5.1, 1.3, 6.1, 6.3]:
                for idx, row in enumerate(matrix_out):
                    matrix_out[idx][1] = idx + 600

            if self.parallel_windfile_gen and not self.mpi_run:
                # Parallel wind file generation (threaded with multiprocessing)
                if self.cores != 0:
                    p = mp.Pool(self.cores)
                else:
                    p = mp.Pool()
                data_out = p.map(
                    gen_windfile,
                    [(iecwind, IEC_WindType, change_vars, var_vals)
                     for var_vals in matrix_out])
                U_out = []
                WindFile_out = []
                WindFile_type_out = []
                for case in data_out:
                    U_out.extend(case[0])
                    WindFile_out.extend(case[1])
                    WindFile_type_out.extend(case[2])

            elif self.parallel_windfile_gen and self.mpi_run:
                # Parallel wind file generation with MPI
                comm = MPI.COMM_WORLD
                # size = comm.Get_size()
                rank = comm.Get_rank()
                sub_ranks = self.comm_map_down[rank]
                size = len(sub_ranks)

                N_cases = len(matrix_out)
                N_loops = int(np.ceil(float(N_cases) / float(size)))

                U_out = []
                WindFile_out = []
                WindFile_type_out = []
                for j in range(N_loops):
                    idx_s = j * size
                    idx_e = min((j + 1) * size, N_cases)

                    for k, var_vals in enumerate(matrix_out[idx_s:idx_e]):
                        data = [
                            gen_windfile,
                            [iecwind, IEC_WindType, change_vars, var_vals]
                        ]
                        rank_k = sub_ranks[k]
                        comm.send(data, dest=rank_k, tag=0)

                    for k, var_vals in enumerate(matrix_out[idx_s:idx_e]):
                        rank_k = sub_ranks[k]
                        data_out = comm.recv(source=rank_k, tag=1)
                        U_out.extend(data_out[0])
                        WindFile_out.extend(data_out[1])
                        WindFile_type_out.extend(data_out[2])

            else:
                # Serial
                U_out = []
                WindFile_out = []
                WindFile_type_out = []
                for var_vals in matrix_out:
                    [U_out_i, WindFile_out_i,
                     WindFile_type_out_i] = gen_windfile(
                         [iecwind, IEC_WindType, change_vars, var_vals])
                    U_out.extend(U_out_i)
                    WindFile_out.extend(WindFile_out_i)
                    WindFile_type_out.extend(WindFile_type_out_i)

            # Set FAST variables from DLC setup
            if ("Fst", "TMax") not in case_inputs_i:
                case_inputs_i[("Fst", "TMax")] = {'vals': [TMax], 'group': 0}
            case_inputs_i[("InflowWind", "WindType")] = {
                'vals': WindFile_type_out,
                'group': 1
            }
            case_inputs_i[("InflowWind", "Filename")] = {
                'vals': WindFile_out,
                'group': 1
            }

            if len(self.dlc_inputs['Yaw'][i]) > 0:
                case_inputs_i[("ElastoDyn", "NacYaw")] = {
                    'vals': self.dlc_inputs['Yaw'][i],
                    'group': 2
                }

            # Set FAST variables from inital conditions
            if self.init_cond:
                for var in self.init_cond.keys():
                    if var not in case_inputs_i.keys():
                        inital_cond_i = [
                            np.interp(U, self.init_cond[var]['U'],
                                      self.init_cond[var]['val'])
                            for U in U_out
                        ]
                        case_inputs_i[var] = {
                            'vals': inital_cond_i,
                            'group': 1
                        }

            # make unique wave seeds
            if self.uniqueWaveSeeds:
                seed_base = int(
                    float(dlc) *
                    10000)  # set wave seed based on dlc so no repeats
                num_in_dlc = len(
                    case_inputs_i[("InflowWind",
                                   "Filename")]['vals'])  # sims in each DLC
                wave_seeds = (seed_base + np.arange(0, num_in_dlc)).tolist()

                case_inputs_i[("HydroDyn", "WaveSeed1")] = {
                    'vals': wave_seeds,
                    'group': 1
                }

            # Append current DLC to full list of cases
            case_list, case_name = CaseGen_General(case_inputs_i,
                                                   self.run_dir,
                                                   self.case_name_base,
                                                   save_matrix=False)
            case_list_all = self.join_case_dicts(case_list_all, case_list)
            case_names_all = [
                self.case_name_base + '_' +
                ('%d' % i).zfill(len('%d' % (len(case_list_all) - 1)))
                for i in range(len(case_list_all))
            ]
            dlc_all.extend([dlc] * len(case_list))

        # Save case matrix file
        self.save_joined_case_matrix(case_list_all, dlc_all, case_names_all)

        return case_list_all, case_names_all, dlc_all
Exemplo n.º 5
0
    def test_run(self):
        # Paths calling the standard modules of WEIS
        fastBatch = runFAST_pywrapper_batch(FAST_ver='OpenFAST',
                                            dev_branch=True)
        run_dir1 = (os.path.dirname(
            os.path.dirname(
                os.path.dirname(os.path.dirname(os.path.realpath(__file__)))))
                    + os.sep)
        fastBatch.FAST_exe = os.path.join(run_dir1, 'local', 'bin',
                                          'openfast')  # Path to executable
        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.FAST_InputFile = 'IEA-15-240-RWT-Monopile.fst'  # FAST input file (ext=.fst)
        fastBatch.FAST_runDirectory = 'steady_state/iea15mw'
        fastBatch.debug_level = 2

        # User settings
        n_cores = 1  # Number of available cores
        TMax = 1.  # Length of wind grids and OpenFAST simulations, suggested 720 s
        cut_in = 3.  # Cut in wind speed
        cut_out = 25.  # Cut out wind speed
        n_ws = 2  # Number of wind speed bins
        wind_speeds = np.linspace(cut_in, cut_out,
                                  int(n_ws))  # Wind speeds to run OpenFAST at
        Ttrans = max([
            0., TMax - 60.
        ])  # Start of the transient for DLC with a transient, e.g. DLC 1.4
        TStart = max([0., TMax - 300.
                      ])  # Start of the recording of the channels of OpenFAST

        # Initial conditions for ElastoDyn
        # 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
        pitch_init = np.interp(wind_speeds, u_ref, pitch_ref)
        omega_init = np.interp(wind_speeds, u_ref, omega_ref)

        # Settings passed to OpenFAST
        case_inputs = {}
        case_inputs[("Fst", "TMax")] = {'vals': [TMax], 'group': 0}
        case_inputs[("Fst", "DT")] = {'vals': [0.01], 'group': 0}
        case_inputs[("Fst", "CompInflow")] = {'vals': [1], 'group': 0}
        case_inputs[("Fst", "CompServo")] = {'vals': [1], 'group': 0}
        case_inputs[("Fst", "OutFileFmt")] = {'vals': [1], 'group': 0}
        case_inputs[("Fst", "DT_Out")] = {'vals': [0.02], 'group': 0}
        case_inputs[("ElastoDyn", "GenDOF")] = {'vals': ['True'], 'group': 0}
        case_inputs[("ServoDyn", "PCMode")] = {'vals': [5], 'group': 0}
        case_inputs[("ServoDyn", "VSContrl")] = {'vals': [5], 'group': 0}
        case_inputs[("InflowWind", "WindType")] = {'vals': [1], 'group': 0}
        case_inputs[("InflowWind", "HWindSpeed")] = {
            'vals': wind_speeds,
            'group': 1
        }
        case_inputs[("Fst", "OutFileFmt")] = {'vals': [0], 'group': 0}
        case_inputs[("ElastoDyn", "RotSpeed")] = {
            'vals': omega_init,
            'group': 1
        }
        case_inputs[("ElastoDyn", "BlPitch1")] = {
            'vals': pitch_init,
            'group': 1
        }
        case_inputs[("ElastoDyn", "BlPitch2")] = case_inputs[("ElastoDyn",
                                                              "BlPitch1")]
        case_inputs[("ElastoDyn", "BlPitch3")] = case_inputs[("ElastoDyn",
                                                              "BlPitch1")]

        # Find the controller
        if platform.system() == 'Windows':
            sfx = 'dll'
        elif platform.system() == 'Darwin':
            sfx = 'dylib'
        else:
            sfx = 'so'
        path2dll = os.path.join(run_dir1, 'local', 'lib', 'libdiscon.' + sfx)

        case_inputs[("ServoDyn", "DLL_FileName")] = {
            'vals': [path2dll],
            'group': 0
        }

        # Generate the matrix of cases
        case_list, case_name_list = CaseGen_General(
            case_inputs,
            dir_matrix=fastBatch.FAST_runDirectory,
            namebase='iea15mw')

        fastBatch.case_list = case_list
        fastBatch.case_name_list = case_name_list

        # Run OpenFAST, either serially or sequentially
        out = fastBatch.run_serial()

        this_file_dir = os.path.dirname(os.path.realpath(__file__))
        compare_regression_values(out,
                                  'general_regression_values.pkl',
                                  directory=this_file_dir,
                                  tol=1e-3,
                                  train=False)
Exemplo n.º 6
0
    def runFAST_linear(self):
        """ 
        Example of running a batch of cases, in serial or in parallel
        """

        ss_opFile = os.path.join(self.FAST_steadyDirectory, 'ss_ops.yaml')
        self.FAST_runDirectory = self.FAST_linearDirectory

        ## Generate case list using General Case Generator
        ## Specify several variables that change independently or collectly
        case_inputs = {}
        case_inputs[("Fst", "TMax")] = {'vals': [self.TMax], 'group': 0}
        case_inputs[("Fst", "Linearize")] = {'vals': ['True'], 'group': 0}
        case_inputs[("Fst", "CalcSteady")] = {'vals': ['True'], 'group': 0}
        case_inputs[("Fst", "TrimGain")] = {'vals': [4e-5], 'group': 0}

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

        if not self.HydroStates:
            case_inputs[("Fst", "CompHydro")] = {'vals': [0], 'group': 0}

        # InflowWind
        case_inputs[("InflowWind", "WindType")] = {'vals': [1], 'group': 0}
        if not isinstance(self.WindSpeeds, list):
            self.WindSpeeds = [self.WindSpeeds]
        case_inputs[("InflowWind", "HWindSpeed")] = {
            'vals': self.WindSpeeds,
            'group': 1
        }

        # AeroDyn Inputs
        case_inputs[("AeroDyn15", "AFAeroMod")] = {'vals': [1], 'group': 0}

        # Servodyn Inputs
        case_inputs[("ServoDyn", "PCMode")] = {'vals': [0], 'group': 0}
        case_inputs[("ServoDyn", "VSContrl")] = {'vals': [1], 'group': 0}

        # Torque Control: these are turbine specific, update later
        case_inputs[("ServoDyn", "VS_RtGnSp")] = {'vals': [7.56], 'group': 0}
        case_inputs[("ServoDyn", "VS_RtTq")] = {'vals': [19.62e6], 'group': 0}
        case_inputs[("ServoDyn", "VS_Rgn2K")] = {'vals': [3.7e5], 'group': 0}
        case_inputs[("ServoDyn", "VS_SlPc")] = {'vals': [10.], 'group': 0}

        # Hydrodyn Inputs, these need to be state-space (2), but they should work if 0
        case_inputs[("HydroDyn", "ExctnMod")] = {'vals': [2], 'group': 0}
        case_inputs[("HydroDyn", "RdtnMod")] = {'vals': [2], 'group': 0}
        case_inputs[("HydroDyn", "DiffQTF")] = {'vals': [0], 'group': 0}
        case_inputs[("HydroDyn", "WvDiffQTF")] = {
            'vals': ['False'],
            'group': 0
        }

        # Degrees-of-freedom: set all to False & enable those defined in self
        case_inputs[("ElastoDyn", "FlapDOF1")] = {
            'vals': ['False'],
            'group': 0
        }
        case_inputs[("ElastoDyn", "FlapDOF2")] = {
            'vals': ['False'],
            'group': 0
        }
        case_inputs[("ElastoDyn", "EdgeDOF")] = {'vals': ['False'], 'group': 0}
        case_inputs[("ElastoDyn", "TeetDOF")] = {'vals': ['False'], 'group': 0}
        case_inputs[("ElastoDyn", "DrTrDOF")] = {'vals': ['False'], 'group': 0}
        case_inputs[("ElastoDyn", "GenDOF")] = {'vals': ['False'], 'group': 0}
        case_inputs[("ElastoDyn", "YawDOF")] = {'vals': ['False'], '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[("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
        }

        for dof in self.DOFs:
            case_inputs[("ElastoDyn", dof)] = {'vals': ['True'], 'group': 0}

        # Initial Conditions
        ss_ops = load_yaml(ss_opFile)
        uu = ss_ops['Wind1VelX']

        for ic in ss_ops:
            if ic != 'Wind1VelX':
                case_inputs[("ElastoDyn", ic)] = {
                    'vals':
                    np.interp(
                        case_inputs[("InflowWind", "HWindSpeed")]['vals'], uu,
                        ss_ops[ic]).tolist(),
                    'group':
                    1
                }

        case_inputs[('ElastoDyn', 'BlPitch2')] = case_inputs[('ElastoDyn',
                                                              'BlPitch1')]
        case_inputs[('ElastoDyn', 'BlPitch3')] = case_inputs[('ElastoDyn',
                                                              'BlPitch1')]

        # Gen Speed to track
        # set for now and update with GB ratio next
        RefGenSpeed = 0.95 * np.array(
            case_inputs[('ElastoDyn', 'RotSpeed')]['vals']) * self.GBRatio
        case_inputs[('ServoDyn', 'VS_RtGnSp')] = {
            'vals': RefGenSpeed.tolist(),
            'group': 1
        }

        channels = {}
        for var in ["BldPitch1","BldPitch2","BldPitch3","IPDefl1","IPDefl2","IPDefl3","OoPDefl1","OoPDefl2","OoPDefl3", \
            "NcIMURAxs","TipDxc1", "TipDyc1", "Spn2MLxb1", "Spn2MLxb2","Spn2MLxb3","Spn2MLyb1", "Spn2MLyb2","Spn2MLyb3" \
                "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", \
                              "TTDspSS", "TTDspFA", "NacYaw", "Wind1VelX", "Wind1VelY", "Wind1VelZ", "LSSTipMxa","LSSTipMya","LSSTipMza", \
                                  "LSSTipMxs","LSSTipMys","LSSTipMzs","LSShftFys","LSShftFzs", "TipRDxr", "TipRDyr", "TipRDzr" \
                                      "TwstDefl1","TwstDefl2","TwstDefl3"]:
            channels[var] = True

        self.channels = channels

        # Lin Times
        # rotPer = 60. / np.array(case_inputs['ElastoDyn','RotSpeed']['vals'])
        # linTimes = np.linspace(self.TMax-100,self.TMax-100 + rotPer,num = self.NLinTimes, endpoint=False)
        # linTimeStrings = []

        # if linTimes.ndim == 1:
        #     linTimeStrings = np.array_str(linTimes,max_line_width=9000,precision=3)[1:-1]
        # else:
        #     for iCase in range(0,linTimes.shape[1]):
        #         linTimeStrings.append(np.array_str(linTimes[:,iCase],max_line_width=9000,precision=3)[1:-1])

        case_inputs[("Fst", "NLinTimes")] = {
            'vals': [self.NLinTimes],
            'group': 0
        }

        # Trim case depends on rated wind speed (torque below-rated, pitch above)
        TrimCase = 3 * np.ones(len(self.WindSpeeds), dtype=int)
        TrimCase[np.array(self.WindSpeeds) < self.v_rated] = 2

        case_inputs[("Fst", "TrimCase")] = {
            'vals': TrimCase.tolist(),
            'group': 1
        }

        case_inputs[("Fst", "TrimTol")] = {'vals': [1e-5], 'group': 0}

        # Generate Cases
        case_list, case_name_list = CaseGen_General(
            case_inputs, dir_matrix=self.FAST_linearDirectory, namebase='lin')

        self.case_list = case_list
        self.case_name_list = case_name_list

        outfiles = glob.glob(
            os.path.join(self.FAST_linearDirectory, 'lin*.outb'))

        if self.overwrite or (len(outfiles) != len(
                self.WindSpeeds)):  # if the steady output files are all there
            if self.parallel:
                self.run_multi(self.cores)
            else:
                self.run_serial()
Exemplo n.º 7
0
def example_runTSFAST_Batch():
    fastBatch = runFAST_pywrapper_batch(FAST_ver='OpenFAST')


    mac = False
    if mac:
        fastBatch.FAST_InputFile = '5MW_Land_DLL_WTurb-fast.fst'   # FAST input file (ext=.fst)
        fastBatch.FAST_exe = '/Users/pgraf/opt/openfast/openfast/install/bin/openfast'   # Path to executable
        fastBatch.FAST_directory = '/Users/pgraf/work/wese/templates/openfast/5MW_Land_DLL_WTurb-ModifiedForPyturbsim'
    else:
        fastBatch.FAST_InputFile = '5MW_Land_DLL_WTurb-fast.fst'   # FAST input file (ext=.fst)
        fastBatch.FAST_exe = '/home/pgraf/opt/openfast/openfast/install/bin/openfast'   # Path to executable
        fastBatch.FAST_directory = '/home/pgraf/projects/wese/newaero/templates/openfast/5MW_Land_DLL_WTurb-ModifiedForPyturbsim'

    fastBatch.FAST_runDirectory = 'temp/OpenFAST'
    fastBatch.debug_level = 2

    ## Define case list explicitly
    # case_list = [{}, {}]
    # case_list[0]['Fst', 'TMax'] = 4.
    # case_list[1]['Fst', 'TMax'] = 5.
    # case_name_list = ['test01', 'test02']


    tmaxs = [60.0]
    vhubs = [12.0]
    rhos = [0.0]
    seeds = [1,2]

    case_inputs = {}
    case_inputs[("WrFMTFF")] = {'vals':[False], 'group':0}
    case_inputs[("WrBLFF")] = {'vals':[True], 'group':0}
    case_inputs[("WrADFF")] = {'vals':[True], 'group':0}
    case_inputs[("WrADTWR")] = {'vals':[False], 'group':0}   #WrADTWR
    case_inputs[("TMax")] = {'vals':[t + 30 for t in tmaxs], 'group':0}
    #case_inputs[("TMax")] = {'vals':[t for t in tmaxs], 'group':0}
    case_inputs[("Vhub")] = {'vals':vhubs, 'group':1}
    case_inputs[("Rho")] = {'vals':rhos, 'group':1}
    case_inputs[("RandSeed1")] = {'vals':seeds, 'group':2}
    case_inputs[("RandSeed")] = {'vals':seeds, 'group':2}
    ts_case_list, ts_case_name_list = CaseGen_General(case_inputs, dir_matrix='', namebase='pyTurbsim_testing')

    if mac:
        ts_filedict = {
            'ts_dir':"/Users/pgraf/work/wese/templates/turbsim/pyturbsim/",
            'ts_file':"evans_faster.inp",
            'run_dir':"test_ts_run_dir"}
    else:
        ts_filedict = {
            'ts_dir':"/home/pgraf/projects/wese/newaero/templates/turbsim/pyturbsim/",
            'ts_file':"evans_faster.inp",
            'run_dir':"test_ts_run_dir"}
        

    tsBatch = runTS_pywrapper_batch(ts_filedict, ts_case_list, ts_case_name_list)
    #tsBatch.run_serial()
    tsBatch.run_multi(4)
    ### At this point turbsim is done running and the .bts file names have been added to each case in tsBatch.case_list

    ## Generate case list using General Case Generator
    ## Specify several variables that change independently or collectly
    case_inputs = {}
    case_inputs[("Fst","TMax")] = {'vals':tmaxs, 'group':0}
#    case_inputs[("AeroDyn15","TwrPotent")] = {'vals':[0], 'group':0}
#    case_inputs[("AeroDyn15","TwrShadow")] = {'vals':['False'], 'group':0}
#    case_inputs[("AeroDyn15","TwrAero")] = {'vals':['True'], 'group':0}
    case_inputs[("InflowWind","WindType")] = {'vals':[3], 'group':0}   # 1 = steady, 3 = turbsim binary
    case_inputs[("Fst","OutFileFmt")] = {'vals':[1], 'group':0}
    case_inputs[("InflowWind","HWindSpeed")] = {'vals':vhubs, 'group':1}
    case_inputs[("InflowWind","Rho")] = {'vals':rhos, 'group':1}
    case_inputs[("InflowWind","RandSeed1")] = {'vals':seeds, 'group':2}

    # case_inputs[("ElastoDyn","RotSpeed")] = {'vals':[9.156, 10.296, 11.431, 11.89, 12.1], 'group':1}
    # case_inputs[("ElastoDyn","BlPitch1")] = {'vals':[0., 0., 0., 0., 3.823], 'group':1}
    # case_inputs[("ElastoDyn","BlPitch2")] = case_inputs[("ElastoDyn","BlPitch1")]
    # case_inputs[("ElastoDyn","BlPitch3")] = case_inputs[("ElastoDyn","BlPitch1")]
    # case_inputs[("ElastoDyn","GenDOF")] = {'vals':['True','False'], 'group':2}
    case_list, case_name_list = CaseGen_General(case_inputs, dir_matrix=fastBatch.FAST_runDirectory, namebase='testing')
    # manually adding the wind file names from turb sim run.  This seems a little sketchy
    ### Note to Evan: I feel I should be able to use ONE call to CaseGen_General, instead of one for turbsim, and one for FAStTunr1
    ## thoughts?  solution?
    #####
    print("ADDING WIND FILE NAMES")
    for i in range(len(case_list)):
        case_list[i][("InflowWind","Filename")] = tsBatch.case_list[i]['tswind_file']
        case_list[i][("InflowWind","FilenameRoot")] = tsBatch.case_list[i]['tswind_file'].replace(".wnd", "")
#        case_list[i][("InflowWind","InflowFile")] = tsBatch.case_name_list[i]
        # print(case_list[i])

    fastBatch.case_list = case_list
    fastBatch.case_name_list = case_name_list

    #fastBatch.run_serial()
    fastBatch.run_multi(4)
    ## at this point FAST has run, and the output file names have been added to the case list.
    print("ADDED FAST OUTPUT FILE NAMES")
    for i in range(len(fastBatch.case_list)):
        print(fastBatch.case_list[i])
    save_case_matrix_direct(fastBatch.case_list, dir_matrix=os.path.join(os.getcwd(),fastBatch.FAST_runDirectory))
Exemplo n.º 8
0
def RotorSE_steady_wind(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 = 30.  # 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[("InflowWind", "WindType")] = {'vals': [1], 'group': 0}
    case_inputs[("InflowWind", "HWindSpeed")] = {'vals': [Vrated], 'group': 0}

    case_inputs[("ElastoDyn", "YawDOF")] = {'vals': ['False'], 'group': 0}
    case_inputs[("ElastoDyn", "FlapDOF1")] = {'vals': ['False'], 'group': 0}
    case_inputs[("ElastoDyn", "FlapDOF2")] = {'vals': ['False'], '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': ['False'], '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': [0], 'group': 0}
    case_inputs[("ServoDyn", "VSContrl")] = {'vals': [0], '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)
    case_list, case_name_list = CaseGen_General(case_inputs,
                                                dir_matrix=runDir,
                                                namebase=namebase)

    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
Exemplo n.º 9
0
def RotorSE_DLC_7_1_Steady(fst_vt,
                           runDir,
                           namebase,
                           TMax,
                           turbine_class,
                           turbulence_class,
                           U,
                           U_init=[],
                           Omega_init=[],
                           pitch_init=[],
                           Turbsim_exe=''):
    # Extreme 1yr return period wind speed with a power fault resulting in the blade not feathering

    # Default Runtime
    T = 60.
    TStart = 30.

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

    Pitch = 0.
    Omega = 0.

    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[("InflowWind", "WindType")] = {'vals': [1], 'group': 0}
    case_inputs[("InflowWind", "HWindSpeed")] = {'vals': [U], 'group': 0}
    case_inputs[("InflowWind", "PLexp")] = {'vals': [0.11], 'group': 0}

    case_inputs[("ElastoDyn", "RotSpeed")] = {'vals': [Omega], 'group': 0}
    case_inputs[("ElastoDyn", "BlPitch1")] = {'vals': [Pitch], 'group': 0}
    case_inputs[("ElastoDyn", "BlPitch2")] = {'vals': [Pitch], 'group': 0}
    case_inputs[("ElastoDyn", "BlPitch3")] = {'vals': [Pitch], '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': ['False'], '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': [0], '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': [1], '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}

    namebase += '_idle50yr'
    case_list, case_name_list = CaseGen_General(case_inputs,
                                                namebase=namebase,
                                                save_matrix=False)

    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
Exemplo n.º 10
0
def RotorSE_rated(fst_vt,
                  runDir,
                  namebase,
                  TMax,
                  turbine_class,
                  turbulence_class,
                  Vrated,
                  U_init=[],
                  Omega_init=[],
                  pitch_init=[],
                  Turbsim_exe='',
                  ptfm_U_init=[],
                  ptfm_pitch_init=[],
                  ptfm_surge_init=[],
                  ptfm_heave_init=[],
                  metocean_U_init=[],
                  metocean_Hs_init=[],
                  metocean_Tp_init=[]):

    # Default Runtime
    T = 240.
    TStart = 120.

    # dt = 0.001
    dt = 0.01

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

    omega = np.interp(Vrated, U_init, Omega_init)
    pitch = np.interp(Vrated, U_init, pitch_init)

    # Check if floating
    floating_dof = [
        fst_vt['ElastoDyn']['PtfmSgDOF'], fst_vt['ElastoDyn']['PtfmSwDOF'],
        fst_vt['ElastoDyn']['PtfmHvDOF'], fst_vt['ElastoDyn']['PtfmRDOF'],
        fst_vt['ElastoDyn']['PtfmPDOF'], fst_vt['ElastoDyn']['PtfmYDOF']
    ]
    if any(floating_dof):
        floating = True
        if ptfm_U_init == []:
            ptfm_U_init = [
                4., 5., 6., 7., 8., 9., 10., 10.5, 11., 12., 14., 19., 24.
            ]
            ptfm_surge_init = [
                3.8758245863838807, 5.57895688031965, 7.619719770801395,
                9.974666446553552, 12.675469235464321, 16.173740623041965,
                20.069526574594757, 22.141906121375552, 23.835466098954708,
                22.976075549477354, 17.742743260748373, 14.464576583154068,
                14.430969814391759
            ]
            ptfm_heave_init = [
                0.030777174904620515, 0.008329930604820483,
                -0.022973502300090893, -0.06506947653943342,
                -0.12101317451310406, -0.20589689839069836,
                -0.3169518280533253, -0.3831692055885472, -0.4409624802614755,
                -0.41411738171337675, -0.2375323506471747, -0.1156867221814119,
                -0.07029955933167854
            ]
            ptfm_pitch_init = [
                0.7519976895165884, 1.104483050851386, 1.5180416334025146,
                1.9864587671004394, 2.5152769741130134, 3.1937704945765795,
                3.951314212429935, 4.357929703098016, 4.693765745171944,
                4.568760630312074, 3.495057478277534, 2.779958240049992,
                2.69008798174216
            ]
        if metocean_U_init == []:
            metocean_U_init = [
                4.00, 6.00, 8.00, 10.00, 12.00, 14.00, 16.00, 18.00, 20.00,
                22.00, 24.00
            ]
            metocean_Hs_init = [
                1.908567568, 1.960162595, 2.062722244, 2.224539415,
                2.489931091, 2.802984019, 3.182301485, 3.652236101,
                4.182596165, 4.695439504, 5.422289377
            ]
            metocean_Tp_init = [
                12.23645701, 12.14497777, 11.90254947, 11.5196666, 11.05403739,
                10.65483551, 10.27562225, 10.13693777, 10.27842325,
                10.11660396, 10.96177917
            ]

        ptfm_heave = [np.interp(Vrated, ptfm_U_init, ptfm_heave_init)]
        ptfm_surge = [np.interp(Vrated, ptfm_U_init, ptfm_surge_init)]
        ptfm_pitch = [np.interp(Vrated, ptfm_U_init, ptfm_pitch_init)]
        metocean_Hs = [np.interp(Vrated, metocean_U_init, metocean_Hs_init)]
        metocean_Tp = [np.interp(Vrated, metocean_U_init, metocean_Tp_init)]
    else:
        floating = False

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

    case_inputs[("InflowWind", "WindType")] = {'vals': [1], 'group': 0}
    case_inputs[("InflowWind", "HWindSpeed")] = {'vals': [Vrated], 'group': 0}

    case_inputs[("ElastoDyn", "RotSpeed")] = {'vals': [omega], 'group': 0}
    case_inputs[("ElastoDyn", "BlPitch1")] = {'vals': [pitch], 'group': 0}
    case_inputs[("ElastoDyn", "BlPitch2")] = {'vals': [pitch], 'group': 0}
    case_inputs[("ElastoDyn", "BlPitch3")] = {'vals': [pitch], 'group': 0}
    case_inputs[("ElastoDyn", "YawDOF")] = {'vals': ['False'], 'group': 0}
    case_inputs[("ElastoDyn", "FlapDOF1")] = {'vals': ['False'], 'group': 0}
    case_inputs[("ElastoDyn", "FlapDOF2")] = {'vals': ['False'], 'group': 0}
    case_inputs[("ElastoDyn", "EdgeDOF")] = {'vals': ['False'], '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[("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}

    if floating == True:
        case_inputs[("ElastoDyn", "PtfmSurge")] = {
            'vals': ptfm_surge,
            'group': 1
        }
        case_inputs[("ElastoDyn", "PtfmHeave")] = {
            'vals': ptfm_heave,
            'group': 1
        }
        case_inputs[("ElastoDyn", "PtfmPitch")] = {
            'vals': ptfm_pitch,
            'group': 1
        }
        case_inputs[("HydroDyn", "WaveHs")] = {'vals': metocean_Hs, 'group': 1}
        case_inputs[("HydroDyn", "WaveTp")] = {'vals': metocean_Tp, 'group': 1}
        case_inputs[("HydroDyn", "RdtnDT")] = {'vals': [dt], 'group': 0}
        case_inputs[("HydroDyn", "WaveMod")] = {'vals': [1], 'group': 0}

    namebase += '_rated'
    case_list, case_name_list = CaseGen_General(case_inputs,
                                                dir_matrix=runDir,
                                                namebase=namebase)

    channels = ["TipDxc1", "TipDyc1"]
    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"]

    return case_list, case_name_list, channels
Exemplo n.º 11
0
def power_curve(fst_vt,
                runDir,
                namebase,
                TMax,
                turbine_class,
                turbulence_class,
                Vrated,
                U_init=[],
                Omega_init=[],
                pitch_init=[],
                Turbsim_exe='',
                ptfm_U_init=[],
                ptfm_pitch_init=[],
                ptfm_surge_init=[],
                ptfm_heave_init=[],
                metocean_U_init=[],
                metocean_Hs_init=[],
                metocean_Tp_init=[],
                V_R25=0.):

    # Default Runtime
    T = 360.
    TStart = 120.
    # T      = 120.
    # TStart = 60.

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

    # Run conditions
    U_all = list(
        sorted([
            4., 6., 8., 9., 10., 10.5, 11., 11.5, 11.75, 12., 12.5, 13., 14.,
            19., 25., Vrated
        ]))
    if V_R25 != 0.:
        U_all.append(V_R25)
        U_all = list(sorted(U_all))
    U = [Vi for Vi in U_all if Vi <= Vrated]
    # print(U)

    # dt = [0.01, 0.01, 0.01, 0.01, 0.01, 0.01, 0.01, 0.001, 0.001, 0.001, 0.001, 0.001, 0.001]
    dt = [0.01] * len(U)

    # U = [4.,8.,9.,10.]
    omega = np.interp(U, U_init, Omega_init)
    pitch = np.interp(U, U_init, pitch_init)
    for i, (omegai, pitchi) in enumerate(zip(omega, pitch)):
        if pitchi > 0. and omegai < Omega_init[-1]:
            pitch[i] = 0.

    # Check if floating
    floating_dof = [
        fst_vt['ElastoDyn']['PtfmSgDOF'], fst_vt['ElastoDyn']['PtfmSwDOF'],
        fst_vt['ElastoDyn']['PtfmHvDOF'], fst_vt['ElastoDyn']['PtfmRDOF'],
        fst_vt['ElastoDyn']['PtfmPDOF'], fst_vt['ElastoDyn']['PtfmYDOF']
    ]
    if any(floating_dof):
        floating = True
        if ptfm_U_init == []:
            ptfm_U_init = [
                3., 5., 6., 7., 8., 9., 10., 10.5, 11., 12., 14., 19., 25.
            ]
            ptfm_surge_init = [
                3.8758245863838807, 5.57895688031965, 7.619719770801395,
                9.974666446553552, 12.675469235464321, 16.173740623041965,
                20.069526574594757, 22.141906121375552, 23.835466098954708,
                22.976075549477354, 17.742743260748373, 14.464576583154068,
                14.430969814391759
            ]
            ptfm_heave_init = [
                0.030777174904620515, 0.008329930604820483,
                -0.022973502300090893, -0.06506947653943342,
                -0.12101317451310406, -0.20589689839069836,
                -0.3169518280533253, -0.3831692055885472, -0.4409624802614755,
                -0.41411738171337675, -0.2375323506471747, -0.1156867221814119,
                -0.07029955933167854
            ]
            ptfm_pitch_init = [
                0.7519976895165884, 1.104483050851386, 1.5180416334025146,
                1.9864587671004394, 2.5152769741130134, 3.1937704945765795,
                3.951314212429935, 4.357929703098016, 4.693765745171944,
                4.568760630312074, 3.495057478277534, 2.779958240049992,
                2.69008798174216
            ]
        if metocean_U_init == []:
            metocean_U_init = [
                3.00, 6.00, 8.00, 10.00, 12.00, 14.00, 16.00, 18.00, 20.00,
                22.00, 25.00
            ]
            metocean_Hs_init = [
                1.908567568, 1.960162595, 2.062722244, 2.224539415,
                2.489931091, 2.802984019, 3.182301485, 3.652236101,
                4.182596165, 4.695439504, 5.422289377
            ]
            metocean_Tp_init = [
                12.23645701, 12.14497777, 11.90254947, 11.5196666, 11.05403739,
                10.65483551, 10.27562225, 10.13693777, 10.27842325,
                10.11660396, 10.96177917
            ]

        ptfm_heave = np.interp(U, ptfm_U_init, ptfm_heave_init)
        ptfm_surge = np.interp(U, ptfm_U_init, ptfm_surge_init)
        ptfm_pitch = np.interp(U, ptfm_U_init, ptfm_pitch_init)
        metocean_Hs = np.interp(U, metocean_U_init, metocean_Hs_init)
        metocean_Tp = np.interp(U, metocean_U_init, metocean_Tp_init)
    else:
        floating = False

    case_inputs = {}
    # simulation settings
    # case_inputs[("ElastoDyn","PtfmSgDOF")]     = {'vals':['False'], 'group':0}
    # case_inputs[("ElastoDyn","PtfmHvDOF")]     = {'vals':['False'], 'group':0}
    # case_inputs[("ElastoDyn","PtfmPDOF")]     = {'vals':['False'], 'group':0}
    case_inputs[("ElastoDyn", "PtfmSwDOF")] = {'vals': ['False'], 'group': 0}
    case_inputs[("ElastoDyn", "PtfmRDOF")] = {'vals': ['False'], 'group': 0}
    case_inputs[("ElastoDyn", "PtfmYDOF")] = {'vals': ['False'], 'group': 0}

    case_inputs[("Fst", "TMax")] = {'vals': [T], 'group': 0}
    case_inputs[("Fst", "TStart")] = {'vals': [TStart], 'group': 0}
    case_inputs[("Fst", "DT")] = {'vals': dt, 'group': 1}
    case_inputs[("ElastoDyn", "YawDOF")] = {'vals': ['True'], 'group': 0}
    case_inputs[("ElastoDyn", "FlapDOF1")] = {'vals': ['False'], 'group': 0}
    case_inputs[("ElastoDyn", "FlapDOF2")] = {'vals': ['False'], 'group': 0}
    case_inputs[("ElastoDyn", "EdgeDOF")] = {'vals': ['False'], '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}
    # inital conditions
    case_inputs[("InflowWind", "WindType")] = {'vals': [1], 'group': 0}
    case_inputs[("InflowWind", "HWindSpeed")] = {'vals': U, 'group': 1}
    case_inputs[("ElastoDyn", "RotSpeed")] = {'vals': omega, 'group': 1}
    case_inputs[("ElastoDyn", "BlPitch1")] = {'vals': pitch, 'group': 1}
    case_inputs[("ElastoDyn", "BlPitch2")] = case_inputs[("ElastoDyn",
                                                          "BlPitch1")]
    case_inputs[("ElastoDyn", "BlPitch3")] = case_inputs[("ElastoDyn",
                                                          "BlPitch1")]
    if floating == True:
        case_inputs[("ElastoDyn", "PtfmSurge")] = {
            'vals': ptfm_surge,
            'group': 1
        }
        case_inputs[("ElastoDyn", "PtfmHeave")] = {
            'vals': ptfm_heave,
            'group': 1
        }
        case_inputs[("ElastoDyn", "PtfmPitch")] = {
            'vals': ptfm_pitch,
            'group': 1
        }
        case_inputs[("HydroDyn", "WaveHs")] = {'vals': metocean_Hs, 'group': 1}
        case_inputs[("HydroDyn", "WaveTp")] = {'vals': metocean_Tp, 'group': 1}
        case_inputs[("HydroDyn", "RdtnDT")] = {'vals': dt, 'group': 1}
        case_inputs[("HydroDyn", "WaveMod")] = {'vals': [1], 'group': 0}

    from weis.aeroelasticse.CaseGen_General import CaseGen_General
    case_list, case_name_list = CaseGen_General(case_inputs,
                                                dir_matrix=runDir,
                                                namebase=namebase)

    channels = [
        'Wind1VelX', 'GenPwr', "RtAeroCp", "RotTorq", "RotThrust", "RotSpeed",
        "BldPitch1"
    ]

    return case_list, case_name_list, channels