Skip to content

Commit

Permalink
Static-dynamic EA improvement and LineProps CdAx bugfixes:
Browse files Browse the repository at this point in the history
- Added a System flag dynamic_stiffness_activated to track the state of
  the stiffness assumptions.
- Changed activateDynamicStiffness methods to only run if the system
  is currently in a static stiffness state. Otherwise calling these
  methods twice in a row would result in exagerated stiffnesses.
- Fixed a bug found by kasia129 with misnaming of CdAx and CaAx when
  loading line properties. The keys should now be consistent.
  • Loading branch information
mattEhall committed Jul 1, 2024
1 parent 6ffdc85 commit 344d229
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 21 deletions.
7 changes: 4 additions & 3 deletions moorpy/helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -714,7 +714,8 @@ def getLineProps(dnommm, material, lineProps=None, source=None, name="", rho=102

lineType = dict(name=typestring, d_vol=d_vol, m=mass, EA=EA, w=w,
MBL=MBL, EAd=EAd, EAd_Lm=EAd_Lm, input_d=d,
cost=cost, notes=notes, material=material, Cdn=Cd, Cdt=CdAx,Can=Ca,Cat=CaAx)
cost=cost, notes=notes, material=material,
Cd=Cd, CdAx=CdAx, Ca=Ca, CaAx=CaAx)

lineType.update(kwargs) # add any custom arguments provided in the call to the lineType's dictionary

Expand Down Expand Up @@ -776,9 +777,9 @@ def loadLineProps(source):
output[mat]['EAd_MBL' ] = getFromDict(props, 'EAd_MBL' , default=0.0)
output[mat]['EAd_MBL_Lm']= getFromDict(props, 'EAd_MBL_Lm',default=0.0)
output[mat]['Cd' ] = getFromDict(props, 'Cd' , default=0.0)
output[mat]['CdAx' ] = getFromDict(props, 'Cd_ax' , default=0.0)
output[mat]['Cd_ax' ] = getFromDict(props, 'Cd_ax' , default=0.0)
output[mat]['Ca' ] = getFromDict(props, 'Ca' , default=0.0)
output[mat]['CaAx' ] = getFromDict(props, 'Ca_ax' , default=0.0)
output[mat]['Ca_ax' ] = getFromDict(props, 'Ca_ax' , default=0.0)

output[mat]['MBL_0' ] = getFromDict(props, 'MBL_0' , default=0.0)
output[mat]['MBL_d' ] = getFromDict(props, 'MBL_d' , default=0.0)
Expand Down
8 changes: 4 additions & 4 deletions moorpy/line.py
Original file line number Diff line number Diff line change
Expand Up @@ -977,10 +977,10 @@ def attachLine(self, lineID, endB):


def activateDynamicStiffness(self, display=0):
'''Switch mooring line model to dynamic line stiffness
value, including potential unstretched line length
adjustment. This only works when dynamic line properties
are used.'''
'''Switch mooring line model to dynamic line stiffness value,
including potential unstretched line length adjustment, taking the
current state as the mean/static offset position to work from.
This only works when dynamic line properties are used.'''

if self.type['EAd'] > 0:
# switch to dynamic stiffness value
Expand Down
11 changes: 4 additions & 7 deletions moorpy/subsystem.py
Original file line number Diff line number Diff line change
Expand Up @@ -472,7 +472,8 @@ def setDynamicOffset(self, offset, z=0):
Optional argument z can be added for a z offset.
'''

self.activateDynamicStiffness() # use dynamic EA values
if not self.dynamic_stiffness_activated: # if not already using them,
System.activateDynamicStiffness(self) # switch to dynamic EA values

# adjust end B to the absolute offsets specified
self.rB = np.array([-self.rad_fair + offset, 0, self.z_fair+z])
Expand All @@ -486,16 +487,12 @@ def setDynamicOffset(self, offset, z=0):


def activateDynamicStiffness(self, display=0):
'''Switch mooring system model to dynamic line stiffness
values and adjust the unstretched line lengths to maintain the
same tensions. This only has an effect when dynamic line properties
are used.'''
'''Calls the dynamic stiffness method from System rather than from Line.'''
System.activateDynamicStiffness(self, display=display)


def revertToStaticStiffness(self):
'''Revert mooring system model back to the static stiffness
values and the original unstretched lenths.'''
'''Calls the static stiffness method from System rather than from Line.'''
System.revertToStaticStiffness(self)


Expand Down
20 changes: 13 additions & 7 deletions moorpy/system.py
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,7 @@ def __init__(self, file="", dirname="", rootname="", depth=0, rho=1025, g=9.81,

self.MDoptions = {} # dictionary that can hold any MoorDyn options read in from an input file, so they can be saved in a new MD file if need be

self.dynamic_stiffness_activated = False # flag turned on when dynamic EA values are activate

# read in data from an input file if a filename was provided
if len(file) > 0:
Expand Down Expand Up @@ -1046,7 +1047,7 @@ def unload(self, fileName, MDversion=2, line_dL=0, rod_dL=0, flag='p',

# Some default settings to fill in if coefficients aren't set
#lineTypeDefaults = dict(BA=-1.0, EI=0.0, Cd=1.2, Ca=1.0, CdAx=0.2, CaAx=0.0)
lineTypeDefaults = dict(BA=-1.0, cIntDamp=-0.8, EI=0.0, Can=1.0, Cat=1.0, Cdn=1.0, Cdt=0.5)
lineTypeDefaults = dict(BA=-1.0, EI=0.0, Ca=1.0, CaAx=1.0, Cd=1.0, CdAx=0.5)
rodTypeDefaults = dict(Cd=1.2, Ca=1.0, CdEnd=1.0, CaEnd=1.0)

# bodyDefaults = dict(IX=0, IY=0, IZ=0, CdA_xyz=[0,0,0], Ca_xyz=[0,0,0])
Expand Down Expand Up @@ -3045,13 +3046,16 @@ def checkTensions(self, N = None):


def activateDynamicStiffness(self, display=0):
'''Switch mooring system model to dynamic line stiffness
values and adjust the unstretched line lengths to maintain the
same tensions. This only has an effect when dynamic line properties
are used.'''
'''Switch mooring system model to dynamic line stiffness values and
adjust the unstretched line lengths to maintain the same tensions.
If dynamic stiffnesses are already activated, it does nothing.
This only has an effect when dynamic line properties are used. '''

for line in self.lineList:
line.activateDynamicStiffness(display=display)
if not self.dynamic_stiffness_activated:
for line in self.lineList:
line.activateDynamicStiffness(display=display)

self.dynamic_stiffness_activated = True


def revertToStaticStiffness(self):
Expand All @@ -3060,6 +3064,8 @@ def revertToStaticStiffness(self):

for line in self.lineList:
line.revertToStaticStiffness()

self.dynamic_stiffness_activated = False


def setBathymetry(self, x, y, depth):
Expand Down

0 comments on commit 344d229

Please sign in to comment.