Skip to content

Commit

Permalink
Read turbine variables using weis if available
Browse files Browse the repository at this point in the history
  • Loading branch information
dzalkind committed Jun 2, 2021
1 parent 8a05fea commit 279cb32
Showing 1 changed file with 34 additions and 11 deletions.
45 changes: 34 additions & 11 deletions ROSCO_toolbox/turbine.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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')
Expand Down Expand Up @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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

Expand Down Expand Up @@ -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'])
Expand Down

0 comments on commit 279cb32

Please sign in to comment.