def generate_rotperf_fast(self, openfast_path, FAST_runDirectory=None, run_BeamDyn=False, debug_level=1, run_type='multi'): ''' Use openfast to generate Cp surface data. Will be slow, especially if using BeamDyn, but may be necessary if cc-blade is not sufficient. Parameters: ----------- openfast_path: str path to openfast FAST_runDirectory: str directory to run openfast simulations in run_BeamDyn: bool Flag to run beamdyn - does not exist yet debug_level: float 0 - no outputs, 1 - simple outputs, 2 - all outputs run_type: str 'serial' - run in serial, 'multi' - run using python multiprocessing tools, 'mpi' - run using mpi tools ''' # Load additional WEIS tools from weis.aeroelasticse import runFAST_pywrapper, CaseGen_General from weis.aeroelasticse.Util import FileTools # Load pCrunch tools from pCrunch import pdTools, Processing # setup values for surface v0 = self.v_rated + 2 TSR_initial = np.arange(3, 15, 1) pitch_initial = np.arange(-1, 25, 1) rotspeed_initial = TSR_initial * v0 / self.rotor_radius * RadSec2rpm # rpms # Specify Case Inputs case_inputs = {} # ------- Setup OpenFAST inputs -------- case_inputs[('Fst', 'TMax')] = {'vals': [330], 'group': 0} case_inputs[('Fst', 'Compinflow')] = {'vals': [1], 'group': 0} case_inputs[('Fst', 'CompAero')] = {'vals': [2], 'group': 0} case_inputs[('Fst', 'CompServo')] = {'vals': [1], 'group': 0} case_inputs[('Fst', 'CompHydro')] = {'vals': [0], 'group': 0} if run_BeamDyn: case_inputs[('Fst', 'CompElast')] = {'vals': [2], 'group': 0} else: case_inputs[('Fst', 'CompElast')] = {'vals': [1], 'group': 0} case_inputs[('Fst', 'OutFileFmt')] = {'vals': [2], 'group': 0} # AeroDyn15 case_inputs[('AeroDyn15', 'WakeMod')] = {'vals': [1], 'group': 0} case_inputs[('AeroDyn15', 'AfAeroMod')] = {'vals': [1], 'group': 0} case_inputs[('AeroDyn15', 'TwrPotent')] = {'vals': [0], 'group': 0} # ElastoDyn 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', '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 } # BeamDyn # NEEDED # InflowWind case_inputs[('InflowWind', 'WindType')] = {'vals': [1], 'group': 0} case_inputs[('InflowWind', 'HWindSpeed')] = {'vals': [v0], 'group': 0} case_inputs[('InflowWind', 'PLexp')] = {'vals': [0], 'group': 0} # ServoDyn case_inputs[('ServoDyn', 'PCMode')] = {'vals': [0], 'group': 0} case_inputs[('ServoDyn', 'VSContrl')] = {'vals': [0], 'group': 0} case_inputs[('ServoDyn', 'HSSBrMode')] = {'vals': [0], 'group': 0} case_inputs[('ServoDyn', 'YCMode')] = {'vals': [0], 'group': 0} # ------- Setup sweep values inputs -------- case_inputs[('ElastoDyn', 'BlPitch1')] = { 'vals': list(pitch_initial), 'group': 1 } case_inputs[('ElastoDyn', 'BlPitch2')] = { 'vals': list(pitch_initial), 'group': 1 } case_inputs[('ElastoDyn', 'BlPitch3')] = { 'vals': list(pitch_initial), 'group': 1 } case_inputs[('ElastoDyn', 'RotSpeed')] = { 'vals': list(rotspeed_initial), 'group': 2 } # FAST details fastBatch = runFAST_pywrapper.runFAST_pywrapper_batch( FAST_ver='OpenFAST', dev_branch=True) fastBatch.FAST_exe = openfast_path # Path to executable fastBatch.FAST_InputFile = self.fast.FAST_InputFile fastBatch.FAST_directory = self.fast.FAST_directory if not FAST_runDirectory: FAST_runDirectory = os.path.join(os.getcwd(), 'RotPerf_OpenFAST') fastBatch.FAST_runDirectory = FAST_runDirectory fastBatch.debug_level = debug_level # Generate cases case_name_base = self.TurbineName + '_rotperf' case_list, case_name_list = CaseGen_General.CaseGen_General( case_inputs, dir_matrix=fastBatch.FAST_runDirectory, namebase=case_name_base) fastBatch.case_list = case_list fastBatch.case_name_list = case_name_list # Make sure proper outputs exist var_out = [ # ElastoDyn (this is probably overkill on the outputs) "BldPitch1", "BldPitch2", "BldPitch3", "Azimuth", "RotSpeed", "GenSpeed", "NacYaw", "OoPDefl1", "IPDefl1", "TwstDefl1", "OoPDefl2", "IPDefl2", "TwstDefl2", "OoPDefl3", "IPDefl3", "TwstDefl3", "RootFxc1", "RootFyc1", "RootFzc1", "RootMxc1", "RootMyc1", "RootMzc1", "RootFxc2", "RootFyc2", "RootFzc2", "RootMxc2", "RootMyc2", "RootMzc2", "RootFxc3", "RootFyc3", "RootFzc3", "RootMxc3", "RootMyc3", "RootMzc3", "Spn1MLxb1", "Spn1MLyb1", "Spn1MLzb1", "Spn1MLxb2", "Spn1MLyb2", "Spn1MLzb2", "Spn1MLxb3", "Spn1MLyb3", "Spn1MLzb3", "RotThrust", "LSSGagFya", "LSSGagFza", "RotTorq", "LSSGagMya", "LSSGagMza", # ServoDyn "GenPwr", "GenTq", # AeroDyn15 "RtArea", "RtVAvgxh", "B1N3Clrnc", "B2N3Clrnc", "B3N3Clrnc", "RtAeroCp", 'RtAeroCq', 'RtAeroCt', 'RtTSR', # NECESSARY # InflowWind "Wind1VelX", ] channels = {} for var in var_out: channels[var] = True fastBatch.channels = channels # Run OpenFAST if run_type.lower() == 'multi': fastBatch.run_multi() elif run_type.lower() == 'mpi': fastBatch.run_mpi() elif run_type.lower() == 'serial': fastBatch.run_serial() # ========== Post Processing ========== # Save statistics fp = Processing.FAST_Processing() # Find all outfiles fname_case_matrix = os.path.join(FAST_runDirectory, 'case_matrix.yaml') case_matrix = FileTools.load_yaml(fname_case_matrix, package=1) cm = pd.DataFrame(case_matrix) # Parse case matrix and find outfiles names outfiles = [] case_names = cm['Case_Name'] outfiles = [] for name in case_names: outfiles.append(os.path.join(FAST_runDirectory, name + '.outb')) # Set some processing parameters fp.OpenFAST_outfile_list = outfiles fp.namebase = case_name_base fp.t0 = 270 fp.parallel_analysis = True fp.results_dir = os.path.join(FAST_runDirectory, 'stats') fp.verbose = True # Save for debug! fp.save_LoadRanking = False fp.save_SummaryStats = False print('Processing openfast data on {} cores.'.format( fp.parallel_cores)) # Load and save statistics and load rankings stats, load_rankings = fp.batch_processing() # Get means of last 30 seconds of 300 second simulation CP = stats[0]['RtAeroCp']['mean'] CT = stats[0]['RtAeroCt']['mean'] CQ = stats[0]['RtAeroCq']['mean'] # Reshape Cp, Ct and Cq Cp = np.transpose( np.reshape(CP, (len(pitch_initial), len(TSR_initial)))) Ct = np.transpose( np.reshape(CT, (len(pitch_initial), len(TSR_initial)))) Cq = np.transpose( np.reshape(CQ, (len(pitch_initial), len(TSR_initial)))) # Store necessary metrics for analysis self.pitch_initial_rad = pitch_initial * deg2rad self.TSR_initial = TSR_initial self.Cp_table = Cp self.Ct_table = Ct self.Cq_table = Cq
case_inputs[('ServoDyn', 'DLL_FileName')] = {'vals': dll_filename, 'group': 2} # Naming, file management, etc iec.case_name_base = case_name_base iec.run_dir = run_dir iec.wind_dir = wind_dir iec.debug_level = debug_level if multi: iec.parallel_windfile_gen = True else: iec.parallel_windfile_gen = False # Run FAST cases fastBatch = runFAST_pywrapper_batch(FAST_ver='OpenFAST', dev_branch=True) fastBatch.FAST_runDirectory = iec.run_dir fastBatch.FAST_directory = FAST_directory fastBatch.FAST_InputFile = FAST_InputFile fastBatch.FAST_exe = FAST_exe iec.Turbsim_exe = Turbsim_exe iec.cores = cores # Make sure output flags are on var_out = [ # ElastoDyn "BldPitch1", "BldPitch2", "BldPitch3", "Azimuth",
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()
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, )
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)
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))