Skip to content

Commit

Permalink
Merge pull request #58 from WISDEM/omdao_rect
Browse files Browse the repository at this point in the history
Rectangular connections to WEIS
  • Loading branch information
gbarter authored Jul 13, 2024
2 parents 7f0fd7e + 97cdc00 commit 94d1953
Show file tree
Hide file tree
Showing 6 changed files with 15,239 additions and 72 deletions.
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"

[project]
name = "OpenRAFT"
version = "1.2.3"
version = "1.2.4"
description = "RAFT: Response Amplitudes of Floating Turbines"
readme = "README.md"
requires-python = ">=3.9"
Expand Down
69 changes: 55 additions & 14 deletions raft/omdao_raft.py
Original file line number Diff line number Diff line change
Expand Up @@ -187,16 +187,28 @@ def setup(self):
self.add_input(m_name+'t', val=0.0, units='m', desc='Wall thicknesses')
else:
self.add_input(m_name+'t', val=np.zeros(mnpts), units='m', desc='Wall thicknesses')
if mshape == "circ":
if scalar_coeff:
self.add_input(m_name+'Cd', val=0.0, desc='Transverse drag coefficient')
self.add_input(m_name+'Ca', val=0.0, desc='Transverse added mass coefficient')
else:
self.add_input(m_name+'Cd', val=np.zeros(mnpts), desc='Transverse drag coefficient')
self.add_input(m_name+'Ca', val=np.zeros(mnpts), desc='Transverse added mass coefficient')
elif mshape == "rect" or mshape == 'square':
if scalar_coeff:
self.add_input(m_name+'Cd', val=[0.0, 0.0], desc='Transverse drag coefficient')
self.add_input(m_name+'Ca', val=[0.0, 0.0], desc='Transverse added mass coefficient')
else:
self.add_input(m_name+'Cd', val=np.zeros([mnpts,2]), desc='Transverse drag coefficient')
self.add_input(m_name+'Ca', val=np.zeros([mnpts,2]), desc='Transverse added mass coefficient')

if scalar_coeff:
self.add_input(m_name+'Cd', val=0.0, desc='Transverse drag coefficient')
self.add_input(m_name+'Ca', val=0.0, desc='Transverse added mass coefficient')
self.add_input(m_name+'CdEnd', val=0.0, desc='End axial drag coefficient')
self.add_input(m_name+'CaEnd', val=0.0, desc='End axial added mass coefficient')
else:
self.add_input(m_name+'Cd', val=np.zeros(mnpts), desc='Transverse drag coefficient')
self.add_input(m_name+'Ca', val=np.zeros(mnpts), desc='Transverse added mass coefficient')
self.add_input(m_name+'CdEnd', val=np.zeros(mnpts), desc='End axial drag coefficient')
self.add_input(m_name+'CaEnd', val=np.zeros(mnpts), desc='End axial added mass coefficient')

self.add_input(m_name+'rho_shell', val=0.0, units='kg/m**3', desc='Material density')
# optional
self.add_input(m_name+'l_fill', val=np.zeros(mnpts_lfill), units='m', desc='Fill heights of ballast in each section')
Expand Down Expand Up @@ -530,9 +542,13 @@ def compute(self, inputs, outputs, discrete_inputs, discrete_outputs):
design['platform']['members'][i]['d'] = np.interp(s_grid, s_0, inputs[m_name+'d'])
elif m_shape == 'rect':
if member_scalar_d[i]:
design['platform']['members'][i]['d'] = [inputs[m_name+'d']]*mnpts
design['platform']['members'][i]['d'] = np.zeros([mnpts,2])
design['platform']['members'][i]['d'][:,0] = [inputs[m_name+'d'][0]]*mnpts
design['platform']['members'][i]['d'][:,1] = [inputs[m_name+'d'][1]]*mnpts
else:
design['platform']['members'][i]['d'] = np.interp(s_grid, s_0, inputs[m_name+'d'])
design['platform']['members'][i]['d'] = np.zeros([len(s_grid),2])
design['platform']['members'][i]['d'][:,0] = np.interp(s_grid, s_0, inputs[m_name+'d'][:,0])
design['platform']['members'][i]['d'][:,1] = np.interp(s_grid, s_0, inputs[m_name+'d'][:,1])
''' original version of handling diameters
if member_scalar_d[i]:
design['platform']['members'][i]['d'] = float(inputs[m_name+'d'])
Expand All @@ -543,14 +559,32 @@ def compute(self, inputs, outputs, discrete_inputs, discrete_outputs):
design['platform']['members'][i]['t'] = float(inputs[m_name+'t'])
else:
design['platform']['members'][i]['t'] = np.interp(s_grid, s_0, inputs[m_name+'t'])

if m_shape == "circ":
if member_scalar_coeff[i]:
design['platform']['members'][i]['Cd'] = float(inputs[m_name+'Cd'])
design['platform']['members'][i]['Ca'] = float(inputs[m_name+'Ca'])
else:
design['platform']['members'][i]['Cd'] = np.interp(s_grid, s_0, inputs[m_name+'Cd'])
design['platform']['members'][i]['Ca'] = np.interp(s_grid, s_0, inputs[m_name+'Ca'])
elif m_shape == "rect":
if member_scalar_coeff[i]:
design['platform']['members'][i]['Cd'][0] = float(inputs[m_name+'Cd'][0])
design['platform']['members'][i]['Cd'][1] = float(inputs[m_name+'Cd'][1])
design['platform']['members'][i]['Ca'][0] = float(inputs[m_name+'Ca'][0])
design['platform']['members'][i]['Ca'][1] = float(inputs[m_name+'Ca'][1])
else:
design['platform']['members'][i]['Cd'] = np.zeros([len(s_grid),2])
design['platform']['members'][i]['Ca'] = np.zeros([len(s_grid),2])
design['platform']['members'][i]['Cd'][:,0] = np.interp(s_grid, s_0, inputs[m_name+'Cd'][:,0])
design['platform']['members'][i]['Cd'][:,1] = np.interp(s_grid, s_0, inputs[m_name+'Cd'][:,1])
design['platform']['members'][i]['Ca'][:,0] = np.interp(s_grid, s_0, inputs[m_name+'Ca'][:,0])
design['platform']['members'][i]['Ca'][:,1] = np.interp(s_grid, s_0, inputs[m_name+'Ca'][:,1])

if member_scalar_coeff[i]:
design['platform']['members'][i]['Cd'] = float(inputs[m_name+'Cd'])
design['platform']['members'][i]['Ca'] = float(inputs[m_name+'Ca'])
design['platform']['members'][i]['CdEnd'] = float(inputs[m_name+'CdEnd'])
design['platform']['members'][i]['CaEnd'] = float(inputs[m_name+'CaEnd'])
else:
design['platform']['members'][i]['Cd'] = np.interp(s_grid, s_0, inputs[m_name+'Cd'])
design['platform']['members'][i]['Ca'] = np.interp(s_grid, s_0, inputs[m_name+'Ca'])
design['platform']['members'][i]['CdEnd'] = np.interp(s_grid, s_0, inputs[m_name+'CdEnd'])
design['platform']['members'][i]['CaEnd'] = np.interp(s_grid, s_0, inputs[m_name+'CaEnd'])
design['platform']['members'][i]['rho_shell'] = float(inputs[m_name+'rho_shell'])
Expand All @@ -566,7 +600,13 @@ def compute(self, inputs, outputs, discrete_inputs, discrete_outputs):
ring_spacing = inputs[m_name+'ring_spacing']
n_stiff = 0 if ring_spacing == 0.0 else int(np.floor(s_height / ring_spacing))
s_ring = (np.arange(1, n_stiff + 0.1) - 0.5) * (ring_spacing / s_height)
d_ring = np.interp(s_ring, s_grid, design['platform']['members'][i]['d'])
if s_ring:
if not m_shape == 'rect':
d_ring = np.interp(s_ring, s_grid, design['platform']['members'][i]['d'])
else:
d_ring = np.zeros([len(s_grid),2])
d_ring[:,0] = np.interp(s_ring, s_grid, design['platform']['members'][i]['d'][:,0])
d_ring[:,1] = np.interp(s_ring, s_grid, design['platform']['members'][i]['d'][:,1])
# Combine internal structures based on spacing and defined positions
s_cap_0 = inputs[m_name+'cap_stations']
idx_cap = np.logical_and(s_cap_0>=s_ghostA, s_cap_0<=s_ghostB)
Expand All @@ -583,9 +623,10 @@ def compute(self, inputs, outputs, discrete_inputs, discrete_outputs):
t_cap = t_cap[:-1]
di_cap = di_cap[:-1]
# Combine with ring stiffeners
s_cap = np.r_[s_ring, s_cap]
t_cap = np.r_[inputs[m_name+'ring_t']*np.ones(n_stiff), t_cap]
di_cap = np.r_[d_ring-2*inputs[m_name+'ring_h'], di_cap]
if s_ring:
s_cap = np.r_[s_ring, s_cap]
t_cap = np.r_[inputs[m_name+'ring_t']*np.ones(n_stiff), t_cap]
di_cap = np.r_[d_ring-2*inputs[m_name+'ring_h'], di_cap]
# Store vectors in sorted order
if len(s_cap) > 0:
isort = np.argsort(s_cap)
Expand Down
Loading

0 comments on commit 94d1953

Please sign in to comment.