How to use FLORIS - 10 common examples

To help you get started, we’ve selected a few FLORIS examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github NREL / floris / examples / test_gauss_m / example_0000_compare_gauss_models.py View on Github external
else:
    df_power_ti = df_power_full[df_power_full.TI < 0.07]
    ti_val = 0.065
    wind_speed = 8.33


# Initialize the FLORIS interface fi
fi_g = wfct.floris_interface.FlorisInterface("example_input.json")
fi_g.reinitialize_flow_field(wind_speed=[wind_speed],turbulence_intensity=[ti_val])

# Get HH and D
HH = fi_g.floris.farm.flow_field.turbine_map.turbines[0].hub_height
D = fi_g.floris.farm.turbines[0].rotor_diameter

# Repeat for Blondel
fi_b = wfct.floris_interface.FlorisInterface("example_input.json")
fi_b.floris.farm.set_wake_model('blondel')
fi_b.reinitialize_flow_field(wind_speed=[wind_speed],turbulence_intensity=[ti_val])

# Repeat for Gauss-M-Gauss
fi_gmg = wfct.floris_interface.FlorisInterface("example_input.json")
fi_gmg.floris.farm.set_wake_model('gauss_m')
fi_gmg.floris.farm.wake.velocity_model.model_code = 'g'
fi_gmg.reinitialize_flow_field(wind_speed=[wind_speed],turbulence_intensity=[ti_val])

# Repeat for Gauss-M-Blondel
fi_gmb = wfct.floris_interface.FlorisInterface("example_input.json")
fi_gmb.floris.farm.set_wake_model('gauss_m')
fi_gmb.floris.farm.wake.velocity_model.model_code = 'b'
fi_gmb.reinitialize_flow_field(wind_speed=[wind_speed],turbulence_intensity=[ti_val])

# Repeat for Gauss-M-Blondel
github NREL / floris / examples / performance_analysis / test_visualization_speed.py View on Github external
# See https://floris.readthedocs.io for documentation

# Short demo of how probe points currently added for
# visualization and demonstration of speed

import time

import numpy as np
import matplotlib.pyplot as plt

import floris.tools as wfct


# Initialize the FLORIS interface fi
fi = wfct.floris_interface.FlorisInterface("../example_input.json")

## Parameters
d_space = 7
d = 126
dist = d * d_space

# Calculate wake
fi.calculate_wake()

# Declare plots
fig, axarr = plt.subplots(2, 2, figsize=(10, 10))

for n_row, ax in zip([5, 6, 7, 8], axarr.flatten()):

    x_array = []
    y_array = []
github NREL / floris / examples / example_0017_compare_gauss_blondel_ishihara.py View on Github external
def get_points_from_flow_data(x_points,y_points,z_points,flow_data):
    X = np.column_stack([flow_data.x,flow_data.y,flow_data.z])
    n_neighbors = 1
    knn = neighbors.KNeighborsRegressor(n_neighbors)
    y_ = knn.fit(X, flow_data.u)

    # Predict new points
    T = np.column_stack([x_points,y_points,z_points])
    return knn.predict(T)

# Load the SOWFA case in
si = wfct.sowfa_utilities.SowfaInterface('sowfa_example')

# Initialize the FLORIS interface fi
fi = wfct.floris_interface.FlorisInterface("example_input.json")

# Get HH and D
HH = fi.floris.farm.flow_field.turbine_map.turbines[0].hub_height
D = fi.floris.farm.turbines[0].rotor_diameter

wind_speed_mod = 0.3

# Match SOWFA
fi.reinitialize_flow_field(wind_speed=[si.precursor_wind_speed - wind_speed_mod],
                           wind_direction=[si.precursor_wind_dir],
                           layout_array=(si.layout_x, si.layout_y)
                           )

# Calculate wake
fi.calculate_wake(yaw_angles=si.yaw_angles)
github NREL / floris / floris / tools / sowfa_utilities.py View on Github external
Read flow array output from SOWFA

        Args:
            filename (str): name of file containing flow data.

        Returns:
            FlowData (pd.DataFrame): a pandas table with the columns,
                of all relavent flow info (e.g. x, y, z, u, v, w).
        """
        # Read the dimension info from the file
        with open(filename, "r") as f:
            for _ in range(10):
                read_data = f.readline()
                if "SPACING" in read_data:
                    splitstring = read_data.rstrip().split(" ")
                    spacing = Vec3(
                        float(splitstring[1]),
                        float(splitstring[2]),
                        float(splitstring[3]),
                    )
                if "DIMENSIONS" in read_data:
                    splitstring = read_data.rstrip().split(" ")
                    dimensions = Vec3(
                        int(splitstring[1]), int(splitstring[2]), int(splitstring[3])
                    )
                if "ORIGIN" in read_data:
                    splitstring = read_data.rstrip().split(" ")
                    origin = Vec3(
                        float(splitstring[1]),
                        float(splitstring[2]),
                        float(splitstring[3]),
                    )
github NREL / floris / floris / tools / sowfa_utilities.py View on Github external
read_data = f.readline()
                if "SPACING" in read_data:
                    splitstring = read_data.rstrip().split(" ")
                    spacing = Vec3(
                        float(splitstring[1]),
                        float(splitstring[2]),
                        float(splitstring[3]),
                    )
                if "DIMENSIONS" in read_data:
                    splitstring = read_data.rstrip().split(" ")
                    dimensions = Vec3(
                        int(splitstring[1]), int(splitstring[2]), int(splitstring[3])
                    )
                if "ORIGIN" in read_data:
                    splitstring = read_data.rstrip().split(" ")
                    origin = Vec3(
                        float(splitstring[1]),
                        float(splitstring[2]),
                        float(splitstring[3]),
                    )

        # Set up x, y, z as lists
        if dimensions.x1 > 1.0:
            xRange = np.arange(0, dimensions.x1 * spacing.x1, spacing.x1)
        else:
            xRange = np.array([0.0])

        if dimensions.x2 > 1.0:
            yRange = np.arange(0, dimensions.x2 * spacing.x2, spacing.x2)
        else:
            yRange = np.array([0.0])
github NREL / floris / floris / tools / sowfa_utilities.py View on Github external
of all relavent flow info (e.g. x, y, z, u, v, w).
        """
        # Read the dimension info from the file
        with open(filename, "r") as f:
            for _ in range(10):
                read_data = f.readline()
                if "SPACING" in read_data:
                    splitstring = read_data.rstrip().split(" ")
                    spacing = Vec3(
                        float(splitstring[1]),
                        float(splitstring[2]),
                        float(splitstring[3]),
                    )
                if "DIMENSIONS" in read_data:
                    splitstring = read_data.rstrip().split(" ")
                    dimensions = Vec3(
                        int(splitstring[1]), int(splitstring[2]), int(splitstring[3])
                    )
                if "ORIGIN" in read_data:
                    splitstring = read_data.rstrip().split(" ")
                    origin = Vec3(
                        float(splitstring[1]),
                        float(splitstring[2]),
                        float(splitstring[3]),
                    )

        # Set up x, y, z as lists
        if dimensions.x1 > 1.0:
            xRange = np.arange(0, dimensions.x1 * spacing.x1, spacing.x1)
        else:
            xRange = np.array([0.0])
github NREL / floris / floris / simulation / wake_velocity / base_velocity_deficit.py View on Github external
# use this file except in compliance with the License. You may obtain a copy of
# the License at http://www.apache.org/licenses/LICENSE-2.0

# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations under
# the License.

import numpy as np

from ...utilities import cosd, sind, tand
from ...logging_manager import LoggerBase


class VelocityDeficit(LoggerBase):
    """
    Base VelocityDeficit object class. This class contains a method for getting
    the relevant model parameters from the input dictionary, or for supplying
    default values if none are supplied.
    """

    def __init__(self, parameter_dictionary):
        """
        Stores the parameter dictionary for the wake velocity model.

        Args:
            parameter_dictionary (dict): Dictionary containing the wake
                velocity model parameters. See individual wake velocity
                models for details of specific key-value pairs.
        """
        self.requires_resolution = False
github NREL / floris / examples / example_0017_compare_gauss_blondel_ishihara.py View on Github external
# Define a quick function for getting arbitrary points from sowfa
from sklearn import neighbors

def get_points_from_flow_data(x_points,y_points,z_points,flow_data):
    X = np.column_stack([flow_data.x,flow_data.y,flow_data.z])
    n_neighbors = 1
    knn = neighbors.KNeighborsRegressor(n_neighbors)
    y_ = knn.fit(X, flow_data.u)

    # Predict new points
    T = np.column_stack([x_points,y_points,z_points])
    return knn.predict(T)

# Load the SOWFA case in
si = wfct.sowfa_utilities.SowfaInterface('sowfa_example')

# Initialize the FLORIS interface fi
fi = wfct.floris_interface.FlorisInterface("example_input.json")

# Get HH and D
HH = fi.floris.farm.flow_field.turbine_map.turbines[0].hub_height
D = fi.floris.farm.turbines[0].rotor_diameter

wind_speed_mod = 0.3

# Match SOWFA
fi.reinitialize_flow_field(wind_speed=[si.precursor_wind_speed - wind_speed_mod],
                           wind_direction=[si.precursor_wind_dir],
                           layout_array=(si.layout_x, si.layout_y)
                           )
github NREL / floris / examples / change_turbine / show_grid.py View on Github external
# See https://floris.readthedocs.io for documentation


# Show the grid points in hetergenous flow calculation

import numpy as np
import pandas as pd
import matplotlib.pyplot as plt

# This import registers the 3D projection, but is otherwise unused.
from mpl_toolkits.mplot3d import Axes3D  # noqa: F401 unused import

import floris.tools as wfct


fi = wfct.floris_interface.FlorisInterface("../example_input.json")
fi.reinitialize_flow_field(layout_array=[[0, 500], [0, 0]])
fi.calculate_wake()

# Show the grid points (note only on turbines, not on wind measurements)
fig = plt.figure(figsize=(15, 5))
ax = fig.add_subplot(131, projection="3d")
xs = fi.floris.farm.flow_field.x
ys = fi.floris.farm.flow_field.y
zs = fi.floris.farm.flow_field.z
ax.scatter(xs, ys, zs, marker=".")

# Show the turbine points in this case
for coord, turbine in fi.floris.farm.turbine_map.items:
    xt, yt, zt = turbine.return_grid_points(coord)
    ax.scatter(xt, yt, zt, marker="o", color="r", alpha=0.25)
github NREL / floris / examples / example_0005_adjust_floris.py View on Github external
# Unless required by applicable law or agreed to in writing, software distributed
# under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
# CONDITIONS OF ANY KIND, either express or implied. See the License for the
# specific language governing permissions and limitations under the License.

# See read the https://floris.readthedocs.io for documentation

import matplotlib.pyplot as plt
import floris.tools as wfct
import floris.tools.visualization as vis
import floris.tools.cut_plane as cp
import numpy as np
from mpl_toolkits.axes_grid1 import make_axes_locatable, axes_size

# Initialize FLORIS model
fi = wfct.floris_interface.FlorisInterface("example_input.json")

# set turbine locations to 4 turbines in a row - demonstrate how to change coordinates
D = fi.floris.farm.flow_field.turbine_map.turbines[0].rotor_diameter
layout_x = [0, 7*D, 0, 7*D]
layout_y = [0, 0, 5*D, 5*D]
fi.reinitialize_flow_field(layout_array=(layout_x, layout_y))

# Calculate wake
fi.calculate_wake()


# ================================================================================
print('Plotting the FLORIS flowfield...')
# ================================================================================

# Initialize the horizontal cut