Skip to content

Commit d619637

Browse files
author
Rudy Alkarem
committed
updating FFarm CompatibleMDOutput:
1) Passing important settings into the unload function in moorpy to generate a moordyn file with some custom output options. 2) Depending on the lenght of the line, the function will choose an appropriate number of segments for that line
1 parent 87cd300 commit d619637

File tree

1 file changed

+56
-16
lines changed

1 file changed

+56
-16
lines changed

famodel/project.py

Lines changed: 56 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -4334,30 +4334,59 @@ def extractFarmInfo(self, cmax=5, fmax=10/6, Cmeander=1.9):
43344334

43354335
return wts, yaw_init
43364336

4337-
def FFarmCompatibleMDOutput(self, filename, unrotateTurbines=True, renameBody=True, removeBody=True, MDoptionsDict={}, bathymetryFile=None):
4337+
def FFarmCompatibleMDOutput(self, filename, MDoptionsDict=None, **kwargs):
43384338
'''
43394339
Function to create FFarm-compatible MoorDyn input file:
43404340
43414341
Parameters
43424342
----------
43434343
filename : str
43444344
Name of the MoorDyn output file (.dat)
4345-
unrotateTurbines: bool, optional
4346-
A flag to unrotate turbine (body) objects when passing it to MoorPy unload function [FFarm takes fairlead points in the local-unrotated reference frame]
4347-
renameBody: bool, optional
4348-
A flag to rename `Body` objects in the output MD file into `Turbine` to be compatible with FFarm.
4349-
removeBody: boo., optional
4350-
A flag to remove 'Body' objects in the Bodies list in the output MD file to be compatible with FFarm.
4351-
MDoptionsDict: dictionary, optional
4352-
MoorDyn Options. If not given, default options are considered.
4353-
'''
4354-
from moorpy.helpers import subsystem2Line
4345+
MDoptionsDict: dict, optional
4346+
MoorDyn Options. If not given, default options are considered.
4347+
**kwargs : optional
4348+
unrotateTurbines : bool
4349+
A flag to unrotate turbine (body) objects when passing it to MoorPy unload function
4350+
[FFarm takes fairlead points in the local-unrotated reference frame]
4351+
renameBody : bool
4352+
A flag to rename `Body` objects in the output MD file into `Turbine` to be compatible with FFarm.
4353+
removeBody : bool
4354+
A flag to remove 'Body' objects in the Bodies list in the output MD file to be compatible with FFarm.
4355+
outputList : dict
4356+
Output options for MoorDyn.
4357+
bathymetryFile : str
4358+
Path to bathymetry file.
4359+
flag : str
4360+
Extra flag to append to MD entries.
4361+
'''
4362+
4363+
# --- Default values ---
4364+
defaults = {
4365+
"unrotateTurbines": True,
4366+
"renameBody": True,
4367+
"removeBody": True,
4368+
"outputList": [],
4369+
"bathymetryFile": None,
4370+
"flag": "-"
4371+
}
4372+
4373+
# Merge defaults with kwargs
4374+
opts = {**defaults, **kwargs}
4375+
4376+
# Assign variables for convenience
4377+
unrotateTurbines = opts["unrotateTurbines"]
4378+
renameBody = opts["renameBody"]
4379+
removeBody = opts["removeBody"]
4380+
outputList = opts["outputList"]
4381+
bathymetryFile = opts["bathymetryFile"]
4382+
flag = opts["flag"]
4383+
4384+
if MDoptionsDict is None:
4385+
MDoptionsDict = {}
4386+
from moorpy.helpers import ss2lines
43554387

43564388
# convert SS to lines
4357-
ms_temp = deepcopy(self.ms) # copy to avoid affecting self.ms
4358-
lineCount = len(ms_temp.lineList)
4359-
for _ in range(lineCount):
4360-
subsystem2Line(ms_temp, 0)
4389+
ms_temp = ss2lines(self.ms)
43614390

43624391
# Unrotate turbines if needed
43634392
if unrotateTurbines:
@@ -4368,7 +4397,18 @@ def FFarmCompatibleMDOutput(self, filename, unrotateTurbines=True, renameBody=Tr
43684397
else:
43694398
phi = None
43704399

4371-
ms_temp.unload(fileName=filename, phi=phi, MDoptionsDict=MDoptionsDict)
4400+
# Setup nNodes of lines manually <<< TODO: Need to figure out a more automatic way of signing those numbers
4401+
for line in ms_temp.lineList:
4402+
if 0 < line.L < 20:
4403+
line.nNodes = 3
4404+
elif 20 <= line.L < 100:
4405+
line.nNodes = 6
4406+
elif 100 <= line.L < 700:
4407+
line.nNodes = 11
4408+
elif line.L >= 700:
4409+
line.nNodes = 16
4410+
4411+
ms_temp.unload(fileName=filename, phi=phi, MDoptionsDict=MDoptionsDict, outputList=outputList, flag=flag)
43724412

43734413
# rename Body to Turbine if needed
43744414
if renameBody:

0 commit comments

Comments
 (0)