Skip to content

Commit f53324a

Browse files
committed
Added optional flag to plot the fowt with axes around it
Before this commit, RAFT fowt.plots() would zoom in the FOWT if not plotting the mooring system, which is specified by plot_ms. Now, we have an optional flag axes_around_fowt that overwrites that behaviour and lets you choose whether you want to zoom in or not. It works like this: - If the flag is not provided, fowt.plot() just like before: it zooms in the FOWT if not plotting the mooring system, it does not zoom in if plotting the mooring system. - If axes_around_fowt==True: Zoom in the FOWT regardless of plotting the mooring system or not. - If axes_around_fowt==False: Zoom in the FOWT regardless of plotting the mooring system or not. In that case, the function uses the axes limits of the ax object passed to it. Users can use MoorPy's helper function `set_axes_equal` to ensure that axes have the same aspect ratio, just like done in model.plot()
1 parent 5276534 commit f53324a

1 file changed

Lines changed: 10 additions & 3 deletions

File tree

raft/raft_fowt.py

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2744,9 +2744,16 @@ def saveTurbineOutputs(self, results, case):
27442744

27452745
def plot(self, ax, color=None, nodes=0, plot_rotor=True, station_plot=[],
27462746
airfoils=False, zorder=2, plot_fowt=True, plot_ms=True,
2747-
shadow=True, plot_frame=False, mp_args={}, frame_opts={}, plot_joints=False):
2747+
shadow=True, plot_frame=False, mp_args={}, frame_opts={}, plot_joints=False, axes_around_fowt=None):
27482748
'''plots the FOWT...'''
27492749

2750+
# Assign values to axes_around_fowt if not specified by the user
2751+
if axes_around_fowt is None:
2752+
if plot_ms:
2753+
axes_around_fowt=False # Do not zoom in on the FOWT
2754+
else:
2755+
axes_around_fowt=True # Zoom in on the FOWT
2756+
27502757
R = rotationMatrix(self.r6[3], self.r6[4], self.r6[5]) # note: eventually Rotor could handle orientation internally <<<
27512758

27522759
if plot_ms:
@@ -2787,8 +2794,8 @@ def plot(self, ax, color=None, nodes=0, plot_rotor=True, station_plot=[],
27872794
color = 'green' if joint['type'] == 'ball' else 'red'
27882795
ax.scatter(joint['r'][0], joint['r'][1], joint['r'][2], color=color, marker='o', facecolors='None')
27892796

2790-
# The code below makes the plot look nicer if plotting the FOWT without its mooring system
2791-
if not plot_ms:
2797+
# The code below makes the plot zoom into the FOWT. Useful when plotting the FOWT without its mooring system
2798+
if axes_around_fowt:
27922799
# Set equal aspect ratio
27932800
ax.set_box_aspect([1, 1, 1]) # Aspect ratio is 1:1:1
27942801

0 commit comments

Comments
 (0)