Skip to content

Commit 9fdc8ee

Browse files
committed
moorMod is now stored outside of ms, and a couple other tweaks:
- Moved the moorMod switch out of the MoorPy System object and into the RAFT objects to avoid burying it. - A couple adjustments for more consistent handling of cases whether a mooring section is provided in the RAFT input YAML. - This helps for a couple less typical use cases.
1 parent 5c75190 commit 9fdc8ee

File tree

2 files changed

+25
-24
lines changed

2 files changed

+25
-24
lines changed

raft/raft_fowt.py

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -164,11 +164,11 @@ def __init__(self, design, w, mpb, depth=600, x_ref=0, y_ref=0, heading_adjust=0
164164
self.body = mpb # reference to Body in mooring system corresponding to this turbine
165165

166166
# this FOWT's own MoorPy system (may not be used)
167-
if design['mooring']:
167+
if 'mooring' in design:
168168

169169
self.ms = mp.System()
170170
self.ms.parseYAML(design['mooring'])
171-
self.ms.moorMod = getFromDict(design['mooring'], 'moorMod', default=0, dtype=int)
171+
self.moorMod = getFromDict(design['mooring'], 'moorMod', default=0, dtype=int)
172172

173173
# ensure proper setup with one coupled Body tied to this FOWT
174174
if len(self.ms.bodyList) == 0:
@@ -189,6 +189,7 @@ def __init__(self, design, w, mpb, depth=600, x_ref=0, y_ref=0, heading_adjust=0
189189

190190
else:
191191
self.ms = None
192+
self.moorMod = 0
192193

193194
self.F_moor0 = np.zeros(6) # mean mooring forces in a given scenario
194195
self.C_moor = np.zeros([6,6]) # mooring stiffness matrix in a given scenario
@@ -286,9 +287,9 @@ def setPosition(self, r6):
286287
# solve the mooring system equilibrium of this FOWT's own MoorPy system
287288
if self.ms:
288289
self.ms.solveEquilibrium()
289-
if self.ms.moorMod == 0 or self.ms.moorMod == 2:
290+
if self.moorMod == 0 or self.moorMod == 2:
290291
C_moor = self.ms.getCoupledStiffnessA(lines_only=True)
291-
elif self.ms.moorMod == 1:
292+
elif self.moorMod == 1:
292293
self.ms.updateSystemDynamicMatrices()
293294
_, _, _, C_moor = self.ms.getCoupledDynamicMatrices(lines_only=True)
294295

@@ -2025,7 +2026,7 @@ def saveTurbineOutputs(self, results, case):
20252026
T_moor_std = np.zeros([2*nLines], dtype=float)
20262027
C_moor, J_moor = self.ms.getCoupledStiffness(lines_only=True, tensions=True) # get stiffness matrix and tension jacobian matrix
20272028
T_moor = self.ms.getTensions() # get line end mean tensions
2028-
if self.ms.moorMod == 0:
2029+
if self.moorMod == 0:
20292030
for ih in range(self.nWaves+1):
20302031
for iw in range(self.nw):
20312032
T_moor_amps[ih,:,iw] = np.matmul(J_moor, self.Xi[ih,:,iw]) # FFT of mooring tensions

raft/raft_model.py

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ def __init__(self, design, nTurbines=1):
102102
else:
103103
raise Exception("When using 'array_mooring', a MoorDyn-style input file must be provided as 'file'.")
104104

105-
self.ms.moorMod = getFromDict(design['array_mooring'], 'moorMod', default=0, dtype=int)
105+
self.moorMod = getFromDict(design['array_mooring'], 'moorMod', default=0, dtype=int)
106106
else:
107107
self.ms = None
108108

@@ -211,9 +211,9 @@ def analyzeUnloaded(self, ballast=0, heave_tol = 1):
211211

212212
if self.ms:
213213
try:
214-
if self.ms.moorMod == 0 or self.ms.moorMod == 2:
214+
if self.moorMod == 0 or self.moorMod == 2:
215215
C_moor = self.ms.getCoupledStiffness(lines_only=True)
216-
elif self.ms.moorMod == 1:
216+
elif self.moorMod == 1:
217217
self.ms.updateLumpedMassSystem()
218218
_, _, _, C_moor = self.ms.getCoupledDynamicMatrices(lines_only=True)
219219

@@ -224,9 +224,9 @@ def analyzeUnloaded(self, ballast=0, heave_tol = 1):
224224

225225
if self.fowtList[0].ms:
226226
try:
227-
if self.fowtList[0].ms.moorMod == 0 or self.fowtList[0].ms.moorMod == 2:
227+
if self.fowtList[0].moorMod == 0 or self.fowtList[0].moorMod == 2:
228228
C_moor = self.fowtList[0].ms.getCoupledStiffness(lines_only=True)
229-
elif self.fowtList[0].ms.moorMod == 1:
229+
elif self.fowtList[0].moorMod == 1:
230230
self.fowtList[0].ms.updateSystemDynamicMatrices()
231231
_, _, _, C_moor = self.fowtList[0].ms.getCoupledDynamicMatrices(lines_only=True)
232232

@@ -377,7 +377,7 @@ def analyzeCases(self, display=0, meshDir=os.path.join(os.getcwd(),'BEM'), RAO_p
377377
T_moor = self.ms.getTensions() # get line end mean tensions
378378

379379

380-
if self.ms.moorMod == 0:
380+
if self.moorMod == 0:
381381
for ih in range(nWaves+1):
382382
for iw in range(self.nw):
383383
T_moor_amps[ih,:,iw] = np.matmul(J_moor, self.Xi[ih,:,iw]) # FFT of mooring tensions
@@ -461,9 +461,9 @@ def solveEigen(self, display=0):
461461

462462
# include array-level mooring stiffness
463463
if self.ms:
464-
if self.ms.moorMod == 0 or self.ms.moorMod == 2:
464+
if self.moorMod == 0 or self.moorMod == 2:
465465
C_moor = self.ms.getCoupledStiffnessA(lines_only=True)
466-
elif self.ms.moorMod == 1:
466+
elif self.moorMod == 1:
467467
self.ms.updateSystemDynamicMatrices()
468468
_, _, _, C_moor = self.ms.getCoupledDynamicMatrices(lines_only=True)
469469
C_tot += C_moor
@@ -732,9 +732,9 @@ def step_func_equil(X, args, Y, oths, Ytarget, err, tol_, iter, maxIter):
732732

733733
# add array mooring system stiffness (if applicable)
734734
if self.ms:
735-
if self.ms.moorMod == 0 or self.ms.moorMod == 2:
735+
if self.moorMod == 0 or self.moorMod == 2:
736736
Kmoor = self.ms.getCoupledStiffnessA(lines_only=True)
737-
elif self.ms.moorMod == 1:
737+
elif self.moorMod == 1:
738738
self.ms.updateSystemDynamicMatrices()
739739
_, _, _, Kmoor = self.ms.getCoupledDynamicMatrices(lines_only=True)
740740

@@ -752,9 +752,9 @@ def step_func_equil(X, args, Y, oths, Ytarget, err, tol_, iter, maxIter):
752752
if fowt.ms:
753753
if fowt.ms:
754754
fowt.ms.solveEquilibrium()
755-
if fowt.ms.moorMod == 0 or fowt.ms.moorMod == 2:
755+
if fowt.moorMod == 0 or fowt.moorMod == 2:
756756
Kmoor_fowt = fowt.ms.getCoupledStiffnessA(lines_only=True)
757-
elif fowt.ms.moorMod == 1:
757+
elif fowt.moorMod == 1:
758758
fowt.ms.updateSystemDynamicMatrices()
759759
_, _, _, Kmoor_fowt = fowt.ms.getCoupledDynamicMatrices(lines_only=True)
760760
K6 += Kmoor_fowt
@@ -961,12 +961,12 @@ def solveDynamics(self, case, tol=0.01, conv_plot=0, RAO_plot=0, display=0):
961961
# We would need to pass the motions of the extremities of the mooring lines within getCoupledDynamicMatrices
962962
# I think this would be straightforward for lines connecting the fairlead to the anchor, but not sure about cases with buoys
963963
M_moor, A_moor, B_moor, C_moor = (np.zeros([6,6]) for _ in range(4))
964-
if not fowt.ms or fowt.ms.moorMod == 0:
964+
if not fowt.ms or fowt.moorMod == 0:
965965
C_moor = fowt.C_moor
966-
elif fowt.ms.moorMod == 1:
966+
elif fowt.moorMod == 1:
967967
fowt.updateMooringDynamicMatrices(XiLast, fowt.S[0,:])
968968
M_moor, A_moor, B_moor, C_moor = fowt.ms.getCoupledDynamicMatrices(lines_only=True)
969-
elif fowt.ms.moorMod == 2:
969+
elif fowt.moorMod == 2:
970970
C_moor = fowt.C_moor
971971
fowt.updateMooringDynamicMatrices(XiLast, fowt.S[0,:])
972972
M_moor, A_moor, B_moor, _ = fowt.ms.getCoupledDynamicMatrices(lines_only=True)
@@ -1007,7 +1007,7 @@ def solveDynamics(self, case, tol=0.01, conv_plot=0, RAO_plot=0, display=0):
10071007
# Recompute mooring damping matrix as it depends on body motions (linearization of drag lods). The other matrices are kept the same.
10081008
# Note: Is it worth recomputing the mooring damping matrix at each step? The impact of mooring damping on body dynamics is small, and the motion
10091009
# RAOs are probably not changing much. Perhaps compute this only once and keep it constant?
1010-
if fowt.ms and (fowt.ms.moorMod == 1 or fowt.ms.moorMod == 2):
1010+
if fowt.ms and (fowt.moorMod == 1 or fowt.moorMod == 2):
10111011
fowt.updateMooringDynamicMatrices(XiLast, fowt.S[0,:])
10121012
_, _, B_moor, _ = fowt.ms.getCoupledDynamicMatrices(lines_only=True)
10131013

@@ -1112,12 +1112,12 @@ def solveDynamics(self, case, tol=0.01, conv_plot=0, RAO_plot=0, display=0):
11121112
# include array-level mooring stiffness
11131113
if self.ms:
11141114
M_moor, A_moor, B_moor, C_moor = (np.zeros([Z_sys.shape[0], Z_sys.shape[1]]) for _ in range(4))
1115-
if self.ms.moorMod == 0:
1115+
if self.moorMod == 0:
11161116
C_moor = self.ms.getCoupledStiffnessA(lines_only=True)
1117-
elif self.ms.moorMod == 1:
1117+
elif self.moorMod == 1:
11181118
self.updateMooringDynamicMatrices(XiLast_all, self.fowtList[0].S[0,:])
11191119
M_moor, A_moor, B_moor, C_moor = self.ms.getCoupledDynamicMatrices(lines_only=True)
1120-
elif self.ms.moorMod == 2:
1120+
elif self.moorMod == 2:
11211121
self.updateMooringDynamicMatrices(XiLast_all, self.fowtList[0].S[0,:])
11221122
C_moor = self.ms.getCoupledStiffnessA(lines_only=True)
11231123
M_moor, A_moor, B_moor, _ = self.ms.getCoupledDynamicMatrices(lines_only=True)

0 commit comments

Comments
 (0)