Initial Commit + Hardcode Example

This commit is contained in:
shadowik 2024-10-14 17:54:58 +04:00
parent 9aae3dec59
commit d36adf55f1
3 changed files with 327 additions and 0 deletions

View File

244
floris_module/src/gch.yaml Normal file
View File

@ -0,0 +1,244 @@
###
# A name for this input file.
# This is not currently only for the user's reference.
name: GCH
###
# A description of the contents of this input file.
# This is not currently only for the user's reference.
description: Three turbines using Gauss Curl Hybrid model
###
# The earliest verion of FLORIS this input file supports.
# This is not currently only for the user's reference.
floris_version: v4
###
# Configure the logging level and where to show the logs.
logging:
###
# Settings for logging to the console (i.e. terminal).
console:
###
# Can be "true" or "false".
enable: true
###
# Set the severity to show output. Messages at this level or higher will be shown.
# Can be one of "CRITICAL", "ERROR", "WARNING", "INFO", "DEBUG".
level: WARNING
###
# Settings for logging to a file.
file:
###
# Can be "true" or "false".
enable: false
###
# Set the severity to show output. Messages at this level or higher will be shown.
# Can be one of "CRITICAL", "ERROR", "WARNING", "INFO", "DEBUG".
level: WARNING
###
# Configure the solver for the type of simulation.
solver:
###
# Select the solver type.
# Can be one of: "turbine_grid", "flow_field_grid", "flow_field_planar_grid".
type: turbine_grid
###
# Options for the turbine type selected above. See the solver documentation for available parameters.
turbine_grid_points: 3
###
# Configure the turbine types and their placement within the wind farm.
farm:
###
# Coordinates for the turbine locations in the x-direction which is typically considered
# to be the streamwise direction (left, right) when the wind is out of the west.
# The order of the coordinates here corresponds to the index of the turbine in the primary
# data structures.
layout_x:
- 0.0
- 630.0
- 1260.0
###
# Coordinates for the turbine locations in the y-direction which is typically considered
# to be the spanwise direction (up, down) when the wind is out of the west.
# The order of the coordinates here corresponds to the index of the turbine in the primary
# data structures.
layout_y:
- 0.0
- 0.0
- 0.0
###
# Listing of turbine types for placement at the x and y coordinates given above.
# The list length must be 1 or the same as ``layout_x`` and ``layout_y``. If it is a
# single value, all turbines are of the same type. Otherwise, the turbine type
# is mapped to the location at the same index in ``layout_x`` and ``layout_y``.
# The types can be either a name included in the turbine_library or
# a full definition of a wind turbine directly.
turbine_type:
- nrel_5MW
###
# Configure the atmospheric conditions.
flow_field:
###
# Air density.
air_density: 1.225
###
# The height to consider the "center" of the vertical wind speed profile
# due to shear. With a shear exponent not 1, the wind speed at this height
# will be the value given in ``wind_speeds``. Above and below this height,
# the wind speed will change according to the shear profile; see
# :py:meth:`.FlowField.initialize_velocity_field`.
# For farms consisting of one wind turbine type, use ``reference_wind_height: -1``
# to use the hub height of the wind turbine definition. For multiple wind turbine
# types, the reference wind height must be given explicitly.
reference_wind_height: -1
###
# The turbulence intensities to include in the simulation, specified as a decimal.
turbulence_intensities:
- 0.06
###
# The wind directions to include in the simulation.
# 0 is north and 270 is west.
wind_directions:
- 270.0
###
# The exponent used to model the wind shear profile; see
# :py:meth:`.FlowField.initialize_velocity_field`.
wind_shear: 0.12
###
# The wind speeds to include in the simulation.
wind_speeds:
- 8.0
###
# The wind veer as a constant value for all points in the grid.
wind_veer: 0.0
###
# The conditions that are specified for use with the multi-dimensional Cp/Ct capbility.
# These conditions are external to FLORIS and specified by the user. They are used internally
# through a nearest-neighbor selection process to choose the correct Cp/Ct interpolants
# to use.
multidim_conditions:
Tp: 2.5
Hs: 3.01
###
# Configure the wake model.
wake:
###
# Select the models to use for the simulation.
# See :py:mod:`~.wake` for a list
# of available models and their descriptions.
model_strings:
###
# Select the wake combination model.
combination_model: sosfs
###
# Select the wake deflection model.
deflection_model: gauss
###
# Select the wake turbulence model.
turbulence_model: crespo_hernandez
###
# Select the wake velocity deficit model.
velocity_model: gauss
###
# Can be "true" or "false".
enable_secondary_steering: true
###
# Can be "true" or "false".
enable_yaw_added_recovery: true
###
# Can be "true" or "false".
enable_active_wake_mixing: false
###
# Can be "true" or "false".
enable_transverse_velocities: true
###
# Configure the parameters for the wake deflection model
# selected above.
# Additional blocks can be provided for
# models that are not enabled, but the enabled model
# must have a corresponding parameter block.
wake_deflection_parameters:
gauss:
ad: 0.0
alpha: 0.58
bd: 0.0
beta: 0.077
dm: 1.0
ka: 0.38
kb: 0.004
jimenez:
ad: 0.0
bd: 0.0
kd: 0.05
###
# Configure the parameters for the wake velocity deficit model
# selected above.
# Additional blocks can be provided for
# models that are not enabled, but the enabled model
# must have a corresponding parameter block.
wake_velocity_parameters:
cc:
a_s: 0.179367259
b_s: 0.0118889215
c_s1: 0.0563691592
c_s2: 0.13290157
a_f: 3.11
b_f: -0.68
c_f: 2.41
alpha_mod: 1.0
gauss:
alpha: 0.58
beta: 0.077
ka: 0.38
kb: 0.004
jensen:
we: 0.05
###
# Configure the parameters for the wake turbulence model
# selected above.
# Additional blocks can be provided for
# models that are not enabled, but the enabled model
# must have a corresponding parameter block.
wake_turbulence_parameters:
crespo_hernandez:
initial: 0.1
constant: 0.5
ai: 0.8
downstream: -0.32

83
floris_module/src/main.py Normal file
View File

@ -0,0 +1,83 @@
import matplotlib.pyplot as plt
import numpy as np
import floris.layout_visualization as layoutviz
from floris import FlorisModel
from floris.flow_visualization import visualize_cut_plane
# Create the plotting objects using matplotlib
fig, axarr = plt.subplots(3, 3, figsize=(16, 10), sharex=False)
axarr = axarr.flatten()
MIN_WS = 1.0
MAX_WS = 8.0
# Initialize FLORIS with the given input file.
fmodel = FlorisModel("./gch.yaml")
# Change to 5-turbine layout with a wind direction from northwest
fmodel.set(
layout_x=[0, 0, 1000, 1000, 1000], layout_y=[0, 500, 0, 500, 1000], wind_directions=[300]
)
# Plot 1: Visualize the flow
ax = axarr[0]
# Plot a horizatonal slice of the initial configuration
horizontal_plane = fmodel.calculate_horizontal_plane(height=90.0)
visualize_cut_plane(
horizontal_plane,
ax=ax,
min_speed=MIN_WS,
max_speed=MAX_WS,
)
# Plot the turbine points, setting the color to white
layoutviz.plot_turbine_points(fmodel, ax=ax, plotting_dict={"color": "w"})
ax.set_title("Flow visualization and turbine points")
# Plot 2: Show a particular flow case
ax = axarr[1]
turbine_names = [f"T{i}" for i in [10, 11, 12, 13, 22]]
layoutviz.plot_turbine_points(fmodel, ax=ax)
layoutviz.plot_turbine_labels(
fmodel, ax=ax, turbine_names=turbine_names, show_bbox=True, bbox_dict={"facecolor": "r"}
)
ax.set_title("Show turbine names with a red bounding box")
# Plot 2: Show turbine rotors on flow
ax = axarr[2]
fmodel.set(yaw_angles=np.array([[0., 30., 0., 0., 0.]]))
horizontal_plane = fmodel.calculate_horizontal_plane(height=90.0)
visualize_cut_plane(horizontal_plane, ax=ax, min_speed=MIN_WS, max_speed=MAX_WS)
layoutviz.plot_turbine_rotors(fmodel, ax=ax, yaw_angles=np.array([[0.0, 30.0, 0.0, 0.0, 0.0]]))
ax.set_title("Flow visualization with yawed turbine")
# Plot 3: Show the layout, including wake directions
ax = axarr[3]
layoutviz.plot_turbine_points(fmodel, ax=ax)
layoutviz.plot_turbine_labels(fmodel, ax=ax, turbine_names=turbine_names)
layoutviz.plot_waking_directions(fmodel, ax=ax)
ax.set_title("Show turbine names and wake direction")
# Plot 4: Plot a subset of the layout, and limit directions less than 7D
ax = axarr[4]
layoutviz.plot_turbine_points(fmodel, ax=ax, turbine_indices=[0, 1, 2, 3])
layoutviz.plot_turbine_labels(
fmodel, ax=ax, turbine_names=turbine_names, turbine_indices=[0, 1, 2, 3]
)
layoutviz.plot_waking_directions(fmodel, ax=ax, turbine_indices=[0, 1, 2, 3], limit_dist_D=7)
ax.set_title("Plot a subset and limit wake line distance")
# Plot with a shaded region
ax = axarr[5]
layoutviz.plot_turbine_points(fmodel, ax=ax)
layoutviz.shade_region(np.array([[0, 0], [300, 0], [300, 1000], [0, 700]]), ax=ax)
ax.set_title("Plot with a shaded region")
# Change hub heights and plot as a proxy for terrain
ax = axarr[6]
fmodel.core.farm.hub_heights = np.array([110, 90, 100, 100, 95])
layoutviz.plot_farm_terrain(fmodel, ax=ax)
plt.show()