How to use the floris.tools.sowfa_utilities.SowfaInterface 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 / 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 / sowfa_comparisons / open_and_vis_sowfa.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


sowfa_case = wfct.sowfa_utilities.SowfaInterface("sowfa_example")

# Summarize self
print(sowfa_case)

# Demonstrate flow field visualizations

# # Get the horizontal cut plane at 90 m
hor_plane = sowfa_case.get_hor_plane(90)

# Show the views in different permutations
fig, axarr = plt.subplots(3, 2, figsize=(10, 10))

# Original
ax = axarr[0, 0]
wfct.visualization.visualize_cut_plane(hor_plane, ax=ax)
ax.set_title("Original")
github NREL / floris / examples / sowfa_comparisons / sowfa_minus_floris.py View on Github external
import numpy as np
import matplotlib.pyplot as plt

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


# Define a minspeed and maxspeed to use across visualiztions
minspeed = 4.0
maxspeed = 8.5

# Load the SOWFA case in
si = wfct.sowfa_utilities.SowfaInterface("sowfa_example")
sowfa_flow_data = si.flow_data

# Load the FLORIS case in
fi = wfct.floris_interface.FlorisInterface("../example_input.json")
fi.calculate_wake()

# Set the relevant FLORIS parameters to equal the SOWFA case
fi.reinitialize_flow_field(
    wind_speed=[si.precursor_wind_speed],
    wind_direction=[si.precursor_wind_dir],
    layout_array=(si.layout_x, si.layout_y),
)

# Set the yaw angles
fi.calculate_wake(yaw_angles=si.yaw_angles)
github NREL / floris / examples / scaling_example / get_scaled_params_with_cc_interface.py View on Github external
import numpy as np
import pandas as pd
import matplotlib.pyplot as plt

import floris.tools as wfct
import floris.tools.cc_blade_utilities as ccb
from ccblade import CCBlade, CCAirfoil


# Some useful constants
degRad = np.pi / 180.0
rpmRadSec = 2.0 * (np.pi) / 60.0

# Load the sowfa case for an example turbine input file for the NREL 5MW
sowfa_case = wfct.sowfa_utilities.SowfaInterface("../sowfa_comparisons/sowfa_example")

# Grab the turbine dict in order to have controller values
turbine_dict = wfct.sowfa_utilities.read_foam_file(
    os.path.join(
        sowfa_case.case_folder, sowfa_case.turbine_sub_path, sowfa_case.turbine_name
    )
)

# Select an R and rating to test
# Get a scaled version to 40m R, 2MW
turbine_dict_base, rotor_base = ccb.scale_controller_and_rotor(turbine_dict)
turbine_dict_scaled_2mw, rotor_scaled_2mw = ccb.scale_controller_and_rotor(
    turbine_dict, 40, 2
)

# Compare the torque curves
github NREL / floris / examples / sowfa_comparisons / modify_floris_to_match_sowfa.py View on Github external
import numpy as np
import matplotlib.pyplot as plt

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


# Define a minspeed and maxspeed to use across visualiztions
minspeed = 4.0
maxspeed = 8.5

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

# Plot the SOWFA flow and turbines using the input information
fig, (ax1, ax2, ax3) = plt.subplots(3, 1, figsize=(5, 8.5))
sowfa_flow_data = si.flow_data
hor_plane = si.get_hor_plane(90)
wfct.visualization.visualize_cut_plane(
    hor_plane, ax=ax2, minSpeed=minspeed, maxSpeed=maxspeed
)
vis.plot_turbines(ax2, si.layout_x, si.layout_y, si.yaw_angles, si.D)
ax2.set_title("SOWFA")
ax2.set_ylabel("y location [m]")

# Load the FLORIS case in
fi = wfct.floris_interface.FlorisInterface("../example_input.json")
fi.calculate_wake()