How to use the floris.tools.floris_interface.FlorisInterface function in FLORIS

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 / 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 / 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
github NREL / floris / examples / visualization / show_grid_points.py View on Github external
# See https://floris.readthedocs.io for documentation


## THIS IS A WORK IN PROGRESS

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


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

# Just one turbine
fi.reinitialize_flow_field(layout_array=([100], [100]))

# Calculate wake
fi.calculate_wake()

# Show thoe points
fig = plt.figure()
ax = fig.add_subplot(111, 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=".")

# # print('yaw')
github NREL / floris / examples / optimization / scipy / co-design_optimizations / optimize_power_density.py View on Github external
# maintain the original energy output by leveraging wake steering. It is meant
# to be an illustrative example of some of the benefits of wake steering.

import os

import numpy as np
import matplotlib.pyplot as plt

import floris.tools as wfct
import floris.tools.visualization as vis
from floris.tools.optimization.scipy.power_density import PowerDensityOptimization


# Instantiate the FLORIS object
file_dir = os.path.dirname(os.path.abspath(__file__))
fi = wfct.floris_interface.FlorisInterface(
    os.path.join(file_dir, "../../../example_input.json")
)

# Set turbine locations to 3 turbines in a triangle
D = fi.floris.farm.turbines[0].rotor_diameter
layout_x = [10, 10, 10 + 7 * D, 10 + 7 * D]
layout_y = [200, 1000, 200, 1000]
fi.reinitialize_flow_field(layout_array=(layout_x, layout_y))

# Define the boundary for the wind farm
boundaries = [[1000.0, 1200.0], [1000.0, 0.1], [0.0, 0.0], [0.0, 1200.0]]

# Generate random wind rose data
wd = np.arange(0.0, 360.0, 45.0)
np.random.seed(1)
ws = 8.0 + np.random.randn(len(wd)) * 0.5
github NREL / floris / examples / optimization / pyoptsparse / controls_optimization / optimize_yaw_wind_rose_no_class.py View on Github external
# the License.

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


import os

import numpy as np

import pyoptsparse
import floris.tools as wfct


# Initialize the FLORIS interface fi
file_dir = os.path.dirname(os.path.abspath(__file__))
fi = wfct.floris_interface.FlorisInterface(
    os.path.join(file_dir, "../../../example_input.json")
)

# Set turbine locations to 4 turbines in a rectangle
D = fi.floris.farm.turbines[0].rotor_diameter
layout_x = [0, 0, 6 * D, 6 * D]
layout_y = [0, 5 * D, 0, 5 * D]
fi.reinitialize_flow_field(layout_array=(layout_x, layout_y))

nturbs = len(fi.floris.farm.turbines)

# Generate random wind rose data
wd = np.arange(0.0, 360.0, 90.0)
np.random.seed(1)
ws = 8.0 + np.random.randn(len(wd)) * 0.5
freq = np.abs(np.sort(np.random.randn(len(wd))))
github NREL / floris / examples / optimization / pyoptsparse / example_yaw_optimization_no_class.py View on Github external
# 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 pyoptsparse
import os

import floris.tools as wfct

# Initialize the FLORIS interface fi
file_dir = os.path.dirname(os.path.abspath(__file__))
fi = wfct.floris_interface.FlorisInterface(
    os.path.join(file_dir, '../../example_input.json')
)

def objective_function(varDict, **kwargs):
    # Parse the variable dictionary
    yaw = varDict['yaw']

    # Compute the objective function
    funcs = {}
    funcs['obj'] = -1*fi.get_farm_power_for_yaw_angle(yaw)/1e5

    fail = False
    return funcs, fail

# Setup the optimization problem
optProb = pyoptsparse.Optimization('yaw_opt', objective_function)
github NREL / floris / examples_new / compare_gauss / example_01_long.py View on Github external
fi.reinitialize_flow_field(layout_array=([0,D*x_loc],[0,0]))
        fi.calculate_wake([0,0])
        base_power = fi.get_turbine_power()[1]/1000.
        fi.calculate_wake([yaw_angle,0])
        power_out[x_idx] = 100 * (fi.get_turbine_power()[1]/1000. - base_power) / base_power

    return sweep_locations, power_out

# Set up the models ....
# ======================
fi_dict = dict()
color_dict = dict()
label_dict = dict()

# Gauss Class -- Current Default
fi_g = wfct.floris_interface.FlorisInterface("../example_input.json")
fi_dict['g'] = fi_g
color_dict['g'] = 'r^-'
label_dict['g'] = 'current_default'

# Gauss_Legacy Class with GCH disabled and deflection multiplier = 1.2
fi_gl = wfct.floris_interface.FlorisInterface("../other_jsons/input_legacy.json")
fi_dict['gl'] = fi_gl
color_dict['gl'] = 'bo--'
label_dict['gl'] = 'gauss_legacy'

# Gauss_Legacy Class with GCH disabled and deflection multiplier = 1.2
fi_gm = wfct.floris_interface.FlorisInterface("../other_jsons/input_merge.json")
fi_dict['gm'] = fi_gm
color_dict['gm'] = 'go--'
label_dict['gm'] = 'gauss_blondel_merge'