Ejemplo n.º 1
0
def florisEval(**kwargs):
    #def florisEval(yaws=[0,0,0,0], density=1.225):

    num_fns = kwargs['functions']
    #   if num_fns > 1:
    #       least_sq_flag = true
    #   else:
    #       least_sq_flag = false

    x = kwargs['cv']
    ASV = kwargs['asv']

    NTURBS = 2
    yaws = x[:NTURBS]
    if len(x) > NTURBS:
        speed = x[NTURBS]
        direction = None
        #direction = x[NTURBS + 1]
        #for ii in range(len(yaws)):
        #   yaws[ii] += np.deg2rad(direction)
    else:
        speed = None
        direction = None
    #print('density',density)
    #print('speed',speed)
    #print('direction',direction)

    filename = 'example_input.json'
    with open(filename, 'r') as f:
        data = json.load(f)
        if speed: data['farm']['properties']['wind_speed'] = speed
        if direction: data['farm']['properties']['wind_direction'] += direction

    #os.remove(filename)
    with open(filename + 'rm', 'w') as f:
        json.dump(data, f, indent=4)

    retval = dict([])

    #if (ASV[0] & 1): # **** f:

    # setup floris and process input file
    floris = Floris(filename + 'rm')

    # run FLORIS with no yaw
    turbines = [
        turbine for _, turbine in floris.farm.flow_field.turbine_map.items()
    ]
    for k, turbine in enumerate(turbines):
        turbine.yaw_angle = yaws[k]
    floris.farm.flow_field.calculate_wake()
    power_initial = np.sum([turbine.power for turbine in turbines
                            ])  # determine initial power production

    power_initial = np.sum([turbine.power for turbine in turbines
                            ])  # determine initial power production
    retval['fns'] = [power_initial] + [turbine.power for turbine in turbines]
    return (retval)
Ejemplo n.º 2
0
def florisEval(**kwargs):
    #def florisEval(yaws=[0,0,0,0], density=1.225):

    # DAKOTA setup
    NTURBS = 52
    x = kwargs['cv']
    ASV = kwargs['asv']
    retval = dict([])
    yaws = x[:NTURBS]
    if len(x) > NTURBS:
        speed = x[NTURBS]
        direction = x[NTURBS + 1]
    else:
        speed = None
        direction = None
    #print('density',density)
    #print('speed',speed)
    #print('direction',direction)

    filename = 'Peetz.json'
    with open(filename, 'r') as f:
        data = json.load(f)
        if speed: data['farm']['properties']['wind_speed'] = speed
        if direction: data['farm']['properties']['wind_direction'] = direction
    os.remove(filename)
    with open(filename, 'w') as f:
        json.dump(data, f, indent=4)

    floris = Floris(filename)

    # run FLORIS with no yaw
    turbines = [
        turbine for _, turbine in floris.farm.flow_field.turbine_map.items()
    ]
    for k, turbine in enumerate(turbines):
        turbine.yaw_angle = yaws[k]
    floris.farm.flow_field.calculate_wake()
    power_initial = np.sum([turbine.power for turbine in turbines
                            ])  # determine initial power production

    retval['fns'] = [-1 * power_initial]
    return (retval)
Ejemplo n.º 3
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 sys
from floris.floris import Floris
import numpy as np
from copy import deepcopy
from floris.visualization import VisualizationManager
import matplotlib.pyplot as plt
import matplotlib

if len(sys.argv) > 1:
    floris = Floris(sys.argv[1])
else:
    floris = Floris("example_input.json")

#a, b = floris.farm.turbine_map.items()
#a[0].yaw_angle = 0.43
floris.farm.flow_field.calculate_wake()
hey = None
ii = 0
fig, ax = plt.subplots(2, sharex=True, figsize=(6, 3))
plt.subplots_adjust(hspace=.09)
for ii in [0, 1]:
    for coord, turbine in floris.farm.turbine_map.items():
        if ii == 1:
            if hey is None:
                turbine.yaw_angle = 0.43
Ejemplo n.º 4
0
# coding: utf-8

# # Examples for running FLORIS

# In[10]:

# load modules
from floris.floris import Floris
import numpy as np

# ## Setup floris and process input file

# In[11]:

floris = Floris("example_input.json")

# ## Calculate Wake

# In[12]:

import time

t1 = time.time()

floris.farm.flow_field.calculate_wake()

t2 = time.time()

print('Time to compute wake = ', t2 - t1, 's')

# ## Compute Velocities at each Turbine