Skip to content

Commit 3f33761

Browse files
committed
Mooring: adding self.lineProps, adjustSectionType(), and some edits
Mooring now has its own lineProps dict, which can be the default from MoorPy, a custom yaml, or lineProps passed in from higher up like Project. adjustSectionType() will be used by LineDesign etc. to adjust section material or diameter while following the lineProps scaling properties stored in Mooring. A few edits to the addCreep, addCorrosion, and the method that I accidentally renamed to adjustPropertySets... (can rerename...)
1 parent 9d492ce commit 3f33761

File tree

1 file changed

+69
-46
lines changed

1 file changed

+69
-46
lines changed

famodel/mooring/mooring.py

Lines changed: 69 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
from copy import deepcopy
55
from moorpy.subsystem import Subsystem
66
from moorpy import helpers
7+
from moorpy.helpers import loadLineProps, getLineProps, getFromDict
78
from famodel.mooring.connector import Connector, Section
89
from famodel.famodel_base import Edge, Node
910
from famodel.helpers import calc_midpoint
@@ -18,7 +19,7 @@ class Mooring(Edge):
1819
'''
1920

2021
def __init__(self, dd=None, subsystem=None, anchor=None,
21-
rho=1025, g=9.81,id=None,shared=0):
22+
rho=1025, g=9.81, id=None, shared=0, lineProps=None):
2223
'''
2324
Parameters
2425
----------
@@ -55,6 +56,9 @@ def __init__(self, dd=None, subsystem=None, anchor=None,
5556
# Design description dictionary for this Mooring
5657
self.dd = dd
5758

59+
# Load or save the mooring line property sizing function coefficients
60+
self.lineProps = loadLineProps(lineProps)
61+
5862
# MoorPy subsystem that corresponds to the mooring line
5963
self.ss = subsystem
6064
self.ss_mod = None
@@ -228,10 +232,35 @@ def setSectionType(self, lineType, i):
228232
# set type dict in dd (which is also Section/subcomponent)
229233
sec['type'] = lineType
230234

231-
if self.ss: # is Subsystem exists, adjust length there too
232-
self.ss.lineTypes[i] = lineType
235+
if self.ss: # is Subsystem exists, ensure lineType is set there too
236+
self.ss.lineTypes[i] = sec['type']
233237

234238

239+
def adjustSectionType(self, i, d_nom=None, material=None):
240+
'''Adjusts the section line Type relative by specifying a new diameter
241+
and/or material, and looking up the resulting lineType from lineProps.
242+
243+
Parameters
244+
----------
245+
d_nom : float, optional
246+
The nominal diameter to set the lineType to [mm], if provided.
247+
d_nom : string, optional
248+
The material type to set the lineType (must match a LineProps key),
249+
if provided.
250+
'''
251+
sec = self.getSubcomponent(self.i_sec[i]) # get the right section
252+
253+
if not d_nom: # if diameter not specified
254+
d_nom = 1000*sec['type']['d_nom'] # use existing value
255+
if not material: # if material not specified
256+
material = sec['type']['material'] # use existing value
257+
258+
# Apply adjusted lineType to the section
259+
sec['type'] = getLineProps(d_nom, material=material,
260+
name=i, lineProps=self.lineProps)
261+
262+
if self.ss: # is Subsystem exists, ensure lineType is set there too
263+
self.ss.lineTypes[i] = sec['type']
235264

236265

237266
def reposition(self, r_center=None, heading=None, project=None,
@@ -1098,16 +1127,16 @@ def addMarineGrowth(self, mgDict):
10981127
return(changeDepths,changePoints)
10991128

11001129

1101-
def addCorrosion(self, lineProps, design_life=28.0, corrosion_mm=None, z_lower_cutoff=None, z_upper_cutoff=None):
1130+
def addCorrosion(self, lineProps, years=25, corrosion_mm=None, z_lower_cutoff=None, z_upper_cutoff=None):
11021131
'''
11031132
Calculates MBL of chain line with corrosion included
11041133
11051134
Parameters
11061135
----------
11071136
lineProps: dict
11081137
Dictionary of line properties from MoorProps yaml
1109-
design_life: float, optional
1110-
design life in years to use with corrosion rate (default is 28 years)
1138+
years: float, optional
1139+
number of years to use with corrosion rate (default is 25 years)
11111140
corrosion_mm : float, optional
11121141
amount of corrosion in mm at splash zone/seabed (harsher environment).
11131142
If the value is not given, the corrosion rate from the lineProps dictionary will be used with a given design life.
@@ -1117,18 +1146,16 @@ def addCorrosion(self, lineProps, design_life=28.0, corrosion_mm=None, z_lower_c
11171146
upper depth cutoff for lesser corrosion to be applied (default is None, meaning no cutoff)
11181147
'''
11191148

1120-
from moorpy.helpers import getLineProps
1121-
11221149
if self.ss:
11231150
for i, line in enumerate(self.ss.lineList):
11241151
# check if the line type has a corrosion property in its MoorProps instead of checking for material name.
11251152
mat = line.type['material']
1126-
if mat not in lineProps:
1153+
if mat not in self.lineProps:
11271154
raise ValueError(f'Line material {mat} not found in lineProps dictionary.')
11281155
else:
1129-
if lineProps[mat].get('corrosion_rate', False):
1156+
if self.lineProps[mat].get('corrosion_rate', False):
11301157
if not corrosion_mm:
1131-
corrosion_mm = lineProps[mat]['corrosion_rate'] * design_life # total corrosion over design life
1158+
corrosion_mm = self.lineProps[mat]['corrosion_rate'] * years # total corrosion over design life
11321159
corrosion_m = corrosion_mm / 1000 # convert to m
11331160

11341161
if z_lower_cutoff and z_upper_cutoff:
@@ -1155,73 +1182,69 @@ def addCorrosion(self, lineProps, design_life=28.0, corrosion_mm=None, z_lower_c
11551182
# else:
11561183
# MBL_cor = sec['type']['MBL']
11571184
# sec['type']['MBL'] = MBL_cor
1158-
1159-
def addCreep(self, lineProps, design_life=28, creep_percent=None):
1185+
1186+
1187+
def addCreep(self, years=25, creep_percent=None):
11601188
'''
11611189
Elongates the polyester lines (if exists) in the mooring by a certain creep percentage
11621190
11631191
Parameters
11641192
----------
1165-
lineProps : dict
1166-
Dictionary of line properties from MoorProps yaml
1167-
design_life: float, optional
1168-
design life in years to use with creep rate (default is 28 years)
1169-
creep_percent : float, optionals
1193+
years: float, optional
1194+
How many years worth of creep to add (default is 25 years).
1195+
creep_percent : float, optional
11701196
Percentage of creep elongation to add to polyester lines.
11711197
If not given, the creep rate from the lineProps dictionary will be used with a given design life.
11721198
'''
1173-
from moorpy.helpers import getLineProps
11741199
if self.ss:
11751200
for i, line in enumerate(self.ss.lineList):
11761201
# check if the line type has a creep property in its MoorProps instead of checking for material name.
11771202
mat = line.type['material']
1178-
if mat not in lineProps:
1203+
if mat not in self.lineProps:
11791204
raise ValueError(f'Line material {mat} not found in lineProps dictionary.')
11801205
else:
1181-
if lineProps[mat].get('creep_rate', False):
1206+
if self.lineProps[mat].get('creep_rate', False):
11821207
if not creep_percent:
1183-
creep_percent = lineProps[mat]['creep_rate'] * design_life # total creep over design life
1184-
L_creep = line.L * (1 + creep_percent)
1185-
self.setSectionLength(L_creep, i)
1208+
creep_percent = lineProps[mat]['creep_rate'] * years # total creep to this point in time
1209+
L_creep = line.L * (1 + 0.01*creep_percent)
1210+
#self.setSectionLength(L_creep, i)
1211+
line.setL(L)
1212+
'''
11861213
# Change the diameter size to account for creep thinning
1187-
11881214
d_nom_creep = line.type['d_nom'] / np.sqrt(1 + creep_percent)
11891215
lineType_creep = getLineProps(d_nom_creep*1e3, mat, lineProps) # convert to mm for getLineProps
11901216
line.type = lineType_creep # update line type with new diameter [not sure if that's what we need to do.]
1217+
'''
11911218
else:
11921219
raise ValueError('Mooring subsystem must be created before adding creep.')
11931220

1194-
def switchStiffnessBounds(self, lineProps, lower=False):
1221+
1222+
def adjustPropertySets(self, suffix):
11951223
'''
1196-
Switches the line stiffnesses to either the lower or upper bounds defined in the MoorProps yaml.
1224+
Switches the line type propertes to another set as defined in the MoorProps yaml.
11971225
11981226
Parameters
11991227
----------
1200-
lineProps : dict
1201-
Dictionary of line properties from MoorProps yaml. The keys in this dictionary must include
1202-
material names with suffixes `_LB` (lower bound) or `_UB` (upper bound) to define the stiffness bounds.
1203-
These suffixes are used to distinguish between the two sets of stiffness properties.
1204-
1205-
lower : bool, optional
1206-
Whether to switch to lower bound (True) or upper bound (False). The default is False.
1228+
suffix : string
1229+
The suffix to look for in the lineProps database for every existing material type.
1230+
For example, if the suffix is "_UB", then a "polyester" line will switch to
1231+
properties defined for "polyester_UB". If that entry does not exist, the properties
1232+
are not changed. Specify "" to reset to the original properties.
12071233
'''
12081234

1209-
suffix = '_LB' if lower else '_UB'
1210-
1211-
from moorpy.helpers import getLineProps
12121235
if self.ss:
12131236
for i, line in enumerate(self.ss.lineList):
1214-
mat = line.type['material']
1215-
1216-
# Remove existing suffix if present
1217-
if mat.endswith('_LB') or mat.endswith('_UB'):
1218-
mat = mat[:-3] # Remove the last 3 characters (_LB or _UB)
1237+
# Get the original material as stored in the design dict
1238+
sec = self.getSubcomponent(self.i_sec[i])
1239+
mat = sec.type['material']
12191240

1220-
mat_suffix = mat + suffix
1241+
# Get and apply the modified properties
1242+
mat_suffix = mat + suffix # New material key to look for
12211243
if mat_suffix in lineProps:
1222-
lineType = getLineProps(line.type['d_nom']*1e3, mat_suffix, lineProps) # convert to mm for getLineProps
1223-
line.type = lineType # update line type with new stiffness
1224-
1244+
# Update the lineType properties in the Line in the MoorPy subsystem
1245+
line.type.update(getLineProps(sec.type['d_nom']*1e3, mat_suffix, self.lineProps))
1246+
1247+
12251248
def getEnvelope(self,ang_spacing=45,SFs=True):
12261249
'''Computes the motion envelope of the Mooring based on the watch
12271250
circle(s) of what it's attached to. If those aren't already

0 commit comments

Comments
 (0)