Skip to content

Commit

Permalink
fixing python deprecation issues
Browse files Browse the repository at this point in the history
  • Loading branch information
gbarter committed Feb 6, 2024
1 parent 499201c commit 7273ae7
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 23 deletions.
30 changes: 11 additions & 19 deletions WISDEM/generateTables.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,4 @@
import os
try:
import ruamel.yaml as yaml
except:
try:
import ruamel_yaml as yaml
except:
raise ImportError('No YAML package found')
import pandas as pd
import csv
import numpy as np
Expand All @@ -15,6 +8,7 @@
import matplotlib.cm as cm
from matplotlib.patches import Rectangle
from scipy.interpolate import interp1d
from wisdem.inputs.validation import load_yaml

def find_nearest(array, value):
return (np.abs(array - value)).argmin()
Expand Down Expand Up @@ -86,9 +80,7 @@ class RWT_Tabular(object):
def __init__(self, finput, towDF=None, rotDF=None, layerDF=None, nacDF=None, overview=None):

# Read ontology file into dictionary-like data structure
f = open(finput, 'r')
self.yaml = yaml.safe_load( f )
f.close()
self.yaml = load_yaml( finput )

# Store output file name
folder_output = os.getcwd() + os.sep + 'outputs'
Expand Down Expand Up @@ -335,16 +327,18 @@ def write_blade_inner(self):
weblist.append( self.yaml['components']['blade']['internal_structure_2d_fem']['webs'][k][ikey] )
elif ikey == 'material':
matlist.append( self.yaml['components']['blade']['internal_structure_2d_fem']['webs'][k][ikey] )
else:
elif ikey == 'offset_plane':
mygrid = np.r_[mygrid, self.yaml['components']['blade']['internal_structure_2d_fem']['webs'][k][ikey]['offset']['grid']]
elif 'grid' in self.yaml['components']['blade']['internal_structure_2d_fem']['webs'][k][ikey]:
mygrid = np.r_[mygrid, self.yaml['components']['blade']['internal_structure_2d_fem']['webs'][k][ikey]['grid']]

for k in range(nlay):
for ikey in self.yaml['components']['blade']['internal_structure_2d_fem']['layers'][k].keys():
if ikey in ['name', 'midpoint_nd_arc','start_nd_arc','end_nd_arc','side','web']:
continue
elif ikey == 'material':
if ikey == 'material':
matlist.append( self.yaml['components']['blade']['internal_structure_2d_fem']['layers'][k][ikey] )
else:
elif ikey == 'offset_plane':
mygrid = np.r_[mygrid, self.yaml['components']['blade']['internal_structure_2d_fem']['layers'][k][ikey]['offset']['grid']]
elif 'grid' in self.yaml['components']['blade']['internal_structure_2d_fem']['layers'][k][ikey]:
mygrid = np.r_[mygrid, self.yaml['components']['blade']['internal_structure_2d_fem']['layers'][k][ikey]['grid']]
mygrid = np.unique( mygrid )

Expand Down Expand Up @@ -522,7 +516,7 @@ def myinterp(xgrid, val):
sparcap_ps_wid = self.yaml['components']['blade']['internal_structure_2d_fem']['layers'][k]['width']['values']
sparcap_ps_beg = self.yaml['components']['blade']['internal_structure_2d_fem']['layers'][k]['start_nd_arc']['values']
sparcap_ps_end = self.yaml['components']['blade']['internal_structure_2d_fem']['layers'][k]['end_nd_arc']['values']
elif self.yaml['components']['blade']['internal_structure_2d_fem']['layers'][k]['name'] == 'LE_reinforcement':
elif self.yaml['components']['blade']['internal_structure_2d_fem']['layers'][k]['name'].lower() == 'le_reinforcement':
reinf_le_thgrid = self.yaml['components']['blade']['internal_structure_2d_fem']['layers'][k]['thickness']['grid']
reinf_le_th = self.yaml['components']['blade']['internal_structure_2d_fem']['layers'][k]['thickness']['values']
reinf_le_wgrid = self.yaml['components']['blade']['internal_structure_2d_fem']['layers'][k]['width']['grid']
Expand Down Expand Up @@ -832,9 +826,7 @@ def write_rotor_performance(self):
# Use OpenFAST output if it is available
foutput = '..'+os.sep+'OpenFAST'+os.sep+'outputs'+os.sep+'IEA-15-240-RWT_steady.yaml'
if os.path.exists(foutput):
f = open(foutput, 'r')
fastout = yaml.safe_load( f )
f.close()
fastout = load_yaml(foutput)

rotmat = np.c_[fastout['Wind1VelX']['mean'],
fastout['BldPitch1']['mean'],
Expand Down
8 changes: 4 additions & 4 deletions WISDEM/run_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -125,9 +125,9 @@ def run_15mw(fname_wt_input):
# 'MoI_cm_xx', 'MoI_cm_yy', 'MoI_cm_zz', 'MoI_cm_xy', 'MoI_cm_xz', 'MoI_cm_yz',
# 'MoI_TT_xx', 'MoI_TT_yy', 'MoI_TT_zz', 'MoI_TT_xy', 'MoI_TT_xz', 'MoI_TT_yz']
nacDF = prob.model.wt.drivese.nac._mass_table
hub_cm = float(prob["drivese.hub_system_cm"])
L_drive = float(prob["drivese.L_drive"])
tilt = float(prob.get_val('nacelle.uptilt', 'rad'))
hub_cm = prob["drivese.hub_system_cm"][0]
L_drive = prob["drivese.L_drive"][0]
tilt = prob.get_val('nacelle.uptilt', 'rad')[0]
shaft0 = prob["drivese.shaft_start"]
Cup = -1.0
hub_cm = R = shaft0 + (L_drive + hub_cm) * np.array([Cup * np.cos(tilt), 0.0, np.sin(tilt)])
Expand Down Expand Up @@ -286,7 +286,7 @@ def run_15mw(fname_wt_input):
overview['Tower top to hub flange height [m]'] = prob['nacelle.distance_tt_hub']
overview['Generator rated efficiency [%]'] = prob['rotorse.rp.powercurve.rated_efficiency']
overview['Blade pre-bend [m]'] = prob['blade.outer_shape_bem.ref_axis'][-1,0]
overview['Blade mass [t]'] = 1e-3*prob['rotorse.re.precomp.blade_mass']
overview['Blade mass [t]'] = 1e-3*prob['rotorse.blade_mass']
overview['Hub mass [t]'] = 1e-3*prob['drivese.hub_mass']
overview['Generator mass [t]'] = 1e-3*prob['drivese.generator_mass']
overview['Nacelle mass [t]'] = 1e-3*prob['drivese.nacelle_mass']
Expand Down

0 comments on commit 7273ae7

Please sign in to comment.