wcomp.foxes_interface#

Classes

WCompFoxes(input_file)

class wcomp.foxes_interface.WCompFoxes(input_file: str | Path)[source]#
Parameters:

input_file (str | Path)

LINE_PLOT_COLOR = 'red'#
LINE_PLOT_MARKER = ''#
LINE_PLOT_LINESTYLE = '--'#
LINE_PLOT_LINEWIDTH = 2#
LEGEND = 'FOXES'#
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

read_resource(res, fixed_vars={}, **kwargs)[source]#

Reads a WindIO energy resource

Parameters:
  • res_yaml (str) -- Path to the yaml file

  • fixed_vars (dict) -- Additional fixes variables that do not occur in the yaml

  • kwargs (dict, optional) -- Additional arguments for StatesTable

Returns:

states -- The uniform states

Return type:

foxes.states.StatesTable

read_site(site, **kwargs)[source]#

Reads a WindIO site

Parameters:
  • site_yaml (str) -- Path to the yaml file

  • kwargs (dict, optional) -- Additional arguments for read_resource

Returns:

states -- The states object

Return type:

foxes.states.States

read_farm(fdict, mbook=None, layout=-1, turbine_models=[], **kwargs)[source]#

Reads a WindIO wind farm

Parameters:
  • farm_yaml (str) -- Path to the yaml file

  • mbook (foxes.ModelBook, optional) -- The model book to start from

  • layout (str or int) -- The layout choice

  • turbine_models (list of str) -- Additional turbine models

  • kwargs (dict, optional) -- Additional parameters for add_from_df()

Returns:

  • mbook (foxes.ModelBook) -- The model book

  • farm (foxes.WindFarm) -- The wind farm

read_analyses(analyses, mbook, farm, states, keymap={}, **algo_pars)[source]#

Reads a WindIO wind farm

Parameters:
  • analyses (dict) -- The analyses sub-dict of the case

  • mbook (foxes.ModelBook) -- The model book

  • farm (foxes.WindFarm) -- The wind farm

  • states (foxes.states.States) -- The states object

  • keymap (dict) -- Translation from windio to foxes keywords

  • algo_type (str) -- The default algorithm class name

  • algo_pars (dict, optional) -- Additional parameters for the algorithm constructor

Returns:

algo -- The algorithm

Return type:

foxes.core.Algorithm

read_case(case, site_pars={}, farm_pars={}, ana_pars={})[source]#

Reads a WindIO case

Parameters:
  • case_yaml (str) -- Path to the yaml file

  • site_pars (dict) -- Additional arguments for read_site

  • farm_pars (dict) -- Additional arguments for read_farm

  • ana_pars (dict) -- Additional arguments for read_analyses

Returns:

  • mbook (foxes.ModelBook) -- The model book

  • farm (foxes.WindFarm) -- The wind farm

  • states (foxes.states.States) -- The states object

  • algo (foxes.core.Algorithm) -- The algorithm

AEP()[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