wcomp.base_interface#

Classes

WCompBase(input_file)

WCompBase is an abstract base class that defines the interfaces required to conform to the wcomp framework.

class wcomp.base_interface.WCompBase(input_file: str | Path)[source]#

WCompBase is an abstract base class that defines the interfaces required to conform to the wcomp framework. This class cannot be used directly. Instead, it should be used to create a subclass, and all attributes and functions described here should be implemented in the subclass. See function docstrings for implementation details.

Parameters:

input_file (str | Path)

LINE_PLOT_COLOR = 'OVERWRITE'#
LINE_PLOT_MARKER = ''#
LINE_PLOT_LINESTYLE = '--'#
LINE_PLOT_LINEWIDTH = 2#
LEGEND = 'OVERWRITE'#
N_POINTS_1D = 100#
RESOLUTION_2D = 10#
property rotor_diameter: float#

Virtual property to get the characteristic rotor diameter for use throughout the post processing and plotting functions. While every turbine may not have the same rotor diameter, one should be chosen as a reference value to set relative distances.

Raises:

NotImplementedError -- This function must be implemented in a subclass

Returns:

Characteristic rotor diameter

Return type:

float

property hub_height: float#

Virtual property to get the characteristic hub height for use throughout the post processing and plotting functions. While every turbine may not have the same hub height, one should be chosen as a reference value to set relative distances.

Raises:

NotImplementedError -- This function must be implemented in a subclass

Returns:

Characteristic hub height

Return type:

float

AEP() float[source]#

Computes the annual energy production (AEP) for the current case. This is typically implemented in the corresponding software, so it should not be computed here.

Raises:

NotImplementedError -- This function must be implemented in a subclass

Returns:

Annual energy production (AEP) for the current case in megawatts-hours (MWh).

Return type:

float

vertical_profile_plot(wind_direction: float, x_coordinate: float, y_coordinate: float, zmax: float) WakeProfile[source]#

This function produces a 1D plot of the velocity profile in the z-x plane where z is normal to the ground and x is streamwise. A sample line is produced from the ground to the height zmax at the location (x_coordinate, y_coordinate) to sample the velocities.

To implement this function, the subclass should produce a line of the u-component of velocities at the specified location and height. The {py:class}`wcomp.plotting.WakeProfile` class should be used to store the data. Then, the {py:meth}`wcomp.plotting.plot_profile` function should be used to produce the plot. A sample implementation is shown below.

Parameters:
  • wind_direction (float) -- Incoming wind direction in degrees with West at 270 degrees.

  • x_coordinate (float) -- X-coordinate of the line to sample.

  • y_coordinate (float) -- Y-coordinate of the line to sample.

  • zmax (float) -- The end-point of the sample line in the vertical direction. The line starts at the ground.

Raises:

NotImplementedError -- This function must be implemented in a subclass

Returns:

The profile of wake data

Return type:

WakeProfile

Example

# Call the wake model to produce the velocities at the sample line
u, v, w = wake_model(...)           # Note v and w are not used
x, y, z = wake_model.get_points()   # Get the coordinates of the sample points

# Create a WakeProfile object to store the data
profile = WakeProfile(z, u)

# Plot the profile
plot_profile(
    profile,
    color=self.LINE_PLOT_COLOR,
    marker=self.LINE_PLOT_MARKER,
    linestyle=self.LINE_PLOT_LINESTYLE,
    label=self.LEGEND
)

return profile
streamwise_profile_plot(wind_direction: float, y_coordinate: float, xmin: float, xmax: float) WakeProfile[source]#

This function produces a 1D plot of the velocity profile in the z-x plane where z is normal to the ground and x is streamwise. A sample line is produced from xmin to xmax at the hub height and y_coordinate to sample the velocities.

To implement this function, the subclass should produce a line of the u-component of velocities at the specified location and height. The {py:class}`wcomp.plotting.WakeProfile` class should be used to store the data. Then, the {py:meth}`wcomp.plotting.plot_profile` function should be used to produce the plot. A sample implementation is shown below.

Parameters:
  • wind_direction (float) -- Incoming wind direction in degrees with West at 270 degrees.

  • y_coordinate (float) -- Y-coordinate of the line to sample.

  • xmin (float) -- Starting point of the sample line in the streamwise direction.

  • xmax (float) -- End point of the sample line in the streamwise direction.

Raises:

NotImplementedError -- This function must be implemented in a subclass

Returns:

The profile of wake data

Return type:

WakeProfile

Example

# Call the wake model to produce the velocities at the sample line
u, v, w = wake_model(...)           # Note v and w are not used
x, y, z = wake_model.get_points()   # Get the coordinates of the sample points

# Create a WakeProfile object to store the data
profile = WakeProfile(x, u)

# Plot the profile
plot_profile(
    profile,
    color=self.LINE_PLOT_COLOR,
    marker=self.LINE_PLOT_MARKER,
    linestyle=self.LINE_PLOT_LINESTYLE,
    label=self.LEGEND
)

return profile
xsection_profile_plot(wind_direction: float, x_coordinate: float, ymin: float, ymax: float) WakeProfile[source]#

This function produces a 1D plot of the velocity profile in the y-z plane where z is normal to the ground and y is normal to z and the streamwise direction. A sample line is produced from ymin to ymax at the hub height and x_coordinate to sample the velocities.

To implement this function, the subclass should produce a line of the u-component of velocities at the specified location and height. The {py:class}`wcomp.plotting.WakeProfile` class should be used to store the data. Then, the {py:meth}`wcomp.plotting.plot_profile` function should be used to produce the plot. A sample implementation is shown below.

Parameters:
  • wind_direction (float) -- Incoming wind direction in degrees with West at 270 degrees.

  • x_coordinate (float) -- X-coordinate of the line to sample.

  • ymin (float) -- Starting point of the sample line in the lateral direction.

  • ymax (float) -- End point of the sample line in the lateral direction.

Raises:

NotImplementedError -- This function must be implemented in a subclass

Returns:

The profile of wake data

Return type:

WakeProfile

Example

# Call the wake model to produce the velocities at the sample line
u, v, w = wake_model(...)           # Note v and w are not used
x, y, z = wake_model.get_points()   # Get the coordinates of the sample points

# Create a WakeProfile object to store the data
profile = WakeProfile(y, u)

# Plot the profile
plot_profile(
    profile,
    color=self.LINE_PLOT_COLOR,
    marker=self.LINE_PLOT_MARKER,
    linestyle=self.LINE_PLOT_LINESTYLE,
    label=self.LEGEND
)

return profile
horizontal_contour(wind_direction: float) WakePlane[source]#

This function produces a contour plot of the velocity in the x-y plane where x is streamwise and y is lateral. The contour is located at the hub height. The extent of the sample plane should be:

  • x min: 2 rotor diameters upstream of the most upstream turbine

  • x max: 10 rotor diameters downstream of the most downstream turbine

  • y min,max: 2 rotor diameters outside the most lateral turbines

To implement this function, the subclass should produce a plane of the u-component of velocities with the required bounds. The {py:class}`wcomp.plotting.WakePlane` class should be used to store the data. Then, the {py:meth}`wcomp.plotting.plot_plane` function should be used to produce the plot. A sample implementation is shown below.

Parameters:

wind_direction (float) -- Incoming wind direction in degrees with West at 270 degrees.

Raises:

NotImplementedError -- This function must be implemented in a subclass

Returns:

The plane of wake data

Return type:

WakePlane

Example

# Call the wake model to produce the velocities at the sample line
u, v, w = wake_model(...)           # Note v and w are not used
x, y, z = wake_model.get_points()   # Get the coordinates of the sample points

# Create a WakePlane object to store the data
plane = WakePlane(
    x,      # If 2d array, use x.flatten()
    y,      # ^ ^ ^
    u,
    "z",
)

# Plot the plane
plot_plane(
    plane,
    color=self.LINE_PLOT_COLOR,
    marker=self.LINE_PLOT_MARKER,
    linestyle=self.LINE_PLOT_LINESTYLE,
    label=self.LEGEND
)

return plane
xsection_contour(wind_direction: float, x_coordinate: float) WakePlane[source]#

This function produces a contour plot of the velocity in the y-z plane where y is lateral and z is vertical. The contour is located in the streamwise direction at the given x_coordinate. The extent of the sample plane should be:

  • y min,max: 2 rotor diameters outside the most lateral turbines

  • z min: z=0.0

  • z max: 6 * hub height

To implement this function, the subclass should produce a plane of the u-component of velocities with the required bounds. The {py:class}`wcomp.plotting.WakePlane` class should be used to store the data. Then, the {py:meth}`wcomp.plotting.plot_plane` function should be used to produce the plot. A sample implementation is shown below.

Parameters:
  • wind_direction (float) -- Wind direction to align the plot in the visualization in degrees with West being 270 degrees and North being 0 degrees

  • x_coordinate (float) -- The streamwise location for the extracted plane

Raises:

NotImplementedError -- This function must be implemented in a subclass

Returns:

The plane of wake data

Return type:

WakePlane

Example

# Call the wake model to produce the velocities at the sample line
u, v, w = wake_model(...)           # Note v and w are not used
x, y, z = wake_model.get_points()   # Get the coordinates of the sample points

# Create a WakePlane object to store the data
plane = WakePlane(
    y,      # If 2d array, use x.flatten()
    z,      # ^ ^ ^
    u,
    "x",
)

# Plot the plane
plot_plane(
    plane,
    color=self.LINE_PLOT_COLOR,
    marker=self.LINE_PLOT_MARKER,
    linestyle=self.LINE_PLOT_LINESTYLE,
    label=self.LEGEND
)

return plane