Skip to content

Commit

Permalink
Merge pull request #54 from dzalkind/weis
Browse files Browse the repository at this point in the history
Save design yaml and increment version
  • Loading branch information
dzalkind authored Jul 10, 2024
2 parents 25bb2f3 + 5e421b3 commit 7f0fd7e
Show file tree
Hide file tree
Showing 6 changed files with 114 additions and 63 deletions.
2 changes: 1 addition & 1 deletion environment.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,4 @@ dependencies:
- pyyaml
- scipy
- setuptools
- wisdem
- wisdem>=3.16
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.0"
version = "1.2.3"
description = "RAFT: Response Amplitudes of Floating Turbines"
readme = "README.md"
requires-python = ">=3.9"
Expand Down
69 changes: 56 additions & 13 deletions raft/omdao_raft.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,13 @@
import pickle, os
import copy
from itertools import compress
from wisdem.inputs import write_yaml, simple_types

DEBUG_OMDAO = False # use within WEIS
DEBUG_OMDAO = False # use within WEIS, test file generated using examples/15_RAFT_Studies/weis_driver_raft_opt.py

ndim = 3
ndof = 6

class RAFT_OMDAO(om.ExplicitComponent):
"""
RAFT OpenMDAO Wrapper API
Expand Down Expand Up @@ -350,11 +352,11 @@ def compute(self, inputs, outputs, discrete_inputs, discrete_outputs):
from weis.aeroelasticse.FileTools import save_yaml
# Options
all_options = {}
all_options['modeling_options'] = self.options['modeling_options']
all_options['turbine_options'] = self.options['turbine_options']
all_options['mooring_options'] = self.options['mooring_options']
all_options['member_options'] = self.options['member_options']
all_options['analysis_options'] = self.options['analysis_options']
all_options['modeling_options'] = copy.deepcopy(self.options['modeling_options'])
all_options['turbine_options'] = copy.deepcopy(self.options['turbine_options'])
all_options['mooring_options'] = copy.deepcopy(self.options['mooring_options'])
all_options['member_options'] = copy.deepcopy(self.options['member_options'])
all_options['analysis_options'] = copy.deepcopy(self.options['analysis_options'])

# handle some paths for testing
gen_opt = all_options['analysis_options']['general']
Expand All @@ -375,7 +377,7 @@ def compute(self, inputs, outputs, discrete_inputs, discrete_outputs):
# set up design
design = {}
design['type'] = ['input dictionary for RAFT']
design['name'] = ['spiderfloat']
design['name'] = [analysis_options['general']['fname_output']]
design['comments'] = ['none']

design['settings'] = {}
Expand Down Expand Up @@ -410,6 +412,10 @@ def compute(self, inputs, outputs, discrete_inputs, discrete_outputs):
design['turbine']['tower']['type'] = 1
design['turbine']['tower']['rA'] = inputs['turbine_tower_rA']
design['turbine']['tower']['rB'] = inputs['turbine_tower_rB']
# RAFT always wants rA below rB, this needs to be flipped for MHKs
if design['turbine']['tower']['rA'][2] > design['turbine']['tower']['rB'][2]:
design['turbine']['tower']['rA'] = inputs['turbine_tower_rB']
design['turbine']['tower']['rB'] = inputs['turbine_tower_rA']
design['turbine']['tower']['shape'] = turbine_opt['shape']
design['turbine']['tower']['gamma'] = inputs['turbine_tower_gamma']
design['turbine']['tower']['stations'] = inputs['turbine_tower_stations']
Expand Down Expand Up @@ -450,13 +456,14 @@ def compute(self, inputs, outputs, discrete_inputs, discrete_outputs):
design['turbine']['blade']['Rtip'] = float(inputs['blade_Rtip'])
design['turbine']['blade']['precurveTip'] = float(inputs['blade_precurveTip'])
design['turbine']['blade']['presweepTip'] = float(inputs['blade_presweepTip'])
design['turbine']['blade']['airfoils'] = list(zip(inputs['airfoils_position'], turbine_opt['af_used_names']))
airfoil_pos = [float(ap) for ap in inputs['airfoils_position']] # Cast to float for yaml saving purposes
design['turbine']['blade']['airfoils'] = list(zip(airfoil_pos, turbine_opt['af_used_names']))
# airfoils data
n_af = turbine_opt['n_af']
design['turbine']['airfoils'] = [dict() for m in range(n_af)] #Note: doesn't work [{}]*n_af
for i in range(n_af):
design['turbine']['airfoils'][i]['name'] = discrete_inputs['airfoils_name'][i]
design['turbine']['airfoils'][i]['relative_thickness'] = inputs['airfoils_r_thick'][i]
design['turbine']['airfoils'][i]['relative_thickness'] = float(inputs['airfoils_r_thick'][i])
design['turbine']['airfoils'][i]['data'] = np.c_[inputs['airfoils_aoa'] * raft.helpers.rad2deg(1),
inputs['airfoils_cl'][i,:,0,0],
inputs['airfoils_cd'][i,:,0,0],
Expand Down Expand Up @@ -604,7 +611,7 @@ def compute(self, inputs, outputs, discrete_inputs, discrete_outputs):
design['mooring']['lines'][i]['endA'] = mooring_opt[ml_name+'endA']
design['mooring']['lines'][i]['endB'] = mooring_opt[ml_name+'endB']
design['mooring']['lines'][i]['type'] = mooring_opt[ml_name+'type']
design['mooring']['lines'][i]['length'] = inputs[ml_name+'length']
design['mooring']['lines'][i]['length'] = float(inputs[ml_name+'length'])
design['mooring']['line_types'] = [dict() for m in range(nline_types)] #Note: doesn't work [{}]*nline_types
for i in range(0, nline_types):
lt_name = f'mooring_line_type{i+1}_'
Expand Down Expand Up @@ -639,10 +646,12 @@ def compute(self, inputs, outputs, discrete_inputs, discrete_outputs):

# Debug
if modeling_opt['save_designs']:
with open(
os.path.join(analysis_options['general']['folder_output'],'raft_designs',
f'raft_design_{self.i_design}.pkl'), 'wb') as handle:
file_base = os.path.join(analysis_options['general']['folder_output'],'raft_designs',f'raft_design_{self.i_design}')
with open(f'{file_base}.pkl', 'wb') as handle:
pickle.dump(design, handle, protocol=pickle.HIGHEST_PROTOCOL)

design = simple_types(design)
write_yaml(design,f'{file_base}.yaml')
self.i_design += 1

# set up the model
Expand All @@ -651,6 +660,40 @@ def compute(self, inputs, outputs, discrete_inputs, discrete_outputs):
ballast= modeling_opt['trim_ballast'],
heave_tol = modeling_opt['heave_tol']
)

if modeling_opt['plot_designs']:
fig, axs = model.plot()

if True:

print('Set breakpoint here and find nice camera angle')

azm=axs.azim
ele=axs.elev

xlm=axs.get_xlim3d() #These are two tupples
ylm=axs.get_ylim3d() #we use them in the next
zlm=axs.get_zlim3d() #graph to reproduce the magnification from mousing

print(f'axs.azim = {axs.azim}')
print(f'axs.elev = {axs.elev}')
print(f'axs.set_xlim3d({xlm})')
print(f'axs.set_ylim3d({ylm})')
print(f'axs.set_zlim3d({zlm})')

else:
print('Setting ')
axs.azim = -143.27922077922082
axs.elev = 6.62337662337643
axs.set_xlim3d((-33.479380470031096, 33.479380470031096))
axs.set_ylim3d((-11.01295410198392, 11.01295410198392))
axs.set_zlim3d((-30.005888228174538, -19.994111771825473))

print('here')

# Save figure
fig.savefig(file_base+'.png')


# option to generate seperate HAMS data for level 2 or 3, with higher res settings
if False: #preprocessBEM:
Expand Down
34 changes: 17 additions & 17 deletions tests/test_data/weis_inputs.yaml
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
turbine_mRNA: [953058.7263221256]
turbine_IxRNA: [408625327.0307215]
turbine_IrRNA: [278258824.3248088]
turbine_xCG_RNA: [-7.345147467401125]
turbine_mRNA: [951299.0379151362]
turbine_IxRNA: [408205447.2970724]
turbine_IrRNA: [277826244.2635883]
turbine_xCG_RNA: [-7.339823141992501]
turbine_hHub: [150.0]
turbine_overhang: [12.0313]
turbine_Fthrust: [3786987.5746872914]
turbine_Fthrust: [3786987.5746872947]
turbine_yaw_stiffness: [9286691506.067833]
turbine_tower_rA: [0.0, 0.0, 15.0]
turbine_tower_rB: [0.0, 0.0, 144.386]
Expand All @@ -18,12 +18,12 @@ turbine_tower_CdEnd: [0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0]
turbine_tower_CaEnd: [0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0]
turbine_tower_rho_shell: [7800.0]
rotor_PC_GS_angles: [0.060633579540634225, 0.08876932963679562, 0.11088520225227017, 0.12933356609920296, 0.14594771941768145, 0.16113975134787484, 0.17539894190783514, 0.1885853080372546, 0.20160737878784504, 0.21344020684173645, 0.22515204755677562, 0.23659644777686822, 0.24730520361770414, 0.25798742515558515, 0.2684822171290169, 0.2783727784561981, 0.2882710131150257, 0.298176211889067, 0.3074358159469139, 0.31668807504705077, 0.3259625627121579, 0.33496651208975164, 0.3436879977462277, 0.35243480046638304, 0.36120812824035214, 0.3695534412752589, 0.3778264931691233, 0.38613537789566205, 0.3944830921539001, 0.4023734005126083]
rotor_PC_GS_Kp: [-1.4536515810406514, -1.2430490835598615, -1.0738645596490477, -0.9349737332692029, -0.818908737474183, -0.7204699158606569, -0.6359254444476244, -0.5625275250430019, -0.4982081029310924, -0.4413809173747869, -0.390808919311879, -0.3455131866856339, -0.30470893538024435, -0.26775966625945197, -0.23414372188046237, -0.20342950367481782, -0.1752568413535638, -0.14932280352269847, -0.12537076154845025, -0.10318186850277143, -0.08256835305449, -0.06336819276324575, -0.04544084672511143, -0.028663809663180943, -0.012929808719481342, 0.0018554926852268141, 0.015775387801861798, 0.028903696562698807, 0.041306075149871155, 0.053041114170498685]
rotor_PC_GS_Ki: [-0.1481348986536011, -0.13197993028542312, -0.11900206599198689, -0.10834798100421908, -0.0994448276316325, -0.09189374885341296, -0.08540848263995579, -0.0797782499482475, -0.07484441373022185, -0.07048529455501627, -0.06660600044029974, -0.06313143989831384, -0.06000141344083614, -0.057167096274544506, -0.05458847292199597, -0.05223243617266558, -0.05007135796090918, -0.04808200092180296, -0.04624467949838277, -0.04454260630568228, -0.04296137771624303, -0.04148856525732482, -0.040113388269227335, -0.038826449575293014, -0.03761952045246276, -0.03648536449816869, -0.0354175924252468, -0.034410541629097804, -0.03345917573285903, -0.03255900034821116]
rotor_PC_GS_Kp: [-1.4522974584694472, -1.2418426358951324, -1.0727767445221308, -0.9339833086767828, -0.81799969789668, -0.719629901788308, -0.6351447131333541, -0.5617982605015064, -0.4975239393013075, -0.4407366010849561, -0.3902000642116044, -0.3449360930466874, -0.30416045376664136, -0.26723709354971786, -0.23364472074039924, -0.20295203940803608, -0.17479913181582493, -0.1488832789858831, -0.12494803223296777, -0.10277469808494918, -0.08217563687630114, -0.06298893977713314, -0.04507416443109033, -0.028308891462220046, -0.012585923232498849, 0.0021890106883082766, 0.016099145145719817, 0.02921824830932211, 0.041611930322997745, 0.05333874071001189]
rotor_PC_GS_Ki: [-0.14799948639648072, -0.13185928551895026, -0.1188932844792952, -0.1082489385449771, -0.09935392367388221, -0.0918097474461781, -0.0853304095085288, -0.07970532349409801, -0.07477599736724339, -0.07042086292603322, -0.06654511493027229, -0.06307373053441921, -0.059946565279475866, -0.05711483900357111, -0.05453857280798968, -0.05218468974598743, -0.05002558700713531, -0.04803804846812144, -0.04620240656683454, -0.04450188926390009, -0.042922106098424166, -0.041450639958713585, -0.04007672003982526, -0.03879095775519694, -0.03758513190376453, -0.036452012697860574, -0.03538521669086102, -0.0343790864544355, -0.03342859021554639, -0.03252923769425987]
Fl_Kp: [-8.953275155844183]
rotor_inertia: [348772675.1440297]
rotor_TC_VS_Kp: [-63411648.20105708]
rotor_TC_VS_Ki: [-5022326.522074027]
rotor_inertia: [348453856.988467]
rotor_TC_VS_Kp: [-63346609.29732228]
rotor_TC_VS_Ki: [-5017735.540633924]
tilt: [6.0]
precone: [4.0]
wind_reference_height: [150.0]
Expand Down Expand Up @@ -14445,7 +14445,7 @@ airfoils_cm:
- [0.004849000257769079]
rotor_powercurve_v: [3.0, 4.272046072021935, 5.304031475548529, 6.080106111341955, 6.588350372834853, 6.82095821746675, 6.867559376486635, 7.192653799388591, 7.791248412775406, 8.6541494974404, 9.768103893234573, 10.668247216246115, 11.116002552239781, 12.677143313907283, 14.42754886624012, 16.340335009504354, 18.386123566365413, 20.533493596628738, 22.7494639864494, 25.0]
rotor_powercurve_omega_rpm: [4.999999999999999, 4.999999999999999, 4.999999999999999, 4.999999999999999, 4.999999999999999, 4.999999999999999, 4.999999999999999, 5.110052569277952, 5.535326748657092, 6.148378624600282, 6.939792431110801, 7.499240932659366, 7.499240932659366, 7.499240932659366, 7.499240932659366, 7.499240932659366, 7.499240932659366, 7.499240932659366, 7.499240932659366, 7.499240932659366]
rotor_powercurve_pitch: [3.899786057291991, 3.560307946471698, 2.5500225702017953, 1.488798029791501, 0.6665181950894715, 0.2542728120713682, 0.16853068063805116, 0.0, 0.0, 0.0, 0.0, 0.0, 3.4359116275010044, 7.615746722824275, 10.687309966215103, 13.420344984312322, 15.975261972552893, 18.404417208394975, 20.723210897028288, 22.9306333825561]
rotor_powercurve_pitch: [3.89978605729199, 3.560307946471666, 2.5500225702018704, 1.4887980297910133, 0.6665181950894756, 0.2542728120723059, 0.16853068063662924, 0.0, 0.0, 0.0, 0.0, 0.0, 3.4359116275010044, 7.615746722824275, 10.687309966215103, 13.420344984312322, 15.975261972552893, 18.404417208394975, 20.723210897028288, 22.9306333825561]
rho_air: [1.225]
rho_water: [1025.0]
mu_air: [1.81e-05]
Expand Down Expand Up @@ -14487,7 +14487,7 @@ platform_member2_Ca: [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0]
platform_member2_CdEnd: [0.6, 0.6, 0.6, 0.6, 0.6, 0.6, 0.6]
platform_member2_CaEnd: [0.6, 0.6, 0.6, 0.6, 0.6, 0.6, 0.6]
platform_member2_rho_shell: [7800.0]
platform_member2_l_fill: [0.0400627872412308, 0.05, 0.06676481277116134, 0.0, 0.0, 0.0]
platform_member2_l_fill: [0.0400627872412308, 0.05, 0.06678915855644674, 0.0, 0.0, 0.0]
platform_member2_rho_fill: [5000.0, 1025.0, 1025.0, 0.0, 0.0, 0.0]
platform_member2_cap_stations: [0.0, 0.05, 0.2, 1.0]
platform_member2_cap_t: [0.05, 0.05, 0.05, 0.05]
Expand All @@ -14509,7 +14509,7 @@ platform_member3_Ca: [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0]
platform_member3_CdEnd: [0.6, 0.6, 0.6, 0.6, 0.6, 0.6, 0.6]
platform_member3_CaEnd: [0.6, 0.6, 0.6, 0.6, 0.6, 0.6, 0.6]
platform_member3_rho_shell: [7800.0]
platform_member3_l_fill: [0.04006278724123036, 0.05, 0.06676481277116139, 0.0, 0.0, 0.0]
platform_member3_l_fill: [0.04006278724123036, 0.05, 0.06678915855644679, 0.0, 0.0, 0.0]
platform_member3_rho_fill: [5000.0, 1025.0, 1025.0, 0.0, 0.0, 0.0]
platform_member3_cap_stations: [0.0, 0.05, 0.2, 1.0]
platform_member3_cap_t: [0.05, 0.05, 0.05, 0.05]
Expand All @@ -14531,7 +14531,7 @@ platform_member4_Ca: [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0]
platform_member4_CdEnd: [0.6, 0.6, 0.6, 0.6, 0.6, 0.6, 0.6]
platform_member4_CaEnd: [0.6, 0.6, 0.6, 0.6, 0.6, 0.6, 0.6]
platform_member4_rho_shell: [7800.0]
platform_member4_l_fill: [0.0400627872412308, 0.05, 0.06676481277116134, 0.0, 0.0, 0.0]
platform_member4_l_fill: [0.0400627872412308, 0.05, 0.06678915855644674, 0.0, 0.0, 0.0]
platform_member4_rho_fill: [5000.0, 1025.0, 1025.0, 0.0, 0.0, 0.0]
platform_member4_cap_stations: [0.0, 0.05, 0.2, 1.0]
platform_member4_cap_t: [0.05, 0.05, 0.05, 0.05]
Expand Down Expand Up @@ -14619,7 +14619,7 @@ platform_member8_Ca: [1.0, 1.0]
platform_member8_CdEnd: [0.6, 0.6]
platform_member8_CaEnd: [0.6, 0.6]
platform_member8_rho_shell: [7800.0]
platform_member8_l_fill: [0.6092077188060592]
platform_member8_l_fill: [0.6093347402945047]
platform_member8_rho_fill: [1025.0]
platform_member8_cap_stations: [0.0, 1.0]
platform_member8_cap_t: [0.02, 0.02]
Expand All @@ -14641,7 +14641,7 @@ platform_member9_Ca: [1.0, 1.0]
platform_member9_CdEnd: [0.6, 0.6]
platform_member9_CaEnd: [0.6, 0.6]
platform_member9_rho_shell: [7800.0]
platform_member9_l_fill: [0.609207718806059]
platform_member9_l_fill: [0.6093347402945046]
platform_member9_rho_fill: [1025.0]
platform_member9_cap_stations: [0.0, 1.0]
platform_member9_cap_t: [0.02, 0.02]
Expand All @@ -14663,7 +14663,7 @@ platform_member10_Ca: [1.0, 1.0]
platform_member10_CdEnd: [0.6, 0.6]
platform_member10_CaEnd: [0.6, 0.6]
platform_member10_rho_shell: [7800.0]
platform_member10_l_fill: [0.6092077188060592]
platform_member10_l_fill: [0.6093347402945047]
platform_member10_rho_fill: [1025.0]
platform_member10_cap_stations: [0.0, 1.0]
platform_member10_cap_t: [0.02, 0.02]
Expand Down
Loading

0 comments on commit 7f0fd7e

Please sign in to comment.