Skip to content

Commit b7aa6a0

Browse files
committed
Merge remote-tracking branch 'origin/main' into new_base
2 parents 3d3a775 + d619637 commit b7aa6a0

File tree

2 files changed

+59
-19
lines changed

2 files changed

+59
-19
lines changed

famodel/helpers.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1178,7 +1178,7 @@ def adjustMooring(mooring, method = 'horizontal', r=[0,0,0], project=None, targe
11781178
mooring.z_anch = mooring.dd['zAnchor']
11791179
mooring.rad_anch = np.linalg.norm(r_anch[:2]-r[:2])
11801180
span = mooring.rad_anch - fairlead_rad
1181-
mooring.setEndPosition(r_anch, 'a') # set the anchor position
1181+
mooring.setEndPosition(r_anch, 'a', sink=True) # set the anchor position
11821182

11831183
#move anchor attachments
11841184
for i,att in enumerate(mooring.attached_to):
@@ -1222,7 +1222,6 @@ def eval_func(X, args):
12221222
mooring.span = span
12231223

12241224
elif method == 'horizontal':
1225-
12261225
def func_TH_L(X, args):
12271226
'''Apply specified section L, return the horizontal pretension error.'''
12281227
ss.lineList[i_line].setL(X[0])

famodel/project.py

Lines changed: 58 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -2222,7 +2222,8 @@ def plot2d(self, ax=None, plot_seabed=True,plot_bathymetry=True, plot_boundary=T
22222222
# >>>> TODO: Update the above to add optional inputs for bounds (vmin/vmax) on contour plot colors for bathymetry <<<<
22232223

22242224
if not bare: # Add colorbar with label
2225-
cbar = plt.colorbar(contourf, ax=ax, fraction=0.04, label='Water Depth (m)')
2225+
import matplotlib.ticker as tkr
2226+
cbar = plt.colorbar(contourf, ax=ax, fraction=0.04, label='Water Depth (m)', format=tkr.FormatStrFormatter('%.0f'))
22262227
# if plot_seabed:
22272228
# if len(self.soil_x) > 1 and len(self.soil_y) > 1:
22282229
# sX, sY = np.meshgrid(self.soil_x, self.soil_y)
@@ -4805,30 +4806,59 @@ def extractFarmInfo(self, cmax=5, fmax=10/6, Cmeander=1.9):
48054806

48064807
return wts, yaw_init
48074808

4808-
def FFarmCompatibleMDOutput(self, filename, unrotateTurbines=True, renameBody=True, removeBody=True, MDoptionsDict={}, bathymetryFile=None):
4809+
def FFarmCompatibleMDOutput(self, filename, MDoptionsDict=None, **kwargs):
48094810
'''
48104811
Function to create FFarm-compatible MoorDyn input file:
48114812
48124813
Parameters
48134814
----------
48144815
filename : str
48154816
Name of the MoorDyn output file (.dat)
4816-
unrotateTurbines: bool, optional
4817-
A flag to unrotate turbine (body) objects when passing it to MoorPy unload function [FFarm takes fairlead points in the local-unrotated reference frame]
4818-
renameBody: bool, optional
4819-
A flag to rename `Body` objects in the output MD file into `Turbine` to be compatible with FFarm.
4820-
removeBody: boo., optional
4821-
A flag to remove 'Body' objects in the Bodies list in the output MD file to be compatible with FFarm.
4822-
MDoptionsDict: dictionary, optional
4823-
MoorDyn Options. If not given, default options are considered.
4824-
'''
4825-
from moorpy.helpers import subsystem2Line
4817+
MDoptionsDict: dict, optional
4818+
MoorDyn Options. If not given, default options are considered.
4819+
**kwargs : optional
4820+
unrotateTurbines : bool
4821+
A flag to unrotate turbine (body) objects when passing it to MoorPy unload function
4822+
[FFarm takes fairlead points in the local-unrotated reference frame]
4823+
renameBody : bool
4824+
A flag to rename `Body` objects in the output MD file into `Turbine` to be compatible with FFarm.
4825+
removeBody : bool
4826+
A flag to remove 'Body' objects in the Bodies list in the output MD file to be compatible with FFarm.
4827+
outputList : dict
4828+
Output options for MoorDyn.
4829+
bathymetryFile : str
4830+
Path to bathymetry file.
4831+
flag : str
4832+
Extra flag to append to MD entries.
4833+
'''
4834+
4835+
# --- Default values ---
4836+
defaults = {
4837+
"unrotateTurbines": True,
4838+
"renameBody": True,
4839+
"removeBody": True,
4840+
"outputList": [],
4841+
"bathymetryFile": None,
4842+
"flag": "-"
4843+
}
4844+
4845+
# Merge defaults with kwargs
4846+
opts = {**defaults, **kwargs}
4847+
4848+
# Assign variables for convenience
4849+
unrotateTurbines = opts["unrotateTurbines"]
4850+
renameBody = opts["renameBody"]
4851+
removeBody = opts["removeBody"]
4852+
outputList = opts["outputList"]
4853+
bathymetryFile = opts["bathymetryFile"]
4854+
flag = opts["flag"]
4855+
4856+
if MDoptionsDict is None:
4857+
MDoptionsDict = {}
4858+
from moorpy.helpers import ss2lines
48264859

48274860
# convert SS to lines
4828-
ms_temp = deepcopy(self.ms) # copy to avoid affecting self.ms
4829-
lineCount = len(ms_temp.lineList)
4830-
for _ in range(lineCount):
4831-
subsystem2Line(ms_temp, 0)
4861+
ms_temp = ss2lines(self.ms)
48324862

48334863
# Unrotate turbines if needed
48344864
if unrotateTurbines:
@@ -4839,7 +4869,18 @@ def FFarmCompatibleMDOutput(self, filename, unrotateTurbines=True, renameBody=Tr
48394869
else:
48404870
phi = None
48414871

4842-
ms_temp.unload(fileName=filename, phi=phi, MDoptionsDict=MDoptionsDict)
4872+
# Setup nNodes of lines manually <<< TODO: Need to figure out a more automatic way of signing those numbers
4873+
for line in ms_temp.lineList:
4874+
if 0 < line.L < 20:
4875+
line.nNodes = 3
4876+
elif 20 <= line.L < 100:
4877+
line.nNodes = 6
4878+
elif 100 <= line.L < 700:
4879+
line.nNodes = 11
4880+
elif line.L >= 700:
4881+
line.nNodes = 16
4882+
4883+
ms_temp.unload(fileName=filename, phi=phi, MDoptionsDict=MDoptionsDict, outputList=outputList, flag=flag)
48434884

48444885
# rename Body to Turbine if needed
48454886
if renameBody:

0 commit comments

Comments
 (0)