Skip to content

Commit

Permalink
Subsystem updates for "span" consistency, "heading", plus a couple te…
Browse files Browse the repository at this point in the history
…sts updates:

- In Subsystem, "span" is now used consistently to be the horizontal
  distance from end A to end B.
- rAFair and rBFair are gone, replaced with rad_fair, z_fair , and span.
- Subsystem.Heading is now compass heading in degrees.
- Added a couple missing tests files, hopefully automated tests now pass.
  • Loading branch information
mattEhall committed Jun 6, 2024
1 parent 9e3237b commit 2f330c8
Show file tree
Hide file tree
Showing 3 changed files with 121 additions and 15 deletions.
33 changes: 18 additions & 15 deletions moorpy/subsystem.py
Original file line number Diff line number Diff line change
Expand Up @@ -90,10 +90,13 @@ def __init__(self, mooringSys=None, num=0, depth=0, rho=1025, g=9.81,
self.current = getFromDict(kwargs, 'current', shape=3)

self.shared = getFromDict(kwargs, 'shared', dtype=bool, default=False) # flag to indicate shared line
self.span = getFromDict(kwargs, 'span', default=0) # spacing (to rename as span<<<)
self.rBFair = getFromDict(kwargs, 'rBFair', shape=-1, default=[0,0,0]) # [m] end coordinates relative to attached body's ref point
self.rAFair = getFromDict(kwargs, 'rAFair', shape=-1, default=[0,0,0]) # [m] counterpart to rBFair for shared lines

self.span = getFromDict(kwargs, 'span', default=0) # horizontal end-end distance [m]
self.rad_fair = getFromDict(kwargs, 'rad_fair', default=0) # [m] fairlead radius [m]
self.z_fair = getFromDict(kwargs, 'z_fair' , default=0) # [m] fairlead z coord [m]

# the old rAFair input for the position of a second fairlead of a shaerd mooring line is gone
# currently we assume rad_fair and z_fair are same for both ends of a shared line...

# seabed bathymetry - seabedMod 0 = flat; 1 = uniform slope, 2 = grid
self.seabedMod = 0

Expand Down Expand Up @@ -188,12 +191,12 @@ def makeGeneric(self, lengths, types, connectors=[], suspended=0):

# set end A location depending on whether configuration is suspended/symmetrical
if suspended==2: # symmetrical suspended case
rA = np.array([-0.5*self.span, 0, -1]) # shared line midpiont coordinates
rA = np.array([-0.5*self.span-self.rad_fair, 0, -1]) # shared line midpoint coordinates
elif suspended==1: # general suspended case
rA = np.array([-self.span + self.rAFair[0], 0, self.rAFair[2]]) # other suspended end
else:
rA = np.array([-self.span, 0, -self.depth]) # anchor coordinates
rB = np.array([-self.rBFair[0], 0, self.rBFair[2]]) # fairlead coordinates
rA = np.array([-self.span-self.self.ss + self.rad_fair, 0, self.z_fair]) # other suspended end
else: # normal anchored line case
rA = np.array([-self.span-self.rad_fair, 0, -self.depth]) # anchor coordinates
rB = np.array([-self.rad_fair, 0, self.z_fair]) # fairlead coordinates

self.rA = rA
self.rB = rB
Expand Down Expand Up @@ -436,15 +439,15 @@ def setOffset(self, offset, z=0):
'''Moves end B of the Subsystem to represent an offset from the
undisplaced position of the endpoint. End A is set based on the
'span' (shouldn't change), and B is set based on offset and the
rBFair setting. Optional argument z can be added for a z offset.
rad_fair/z_fair setting. Optional argument z can be added for a z offset.
'''

# Use static EA values and unstretched lengths
self.revertToStaticStiffness()

# Ensure end A position and set end B position to offset values
self.rA = np.array([-self.span, 0, self.rA[2]])
self.rB = np.array([-self.rBFair[0] + offset, 0, self.rBFair[2]+z])
self.rA = np.array([-self.span-self.rad_fair, 0, self.rA[2]])
self.rB = np.array([-self.rad_fair + offset, 0, self.z_fair+z])

self.staticSolve(tol=self.eqtol) # solve the subsystem

Expand All @@ -465,14 +468,14 @@ def setDynamicOffset(self, offset, z=0):
applies dynamic amplification factors (DAFs) on the difference from
the mean tensions (which would have been calculated in getOffset).
End A is set based on the 'span' (shouldn't change),
and B is set based on offset and the rBFair setting.
and B is set based on offset and the rad_fair/z_fair setting.
Optional argument z can be added for a z offset.
'''

self.activateDynamicStiffness() # use dynamic EA values

# adjust end B to the absolute offsets specified
self.rB = np.array([-self.rBFair[0] + offset, 0, self.rBFair[2]+z])
self.rB = np.array([-self.rad_fair + offset, 0, self.z_fair+z])

self.staticSolve(tol=self.eqtol) # solve the subsystem

Expand Down Expand Up @@ -605,7 +608,7 @@ def getYawStiffness(self):

tau0 = -self.fB[0] # horizontal tension component [N]

yaw_stiff = (tau0/l)*self.rBFair[0]**2 + tau0*self.rBFair[0] # [N-m]
yaw_stiff = (tau0/l)*self.rad_fair**2 + tau0*self.rad_fair # [N-m]

return yaw_stiff

Expand Down
48 changes: 48 additions & 0 deletions tests/case7.dat
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
MoorDyn Input File
Case 7: Single catenary line attached to body to test 6DOF stifness - case b: 3Doffset
----------------------- LINE TYPES ------------------------------------------
Name Diam MassDen EA BA/-zeta EI Cd Ca CdAx CaAx
(-) (m) (kg/m) (N) (N-s/-) (-) (-) (-) (-) (-)
main 0.2 200.00 2.0E+09 -1 0 4 0.27 4 0.20
----------------------- BODIES ------------------------------------------------------
ID Attachment X0 Y0 Z0 r0 p0 y0 Mass CG* I* Volume CdA* Ca*
(#) (-) (m) (m) (m) (deg) (deg) (deg) (kg) (m) (kg-m^2) (m^3) (m^2) (-)
1 coupled 0.00 0.00 0.00 0.00 0.00 0.00 0.0 0.0 0.000e+00 0.0 0.00 0.00
---------------------- POINTS --------------------------------
Node Type X Y Z M V CdA CA
(-) (-) (m) (m) (m) (kg) (m^3) (m^2) (-)
1 Fixed 100.0 0.0 -50.0 0 0 0 0
2 Body1 5.0 3.0 -10.0 0 0 0 0
---------------------- LINES --------------------------------------
Line LineType EndA EndB UnstrLen NumSegs Flags/Outputs
(-) (-) (-) (-) (m) (-) (-)
1 main 1 2 107.00 80 pt
---------------------- SOLVER OPTIONS ---------------------------------------
50 WtrDpth
0.0002 dtM - time step to use in mooring integration (s)
3.0e6 kbot - bottom stiffness (Pa/m)
3.0e5 cbot - bottom damping (Pa-s/m)
1.0 dtIC - time interval for analyzing convergence during IC gen (s)
60.0 TmaxIC - max time for ic gen (s)
4.0 CdScaleIC - factor by which to scale drag coefficients during dynamic relaxation (-)
0.001 threshIC - threshold for IC convergence (-)
------------------------ OUTPUTS --------------------------------------------
FairTen1
AnchTen1
Con1fx
Con1fy
Con1fz
Con2fx
Con2fy
Con2fz
Con2px
Con2py
Con2pz
Body1fx
Body1fy
Body1fz
Body1mx
Body1my
Body1mz
------------------------- need this line --------------------------------------

55 changes: 55 additions & 0 deletions tests/test_line.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
# tests MoorPy Line functionality and results (work in progres)

import pytest

from numpy.testing import assert_allclose

import numpy as np
import moorpy as mp
#from moorpy.MoorProps import getLineProps
from moorpy.helpers import getLineProps

import matplotlib.pyplot as plt


inCBs = [0, 1.0, 10.0] # friction coefficients as inputs for test_seabed



def test_line_stiffness():
'''Checks stiffness of mooring lines.'''



if __name__ == '__main__':

import moorpy as mp
import matplotlib.pyplot as plt

ms = mp.System(depth=100)
ms.setLineType(100, 'chain', name='chain')

ms.addPoint(1, [1, 0, -100]) # anchor point
ms.addPoint(-1, [0, 0, 0]) # moving point

ms.addLine(99, 'chain', pointA=1, pointB=2)

ms.initialize()

fig, ax = ms.plot()

ms.solveEquilibrium()
f0 = ms.pointList[1].getForces()
print(f0)
print(ms.lineList[0].KA[1,1])

ms.pointList[1].setPosition([0,0.1,0])
ms.solveEquilibrium()
f1 = ms.pointList[1].getForces()
print(f1)
print(ms.lineList[0].KA[1,1])

ms.plot(ax=ax, color='red')

plt.show()

0 comments on commit 2f330c8

Please sign in to comment.