Skip to content

Commit 349c1c6

Browse files
committed
Updates for loading and unloading cable info
-- update to load in of 3D cable design from addCablesConnections to match new cable appendage storage method -- update to unload function to properly unload cable appendage info. Relevant for cost calcs
1 parent 949bca2 commit 349c1c6

File tree

2 files changed

+26
-5
lines changed

2 files changed

+26
-5
lines changed

famodel/helpers.py

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -431,24 +431,36 @@ def getCableDD(dd,selected_cable,cableConfig,cableType_def,connVal):
431431
dd['joints'].append({'cost':joint_cost}) # default 0
432432

433433
# add routing if necessary
434-
if dd['cables'][j]['type']=='static':
434+
if 'static' in dd['cables'][j]['cable_type']:
435435
cd['routing'] = []
436436
# if len(connDict[i]['coordinates'])>2:
437437
# for coord in connDict[i]['coordinates'][1:-1]:
438438
# cd['routing'].append(coord)
439439
cableType = 'static_cable_'+cableType_def[-2:]
440440
else:
441441
cableType = 'dynamic_cable_'+cableType_def[-2:]
442+
Acondd, jAcondd = getDynamicCables(cableConfig['cableTypes'][selected_cable['sections'][j]],
443+
cableConfig['cableTypes'],
444+
cableConfig['cableAppendages'],
445+
depth
446+
)
447+
cd.update(Acondd)
442448
cd['rJTube'] = 5
449+
# for now reset these back
450+
cd['A'] = selected_cable['A']
451+
cd['z_anch'] = -depth
452+
# if dd['connector_cost']:
453+
# cd['appendages'] = [{'type:'cable_connector',
454+
# 'cost':dd['connector_cost']}]
443455

444456

445-
if not 'cable_type' in cd or not cd['cable_type']:
457+
if not 'cable_type' in cd or not isinstance(cd['cable_type'],dict):
446458
cp = loadCableProps(None)
447459
cabProps = getCableProps(connVal['conductor_area'],cableType,cableProps=cp)
448460
# fix units
449461
cabProps['power'] = cabProps['power']*1e6
450462
cd['cable_type'] = cabProps
451-
463+
452464
cd['cable_type']['name'] = selected_cable['sections'][j]
453465

454466
return(dd)
@@ -572,15 +584,15 @@ def getCableDesign(connVal, cableType_def, cableConfig, configType, depth=None):
572584
# else:
573585
# raise Exception(f"No cable matching the selection criteria found for cable {connVal['cable_id']}")
574586
dd = getCableDD(dd,selected_cable,cableConfig,cableType_def,connVal)
575-
i_dc = [i for i,sec in enumerate(dd['cables']) if sec['type']=='dynamic']
587+
i_dc = [i for i,sec in enumerate(dd['cables']) if 'dynamic' in sec['cable_type']]
576588
dd['name'] = cableType_def
577589
dc_cands = []
578590
# pull out the dc definitions of candidate cables
579591
for cand in cable_candidates:
580592
cand = dict(cand)
581593
for sec in cand['sections']:
582594
typedef = cableConfig['cableTypes'][sec]
583-
if typedef['type']=='dynamic' and typedef not in dc_cands:
595+
if 'dynamic' in typedef['cable_type'] and typedef not in dc_cands:
584596
dc_cands.append(cableConfig['cableTypes'][sec])
585597
for i in i_dc:
586598
dd['cables'][i] = cableDesignInterpolation(

famodel/project.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4780,10 +4780,19 @@ def unload(self,file='project.yaml'):
47804780
ctn = 'dyn_cab_'+str(cIdx)
47814781
# collect buoyancy sections (and appendages) info if applicable
47824782
bs = []
4783+
ac = 0
47834784
if 'appendages' in sub.dd:
47844785
for app in sub.dd['appendages']:
47854786
if not app['type'] in appendageTypes:
47864787
appendageTypes[app['type']] = app
4788+
elif appendageTypes[app['type']] != app:
4789+
# adjust new name
4790+
app['type'] = app['type']+'_'+str(ac)
4791+
while app['type'] in appendageTypes and appendageTypes[app['type']] != app:
4792+
ac += 1
4793+
app['type'] = app['type'][:-1]+str(ac)
4794+
appendageTypes[app['type']] = app
4795+
47874796
bs.append({'type':app['type']})
47884797
if 'buoyancy_sections' in sub.dd:
47894798
for b in sub.dd['buoyancy_sections']:

0 commit comments

Comments
 (0)