How to use the floris.tools 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 / 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 / flow_interaction / flow_data_to_vtk.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 https://floris.readthedocs.io for documentation


# Demonstrate extracting the flow field to vtk

import floris.tools as wfct


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

# Calculate wake
fi.calculate_wake()

# Get the flow data and save to vtk
flow_data = fi.get_flow_data()
flow_data.save_as_vtk("flow.vtk")
github NREL / floris / examples_new / compare_gauss / example_00.py View on Github external
fi.reinitialize_flow_field(layout_array=([0,dist_downstream*D],[0,y_loc*D]))
        fi.calculate_wake([0,0])
        base_power = fi.get_turbine_power()[1]/1000.
        fi.calculate_wake([yaw_angle,0])
        power_out[y_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'
github NREL / floris / examples / optimization / scipy / example_optimize_power_density1D.py View on Github external
# freq = freq/freq.sum()
wd = [270]
ws = [8]
freq = [1]

# Set optimization options
opt_options = {'maxiter': 50, 'disp': True, 'iprint': 2, 'ftol': 1e-9}

# Compute initial AEP for optimization normalization
AEP_initial = fi.get_farm_AEP(wd, ws, freq)

# Set initial conditions for optimization (scaled between 0 and 1)
x0 = [0., 0.25, 0.5, 0.75, 1.0] + [0.25, 0., 0., 0., 0.]

# Instantiate the layout otpimization object
powdens_opt = wfct.optimization.PowerDensityOptimization1D(
                        fi=fi,
                        wd=wd,
                        ws=ws,
                        freq=freq,
                        AEP_initial=AEP_initial,
                        x0=x0,
                        opt_options=opt_options
)

# Perform layout optimization
powdens_results = powdens_opt.optimize()

print(layout_x)
print(powdens_results)
github NREL / floris / examples / visualization / demo_vis_layout.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 https://floris.readthedocs.io for documentation

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")

# Make a random 9-turbine layout
layout_x = np.random.uniform(low=0, high=126 * 10, size=4)
layout_y = np.random.uniform(low=0, high=126 * 10, size=4)
fi.reinitialize_flow_field(layout_array=(layout_x, layout_y))
fi.calculate_wake()

# Show layout visualizations
fig, axarr = plt.subplots(1, 3, figsize=(15, 5))

ax = axarr[0]
hor_plane = fi.get_hor_plane()
wfct.visualization.visualize_cut_plane(hor_plane, ax=ax)

ax = axarr[1]
fi.vis_layout(ax=ax)
github NREL / floris / examples / compare_models / gch_components.py View on Github external
# Compare 5 turbine results to SOWFA in 8 m/s, higher TI case

import copy
import pickle

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

import floris.tools as wfct


# Set up default model
fi_gch = wfct.floris_interface.FlorisInterface("../example_input.json")

# Set as a row of 5 turbines spaced 6D apart
D = 126.0
fi_gch.reinitialize_flow_field(
    layout_array=[[D * 6 * r for r in range(5)], [0, 0, 0, 0, 0]]
)

# Set up versions with components disabled
fi_ss = copy.deepcopy(fi_gch)
fi_ss.set_gch_yaw_added_recovery(False)

# Set up versions with components disabled
fi_yar = copy.deepcopy(fi_gch)
fi_yar.set_gch_secondary_steering(False)

# Set up versions with components disabled
github NREL / floris / examples / example_0014_optimize_layout_and_height.py View on Github external
plant_kw = 3*5000

# Generate random wind rose data
wd = np.arange(0., 360., 5.)
np.random.seed(1)
ws = 8.0 + np.random.randn(len(wd))*0.5
freq = np.abs(np.sort(np.random.randn(len(wd))))
freq = freq/freq.sum()

# Set optimization options
opt_options = {'maxiter': 50, 'disp': True, 'iprint': 2, 'ftol': 1e-8}

AEP_initial = fi.get_farm_AEP(wd, ws, freq)

# Instantiate the layout otpimization object
layout_height_opt = wfct.optimization.LayoutHeightOptimization(
                        fi=fi,
                        boundaries=boundaries,
                        height_lims=height_lims,
                        wd=wd,
                        ws=ws,
                        freq=freq,
                        AEP_initial=AEP_initial,
                        COE_initial=None,
                        plant_kw=plant_kw,
                        opt_options=opt_options
)

# Compute initial COE for optimization normalization
COE_initial = layout_height_opt.COE_model.COE(
    height=fi.floris.farm.turbines[0].hub_height,
    AEP_sum=AEP_initial
github NREL / floris / examples / optimization / scipy / example_optimize_yaw.py View on Github external
# the License.


import matplotlib.pyplot as plt
import floris.tools as wfct
import floris.tools.visualization as vis
import floris.tools.cut_plane as cp
from floris.tools.optimization.scipy.optimization import YawOptimization
import numpy as np
import os


print('Running FLORIS with no yaw...')
# 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 row
D = fi.floris.farm.turbines[0].rotor_diameter
layout_x = [0, 7*D, 14*D]
layout_y = [0, 0, 0]
fi.reinitialize_flow_field(layout_array=(layout_x, layout_y))
fi.calculate_wake()

# Initial power output
power_initial = fi.get_farm_power()

# =============================================================================
print('Plotting the FLORIS flowfield...')
# =============================================================================
github NREL / floris / examples / visualization / subtract_inflow.py View on Github external
# 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 https://floris.readthedocs.io for documentation


import matplotlib.pyplot as plt

import floris.tools as wfct
import floris.tools.cut_plane as cp


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

# Single turbine at 0,0
fi.reinitialize_flow_field(layout_array=([0], [0]))

# Calculate wake
fi.calculate_wake()

# Grab some cross planes
D = 126
cut_plane_base_5 = fi.get_cross_plane(5 * D)
cut_plane_base_in = fi.get_cross_plane(-5 * D)


# Get the difference planes
cut_plane_diff = cp.subtract(cut_plane_base_5, cut_plane_base_in)