Skip to content

Commit 5f2e63a

Browse files
committed
Add configureAdjuster helpers func, update project.addMooring
-- added helpers.configureAdjuster to configure a given mooring adjuster function for the specific mooring line - this will add the necessary adjuster properties to the mooring object -- altered project.addMooring to unpack an optional adjuster_settings dictionary which can contain the adjuster settings - This information is then sent to the helpers.configureAdjuster for the mooring line to save the settings as properties
1 parent 42f59a2 commit 5f2e63a

File tree

2 files changed

+74
-36
lines changed

2 files changed

+74
-36
lines changed

famodel/helpers.py

Lines changed: 61 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -833,6 +833,66 @@ def getAnchors(lineAnch, arrayAnchor, proj):
833833

834834
return(ad, mass)
835835

836+
def configureAdjuster(mooring, adjuster=None, method='horizontal',
837+
i_line=0, span=None, project=None, target=None):
838+
'''Configures adjuster function for mooring object
839+
840+
mooring : FAModel Mooring object
841+
adjuster : function, optional
842+
Function to adjust the mooring object
843+
method : str
844+
'horizontal' or 'pretension' ; method of adjusting the mooring
845+
i_line : int
846+
Line section number (0 is closest to end A) to adjust the length of
847+
span : float
848+
Horizontal distance from fairlead to anchor (or fairlead to fairlead for shared lines)
849+
project : FAModel project class
850+
Project class this mooring object is associated with. Required if adjuster function provided and
851+
target is not provided, or method=pretension
852+
target : target value(s) for method - either pretension value or horizontal force value in x and y
853+
854+
'''
855+
#calculate target pretension or horizontal tension if none provided
856+
if adjuster != None and target == None:
857+
targetdd = deepcopy(mooring.dd)
858+
if project == None:
859+
raise Exception('Project class instance needs to be provided to determine target')
860+
targetdd['zAnchor'] = project.depth
861+
mooring.createSubsystem()
862+
863+
if method == 'horizontal':
864+
mooring.target = np.linalg.norm(mooring.ss.fB_L[:2])
865+
elif method =='pretension':
866+
mooring.target = np.linalg.norm(mooring.ss.fB_L)
867+
else:
868+
raise Exception('Invalid adjustment method. Must be pretension or horizontal')
869+
else:
870+
mooring.target = target
871+
872+
if adjuster!= None:
873+
mooring.adjuster = adjuster
874+
mooring.i_line = i_line
875+
876+
# check if method is 'pretension' then save slope
877+
if method == 'pretension':
878+
879+
if project == None:
880+
raise Exception('Project class instance needs to be provided to determine slope')
881+
882+
if mooring.dd:
883+
884+
#calculate mooring slope using base depth
885+
#**** this assumes that the mooring system is designed for the base depth*****
886+
mooring.slope = project.depth / mooring.dd['span']
887+
888+
else:
889+
if span:
890+
mooring.slope = project.depth / span
891+
else:
892+
raise Exception('Span required to perform adjustment')
893+
894+
return(mooring)
895+
836896
def adjustMooring(mooring, method = 'horizontal', r=[0,0,0], project=None, target=1e6,
837897
i_line = 0, slope = 0.58 ):
838898
'''Custom function to adjust a mooring, called by
@@ -857,7 +917,7 @@ def adjustMooring(mooring, method = 'horizontal', r=[0,0,0], project=None, targe
857917
depth over span for baseline case (to match same geometric angle for 'pretension' option)
858918
859919
'''
860-
from fadesign.fadsolvers import dsolve2
920+
from moorpy.helpers import dsolve2
861921
ss = mooring.ss # shorthand for the mooring's subsystem
862922

863923
if method == 'pretension':

famodel/project.py

Lines changed: 13 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@
3434
# Import select required helper functions
3535
from famodel.helpers import (check_headings, head_adjust, getCableDD, getDynamicCables,
3636
getMoorings, getAnchors, getFromDict, cleanDataTypes,
37-
getStaticCables, getCableDesign,m2nm, loadYAML)
37+
getStaticCables, getCableDesign,m2nm, loadYAML, configureAdjuster)
3838

3939

4040
class Project():
@@ -1486,9 +1486,10 @@ def addPlatform(self,r=[0,0,0], id=None, phi=0, entity='',
14861486

14871487
def addMooring(self, id=None, endA=None, endB=None, heading=0, dd={},
14881488
section_types=[], section_lengths=[],
1489-
connectors=[], span=0, shared=0, reposition=False, adjuster=None,
1490-
method = 'horizontal', target = None, i_line = 0, subsystem=None):
1491-
1489+
connectors=[], span=0, shared=0, reposition=False, subsystem=None,
1490+
**adjuster_settings):
1491+
# adjuster=None,
1492+
# method = 'horizontal', target = None, i_line = 0,
14921493
'''
14931494
Function to create a mooring object and save in mooringList
14941495
Optionally does the following:
@@ -1567,21 +1568,6 @@ def addMooring(self, id=None, endA=None, endB=None, heading=0, dd={},
15671568
'z_fair':self.platformList[id_part[0]].zFair if id_part else 0}
15681569

15691570
mooring = Mooring(dd=dd, id=id, subsystem=subsystem) # create mooring object
1570-
1571-
#calculate target pretension or horizontal tension if none provided
1572-
if adjuster != None and target == None:
1573-
targetdd = deepcopy(mooring.dd)
1574-
targetdd['zAnchor'] = self.depth
1575-
mooring.createSubsystem()
1576-
1577-
if method == 'horizontal':
1578-
mooring.target = np.linalg.norm(mooring.ss.fB_L[:2])
1579-
elif method =='pretension':
1580-
mooring.target = np.linalg.norm(mooring.ss.fB_L)
1581-
else:
1582-
raise Exception('Invalid adjustment method. Must be pretension or horizontal')
1583-
else:
1584-
mooring.target = target
15851571

15861572
# update shared prop if needed
15871573
if len(id_part)==2 and shared<1:
@@ -1611,26 +1597,18 @@ def addMooring(self, id=None, endA=None, endB=None, heading=0, dd={},
16111597
mooring.heading = np.degrees(heading)
16121598

16131599
#add mooring adjuster if porivded
1614-
if adjuster!= None:
1615-
mooring.adjuster = adjuster
1616-
mooring.i_line = i_line
1617-
1618-
# check if method is 'pretension' then save slope
1619-
if method == 'pretension':
1620-
1621-
if dd:
1622-
1623-
#calculate mooring slope using base depth
1624-
#**** this assumes that the mooring system is designed for the base depth*****
1625-
mooring.slope = self.depth / dd['span']
1626-
1627-
else:
1628-
1629-
mooring.slope = self.depth / span
1600+
adjuster = adjuster_settings.get('adjuster',None)
1601+
method = adjuster_settings.get('method', None)
1602+
i_line = adjuster_settings.get('i_line', None)
1603+
target = adjuster_settings.get('target', None)
1604+
mooring = configureAdjuster(mooring, adjuster=adjuster, method=method,
1605+
i_line=i_line, target=target, span=span,
1606+
project=self)
16301607

16311608
self.mooringList[id] = mooring
16321609

16331610
return(mooring)
1611+
16341612

16351613

16361614
def addAnchor(self, id=None, dd=None, design=None, cost=0, atype=None, platform=None,

0 commit comments

Comments
 (0)