예제 #1
0
def test_aep_wind_atlas_method():
    site = Hornsrev1Site()

    wt = IEA37_WindTurbines()
    wfm = IEA37SimpleBastankhahGaussian(site, wt)
    x, y = [0], [0]
    wd = np.arange(360)
    aep_lps = wfm(x, y, wd=wd,
                  ws=np.arange(3, 27)).aep(linear_power_segments=True)
    aep = wfm(x, y, wd=wd, ws=np.r_[3, np.arange(3.5, 27)]).aep()
    if 0:
        plt.plot(aep_lps.ws,
                 np.cumsum(aep_lps.sum(['wt', 'wd'])),
                 '.-',
                 label='Linear power segments')
        plt.plot(aep.ws,
                 np.cumsum(aep.sum(['wt', 'wd'])),
                 '.-',
                 label='Constant power segments')
        plt.ylabel('Cumulated AEP [GWh]')
        plt.xlabel('Wind speed [m/s]')
        plt.legend()
        plt.show()
    npt.assert_almost_equal(aep_lps.sum(), 16.73490444)
    npt.assert_almost_equal(aep.sum(), 16.69320343)
예제 #2
0
def get_iea37_cost(n_wt=9):
    """Cost component that wraps the IEA 37 AEP calculator"""
    wd = npa(range(16)) * 22.5  # only 16 bins
    site = IEA37Site(n_wt)
    wind_turbines = IEA37_WindTurbines()
    wake_model = IEA37SimpleBastankhahGaussian(site, wind_turbines)
    return PyWakeAEPCostModelComponent(wake_model, n_wt, wd=wd)
예제 #3
0
def test_yaw_tilt(yaw, tilt, cx, cz):
    site = IEA37Site(16)
    x, y = [0], [0]
    windTurbines = V80()

    D = windTurbines.diameter()
    wfm = IEA37SimpleBastankhahGaussian(
        site, windTurbines, deflectionModel=JimenezWakeDeflection())
    x_lst = np.linspace(-200, 1000, 100)
    y_lst = np.linspace(-100, 100, 201)
    z_lst = np.arange(10, 200, 1)

    fm_yz = wfm(x, y, wd=270, ws=10, yaw=yaw,
                tilt=tilt).flow_map(YZGrid(x=5 * D, y=y_lst, z=z_lst))
    fm_xz = wfm(x, y, wd=180, ws=10, yaw=yaw,
                tilt=tilt).flow_map(YZGrid(x=0, y=x_lst, z=z_lst))
    fm_xy = wfm(x, y, wd=270, ws=10, yaw=yaw,
                tilt=tilt).flow_map(XYGrid(x=x_lst))
    if 0:
        axes = plt.subplots(3, 1)[1].flatten()
        fm_xy.plot_wake_map(ax=axes[0])
        axes[0].axvline(5 * D)
        fm_xz.plot_wake_map(ax=axes[1])
        axes[1].axvline(5 * D)
        fm_yz.plot_wake_map(ax=axes[2])
        plt.show()

    wake_center = fm_yz.WS_eff.where(fm_yz.WS_eff == fm_yz.WS_eff.min(),
                                     drop=True).squeeze()
    npt.assert_allclose(wake_center.y, cx, atol=.1)
    npt.assert_allclose(wake_center.h, cz, atol=.24)
예제 #4
0
def test_get_model_input():
    site, windTurbines = IEA37Site(16), IEA37_WindTurbines()
    wfm = IEA37SimpleBastankhahGaussian(site, windTurbines)
    args = get_model_input(wfm, [1000], [0], ws=10, wd=270)
    npt.assert_array_almost_equal(args['dw_ijl'], [[[1000]]])
    npt.assert_array_almost_equal(args['hcw_ijl'], [[[0]]])
    npt.assert_array_almost_equal(args['dh_ijl'], [[[0]]])
    npt.assert_array_almost_equal(args['yaw_ilk'], [[[0]]])
    npt.assert_array_almost_equal(args['WS_ilk'], [[[10]]])
    npt.assert_array_almost_equal(args['ct_ilk'], [[[8 / 9]]])
예제 #5
0
def test_RotorGridAvg_deficit():
    site = IEA37Site(16)
    x, y = site.initial_position.T
    windTurbines = IEA37_WindTurbines()
    wfm = IEA37SimpleBastankhahGaussian(site,
                                        windTurbines)
    flow_map = wfm([0, 500], [0, 0], wd=270, ws=10).flow_map(HorizontalGrid(x=[500], y=np.arange(-100, 100)))
    plt.plot(flow_map.Y[:, 0], flow_map.WS_eff_xylk[:, 0, 0, 0])
    R = windTurbines.diameter() / 2

    for name, rotorAvgModel, ref1 in [
            ('RotorCenter', RotorCenter(), 7.172723970425709),
            ('RotorGrid2', EqGridRotorAvg(2), 7.495889360682771),
            ('RotorGrid3', EqGridRotorAvg(3), 7.633415167369133),
            ('RotorGrid4', EqGridRotorAvg(4), 7.710215921858325),
            ('RotorGrid100', EqGridRotorAvg(100), 7.820762402628349),
            ('RotorGQGrid_4,3', GQGridRotorAvg(4, 3), 7.826105012683896),
            ('RotorCGI4', CGIRotorAvg(4), 7.848406907726826),
            ('RotorCGI4', CGIRotorAvg(7), 7.819900693605533),
            ('RotorCGI4', CGIRotorAvg(9), 7.82149363932618),
            ('RotorCGI4', CGIRotorAvg(21), 7.821558905416136)]:

        # test with PropagateDownwind
        wfm = IEA37SimpleBastankhahGaussian(site,
                                            windTurbines,
                                            rotorAvgModel=rotorAvgModel)
        sim_res = wfm([0, 500], [0, 0], wd=270, ws=10)
        npt.assert_almost_equal(sim_res.WS_eff_ilk[1, 0, 0], ref1)

        # test with All2AllIterative
        wfm = All2AllIterative(site, windTurbines,
                               IEA37SimpleBastankhahGaussianDeficit(),
                               rotorAvgModel=rotorAvgModel,
                               superpositionModel=SquaredSum())
        sim_res = wfm([0, 500], [0, 0], wd=270, ws=10)
        npt.assert_almost_equal(sim_res.WS_eff_ilk[1, 0, 0], ref1)

        plt.plot([-R, R], [sim_res.WS_eff_ilk[1, 0, 0]] * 2, label=name)
    if 0:
        plt.legend()
        plt.show()
    plt.close('all')
예제 #6
0
def main():
    if __name__ == '__main__':
        try:
            import matplotlib.pyplot as plt
            plt.gcf()
            plot_comp = XYPlotComp()
            plot = True
        except RuntimeError:
            plot_comp = NoPlot()
            plot = False

        n_wt = 16
        site = IEA37Site(n_wt)
        windTurbines = IEA37_WindTurbines()
        windFarmModel = IEA37SimpleBastankhahGaussian(site, windTurbines)
        Drotor_vector = [windTurbines.diameter()] * n_wt
        power_rated_vector = [float(windTurbines.power(20) / 1000)] * n_wt
        hub_height_vector = [windTurbines.hub_height()] * n_wt

        def irr_func(aep, **kwargs):
            my_irr = economic_evaluation(Drotor_vector, power_rated_vector,
                                         hub_height_vector,
                                         aep).calculate_irr()
            print(my_irr)
            return my_irr

        aep_comp = CostModelComponent(
            input_keys=['x', 'y'],
            n_wt=n_wt,
            cost_function=lambda x, y, **_: windFarmModel(x=x, y=y).aep().sum(
                ['wd', 'ws']) * 10**6,
            output_key="aep",
            output_unit="GWh",
            objective=False,
            output_val=np.zeros(n_wt))
        irr_comp = CostModelComponent(input_keys=['aep'],
                                      n_wt=n_wt,
                                      cost_function=irr_func,
                                      output_key="irr",
                                      output_unit="%",
                                      objective=True,
                                      income_model=True)
        group = TopFarmGroup([aep_comp, irr_comp])
        problem = TopFarmProblem(
            design_vars=dict(zip('xy', site.initial_position.T)),
            cost_comp=group,
            driver=EasyRandomSearchDriver(
                randomize_func=RandomizeTurbinePosition_Circle(), max_iter=5),
            constraints=[
                SpacingConstraint(200),
                CircleBoundaryConstraint([0, 0], 1300.1)
            ],
            plot_comp=plot_comp)
        cost, state, recorder = problem.optimize()
예제 #7
0
def test_RotorGridAvg_ti():
    site = IEA37Site(16)
    x, y = site.initial_position.T
    windTurbines = IEA37_WindTurbines()
    wfm = IEA37SimpleBastankhahGaussian(site,
                                        windTurbines,
                                        turbulenceModel=STF2017TurbulenceModel())
    flow_map = wfm([0, 500], [0, 0], wd=270, ws=10).flow_map(HorizontalGrid(x=[500], y=np.arange(-100, 100)))
    plt.plot(flow_map.Y[:, 0], flow_map.TI_eff_xylk[:, 0, 0, 0])
    R = windTurbines.diameter() / 2

    for name, rotorAvgModel, ref1 in [
            ('RotorCenter', RotorCenter(), 0.22292190804089568),
            ('RotorGrid2', EqGridRotorAvg(2), 0.2111162769995657),
            ('RotorGrid3', EqGridRotorAvg(3), 0.2058616982653193),
            ('RotorGrid4', EqGridRotorAvg(4), 0.2028701990648858),
            ('RotorGrid100', EqGridRotorAvg(100), 0.1985255601976247),
            ('RotorGQGrid_4,3', GQGridRotorAvg(4, 3), 0.1982984399750206)]:

        # test with PropagateDownwind
        wfm = IEA37SimpleBastankhahGaussian(site,
                                            windTurbines,
                                            rotorAvgModel=rotorAvgModel,
                                            turbulenceModel=STF2017TurbulenceModel())
        sim_res = wfm([0, 500], [0, 0], wd=270, ws=10)
        npt.assert_almost_equal(sim_res.TI_eff_ilk[1, 0, 0], ref1)

        # test with All2AllIterative
        wfm = All2AllIterative(site, windTurbines,
                               IEA37SimpleBastankhahGaussianDeficit(),
                               rotorAvgModel=rotorAvgModel,
                               superpositionModel=SquaredSum(),
                               turbulenceModel=STF2017TurbulenceModel())
        sim_res = wfm([0, 500], [0, 0], wd=270, ws=10)
        npt.assert_almost_equal(sim_res.TI_eff_ilk[1, 0, 0], ref1)

        plt.plot([-R, R], [sim_res.TI_eff_ilk[1, 0, 0]] * 2, label=name)
    if 0:
        plt.legend()
        plt.show()
    plt.close('all')
def test_dAEP_2wt():
    site = Hornsrev1Site()
    iea37_site = IEA37Site(16)

    wt = IEA37_WindTurbines()
    wfm = IEA37SimpleBastankhahGaussian(site, wt)
    x, y = iea37_site.initial_position[np.array([0, 2, 5, 8, 14])].T

    # plot 2 wt case
    x, y = np.array([[0, 130 * 4], [0, 0]], dtype=np.float)
    x_lst = np.array([0., 1.]) * np.arange(1, 600, 10)[:, na]
    kwargs = {'ws': [10], 'wd': [270]}

    _, (ax1, ax2) = plt.subplots(1, 2, sharey=False)
    ax1.plot(x_lst[:, 1], [wfm.aep(x_, y, **kwargs) for x_ in x_lst])
    ax1.set_xlabel('Downwind distance [m]')
    ax1.set_ylabel('AEP [GWh]')

    x_ = x_lst[20]
    ax1.set_title("Center line")
    for grad in [fd, cs, autograd]:
        dAEPdx = wfm.dAEPdn(0, grad)(x_, y, **kwargs)[1]
        npt.assert_almost_equal(dAEPdx / 360, 3.976975605364392e-06,
                                (10, 5)[grad == fd])
        plot_gradients(wfm.aep(x_, y, **kwargs),
                       dAEPdx,
                       x_[1],
                       grad.__name__,
                       step=100,
                       ax=ax1)
    y_lst = np.array([0, 1.]) * np.arange(-100, 100, 5)[:, na]
    ax2.plot(y_lst[:, 1], [wfm.aep(x, y_, **kwargs) for y_ in y_lst])
    ax2.set_xlabel('Crosswind distance [m]')
    ax2.set_ylabel('AEP [GWh]')
    y_ = y_lst[25]
    ax2.set_title("%d m downstream" % x[1])
    for grad in [fd, cs, autograd]:
        dAEPdy = wfm.dAEPdn(1, grad)(x, y_, **kwargs)[1]
        plot_gradients(wfm.aep(x, y_, **kwargs),
                       dAEPdy,
                       y_[1],
                       grad.__name__,
                       step=50,
                       ax=ax2)
        npt.assert_almost_equal(dAEPdy / 360, 3.794435973860448e-05,
                                (10, 5)[grad == fd])

    if 0:
        plt.legend()
        plt.show()
    plt.close()
예제 #9
0
def test_RotorAvg_deficit():
    site = IEA37Site(16)
    windTurbines = IEA37_WindTurbines()
    wfm = IEA37SimpleBastankhahGaussian(site,
                                        windTurbines,
                                        turbulenceModel=STF2017TurbulenceModel())
    flow_map = wfm([0, 500], [0, 0], wd=270, ws=10).flow_map(HorizontalGrid(x=[500], y=np.arange(-100, 100)))
    plt.plot(flow_map.Y[:, 0], flow_map.TI_eff_xylk[:, 0, 0, 0])
    R = windTurbines.diameter() / 2

    for name, rotorAvgModel, ref1 in [
            ('None', None, 0.22292190804089568),
            ('RotorCenter', RotorCenter(), 0.22292190804089568),
            ('RotorGrid100', EqGridRotorAvg(100), 0.1989725533174574),
            ('RotorGQGrid_4,3', GQGridRotorAvg(4, 3), 0.19874837617113356),
            ('RotorCGI4', CGIRotorAvg(4), 0.19822024411411204),
            ('RotorCGI4', CGIRotorAvg(21), 0.1989414764606653)]:

        # test with PropagateDownwind
        wfm = IEA37SimpleBastankhahGaussian(site,
                                            windTurbines,
                                            turbulenceModel=STF2017TurbulenceModel(rotorAvgModel=rotorAvgModel))
        sim_res = wfm([0, 500], [0, 0], wd=270, ws=10)
        npt.assert_almost_equal(sim_res.TI_eff_ilk[1, 0, 0], ref1, err_msg=name)

        # test with All2AllIterative
        wfm = All2AllIterative(site, windTurbines,
                               IEA37SimpleBastankhahGaussianDeficit(),
                               turbulenceModel=STF2017TurbulenceModel(rotorAvgModel=rotorAvgModel),
                               superpositionModel=SquaredSum())
        sim_res = wfm([0, 500], [0, 0], wd=270, ws=10)
        npt.assert_almost_equal(sim_res.TI_eff_ilk[1, 0, 0], ref1)

        plt.plot([-R, R], [sim_res.WS_eff_ilk[1, 0, 0]] * 2, label=name)
    if 0:
        plt.legend()
        plt.show()
    plt.close()
def test_dAEPdx():
    site = Hornsrev1Site()
    iea37_site = IEA37Site(16)

    wt = IEA37_WindTurbines()
    wfm = IEA37SimpleBastankhahGaussian(site, wt)
    x, y = iea37_site.initial_position[np.array([0, 2, 5, 8, 14])].T

    dAEPdxy_autograd = wfm.dAEPdxy(gradient_method=autograd)(x, y)
    dAEPdxy_cs = wfm.dAEPdxy(gradient_method=cs)(x, y)
    dAEPdxy_fd = wfm.dAEPdxy(gradient_method=fd)(x, y)

    npt.assert_array_almost_equal(dAEPdxy_autograd, dAEPdxy_cs, 15)
    npt.assert_array_almost_equal(dAEPdxy_autograd, dAEPdxy_fd, 6)
예제 #11
0
def main():
    if __name__ == '__main__':
        n_wt = 16
        site = IEA37Site(n_wt)
        windTurbines = IEA37_WindTurbines()
        windFarmModel = IEA37SimpleBastankhahGaussian(site, windTurbines)
        tf = TopFarmProblem(
            design_vars=dict(zip('xy', site.initial_position.T)),
            cost_comp=PyWakeAEPCostModelComponent(windFarmModel, n_wt),
            driver=EasyRandomSearchDriver(
                randomize_func=RandomizeTurbinePosition_Circle(), max_iter=5),
            constraints=[CircleBoundaryConstraint([0, 0], 1300.1)],
            plot_comp=XYPlotComp())
        tf.optimize()
        tf.plot_comp.show()
def main():
    if __name__ == '__main__':
        plot_comp = XYPlotComp()
        site = get_site()
        n_wt = len(site.initial_position)
        windTurbines = DTU10MW()
        min_spacing = 2 * windTurbines.diameter(0)
        windFarmModel = IEA37SimpleBastankhahGaussian(site, windTurbines)
        Drotor_vector = [windTurbines.diameter()] * n_wt
        power_rated_vector = [float(windTurbines.power(20) / 1000)] * n_wt
        hub_height_vector = [windTurbines.hub_height()] * n_wt

        def aep_func(x, y, **_):
            sim_res = windFarmModel(x, y)
            aep = sim_res.aep()
            return aep.sum(['wd', 'ws']).values * 10**6

        def irr_func(aep, **_):
            return economic_evaluation(Drotor_vector, power_rated_vector,
                                       hub_height_vector, aep).calculate_irr()

        aep_comp = CostModelComponent(input_keys=['x', 'y'],
                                      n_wt=n_wt,
                                      cost_function=aep_func,
                                      output_key="aep",
                                      output_unit="GWh",
                                      objective=False,
                                      output_val=np.zeros(n_wt))
        irr_comp = CostModelComponent(input_keys=['aep'],
                                      n_wt=n_wt,
                                      cost_function=irr_func,
                                      output_key="irr",
                                      output_unit="%",
                                      objective=True,
                                      income_model=True)
        group = TopFarmGroup([aep_comp, irr_comp])
        problem = TopFarmProblem(
            design_vars=dict(zip('xy', site.initial_position.T)),
            cost_comp=group,
            driver=EasyRandomSearchDriver(
                randomize_func=RandomizeTurbinePosition_Circle(), max_iter=10),
            constraints=[
                SpacingConstraint(min_spacing),
                XYBoundaryConstraint(site.boundary),
            ],
            plot_comp=plot_comp)
        cost, state, recorder = problem.optimize()
        problem.plot_comp.show()
예제 #13
0
def main():
    if __name__ == '__main__':

        for n_wt in [9, 16, 36, 64]:
            x, y, aep_ref = read_iea37_windfarm(iea37_path +
                                                'iea37-ex%d.yaml' % n_wt)
            if 0:
                import matplotlib.pyplot as plt
                plt.plot(x, y, '2k')
                for i, (x_, y_) in enumerate(zip(x, y)):
                    plt.annotate(i, (x_, y_))
                plt.axis('equal')
                plt.show()
            site = IEA37Site(n_wt)
            windTurbines = IEA37_WindTurbines(iea37_path + 'iea37-335mw.yaml')
            wake_model = IEA37SimpleBastankhahGaussian(site, windTurbines)

            aep = wake_model(x, y, wd=np.arange(0, 360, 22.5), ws=[9.8]).aep()

            # Compare to reference results provided for IEA task 37
            print(n_wt, aep_ref[0] * 1e-3, aep)
예제 #14
0
def test_dAEP_2wt():
    site = Hornsrev1Site()
    iea37_site = IEA37Site(16)

    wsp_cut_in = 4
    wsp_cut_out = 25
    wsp_rated = 9.8
    power_rated = 3350000
    constant_ct = 8 / 9

    def ct(wsp):
        wsp = np.asarray(wsp)
        ct = np.zeros_like(wsp, dtype=float)
        ct[(wsp >= wsp_cut_in) & (wsp <= wsp_cut_out)] = constant_ct
        return ct

    def power(wsp):
        wsp = np.asarray(wsp)
        power = np.where((wsp > wsp_cut_in) & (wsp <= wsp_cut_out),
                         np.minimum(
                             power_rated * ((wsp - wsp_cut_in) /
                                            (wsp_rated - wsp_cut_in))**3,
                             power_rated), 0)

        return power

    def dpower(wsp):
        return np.where((wsp > wsp_cut_in) & (wsp <= wsp_rated),
                        3 * power_rated * (wsp - wsp_cut_in)**2 /
                        (wsp_rated - wsp_cut_in)**3, 0)

    def dct(wsp):
        return wsp * 0  # constant ct

    wt = DeprecatedOneTypeWindTurbines(name='test',
                                       diameter=130,
                                       hub_height=110,
                                       ct_func=ct,
                                       power_func=power,
                                       power_unit='w')
    wt.set_gradient_funcs(dpower, dct)
    wfm = IEA37SimpleBastankhahGaussian(site, wt)
    x, y = iea37_site.initial_position[np.array([0, 2, 5, 8, 14])].T

    # plot 2 wt case
    x, y = np.array([[0, 130 * 4], [0, 0]], dtype=float)
    x_lst = np.array([0., 1.]) * np.arange(1, 600, 10)[:, na]
    kwargs = {'ws': [10], 'wd': [270]}

    _, (ax1, ax2) = plt.subplots(1, 2, sharey=False)
    ax1.plot(x_lst[:, 1], [wfm.aep(x_, y, **kwargs) for x_ in x_lst])
    ax1.set_xlabel('Downwind distance [m]')
    ax1.set_ylabel('AEP [GWh]')

    x_ = x_lst[20]
    ax1.set_title("Center line")
    for grad in [fd, cs, autograd]:
        dAEPdx = wfm.dAEPdn(0, grad)(x_, y, **kwargs)[1]
        npt.assert_almost_equal(dAEPdx / 360, 3.976975605364392e-06,
                                (10, 5)[grad == fd])
        plot_gradients(wfm.aep(x_, y, **kwargs),
                       dAEPdx,
                       x_[1],
                       grad.__name__,
                       step=100,
                       ax=ax1)
    y_lst = np.array([0, 1.]) * np.arange(-100, 100, 5)[:, na]
    ax2.plot(y_lst[:, 1], [wfm.aep(x, y_, **kwargs) for y_ in y_lst])
    ax2.set_xlabel('Crosswind distance [m]')
    ax2.set_ylabel('AEP [GWh]')
    y_ = y_lst[25]
    ax2.set_title("%d m downstream" % x[1])
    for grad in [fd, cs, autograd]:
        dAEPdy = wfm.dAEPdn(1, grad)(x, y_, **kwargs)[1]
        plot_gradients(wfm.aep(x, y_, **kwargs),
                       dAEPdy,
                       y_[1],
                       grad.__name__,
                       step=50,
                       ax=ax2)
        npt.assert_almost_equal(dAEPdy / 360, 3.794435973860448e-05,
                                (10, 5)[grad == fd])

    if 0:
        plt.legend()
        plt.show()
    plt.close('all')
예제 #15
0
from topfarm.drivers.random_search_driver import RandomizeTurbinePosition
from topfarm import TopFarmProblem
from topfarm.plotting import NoPlot, XYPlotComp
from topfarm.constraint_components.boundary import XYBoundaryConstraint
from topfarm.constraint_components.spacing import SpacingConstraint
from topfarm.examples.data.parque_ficticio_offshore import ParqueFicticioOffshore

from py_wake.deficit_models.gaussian import IEA37SimpleBastankhahGaussian
from py_wake.examples.data.iea37._iea37 import IEA37_WindTurbines

site = ParqueFicticioOffshore()
x_init, y_init = site.initial_position[:, 0], site.initial_position[:, 1]
boundary = site.boundary
# # # Wind turbines and wind farm model definition
windTurbines = IEA37_WindTurbines()
wfm = IEA37SimpleBastankhahGaussian(site, windTurbines)

wsp = np.asarray([10, 15])
wdir = np.arange(0, 360, 45)
maximum_water_depth = -52
n_wt = x_init.size
maxiter = 10


def aep_func(x, y, **kwargs):
    simres = wfm(x, y, wd=wdir, ws=wsp)
    aep = simres.aep().values.sum()
    water_depth = np.diag(wfm.site.ds.interp(x=x, y=y)['water_depth'])
    return [aep, water_depth]

def main():
    if __name__ == '__main__':
        try:
            import matplotlib.pyplot as plt
            plt.gcf()
            plot_comp = XYPlotComp()
            plot = True
        except RuntimeError:
            plot_comp = NoPlot()
            plot = False

        n_wt = 16
        site = IEA37Site(n_wt)
        windTurbines = IEA37_WindTurbines()
        windFarmModel = IEA37SimpleBastankhahGaussian(site, windTurbines)
        Drotor_vector = [windTurbines.diameter()] * n_wt
        power_rated_vector = [float(windTurbines.power(20)) * 1e-6] * n_wt
        hub_height_vector = [windTurbines.hub_height()] * n_wt
        distance_from_shore = 10         # [km]
        energy_price = 0.1              # [Euro/kWh] What we get per kWh
        project_duration = 20            # [years]
        rated_rpm_array = [12] * n_wt    # [rpm]
        water_depth_array = [15] * n_wt  # [m]

        eco_eval = economic_evaluation(distance_from_shore, energy_price, project_duration)

        def irr_func(aep, **kwargs):
            eco_eval.calculate_irr(
                rated_rpm_array,
                Drotor_vector,
                power_rated_vector,
                hub_height_vector,
                water_depth_array,
                aep)
            print(eco_eval.IRR)
            return eco_eval.IRR

        aep_comp = CostModelComponent(
            input_keys=['x', 'y'],
            n_wt=n_wt,
            cost_function=lambda x, y, **_: windFarmModel(x=x, y=y).aep().sum(['wd', 'ws']) * 10**6,
            output_key="aep",
            output_unit="kWh",
            objective=False,
            output_val=np.zeros(n_wt))
        irr_comp = CostModelComponent(
            input_keys=['aep'],
            n_wt=n_wt,
            cost_function=irr_func,
            output_key="irr",
            output_unit="%",
            objective=True,
            income_model=True)
        group = TopFarmGroup([aep_comp, irr_comp])
        problem = TopFarmProblem(
            design_vars=dict(zip('xy', site.initial_position.T)),
            cost_comp=group,
            driver=EasyRandomSearchDriver(randomize_func=RandomizeTurbinePosition_Circle(), max_iter=5),
            constraints=[SpacingConstraint(200),
                         CircleBoundaryConstraint([0, 0], 1300.1)],
            plot_comp=plot_comp)
        cost, state, recorder = problem.optimize()
예제 #17
0
from py_wake.examples.data.iea34_130rwt import IEA34_130_1WT_Surrogate
from py_wake.deflection_models.jimenez import JimenezWakeDeflection
from py_wake.superposition_models import MaxSum
from py_wake.wind_turbines.power_ct_functions import SimpleYawModel

site = LillgrundSite()
x, y = site.initial_position.T
#keeping only every second turbine as lillegrund turbines are approx. half the size of the iea 3.4MW
x = x[::2]
y = y[::2]
# # Wind turbines and wind farm model definition
windTurbines = IEA34_130_1WT_Surrogate()  #additional_models=[SimpleYawModel()]

wfm = IEA37SimpleBastankhahGaussian(
    site,
    windTurbines,
    deflectionModel=JimenezWakeDeflection(),
    turbulenceModel=STF2017TurbulenceModel(
        addedTurbulenceSuperpositionModel=MaxSum()))

load_signals = [
    'del_blade_flap', 'del_blade_edge', 'del_tower_bottom_fa',
    'del_tower_bottom_ss', 'del_tower_top_torsion'
]
wsp = np.asarray([10, 15])
wdir = np.asarray([90])

n_wt = x.size
i = n_wt
k = wsp.size
l = wdir.size
from py_wake.turbulence_models.stf import STF2017TurbulenceModel
from py_wake.examples.data.iea34_130rwt import IEA34_130_1WT_Surrogate
from py_wake.superposition_models import MaxSum

site = LillgrundSite()
x, y = site.initial_position.T
#keeping only every second turbine as lillegrund turbines are approx. half the size of the iea 3.4MW
x = x[::2]
y = y[::2]
x_init = x
y_init = y
# # Wind turbines and wind farm model definition
windTurbines = IEA34_130_1WT_Surrogate()
wfm = IEA37SimpleBastankhahGaussian(
    site,
    windTurbines,
    turbulenceModel=STF2017TurbulenceModel(
        addedTurbulenceSuperpositionModel=MaxSum()))

load_signals = [
    'del_blade_flap', 'del_blade_edge', 'del_tower_bottom_fa',
    'del_tower_bottom_ss', 'del_tower_top_torsion'
]
wsp = np.asarray([10, 15])
wdir = np.arange(0, 360, 45)

n_wt = x.size
i = n_wt
k = wsp.size
l = wdir.size