From 279cb3276ca1ebbf3e4fb147df0e173604b9f9b4 Mon Sep 17 00:00:00 2001 From: dzalkind Date: Wed, 2 Jun 2021 16:30:59 -0600 Subject: [PATCH] Read turbine variables using weis if available --- ROSCO_toolbox/turbine.py | 45 ++++++++++++++++++++++++++++++---------- 1 file changed, 34 insertions(+), 11 deletions(-) diff --git a/ROSCO_toolbox/turbine.py b/ROSCO_toolbox/turbine.py index 46fd8668f..d9869e2ab 100644 --- a/ROSCO_toolbox/turbine.py +++ b/ROSCO_toolbox/turbine.py @@ -12,7 +12,6 @@ import os import numpy as np import datetime -from wisdem.ccblade.ccblade import CCAirfoil, CCBlade from scipy import interpolate from numpy import gradient import pickle @@ -21,6 +20,16 @@ from ROSCO_toolbox.utilities import load_from_txt +# Load OpenFAST readers +try: + import weis.aeroelasticse + use_weis = True + print('Using weis.aeroelasticse in ROSCO_toolbox...') +except: + use_weis = False + print('ofTools in ROSCO_toolbox...') + + # Some useful constants now = datetime.datetime.now() pi = np.pi @@ -160,7 +169,10 @@ def load_from_fast(self, FAST_InputFile,FAST_directory, FAST_ver='OpenFAST',dev_ txt_filename: str, optional filename for *.txt, only used if rot_source='txt' """ - from weis.aeroelasticse.FAST_reader import InputReader_OpenFAST + if use_weis: + from weis.aeroelasticse.FAST_reader import InputReader_OpenFAST + else: + from ROSCO_toolbox.ofTools.fast_io.FAST_reader import InputReader_OpenFAST print('Loading FAST model: %s ' % FAST_InputFile) self.TurbineName = FAST_InputFile.strip('.fst') @@ -249,6 +261,8 @@ def load_from_ccblade(self): Dictionary containing fast model details - defined using from InputReader_OpenFAST (distributed as a part of AeroelasticSE) ''' + from wisdem.ccblade.ccblade import CCAirfoil, CCBlade + print('Loading rotor performance data from CC-Blade.') # Load blade information if it isn't already @@ -273,10 +287,13 @@ def load_from_ccblade(self): # Get values from cc-blade print('Running CCBlade aerodynamic analysis, this may take a minute...') - outputs, derivs = self.cc_rotor.evaluate(ws_flat, omega_flat, pitch_flat, coefficients=True) - CP = outputs['CP'] - CT = outputs['CT'] - CQ = outputs['CQ'] + try: # wisde/master as of Nov 9, 2020 + _, _, _, _, CP, CT, CQ, CM = self.cc_rotor.evaluate(ws_flat, omega_flat, pitch_flat, coefficients=True) + except(ValueError): # wisdem/dev as of Nov 9, 2020 + outputs, derivs = self.cc_rotor.evaluate(ws_flat, omega_flat, pitch_flat, coefficients=True) + CP = outputs['CP'] + CT = outputs['CT'] + CQ = outputs['CQ'] print('CCBlade aerodynamic analysis run successfully.') # Reshape Cp, Ct and Cq @@ -312,10 +329,12 @@ def generate_rotperf_fast(self, openfast_path, FAST_runDirectory=None, run_BeamD '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 + if use_weis: + from weis.aeroelasticse import runFAST_pywrapper, CaseGen_General + from weis.aeroelasticse.Util import FileTools + else: + from ROSCO_toolbox.ofTools.case_gen import runFAST_pywrapper, CaseGen_General + from ROSCO_toolbox.ofTools.util import FileTools # Load pCrunch tools from pCrunch import pdTools, Processing @@ -497,7 +516,11 @@ def load_blade_info(self): ----------- self - note: needs to contain fast input file info provided by load_from_fast. ''' - from weis.aeroelasticse.FAST_reader import InputReader_OpenFAST + if use_weis: + from weis.aeroelasticse.FAST_reader import InputReader_OpenFAST + else: + from ROSCO_toolbox.ofTools.fast_io.FAST_reader import InputReader_OpenFAST + from wisdem.ccblade.ccblade import CCAirfoil, CCBlade # Create CC-Blade Rotor r0 = np.array(self.fast.fst_vt['AeroDynBlade']['BlSpn'])