Skip to content

Commit 2b193ab

Browse files
committed
In progress update
-- updated helpers function for loading and project.loadDesign to load in subcomponents in series and parallel under the key subcomponents instead of connectors and sections lists -- updated mooring.py to collect subcomponents list from design dictionary and convert to sections and connectors objects -- updated mooring.py methods (mostly) to work with self.dd['subcomponents'] and use the edge.getSubcomponent method with i_sec and i_con to get lists of sections and connectors This is only loosely tested with basic test, likely not to work for more complex situations.
1 parent 8b86cc7 commit 2b193ab

File tree

4 files changed

+276
-160
lines changed

4 files changed

+276
-160
lines changed

famodel/helpers.py

Lines changed: 32 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -691,17 +691,15 @@ def getMoorings(lcID, lineConfigs, connectorTypes, pfID, proj):
691691
692692
Returns
693693
-------
694-
m_config : dict
695-
mooring configuration dictionary
696-
c_config : dict
697-
connector configuration dictionary
694+
dd : dict
695+
mooring design dictionary
698696
699697
'''
700698
# set up dictionary of information on the mooring configurations
701-
m_config = {'sections':[],'anchor':{},'span':{},'zAnchor':{}}#,'EndPositions':{}}
699+
dd = {'sections':[],'span':{},'zAnchor':{}}#,'EndPositions':{}}
702700
# set up connector dictionary
703701
c_config = []
704-
config = []
702+
config = [] # mooring and connector combined configuation list
705703

706704
lineLast = 1 # boolean whether item with index k-1 is a line. Set to 1 for first run through of for loop
707705
ct = 0 # counter for number of line types
@@ -719,15 +717,13 @@ def getMoorings(lcID, lineConfigs, connectorTypes, pfID, proj):
719717
lt = MooringProps(lc, proj.lineTypes, proj.rho_water, proj.g)
720718
# lt = self.lineTypes[lc['type']] # set location for code clarity and brevity later
721719
# set up sub-dictionaries that will contain info on the line type
722-
m_config['sections'].append({'type':lt})# {'name':str(ct)+'_'+lc['type'],'d_nom':lt['d_nom'],'material':lt['material'],'d_vol':lt['d_vol'],'m':lt['m'],'EA':float(lt['EA'])}})
723-
m_config['sections'][ct]['type']['name'] = str(ct)+'_'+str(lt['name'])
720+
config.append({'type':lt})# {'name':str(ct)+'_'+lc['type'],'d_nom':lt['d_nom'],'material':lt['material'],'d_vol':lt['d_vol'],'m':lt['m'],'EA':float(lt['EA'])}})
721+
config[-1]['type']['name'] = str(ct)+'_'+str(lt['name'])
724722
# make EA a float not a string
725-
m_config['sections'][ct]['type']['EA'] = float(lt['EA'])
723+
config[-1]['type']['EA'] = float(lt['EA'])
726724
# set line length
727-
m_config['sections'][ct]['L'] = lc['length']
728-
config.append(m_config['sections'][ct])
729-
# update counter for line types
730-
ct = ct + 1
725+
config[-1]['L'] = lc['length']
726+
731727
# update line last boolean
732728
lineLast = 1
733729

@@ -741,51 +737,44 @@ def getMoorings(lcID, lineConfigs, connectorTypes, pfID, proj):
741737

742738
# last item in list was a line
743739
if cID in connectorTypes:
744-
c_config.append(connectorTypes[cID]) # add connector to list
745-
c_config[-1]['type'] = cID
746-
config.append(c_config[-1])
740+
config.append(connectorTypes[cID]) # add connector to list
741+
config[-1]['type'] = cID
747742
else:
748743
# try pointProps
749744
try:
750745
props = loadPointProps(None)
751746
design = {f"num_c_{cID}":1}
752-
c_config.append(getPointProps(design, Props=props))
753-
config.append(c_config[-1])
747+
config.append(getPointProps(design, Props=props))
748+
754749
except Exception as e:
755750
raise Exception(f"Connector type {cID} not found in connector_types dictionary, and getPointProps raised the following exception:",e)
756751

757752
# update lineLast boolean
758753
lineLast = 0
759754
elif 'subsections' in lc:
760755
# TODO: LHS: ERROR CHECKING FOR ORDER OF COMPONENTS PROVIDED WITHIN SUBSECTIONS, ADD IN NEEDED CONNECTORS!!
761-
c_config.append([])
762-
m_config.append([])
756+
config.append([])
763757
sublineLast = [lineLast]*len(lc['subsections']) # to check if there was a connector provided before this
764758
for ii,sub in enumerate(lc['subsections']):
765-
c_config[-1].append([])
766-
m_config[-1].append([])
767-
config.append([])
759+
config[-1].append([])
768760
for subsub in sub:
769761
if 'connectorType' in subsub:
770762
if cID in connectorTypes:
771763
cID = subsub['connectorType']
772-
c_config[-1][-1].append(connectorTypes[cID])
773764
config[-1][-1].append(connectorTypes[cID])
774765
else:
775766
# try pointProps
776767
try:
777768
props = loadPointProps(None)
778769
design = {f"num_c_{cID}":1}
779-
c_config[-1][-1].append(getPointProps(design, Props=props))
780-
config[-1][-1].append(c_config[-1][-1])
770+
config[-1][-1].append(getPointProps(design, Props=props))
781771
except Exception as e:
782772
raise Exception(f"Connector type {cID} not found in connector_types dictionary, and getPointProps raised the following exception:",e)
783773
sublineLast[ii] = 0
784774
elif 'type' or 'mooringFamily' in subsub:
785775
lt = MooringProps(subsub)
786-
m_config[-1][-1].append({'type':lt,
776+
config[-1][-1].append({'type':lt,
787777
'L': subsub['length']})
788-
config[-1][-1].append(m_config[-1][-1])
789778
sublineLast[ii] = 1
790779
else:
791780
raise Exception(f"keys in subsection line definitions must either be 'type', 'mooringFamily', or 'connectorType'")
@@ -795,39 +784,38 @@ def getMoorings(lcID, lineConfigs, connectorTypes, pfID, proj):
795784
raise Exception(f"Please make sure that all section entries for line configuration '{lcID}' are either line sections (which must have a 'type' key), connectors (which must have a 'connectorType' key, or subsections")
796785

797786
# check if line is a shared symmetrical configuration
798-
# TODO: LHS figure out subsections with symmetrical lines... or just ban symmetrical for situations with subsections...
799787
if 'symmetric' in lineConfigs[lcID] and lineConfigs[lcID]['symmetric']:
800788
if not lineLast: # check if last item in line config list was a connector
801-
for ii in range(0,ct):
789+
for ii in range(len()):
802790
# set mooring configuration
803-
m_config['sections'].append(m_config['sections'][-1-2*ii])
791+
config.append(config[-1-2*ii])
804792
# set connector (since it's mirrored, connector B becomes connector A)
805-
c_config.append(c_config[-2-2*ii])
793+
config.append(config[-2-2*ii])
806794
else: # double the length of the end line
807-
m_config['sections'][-1]['L'] = m_config['sections'][-1]['L']*2
795+
config[-1]['L'] =config[-1]['L']*2
808796
# set connector B for line same as previous listed connector
809-
c_config.append(c_config[-1])
797+
config.append(config[-1])
810798
for ii in range(0,ct-1): # go through every line config except the last (since it was doubled already)
811799
# set mooring configuration
812-
m_config['sections'].append(m_config['sections'][-2-2*ii])
800+
config.append(config[-2-2*ii])
813801
# set connector
814-
c_config.append(c_config[-3-2*ii])
802+
config.append(config[-3-2*ii])
815803
else: # if not a symmetric line, check if last item was a line (if so need to add another empty connector)
816804
if lineLast:
817805
# add an empty connector object
818-
c_config.append({})
806+
config.append({})
819807
# set general information on the whole line (not just a section/line type)
820808
# set to general depth first (will adjust to depth at anchor location after repositioning finds new anchor location)
821-
m_config['zAnchor'] = -proj.depth
822-
m_config['span'] = lineConfigs[lcID]['span']
823-
m_config['name'] = lcID
809+
dd['subcomponents'] = config
810+
dd['zAnchor'] = -proj.depth
811+
dd['span'] = lineConfigs[lcID]['span']
812+
dd['name'] = lcID
824813
# add fairlead radius and depth to dictionary
825-
m_config['rad_fair'] = proj.platformList[pfID].rFair
826-
m_config['z_fair'] = proj.platformList[pfID].zFair
814+
dd['rad_fair'] = proj.platformList[pfID].rFair
815+
dd['z_fair'] = proj.platformList[pfID].zFair
827816

828-
m_config['connectors'] = c_config # add connectors section to the mooring dict
829817

830-
return(m_config, config) #, c_config)
818+
return(dd) #, c_config)
831819

832820

833821

0 commit comments

Comments
 (0)