How to use the floris.tools.floris_utilities.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 / example_0006_floris_demonstrate_hh_plot.py View on Github external
# 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
import time

# Define speed limits
minSpeed = 4.
maxSpeed = 8.

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

# Calculate the time to run wake
start = time.time()
fi.calculate_wake()
finish = time.time()
print('Time to calculate flow field', finish - start)

# Get a horizontal cut from default flow field
start = time.time()
hor_plane_1 = wfct.cut_plane.HorPlane(
    fi.get_flow_data(),
    fi.floris.farm.turbines[0].hub_height
)
fi.calculate_wake()
finish = time.time()
print('Time to extract default flow field', finish - start)
github NREL / floris / examples / example_0010_optimize_yaw.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
from floris.tools.optimization import optimize_yaw
import numpy as np

print('Running FLORIS with no yaw...')
fi = wfct.floris_utilities.FlorisInterface("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 = np.sum(fi.get_turbine_power())

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

# Initialize the horizontal cut
github NREL / floris / examples / example_0050_run_floris_from_openmdao.py View on Github external
# 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.
#

# Try out calling floris from OpenMDAO

import numpy as np
import floris.tools as wfct
import openmdao.api as om

# Initialize the FLORIS OpenMDAO interface
fi = wfct.floris_utilities.FlorisInterface("example_input.json", mode='python', openmdao=True)

# get OpenMDAO component
FlorisComponent = fi._floris_openMDAO()

# set up OpenMDAO problem
prob = om.Problem()

# add floris to the OpenMDAO problem
prob.model.add_subsystem('floris', FlorisComponent(fi=fi), promotes=['*'])

# set up OpenMDAO problem
prob.setup()

# define wind rose information
prob['wind_direction'] = 270.
prob['wind_frequency'] = 1.
github NREL / floris / examples / optimization / scipy / example_optimize_power_density1D.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

# Instantiate the FLORIS object
fi = wfct.floris_utilities.FlorisInterface("example_input.json")

# Set turbine locations to 3 turbines in a triangle
D = fi.floris.farm.turbines[0].rotor_diameter
spacing = 9*D
layout_x = [0, spacing, 2*spacing, 3*spacing, 4*spacing]
layout_y = [0, 0, 0, 0, 0]
fi.reinitialize_flow_field(layout_array=(layout_x, layout_y))

# 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()
wd = [270]
ws = [8]
github NREL / floris / examples / example_0051_optimize_layout_using_floris_from_openmdao.py View on Github external
# 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.
#

# Try out calling floris from OpenMDAO

import numpy as np
import floris.tools as wfct
import openmdao.api as om

# Initialize the FLORIS OpenMDAO interface
fi = wfct.floris_utilities.FlorisInterface("example_input.json", mode='python', openmdao=True)

# get OpenMDAO component
FlorisComponent = fi._floris_openMDAO()

# set up OpenMDAO problem
prob = om.Problem()

# set up indep var comp for optimization design variables
indeps = prob.model.add_subsystem('indeps', om.IndepVarComp(), promotes=['*'])
indeps.add_output('turbineX', fi.layout_x, units='m')
indeps.add_output('turbineY', fi.layout_y, units='m')

# add floris to the OpenMDAO problem
prob.model.add_subsystem('floris', FlorisComponent(fi=fi), promotes=['*'])

# set up objective component
github NREL / floris / examples / example_0011_optimize_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 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

# Instantiate the FLORIS object
fi = wfct.floris_utilities.FlorisInterface("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]
layout_y = [200, 1000, 200]
fi.reinitialize_flow_field(layout_array=(layout_x, layout_y))

# Define the boundary for the wind farm
boundaries = [[2000.1, 4000.], [2000., 0.1], [0., 0.], [0.1, 2000.]]

# 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()
github NREL / floris / examples / optimization / scipy / example_optimize_power_density.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

# Instantiate the FLORIS object
fi = wfct.floris_utilities.FlorisInterface("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., 1200.], [1000., 0.1], [0., 0.], [0., 1200.]]

# Generate random wind rose data
wd = np.arange(0., 360., 45.)
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()