diff --git a/.buildinfo b/.buildinfo index 0d1cd27..1651d68 100644 --- a/.buildinfo +++ b/.buildinfo @@ -1,4 +1,4 @@ # Sphinx build info version 1 # This file hashes the configuration used when building these files. When it is not found, a full rebuild will be done. -config: 724438fc8258c7ea37fb6a37cf731147 +config: c49c331cc3bf202d58dda2c63b9dd08a tags: 645f666f9bcd5a90fca523b33c5a78b7 diff --git a/_autosummary/wcomp.base_interface.html b/_autosummary/wcomp.base_interface.html index 1663114..1f6e8cc 100644 --- a/_autosummary/wcomp.base_interface.html +++ b/_autosummary/wcomp.base_interface.html @@ -188,8 +188,6 @@
  • API Documentation @@ -435,14 +433,14 @@

    Contents

    Classes

    - +

    WCompBase(input_file, velocity_deficit, ...)

    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, velocity_deficit: Any, velocity_deficit_p: dict, deflection: Any | None = None, deflection_p: dict | None = None, yaw_angles: list[float] = [0.0])[source]#
    +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 @@ -450,14 +448,7 @@

    Contents

    for implementation details.

    Parameters:
    -
      -
    • input_file (str | Path) --

    • -
    • velocity_deficit (Any) --

    • -
    • velocity_deficit_p (dict) --

    • -
    • deflection (Any) --

    • -
    • deflection_p (dict) --

    • -
    • yaw_angles (list[float]) --

    • -
    +

    input_file (str | Path) --

    diff --git a/_autosummary/wcomp.floris_interface.html b/_autosummary/wcomp.floris_interface.html index 876fdeb..fa609f4 100644 --- a/_autosummary/wcomp.floris_interface.html +++ b/_autosummary/wcomp.floris_interface.html @@ -73,7 +73,7 @@ - + @@ -188,8 +188,6 @@
  • API Documentation @@ -437,24 +435,18 @@

    Contents

    Classes

    - +

    WCompFloris(input_file, velocity_deficit, ...)

    WCompFloris(input_file)

    WCompFloris implements the wcomp interface to the FLORIS software.

    -class wcomp.floris_interface.WCompFloris(input_file: str | Path, velocity_deficit: str, velocity_deficit_p: dict, deflection: str = 'none', deflection_p: dict | None = None, yaw_angles=[0.0])[source]#
    +class wcomp.floris_interface.WCompFloris(input_file: str | Path)[source]#

    WCompFloris implements the wcomp interface to the FLORIS software.

    Parameters:
    -
      -
    • input_file (str | Path) --

    • -
    • velocity_deficit (str) --

    • -
    • velocity_deficit_p (dict) --

    • -
    • deflection (str) --

    • -
    • deflection_p (dict) --

    • -
    +

    input_file (str | Path) --

    @@ -709,11 +701,11 @@

    Contents

    next

    -

    wcomp.foxes_interface

    +

    wcomp.output_struct

    diff --git a/_autosummary/wcomp.foxes_interface.html b/_autosummary/wcomp.foxes_interface.html deleted file mode 100644 index 4136e78..0000000 --- a/_autosummary/wcomp.foxes_interface.html +++ /dev/null @@ -1,1006 +0,0 @@ - - - - - - - - - - - wcomp.foxes_interface — wcomp - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    - - - - - - - - - - -
    -
    -
    -
    -
    - - - - -
    -
    - - - -
    - - - - - - - - - - - - - -
    - -
    - - - -
    - -
    -
    - -
    -
    - -
    - -
    - -
    - - -
    - -
    - -
    - - - - - - - - - - - - - - - - - - - - - - - - - - -
    - -
    - -
    -
    - - - - - - - - -
    - -
    -

    wcomp.foxes_interface#

    -

    Classes

    - - - - - - -

    WCompFoxes(input_file, velocity_deficit, ...)

    -
    -
    -class wcomp.foxes_interface.WCompFoxes(input_file: str | Path, velocity_deficit: WakeModel, velocity_deficit_p: dict, deflection=None, deflection_p: dict | None = None, yaw_angles=[0.0])[source]#
    -
    -
    Parameters:
    -
      -
    • input_file (str | Path) --

    • -
    • velocity_deficit (WakeModel) --

    • -
    • velocity_deficit_p (dict) --

    • -
    • deflection_p (dict) --

    • -
    -
    -
    -
    -
    -LINE_PLOT_COLOR = 'red'#
    -
    - -
    -
    -LINE_PLOT_MARKER = ''#
    -
    - -
    -
    -LINE_PLOT_LINESTYLE = '--'#
    -
    - -
    -
    -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)[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
    -ax = plt.gca()      # Get the current pyplot axis to place the plot
    -plot_profile(
    -    profile,
    -    ax=ax,
    -    color=self.LINE_PLOT_COLOR,
    -    marker=self.LINE_PLOT_MARKER,
    -    linestyle=self.LINE_PLOT_LINESTYLE,
    -    label=self.LEGEND
    -)
    -
    -
    -
    - -
    -
    -streamwise_profile_plot(wind_direction: float, y_coordinate: float, xmin: float, xmax: float)[source]#
    -
    -
    Parameters:
    -
      -
    • wind_direction (float) -- The wind direction to use for the visualization

    • -
    • resolution (tuple) -- The (x, y) resolution of the horizontal plane

    • -
    • y_coordinate (float) --

    • -
    • xmin (float) --

    • -
    • xmax (float) --

    • -
    -
    -
    -
    - -
    -
    -xsection_profile_plot(wind_direction: float, x_coordinate: float, ymin: float, ymax: float)[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
    -ax = plt.gca()      # Get the current pyplot axis to place the plot
    -plot_profile(
    -    profile,
    -    ax=ax,
    -    color=self.LINE_PLOT_COLOR,
    -    marker=self.LINE_PLOT_MARKER,
    -    linestyle=self.LINE_PLOT_LINESTYLE,
    -    label=self.LEGEND
    -)
    -
    -
    -
    - -
    -
    -horizontal_contour(wind_direction: float, resolution: tuple) WakePlane[source]#
    -

    This routine creates a 2D horizontal contour of all turbines in the farm. -NOTE: the get_mean_fig_xy routine requires a single resolution setting -and uses this for both directions in the plot. This is distinct from the -other interfaces where a resolution is supported for each direction -of the plot.

    -
    -
    Parameters:
    -
      -
    • wind_direction (float) --

    • -
    • resolution (tuple) --

    • -
    -
    -
    Return type:
    -

    WakePlane

    -
    -
    -
    - -
    -
    -xsection_contour(wind_direction: float, resolution: tuple, 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

    • -
    • resolution (tuple) -- Grid resolution for the contour plot; -element 0 is the resolution in y and element 1 is the resolution in z

    • -
    • 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",
    -    resolution,
    -)
    -
    -# Plot the plane
    -ax = plt.gca()      # Get the current pyplot axis to place the plot
    -plot_plane(
    -    plane,
    -    ax=ax,
    -    color=self.LINE_PLOT_COLOR,
    -    marker=self.LINE_PLOT_MARKER,
    -    linestyle=self.LINE_PLOT_LINESTYLE,
    -    label=self.LEGEND
    -)
    -
    -return plane
    -
    -
    -
    - -
    - -
    - - - - -
    - - - - - - - - -
    - - - - - - -
    -
    - - -
    - - -
    -
    -
    - - - - - -
    -
    - - \ No newline at end of file diff --git a/_autosummary/wcomp.output_struct.html b/_autosummary/wcomp.output_struct.html index ea1ea3b..aa48e4b 100644 --- a/_autosummary/wcomp.output_struct.html +++ b/_autosummary/wcomp.output_struct.html @@ -74,7 +74,7 @@ - + @@ -188,8 +188,6 @@
  • API Documentation @@ -503,12 +501,12 @@

    Contents

    previous

    -

    wcomp.pywake_interface

    +

    wcomp.floris_interface

    API Documentation diff --git a/_autosummary/wcomp.pywake_interface.html b/_autosummary/wcomp.pywake_interface.html deleted file mode 100644 index 76cb02d..0000000 --- a/_autosummary/wcomp.pywake_interface.html +++ /dev/null @@ -1,838 +0,0 @@ - - - - - - - - - - - wcomp.pywake_interface — wcomp - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    - - - - - - - - - - -
    -
    -
    -
    -
    - - - - -
    -
    - - - -
    - - - - - - - - - - - - - -
    - -
    - - - -
    - -
    -
    - -
    -
    - -
    - -
    - -
    - - -
    - -
    - -
    - - - - - - - - - - - - - - - - - - - - - - - - - - -
    - -
    - -
    -
    - - - - - - - - -
    - -
    -

    wcomp.pywake_interface#

    -

    Classes

    - - - - - - -

    WCompPyWake(input_file, velocity_deficit, ...)

    -
    -
    -class wcomp.pywake_interface.WCompPyWake(input_file: str | Path, velocity_deficit: PropagateDownwind, velocity_deficit_p: dict, deflection: DeflectionModel | None = None, deflection_p: dict | None = None, yaw_angles=[0.0])[source]#
    -
    -
    Parameters:
    -
      -
    • input_file (str | Path) --

    • -
    • velocity_deficit (PropagateDownwind) --

    • -
    • velocity_deficit_p (dict) --

    • -
    • deflection (DeflectionModel) --

    • -
    • deflection_p (dict) --

    • -
    -
    -
    -
    -
    -LINE_PLOT_COLOR = 'blue'#
    -
    - -
    -
    -LINE_PLOT_MARKER = ''#
    -
    - -
    -
    -LINE_PLOT_LINESTYLE = '--'#
    -
    - -
    -
    -LEGEND = 'PyWake'#
    -
    - -
    -
    -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()[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)[source]#
    -
    -
    Parameters:
    -
      -
    • wind_direction (float) -- The wind direction to use for the visualization

    • -
    • resolution (tuple) -- The (x, y) resolution of the horizontal plane

    • -
    • x_coordinate (float) --

    • -
    • y_coordinate (float) --

    • -
    • zmax (float) --

    • -
    -
    -
    -
    - -
    -
    -streamwise_profile_plot(wind_direction: float, y_coordinate: float, xmin: float, xmax: float)[source]#
    -
    -
    Parameters:
    -
      -
    • wind_direction (float) -- The wind direction to use for the visualization

    • -
    • resolution (tuple) -- The (x, y) resolution of the horizontal plane

    • -
    • y_coordinate (float) --

    • -
    • xmin (float) --

    • -
    • xmax (float) --

    • -
    -
    -
    -
    - -
    -
    -xsection_profile_plot(wind_direction: float, x_coordinate: float, ymin: float, ymax: float)[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
    -ax = plt.gca()      # Get the current pyplot axis to place the plot
    -plot_profile(
    -    profile,
    -    ax=ax,
    -    color=self.LINE_PLOT_COLOR,
    -    marker=self.LINE_PLOT_MARKER,
    -    linestyle=self.LINE_PLOT_LINESTYLE,
    -    label=self.LEGEND
    -)
    -
    -
    -
    - -
    -
    -horizontal_contour(wind_direction: float, resolution: tuple) WakePlane[source]#
    -
    -
    Parameters:
    -
      -
    • wind_direction (float) -- The wind direction to use for the visualization

    • -
    • resolution (tuple) -- The (x, y) resolution of the horizontal plane

    • -
    -
    -
    Return type:
    -

    WakePlane

    -
    -
    -
    - -
    -
    -xsection_contour(wind_direction: float, resolution: tuple, 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

    • -
    • resolution (tuple) -- Grid resolution for the contour plot; -element 0 is the resolution in y and element 1 is the resolution in z

    • -
    • 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",
    -    resolution,
    -)
    -
    -# Plot the plane
    -ax = plt.gca()      # Get the current pyplot axis to place the plot
    -plot_plane(
    -    plane,
    -    ax=ax,
    -    color=self.LINE_PLOT_COLOR,
    -    marker=self.LINE_PLOT_MARKER,
    -    linestyle=self.LINE_PLOT_LINESTYLE,
    -    label=self.LEGEND
    -)
    -
    -return plane
    -
    -
    -
    - -
    - -
    - - - - -
    - - - - - - - - -
    - - - - - - -
    -
    - - -
    - - -
    -
    -
    - - - - - -
    -
    - - \ No newline at end of file diff --git a/_modules/index.html b/_modules/index.html index aa11ee4..90d0221 100644 --- a/_modules/index.html +++ b/_modules/index.html @@ -189,8 +189,6 @@
  • API Documentation @@ -347,10 +345,8 @@

    All modules for which code is available

    diff --git a/_modules/wcomp/base_interface.html b/_modules/wcomp/base_interface.html index b1869c1..8959f0a 100644 --- a/_modules/wcomp/base_interface.html +++ b/_modules/wcomp/base_interface.html @@ -189,8 +189,6 @@
  • API Documentation @@ -367,16 +365,7 @@

    Source code for wcomp.base_interface

         LINE_PLOT_COLOR = "OVERWRITE"   # Color to use for all line plots; use matplotlib color codes
         LEGEND = "OVERWRITE"            # Legend entry; typically should be the name of the corresponding software
     
    -    def __init__(
    -        self,
    -        input_file: str | Path,
    -        velocity_deficit: Any,
    -        velocity_deficit_p: dict,
    -        deflection: Any = None,
    -        deflection_p: dict = None,
    -        yaw_angles: list[float] = [0.0],
    -    ):
    -        
    +    def __init__(self, input_file: str | Path):
             """
             The initialization for all subclasses must create the results from the
             corresponding software, so that they are ready for post processing in
    diff --git a/_modules/wcomp/floris_interface.html b/_modules/wcomp/floris_interface.html
    index f8b0faa..52b6b46 100644
    --- a/_modules/wcomp/floris_interface.html
    +++ b/_modules/wcomp/floris_interface.html
    @@ -189,8 +189,6 @@
     
  • API Documentation @@ -364,17 +362,67 @@

    Source code for wcomp.floris_interface

     # "windIO_model_name": {
     #   "model_ref": the current software's reference for this wake model,
     #   "parameters": {
    -#       "windIO_parameter": current software's analogous parameter
    +#       "model parameter": windIO parameter
     #   }
     # }
    -# WAKE_MODEL_MAPPING = {
    -#     "jensen": {
    -#         "model_ref": "jensen",
    -#         "parameters": {
    -#             "alpha": "we",
    -#         }
    -#     },    
    -# }
    +WAKE_MODEL_MAPPING = {
    +
    +    # Velocity models
    +    "jensen": {
    +        "model_ref": "jensen",
    +        "parameters": {
    +            "we": "alpha",
    +        }
    +    },
    +    "bastankhah2014": {     # NOT IMPLEMENTED
    +        "model_ref": None,
    +        "parameters": {}
    +    },
    +    "bastankhah2016": {
    +        "model_ref": "gauss",
    +        "parameters": {
    +            "alpha": "alpha",
    +            "beta": "beta",
    +            "ka": "k",
    +            "kb": "k",
    +        }
    +    },
    +    "turbopark": {
    +        "model_ref": "turbopark",
    +        "parameters": {
    +            "A": "A",
    +        }
    +    },
    +
    +    # Deflection model
    +    None: {
    +        "model_ref": "none",
    +        "parameters": {}
    +    },
    +    "jimenez": {
    +        "model_ref": "jimenez",
    +        "parameters": {
    +            "ad": "ad",
    +            "bd": "bd",
    +            "kd": "kd",
    +        }
    +    },
    +    "bastankhah2016_deflection": {
    +        "model_ref": "gauss",
    +        "parameters": {
    +            "ad": "ad",
    +            "bd": "bd",
    +            "alpha": "alpha",
    +            "beta": "beta",
    +            "ka": "ka",
    +            "kb": "kb",
    +        }
    +    },
    +}
    +
    +# ASSUMPTION: FLORIS has a vertical and horizontal wake expansion rate for Bastankhah 2016, but FOXES uses the same for both.
    +# This is also mentioned in the paper in section 7 Model Predictions.
    +# For simplicity in connecting the models, I'm setting FLORIS to use the same for both.
     
     basic_dict = {
         'name': 'Jensen-Jimenez',
    @@ -408,9 +456,9 @@ 

    Source code for wcomp.floris_interface

                 'turbulence_model': 'crespo_hernandez',
                 'velocity_model': 'jensen'
             },
    -        'enable_secondary_steering': True,
    -        'enable_yaw_added_recovery': True,
    -        'enable_transverse_velocities': True,
    +        'enable_secondary_steering': False,
    +        'enable_yaw_added_recovery': False,
    +        'enable_transverse_velocities': False,
             'wake_deflection_parameters': {
                 'jimenez': {
                     'ad': 0.0,
    @@ -446,26 +494,18 @@ 

    Source code for wcomp.floris_interface

         LINE_PLOT_LINESTYLE = "--"
         LEGEND = "Floris"
     
    -    def __init__(
    -        self,
    -        input_file: str | Path,
    -        velocity_deficit: str,
    -        velocity_deficit_p: dict,
    -        deflection: str = "none",
    -        deflection_p: dict = None,
    -        yaw_angles = [0.0],
    -    ):
    -        input_dictionary = load_yaml(input_file)
    +    def __init__(self, input_file: str | Path):
     
    -        self.velocity_deficit_model_string = velocity_deficit
    -        self.velocity_deficit_parameters = velocity_deficit_p
    -        self.deflection_model_string = deflection
    -        self.deflection_parameters = deflection_p
    +        input_dictionary = load_yaml(input_file)
     
             self.floris_dict = self._create_floris_dict(input_dictionary)
             self.fi = FlorisInterface(self.floris_dict)
     
    -        self.yaw_angles = np.array([[yaw_angles]])
    +        n_wind_directions = self.fi.floris.flow_field.n_wind_directions
    +        n_wind_speeds = self.fi.floris.flow_field.n_wind_speeds
    +        n_turbines = self.fi.floris.farm.n_turbines
    +        self.yaw_angles = np.zeros((n_wind_directions, n_wind_speeds, n_turbines))
    +        self.yaw_angles[:,:] = input_dictionary["attributes"]["analyses"]["yaw_angles"]
             self.fi.calculate_wake(yaw_angles=self.yaw_angles)
     
         @property
    @@ -522,29 +562,35 @@ 

    Source code for wcomp.floris_interface

                 'turbine_type': [new_turbine]
             }
     
    -        if self.deflection_parameters is not None:
    -            _deflection_parameters = {**self.deflection_parameters}
    -        else:
    -            _deflection_parameters = {}
    +        wes_analysis = wes["attributes"]["analyses"]
    +        _velocity_model_mapping = WAKE_MODEL_MAPPING[wes_analysis["wake_model"]["velocity"]["name"]]
    +        _velocity_model = _velocity_model_mapping["model_ref"]
    +        _velocity_model_parameters = {
    +            k: wes_analysis["wake_model"]["velocity"]["parameters"][v]
    +            for k, v in _velocity_model_mapping["parameters"].items()
    +        }
     
    +        _deflection_model_mapping = WAKE_MODEL_MAPPING[wes_analysis["wake_model"]["deflection"]["name"]]
    +        _deflection_model = _deflection_model_mapping["model_ref"]
    +        if _deflection_model != "none":
    +            _deflection_model_parameters = {
    +                k: wes_analysis["wake_model"]["deflection"]["parameters"][v]
    +                for k, v in _deflection_model_mapping["parameters"].items()
    +            }
    +        else:
    +            _deflection_model_parameters = {}
             new_dict['wake'] = {
                 'model_strings': {
                     'combination_model': 'sosfs',
    -                'deflection_model': self.deflection_model_string,
    +                'deflection_model': _deflection_model,
                     'turbulence_model': 'crespo_hernandez',
    -                'velocity_model': self.velocity_deficit_model_string
    +                'velocity_model': _velocity_model
                 },
                 'enable_secondary_steering': False,
                 'enable_yaw_added_recovery': False,
                 'enable_transverse_velocities': False,
    -            'wake_deflection_parameters': { 
    -                self.deflection_model_string: _deflection_parameters
    -            },
    -            'wake_velocity_parameters': {
    -                self.velocity_deficit_model_string: {
    -                    **self.velocity_deficit_parameters
    -                }
    -            },
    +            'wake_deflection_parameters': {_deflection_model: _deflection_model_parameters},
    +            'wake_velocity_parameters': {_velocity_model: _velocity_model_parameters},
                 'wake_turbulence_parameters': {
                     'crespo_hernandez': {
                         'initial': 0.1,
    diff --git a/_modules/wcomp/foxes_interface.html b/_modules/wcomp/foxes_interface.html
    deleted file mode 100644
    index 58779d8..0000000
    --- a/_modules/wcomp/foxes_interface.html
    +++ /dev/null
    @@ -1,969 +0,0 @@
    -
    -
    -
    -
    -
    -
    -  
    -    
    -    
    -    wcomp.foxes_interface — wcomp
    -  
    -  
    -  
    -  
    -  
    -  
    -  
    -
    -
    -
    -  
    -  
    -  
    -
    -
    -
    -    
    -    
    -    
    -    
    -    
    -    
    -    
    -  
    -  
    -  
    -
    -  
    -
    -    
    -    
    -    
    -    
    -    
    -    
    -    
    -    
    -    
    -    
    -    
    -    
    -    
    -    
    -    
    -    
    -    
    -    
    -    
    -    
    -    
    -    
    -    
    -    
    -  
    -  
    -  
    -  
    -  
    -  
    -
    -  
    -  
    -  
    -  
    -  
    - - - - - - - - - - -
    -
    -
    -
    -
    - - - - -
    -
    - - - - - -
    - - - - - - - - - - - - - -
    - -
    - - - -
    - -
    -
    - -
    -
    - -
    - -
    - -
    - - -
    - -
    - -
    - - - - - - - - - - - - - - - - - - - -
    - -
    - -
    -
    - - - -
    -

    - -
    -
    - -
    -
    -
    - - - - -
    - -

    Source code for wcomp.foxes_interface

    -
    -from pathlib import Path
    -
    -import matplotlib.pyplot as plt
    -import foxes.constants as FC
    -import foxes.variables as FV
    -import matplotlib.pyplot as plt
    -import numpy as np
    -import pandas as pd
    -from foxes.algorithms.downwind import Downwind
    -from foxes.core import WindFarm, WakeModel
    -from foxes.input.farm_layout import add_from_df
    -from foxes.input.states import StatesTable
    -from foxes.models.turbine_types import CpCtFromTwo
    -from foxes.output import FlowPlots2D
    -from foxes.models.model_book import ModelBook
    -# from foxes.models.wake_models.wind import JensenWake
    -
    -from windIO.utils.yml_utils import load_yaml
    -from .base_interface import WCompBase
    -from .output_struct import WakePlane, WakeProfile
    -from .plotting import plot_plane, plot_profile
    -
    -# This dictionary maps generic model names in the windIO input file
    -# to the tool's specific name. It also maps parameter names from the
    -# referenced papers to the parameters in the implementation.
    -# WAKE_MODEL_MAPPING = {
    -#     "jensen": JensenWake,
    -#     "alpha": "k"
    -# }
    -
    -
    -[docs] -class WCompFoxes(WCompBase): - - LINE_PLOT_COLOR = "red" - LINE_PLOT_MARKER = "" - LINE_PLOT_LINESTYLE = "--" - LEGEND = "Foxes" - - def __init__( - self, - input_file: str | Path, - velocity_deficit: WakeModel, - velocity_deficit_p: dict, - deflection = None, - deflection_p: dict = None, - yaw_angles = [0.0], - ): - input_dictionary = load_yaml(input_file) - - self.velocity_deficit_model = velocity_deficit - self.velocity_deficit_parameters = velocity_deficit_p - self.deflection_model = deflection - self.deflection_parameters = deflection_p - - self.mbook, self.farm, self.states, self.algo = self.read_case(input_dictionary) - self.farm_results = self.algo.calc_farm() - - @property - def rotor_diameter(self) -> float: - return self.mbook.turbine_types["windio_turbine"].D - - @property - def hub_height(self) -> float: - return self.mbook.turbine_types["windio_turbine"].H - - ### Create the model from windIO - -
    -[docs] - def read_resource(self, res, fixed_vars={}, **kwargs): - """ - 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: foxes.states.StatesTable - The uniform states - - """ - wres = res["wind_resource"] - - wd = np.array(wres["wind_direction"], dtype=FC.DTYPE) - ws = np.array(wres["wind_speed"], dtype=FC.DTYPE) - n_wd = len(wd) - n_ws = len(ws) - n = n_wd*n_ws - - data = np.zeros((n_wd, n_ws, 2), dtype=FC.DTYPE) - data[:, :, 0] = wd[:, None] - data[:, :, 1] = ws[None, :] - names = ["wind_direction", "wind_speed"] - - def _to_data(v, d, dims): - nonlocal data, names - hdata = np.zeros((n_wd, n_ws, 1), dtype=FC.DTYPE) - if len(dims) == 0: - hdata[:, :, 0] = FC.DTYPE(d) - elif len(dims) == 1: - if dims[0] == "wind_direction": - hdata[:, :, 0] = np.array(d, dtype=FC.DTYPE)[:, None] - elif dims[0] == "wind_speed": - hdata[:, :, 0] = np.array(d, dtype=FC.DTYPE)[None, :] - else: - raise ValueError(f"Unknown dimension '{dims[0]}' for data '{v}'") - elif len(dims) == 2: - if dims[0] == "wind_direction" and dims[1] == "wind_speed": - hdata[:, :, 0] = np.array(d, dtype=FC.DTYPE) - elif dims[1] == "wind_direction" and dims[0] == "wind_speed": - hdata[:, :, 0] = np.swapaxes(np.array(d, dtype=FC.DTYPE), 0, 1) - else: - raise ValueError(f"Cannot handle dims = {dims} for data '{v}'") - else: - raise ValueError(f"Can not accept more than two dimensions, got {dims} for data '{v}'") - data = np.append(data, hdata, axis=2) - names.append(v) - - vmap = { - "wind_direction": FV.WD, - "wind_speed": FV.WS, - "turbulence_intensity": FV.TI, - "air_density": FV.RHO, - "probability": FV.WEIGHT - } - - for v, d in wres.items(): - if v in vmap and isinstance(d, dict): - _to_data(v, d["data"], d["dims"]) - - n_vars = len(names) - data = data.reshape(n, n_vars) - - data = pd.DataFrame(index=range(n), data=data, columns=names) - data.index.name = "state" - data.rename(columns=vmap, inplace=True) - - ovars = {v: v for v in data.columns if v != FV.WEIGHT} - ovars.update({k: v for k, v in fixed_vars.items() if k not in data.columns}) - - return StatesTable( - data, - output_vars=ovars, - fixed_vars=fixed_vars, - **kwargs - )
    - - -
    -[docs] - def read_site(self, site, **kwargs): - """ - Reads a WindIO site - - Parameters - ---------- - site_yaml : str - Path to the yaml file - kwargs : dict, optional - Additional arguments for read_resource - - Returns - ------- - states : foxes.states.States - The states object - - """ - res_yaml = site["energy_resource"] - states = self.read_resource(res_yaml, **kwargs) - - return states
    - - -
    -[docs] - def read_farm(self, fdict, mbook=None, layout=-1, turbine_models=[], **kwargs): - """ - 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 - - """ - mbook = ModelBook() if mbook is None else mbook - - if isinstance(layout, str): - layout = fdict['layouts'][layout] - else: - lname = list(fdict['layouts'].keys())[layout] - layout = fdict['layouts'][lname] - - x = np.array(layout["coordinates"]["x"], dtype=FC.DTYPE) - y = np.array(layout["coordinates"]["y"], dtype=FC.DTYPE) - N = len(x) - ldata = pd.DataFrame(index=range(N)) - ldata.index.name = "index" - ldata["x"] = x - ldata["y"] = y - - tdict = fdict["turbines"] - pdict = tdict["performance"] - - ct_ws = np.array(pdict["Ct_curve"]["Ct_wind_speeds"], dtype=FC.DTYPE) - ct_data = pd.DataFrame(index=range(len(ct_ws))) - ct_data["ws"] = ct_ws - ct_data["ct"] = np.array(pdict["Ct_curve"]["Ct_values"], dtype=FC.DTYPE) - - cp_ws = np.array(pdict["Cp_curve"]["Cp_wind_speeds"], dtype=FC.DTYPE) - cp_data = pd.DataFrame(index=range(len(cp_ws))) - cp_data["ws"] = cp_ws - cp_data["cp"] = np.array(pdict["Cp_curve"]["Cp_values"], dtype=FC.DTYPE) - - D = float(tdict["rotor_diameter"]) - H = float(tdict["hub_height"]) - - mbook.turbine_types["windio_turbine"] = CpCtFromTwo( - cp_data, - ct_data, - col_ws_cp_file="ws", - col_cp="cp", - D=D, - H=H - ) - - models = ["windio_turbine"] + turbine_models - farm = WindFarm(name=fdict["name"]) - - add_from_df(farm, ldata, col_x="x", col_y="y", turbine_models=models, **kwargs) - - return mbook, farm
    - - -
    -[docs] - def read_analyses(self, analyses, mbook, farm, states, keymap={}, **algo_pars): - """ - 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 : foxes.core.Algorithm - The algorithm - - """ - # windIO_model_name = analyses["wake_model"]["name"] - # wmodel_class = WAKE_MODEL_MAPPING[windIO_model_name] - wmodel_class = self.velocity_deficit_model - # Extract parameters from windIO input and convert to this model's conventions - # parameters = {} - # for p in analyses["wake_model"]["parameters"]: - # parameters[WAKE_MODEL_MAPPING[p]] = analyses["wake_model"]["parameters"][p] - parameters = self.velocity_deficit_parameters - - temp_model_name = "this_model" - mbook.wake_models[temp_model_name] = wmodel_class( - **parameters, - superposition="quadratic" - ) - # mbook.print_toc(subset="wake_models") - return Downwind( - mbook, - farm, - states, - verbosity=0, - rotor_model="grid16", - wake_models=[temp_model_name], - **algo_pars - )
    - - -
    -[docs] - def read_case(self, case, site_pars={}, farm_pars={}, ana_pars={}): - """ - 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 - - """ - site_yaml = case["site"] - states = self.read_site(site_yaml, **site_pars) - - farm_yaml = case["wind_farm"] - mbook, farm = self.read_farm(farm_yaml, **farm_pars) - - attr_dict = case["attributes"] - - algo = self.read_analyses( - attr_dict["analyses"], - mbook, - farm, - states, - **ana_pars - ) - - return mbook, farm, states, algo
    - - - ### Post processing - -
    -[docs] - def AEP(self): - return self.sim_res.aep(normalize_probabilities=True).sum()
    - - - # 1D line plots - -
    -[docs] - def vertical_profile_plot( - self, - wind_direction: float, - x_coordinate: float, - y_coordinate: float, - zmax: float - ): - ax = plt.gca() - - # create points of interest, shape (n_states, n_points, 3): - n_points = 20 - points = np.zeros((1, n_points, 3)) - points[:, :, 0] = x_coordinate - points[:, :, 1] = y_coordinate - points[:, :, 2] = np.linspace(0, zmax, n_points)[None, :] - point_results = self.algo.calc_points(self.farm_results, points) - - profile = WakeProfile( - points[0, :, 2], - point_results[FV.WS][0, :], - ) - plot_profile( - profile, - ax=ax, - # direction='x', - # component='u', - color=self.LINE_PLOT_COLOR, - marker=self.LINE_PLOT_MARKER, - linestyle=self.LINE_PLOT_LINESTYLE, - label=self.LEGEND - )
    - - - -
    -[docs] - def streamwise_profile_plot( - self, - wind_direction: float, - y_coordinate: float, - xmin: float, - xmax: float - ): - """ - Args: - wind_direction (float): The wind direction to use for the visualization - resolution (tuple): The (x, y) resolution of the horizontal plane - """ - ax = plt.gca() - - # create points of interest, shape (n_states, n_points, 3): - n_points = 50 - points = np.zeros((1, n_points, 3)) - points[:, :, 0] = np.linspace(xmin, xmax, n_points)[None, :] - points[:, :, 1] = y_coordinate - points[:, :, 2] = self.hub_height - - point_results = self.algo.calc_points(self.farm_results, points) - - profile = WakeProfile( - points[0, :, 0], - point_results[FV.WS][0, :], - ) - plot_profile( - profile, - ax=ax, - # direction='x', - # component='u', - color=self.LINE_PLOT_COLOR, - marker=self.LINE_PLOT_MARKER, - linestyle=self.LINE_PLOT_LINESTYLE, - label=self.LEGEND - )
    - - -
    -[docs] - def xsection_profile_plot( - self, - wind_direction: float, - x_coordinate: float, - ymin: float, - ymax: float - ): - ax = plt.gca() - - # create points of interest, shape (n_states, n_points, 3): - n_points = 20 - points = np.zeros((1, n_points, 3)) - points[:, :, 0] = x_coordinate * np.ones((1, n_points))[None, :] - points[:, :, 1] = np.linspace(ymin, ymax, n_points)[None, :] - points[:, :, 2] = self.hub_height - - # calculate point results: - point_results = self.algo.calc_points(self.farm_results, points) - - # create figure: - profile = WakeProfile( - points[0, :, 1], - point_results[FV.WS][0, :], - ) - plot_profile( - profile, - ax=ax, - # direction='y', - # component='u', - color=self.LINE_PLOT_COLOR, - marker=self.LINE_PLOT_MARKER, - linestyle=self.LINE_PLOT_LINESTYLE, - label=self.LEGEND - )
    - - - # 2D contour plots - -
    -[docs] - def horizontal_contour( - self, - wind_direction: float, - resolution: tuple - ) -> WakePlane: - """ - This routine creates a 2D horizontal contour of all turbines in the farm. - NOTE: the `get_mean_fig_xy` routine requires a single resolution setting - and uses this for both directions in the plot. This is distinct from the - other interfaces where a resolution is supported for each direction - of the plot. - """ - - x1_bounds = (np.min(self.farm_results.X) - 2 * self.rotor_diameter, np.max(self.farm_results.X) + 10 * self.rotor_diameter) - x2_bounds = (np.min(self.farm_results.Y) - 2 * self.rotor_diameter, np.max(self.farm_results.Y) + 2 * self.rotor_diameter) - # print("foxes bounds") - # print(x1_bounds) - # print(x2_bounds) - o = FlowPlots2D(self.algo, self.farm_results) - # g = o.gen_states_fig_xy("WS", resolution=10, figsize=(10, 5), verbosity=0) - xres = (x1_bounds[1] - x1_bounds[0]) / resolution[0] - yres = (x2_bounds[1] - x2_bounds[0]) / resolution[1] - grid_points, u = o.get_mean_fig_xy( - "WS", - xmin=x1_bounds[0], - xmax=x1_bounds[1], - ymin=x2_bounds[0], - ymax=x2_bounds[1], - resolution=(xres, yres), - figsize=(10, 5) - ) - x = grid_points[:, :, 0] - y = grid_points[:, :, 1] - # z = grid_points[:, :, 2] - - plane = WakePlane( - x[0], - y[0], - u[0], - "z", - resolution, - ) - plot_plane( - plane, - ax=plt.gca(), #axarr, - # cmap='Blues_r', - # color_bar=True, - clevels=100 - ) - return plane
    - - -
    -[docs] - def xsection_contour(self, wind_direction: float, resolution: tuple, x_coordinate: float) -> WakePlane: - # TODO - pass
    -
    - -
    - -
    - - - - - - -
    - -
    -
    -
    - -
    - - - -
    - - -
    -
    - - -
    - - -
    -
    -
    - - - - - -
    -
    - - \ No newline at end of file diff --git a/_modules/wcomp/output_struct.html b/_modules/wcomp/output_struct.html index 0373761..01ef034 100644 --- a/_modules/wcomp/output_struct.html +++ b/_modules/wcomp/output_struct.html @@ -189,8 +189,6 @@
  • API Documentation @@ -356,7 +354,16 @@

    Source code for wcomp.output_struct

     class WakeProfile:
         def __init__(self, x1: np.ndarray, values: np.ndarray):
             self.x1 = x1
    -        self.values = values
    + self.values = values + + def __sub__(self, other): + if np.shape(self.x1) != np.shape(other.x1): + raise ValueError("Operands must have consistent grid shapes.") + + return WakeProfile( + self.x1, + self.values - other.values + )
  • diff --git a/_modules/wcomp/plotting.html b/_modules/wcomp/plotting.html index 5503d85..678b363 100644 --- a/_modules/wcomp/plotting.html +++ b/_modules/wcomp/plotting.html @@ -189,8 +189,6 @@
  • API Documentation diff --git a/_modules/wcomp/pywake_interface.html b/_modules/wcomp/pywake_interface.html deleted file mode 100644 index 4f0624e..0000000 --- a/_modules/wcomp/pywake_interface.html +++ /dev/null @@ -1,815 +0,0 @@ - - - - - - - - - - wcomp.pywake_interface — wcomp - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    - - - - - - - - - - -
    -
    -
    -
    -
    - - - - -
    -
    - - - - - -
    - - - - - - - - - - - - - -
    - -
    - - - -
    - -
    -
    - -
    -
    - -
    - -
    - -
    - - -
    - -
    - -
    - - - - - - - - - - - - - - - - - - - -
    - -
    - -
    -
    - - - -
    -

    - -
    -
    - -
    -
    -
    - - - - -
    - -

    Source code for wcomp.pywake_interface

    -
    -from pathlib import Path
    -
    -import matplotlib.pyplot as plt
    -import numpy as np
    -import xarray as xr
    -from py_wake import HorizontalGrid, XZGrid, YZGrid
    -from py_wake.site.xrsite import XRSite
    -from py_wake.wind_farm_models.engineering_models import EngineeringWindFarmModel
    -from py_wake.wind_turbines import WindTurbine
    -from py_wake.wind_turbines.power_ct_functions import PowerCtFunctions
    -
    -from py_wake.wind_farm_models.engineering_models import PropagateDownwind
    -# from py_wake.literature.noj import Jensen_1983
    -# from py_wake.literature.gaussian_models import Niayifar_PorteAgel_2016
    -# from py_wake.deficit_models.gaussian import BastankhahGaussianDeficit
    -from py_wake.deflection_models.deflection_model import DeflectionModel
    -
    -from windIO.utils.yml_utils import load_yaml
    -
    -from .base_interface import WCompBase
    -from .output_struct import WakePlane, WakeProfile
    -from .plotting import plot_plane, plot_profile
    -
    -# This dictionary maps generic model names in the windIO input file
    -# to the tool's specific name. It also maps parameter names from the
    -# referenced papers to the parameters in the implementation.
    -# WAKE_MODEL_MAPPING = {
    -#     "jensen": {
    -#         "model_ref": Jensen_1983,
    -#         "parameters": {
    -#             "alpha": "k",
    -#         }
    -#     },
    -#     "niayifar-porteagel": {
    -#         "model_ref": Niayifar_PorteAgel_2016,
    -#         "parameters": {
    -#             "a1": "a0",
    -#             "a2": "a1",
    -#         }
    -#     },
    -#     # "bastankhah2016": {
    -        
    -#     #     "model_ref": BastankhahGaussianDeficit,
    -#     #     "parameters": {
    -#     #         "k": "a0",
    -#     #         "a2": "a1",
    -#     #     }
    -#     #     (self, ct2a=ct2a_madsen, k=0.0324555, ceps=.2,
    -# }
    -
    -
    -[docs] -class WCompPyWake(WCompBase): - - LINE_PLOT_COLOR = "blue" - LINE_PLOT_MARKER = "" - LINE_PLOT_LINESTYLE = "--" - LEGEND = "PyWake" - - def __init__( - self, - input_file: str | Path, - velocity_deficit: PropagateDownwind, - velocity_deficit_p: dict, - deflection: DeflectionModel = None, - deflection_p: dict = None, - yaw_angles = [0.0], - ): - input_dictionary = load_yaml(input_file) - self.site, self.wt, (self.x, self.y) = self._create_pywake_data(input_dictionary) - - tilt_angles = [0.0] - - # model_map = WAKE_MODEL_MAPPING[input_dictionary["attributes"]["analyses"]["wake_model"]["name"]] - # wind_farm_model = model_map["model_ref"] - - # # Extract parameters from windIO input and convert to this model's conventions - # parameters = {} - # for p in input_dictionary["attributes"]["analyses"]["wake_model"]["parameters"]: - # parameters[model_map["parameters"]] = input_dictionary["attributes"]["analyses"]["wake_model"]["parameters"][p] - - deflection_model = None - if deflection is not None: - deflection_model = deflection(**deflection_p) - - # added_args_velocity_deficit = {} - # if velocity_deficit - - self.wfm = velocity_deficit( - site=self.site, - windTurbines=self.wt, - **velocity_deficit_p, - deflectionModel=deflection_model, - ) - self.sim_res = self.wfm( - self.x, - self.y, - wd=self.site.ds.wd.data, - yaw=yaw_angles, - tilt=tilt_angles, - ) - - @property - def rotor_diameter(self) -> float: - return self.wt.diameter() - - @property - def hub_height(self) -> float: - return self.wt.hub_height() - - ### Create the model from windIO - - def _yml2Site(self, resource): - if 'energy_resource' in resource: - resource = resource['energy_resource'] - data = resource['wind_resource'] - ds = xr.Dataset({k: (v['dims'], v['data']) for k, v in data.items() if hasattr(v, 'keys') and 'dims' in v}, - coords={k: v for k, v in data.items() if not hasattr(v, 'keys')}) - return self._xr2Site(ds) - - def _xr2Site(self, ds, interp_method='nearest') -> XRSite: - ds = ds.rename(**{k: v for k, v in [('height', 'h'), - ('wind_direction', 'wd'), - ('wind_speed', 'ws'), - ('wind_turbine', 'i'), - ('probability', 'P'), - ('weibull_a', 'Weibull_A'), - ('weibull_k', 'Weibull_k'), - ('sector_probability', 'Sector_frequency'), - ('turbulence_intensity', 'TI')] if k in ds}) - if 'ws' in ds: - return XRSite(ds, default_ws=ds.ws, interp_method=interp_method) - else: - return XRSite(ds, interp_method=interp_method) - - def _yml2WindTurbines(self, wt): - power = wt['performance'] - - if 'power_curve' in power: - raise NotImplementedError() - elif 'cp_curve' in power: - raise NotImplementedError() - else: - def power_func(ws): - return np.interp( - ws, - power['Cp_curve']['Cp_wind_speeds'], - power['Cp_curve']['Cp_values'] - ) - - def ct_func(ws): - return np.interp( - ws, - power['Ct_curve']['Ct_wind_speeds'], - power['Ct_curve']['Ct_values'] - ) - - return WindTurbine( - name=wt['name'], - diameter=wt['rotor_diameter'], - hub_height=wt['hub_height'], - powerCtFunction=PowerCtFunctions(power_func, 'w', ct_func) - ) - - def _create_pywake_data(self, wes): - wf = wes['wind_farm'] - x, y = [wf['layouts']['initial_layout']['coordinates'][xy] for xy in 'xy'] - - wt = self._yml2WindTurbines(wf['turbines']) - site = self._yml2Site(wes['site']) - return site, wt, (x, y) - - ### Post processing - -
    -[docs] - def AEP(self): - return self.sim_res.aep(normalize_probabilities=True).sum()
    - - - # 1D line plots - -
    -[docs] - def vertical_profile_plot( - self, - wind_direction: float, - x_coordinate: float, - y_coordinate: float, - zmax: float - ): - """ - Args: - wind_direction (float): The wind direction to use for the visualization - resolution (tuple): The (x, y) resolution of the horizontal plane - """ - ax = plt.gca() - - n_points = 20 - - wake_data = self.sim_res.flow_map( - XZGrid( - y=y_coordinate, - x=x_coordinate, - z=np.arange(0, zmax + 1, zmax / n_points), - ), - wd=wind_direction, - ws=None - ) - # wake_data.plot_wake_map() - - _z = wake_data.h - _u = wake_data.sel(h=_z).WS_eff - profile = WakeProfile( - _z, - _u[:,0,0,0] - ) - plot_profile( - profile, - ax=ax, - color=self.LINE_PLOT_COLOR, - marker=self.LINE_PLOT_MARKER, - linestyle=self.LINE_PLOT_LINESTYLE, - label=self.LEGEND - )
    - - -
    -[docs] - def streamwise_profile_plot( - self, - wind_direction: float, - y_coordinate: float, - xmin: float, - xmax: float - ): - """ - Args: - wind_direction (float): The wind direction to use for the visualization - resolution (tuple): The (x, y) resolution of the horizontal plane - """ - ax = plt.gca() - - n_points_x = 50 - # n_points_y = 50 - - wake_data = self.sim_res.flow_map( - XZGrid( - y=y_coordinate, - x=np.arange(xmin, xmax + 1, (xmax - xmin)/n_points_x), - z=np.arange(self.hub_height, self.hub_height+2, 1), - # resolution=100, # Points in the x direction; z points are derived from this: z = np.arange(0, (1 + self.extend) * (h_i.max() + d_i.max() / 2), np.diff(x[:2])[0]) - # resolution is not used in this case because I'm specifying x and z grids and the y location - # extend=1000 - ), - wd=wind_direction, - ws=None - ) - # wake_data.plot_wake_map() - - _x = wake_data.sel(h=self.hub_height).x - _u = wake_data.sel(h=self.hub_height).WS_eff - - profile = WakeProfile( - _x, - _u[:,0,0,0] - ) - plot_profile( - profile, - ax=ax, - # direction='x', - # component='u', - color=self.LINE_PLOT_COLOR, - marker=self.LINE_PLOT_MARKER, - linestyle=self.LINE_PLOT_LINESTYLE, - label=self.LEGEND - )
    - - -
    -[docs] - def xsection_profile_plot( - self, - wind_direction: float, - x_coordinate: float, - ymin: float, - ymax: float - ): - ax = plt.gca() - - min_bound = ymin - max_bound = ymax - n_points = 20 - wake_data = self.sim_res.flow_map( - YZGrid( - x=x_coordinate, - y=np.arange(min_bound, max_bound, (max_bound - min_bound) / n_points), - z=np.arange(self.hub_height, self.hub_height+2, 1), - ), - wd=wind_direction, - ws=None - ) - # wake_data.plot_wake_map() - - _y = wake_data.sel(h=self.hub_height).y - _u = wake_data.sel(h=self.hub_height).WS_eff - profile = WakeProfile( - _y, - _u[:,0,0,0], - ) - plot_profile( - profile, - ax=ax, - # direction='x', - # component='u', - color=self.LINE_PLOT_COLOR, - marker=self.LINE_PLOT_MARKER, - linestyle=self.LINE_PLOT_LINESTYLE, - label=self.LEGEND - )
    - - - # 2D contour plots - -
    -[docs] - def horizontal_contour(self, wind_direction: float, resolution: tuple) -> WakePlane: - """ - Args: - wind_direction (float): The wind direction to use for the visualization - resolution (tuple): The (x, y) resolution of the horizontal plane - """ - - x1_bounds = (np.min(self.sim_res.x) - 2 * self.rotor_diameter, np.max(self.sim_res.x) + 10 * self.rotor_diameter) - x2_bounds = (np.min(self.sim_res.y) - 2 * self.rotor_diameter, np.max(self.sim_res.y) + 2 * self.rotor_diameter) - - grid = HorizontalGrid( - x=np.linspace(x1_bounds[0], x1_bounds[1], int(resolution[0])), - y=np.linspace(x2_bounds[0], x2_bounds[1], int(resolution[1])), - h=self.hub_height, - ) - flow_map = self.sim_res.flow_map(wd=wind_direction, grid=grid) - # flow_map.plot_wake_map() - - plane = WakePlane( - flow_map.X.flatten(), - flow_map.Y.flatten(), - flow_map.WS_eff.to_numpy().flatten(), - "z", - resolution, - ) - plot_plane( - plane, - ax=plt.gca(), #axarr, - # cmap='Blues_r', - # color_bar=True, - clevels=100 - ) - return plane
    - - -
    -[docs] - def xsection_contour(self, wind_direction: float, resolution: tuple, x_coordinate: float) -> WakePlane: - x1_bounds = (np.min(self.sim_res.y) - 2 * self.rotor_diameter, np.max(self.sim_res.y) + 2 * self.rotor_diameter) - x2_bounds = (0.001, 6 * self.hub_height) - - grid = YZGrid( - x=x_coordinate, - y=np.linspace(x1_bounds[0], x1_bounds[1], int(resolution[0])), - z=np.linspace(x2_bounds[0], x2_bounds[1], int(resolution[1])), - ) - flow_map = self.sim_res.flow_map(wd=wind_direction, grid=grid) - # flow_map.plot_wake_map() - - x1 = flow_map.X.flatten() - x2 = flow_map.Y.flatten() - u = flow_map.WS_eff.to_numpy().flatten() - - plane = WakePlane( - x1, - x2, - u, - "x", - (resolution[0], resolution[1]), - ) - plot_plane( - plane, - ax=plt.gca(), #axarr, - # cmap='Blues_r', - # color_bar=True, - clevels=100 - ) - return plane
    -
    - -
    - -
    - - - - - - -
    - -
    -
    -
    - -
    - - - -
    - - -
    -
    - - -
    - - -
    -
    -
    - - - - - -
    -
    - - \ No newline at end of file diff --git a/_sources/_autosummary/wcomp.foxes_interface.rst b/_sources/_autosummary/wcomp.foxes_interface.rst deleted file mode 100644 index b7ffac9..0000000 --- a/_sources/_autosummary/wcomp.foxes_interface.rst +++ /dev/null @@ -1,29 +0,0 @@ -wcomp.foxes\_interface -====================== - -.. automodule:: wcomp.foxes_interface - - - - - - - - - - - - .. rubric:: Classes - - .. autosummary:: - - WCompFoxes - - - - - - - - - diff --git a/_sources/_autosummary/wcomp.pywake_interface.rst b/_sources/_autosummary/wcomp.pywake_interface.rst deleted file mode 100644 index 1e2a85d..0000000 --- a/_sources/_autosummary/wcomp.pywake_interface.rst +++ /dev/null @@ -1,29 +0,0 @@ -wcomp.pywake\_interface -======================= - -.. automodule:: wcomp.pywake_interface - - - - - - - - - - - - .. rubric:: Classes - - .. autosummary:: - - WCompPyWake - - - - - - - - - diff --git a/_sources/api_docs.md b/_sources/api_docs.md index 56079b0..911b238 100644 --- a/_sources/api_docs.md +++ b/_sources/api_docs.md @@ -7,8 +7,9 @@ wcomp.base_interface wcomp.floris_interface - wcomp.foxes_interface - wcomp.pywake_interface wcomp.output_struct wcomp.plotting -``` \ No newline at end of file +``` + +wcomp.pywake_interface +wcomp.foxes_interface diff --git a/_sources/index.md b/_sources/index.md index 34e7ea4..cc6e47c 100644 --- a/_sources/index.md +++ b/_sources/index.md @@ -46,5 +46,31 @@ classDiagram pywake_interface --> plotting ``` +# Installation + +Currently, `wcomp` must be installed manually with `pip`. The dependencies are: + +- windIO v1.0, can be installed directly from PyPI +- FLORIS v3.5, can be installed directly from PyPI but preferably locally from https://github.com/nrel/floris +- FOXES v0.5.1 plus two additional commits, must be installed from https://github.com/rafmudaf/foxes at main branch +- PyWake v2.5.0 plus two additional commits, must be installed from https://github.com/rafmudaf/PyWake at master branch + +Follow these steps to install the dependencies and `wcomp`: +1. Create a new Python environment +2. Install the dependencies: + +```bash +pip install windIO +git clone https://github.com/nrel/floris && pip install -e floris/ +git clone https://github.com/rafmudaf/foxes && pip install -e foxes/ +git clone https://github.com/rafmudaf/PyWake && pip install -e PyWake/ +``` + +3. Install `wcomp`: + +```bash +pip install wcomp +``` + # Getting started Here's how to get started diff --git a/api_docs.html b/api_docs.html index fd31f77..2b95015 100644 --- a/api_docs.html +++ b/api_docs.html @@ -188,8 +188,6 @@
  • API Documentation @@ -418,12 +416,6 @@

    API Documentation

    wcomp.floris_interface

    -

    wcomp.foxes_interface

    -

    - -

    wcomp.pywake_interface

    -

    -

    wcomp.output_struct

    @@ -432,6 +424,8 @@

    API Documentation diff --git a/architecture.html b/architecture.html index 172c971..c3db297 100644 --- a/architecture.html +++ b/architecture.html @@ -190,8 +190,6 @@
  • API Documentation @@ -472,10 +470,10 @@

    Architecture and Design

    wcomp.floris_interface

    FOXES

    -

    wcomp.foxes_interface

    +

    wcomp.foxes_interface

    PyWake

    -

    wcomp.pywake_interface

    +

    wcomp.pywake_interface

    diff --git a/genindex.html b/genindex.html index fd57a1a..85d2803 100644 --- a/genindex.html +++ b/genindex.html @@ -189,8 +189,6 @@
  • API Documentation @@ -367,10 +365,6 @@

    A

  • @@ -383,10 +377,6 @@

    H

  • @@ -395,10 +385,6 @@

    H

  • @@ -411,40 +397,20 @@

    L

  • LINE_PLOT_COLOR (wcomp.base_interface.WCompBase attribute)
  • @@ -458,14 +424,10 @@

    M

  • wcomp.base_interface
  • wcomp.floris_interface -
  • -
  • wcomp.foxes_interface
  • wcomp.output_struct
  • wcomp.plotting -
  • -
  • wcomp.pywake_interface
  • @@ -486,26 +448,10 @@

    P

    R

    - @@ -518,10 +464,6 @@

    S

    @@ -534,10 +476,6 @@

    V

    @@ -564,13 +502,6 @@

    W

    -
  • - wcomp.foxes_interface - -
  • @@ -587,22 +518,11 @@

    W

    -
  • - wcomp.pywake_interface - -
  • WCompBase (class in wcomp.base_interface)
  • WCompFloris (class in wcomp.floris_interface) -
  • -
  • WCompFoxes (class in wcomp.foxes_interface) -
  • -
  • WCompPyWake (class in wcomp.pywake_interface)
  • @@ -614,10 +534,6 @@

    X

  • @@ -626,10 +542,6 @@

    X

  • diff --git a/index.html b/index.html index c062fe5..49f65b3 100644 --- a/index.html +++ b/index.html @@ -191,8 +191,6 @@
  • API Documentation @@ -410,6 +408,7 @@

    Contents