def ainsliefull_1angle(layout_x, layout_y, wind_speed, angle, rotor_radius, TI):
    layout_xD = []
    layout_yD = []

    D = 2.0 * rotor_radius  # Diameter

    for x in range(len(layout_x)):
        layout_xD.append(layout_x[x] / D)

    for x in range(len(layout_y)):
        layout_yD.append(layout_y[x] / D)

    nt = len(layout_y)
    U0 = wind_speed  # Free stream wind speed
    angle3 = angle + 180.0
    wake_deficit_matrix = [[0.0 for _ in range(nt)] for _ in range(nt)]
    distance = [[0.0 for _ in range(2)] for _ in range(nt)]
    total_deficit = [0.0 for _ in range(nt)]
    U = [U0 for _ in range(nt)]
    U = U
    TI *= 100.0

    for tur in range(nt):
        distance[tur] = [distance_to_front(layout_xD[tur], layout_yD[tur], angle), tur]
    distance.sort()

    for turbine in range(nt):

        for num in range(turbine):
            total_deficit[distance[turbine][1]] += wake_deficit_matrix[distance[turbine][1]][
                                                       distance[num][1]] ** 2.0
        total_deficit[distance[turbine][1]] = sqrt(total_deficit[distance[turbine][1]])
        U[distance[turbine][1]] = U0 * (1.0 - total_deficit[distance[turbine][1]])
        parallel_distance = [0.0 for _ in range(nt)]
        perpendicular_distance = [0.0 for _ in range(nt)]

        for i in range(turbine + 1, nt):
            parallel_distance[distance[i][1]] = determine_front(angle3, layout_xD[distance[turbine][1]],
                                                                layout_yD[distance[turbine][1]],
                                                                layout_xD[distance[i][1]],
                                                                layout_yD[distance[i][1]])
            perpendicular_distance[distance[i][1]] = wake.crosswind_distance(radians(angle3),
                                                                             layout_xD[distance[turbine][1]],
                                                                             layout_yD[distance[turbine][1]],
                                                                             layout_xD[distance[i][1]],
                                                                             layout_yD[distance[i][1]])

            if perpendicular_distance[distance[i][1]] <= 2.0 and parallel_distance[
                distance[i][1]] > 0.0:  ## 1.7 gives same results as a bigger distance, many times faster.

                wake_deficit_matrix[distance[i][1]][distance[turbine][1]] = ainslie_full(
                    Ct(U[distance[turbine][1]]), U[distance[turbine][1]],
                    parallel_distance[distance[i][1]], perpendicular_distance[distance[i][1]], TI)
            else:
                wake_deficit_matrix[distance[i][1]][distance[turbine][1]] = 0.0

    # print angle, sum([power(U[i]) for i in range(len(U))])
    return U
Example #2
0
    def solve_nonlinear(self, params, unknowns, resids):

        D = 2.0 * params['rotor_radius']  # Diameter

        layout_x = params['layout_x']
        layout_y = params['layout_y']
        layout_xD = array(layout_x) / D
        layout_yD = array(layout_y) / D

        U0 = params['mean_ambient_wind_speed']  # Free stream wind speed
        angle = params['wind_direction']
        nt = num_turb
        angle3 = angle + 180.0
        wake_deficit_matrix = [[0.0 for _ in range(nt)] for _ in range(nt)]
        distance = [[0.0 for _ in range(2)] for _ in range(nt)]
        total_deficit = [0.0 for _ in range(nt)]
        U = [U0 for _ in range(nt)]

        for tur in range(nt):
            distance[tur] = [distance_to_front(layout_xD[tur], layout_yD[tur], angle), tur]

        distance.sort()

        for turbine in range(nt):
            for num in range(turbine):
                total_deficit[distance[turbine][1]] += wake_deficit_matrix[distance[turbine][1]][
                                                           distance[num][1]] ** 2.0
            total_deficit[distance[turbine][1]] = sqrt(total_deficit[distance[turbine][1]])
            U[distance[turbine][1]] = U0 * (1.0 - total_deficit[distance[turbine][1]])
            parallel_distance = [0.0 for _ in range(nt)]
            perpendicular_distance = [0.0 for _ in range(nt)]

            for i in range(turbine + 1, nt):
                parallel_distance[distance[i][1]] = determine_front(angle3, layout_xD[distance[turbine][1]],
                                                                    layout_yD[distance[turbine][1]],
                                                                    layout_xD[distance[i][1]],
                                                                    layout_yD[distance[i][1]])
                perpendicular_distance[distance[i][1]] = wake.crosswind_distance(radians(angle3),
                                                                                 layout_xD[distance[turbine][1]],
                                                                                 layout_yD[distance[turbine][1]],
                                                                                 layout_xD[distance[i][1]],
                                                                                 layout_yD[distance[i][1]])

                if perpendicular_distance[distance[i][1]] <= 1.7 and parallel_distance[
                    distance[i][1]] > 0.0:  ## 1.7 gives same results as a bigger distance, many times faster.

                    wake_deficit_matrix[distance[i][1]][distance[turbine][1]] = ainslie(
                        Ct(U[distance[turbine][1]]), U[distance[turbine][1]],
                        parallel_distance[distance[i][1]], perpendicular_distance[distance[i][1]], params['TI'])
                else:
                    wake_deficit_matrix[distance[i][1]][distance[turbine][1]] = 0.0

        unknowns['U'] = array(U)
def ainslie_1angle(layout_x, layout_y, wind_speed, angle, rotor_radius, TI):

    layout_xD = []
    layout_yD = []

    D = 2.0 * rotor_radius  # Diameter

    for x in range(len(layout_x)):
        layout_xD.append(layout_x[x] / D)

    for x in range(len(layout_y)):
        layout_yD.append(layout_y[x] / D)

    nt = len(layout_y)
    U0 = wind_speed  # Free stream wind speed
    angle3 = angle + 180.0
    wake_deficit_matrix = [[0.0 for _ in range(nt)] for _ in range(nt)]
    distance = [[0.0 for _ in range(2)] for _ in range(nt)]
    total_deficit = [0.0 for _ in range(nt)]
    U = [U0 for _ in range(nt)]
    U = U
    TI *= 100.0

    for tur in range(nt):
        distance[tur] = [
            distance_to_front(layout_xD[tur], layout_yD[tur], angle), tur
        ]
    distance.sort()

    for turbine in range(nt):
        for num in range(turbine):
            total_deficit[distance[turbine][1]] += wake_deficit_matrix[
                distance[turbine][1]][distance[num][1]]**2.0
        total_deficit[distance[turbine][1]] = sqrt(
            total_deficit[distance[turbine][1]])
        U[distance[turbine][1]] = U0 * (1.0 -
                                        total_deficit[distance[turbine][1]])
        parallel_distance = [0.0 for _ in range(nt)]
        perpendicular_distance = [0.0 for _ in range(nt)]

        for i in range(turbine + 1, nt):
            parallel_distance[distance[i][1]] = determine_front(
                angle3, layout_xD[distance[turbine][1]],
                layout_yD[distance[turbine][1]], layout_xD[distance[i][1]],
                layout_yD[distance[i][1]])
            perpendicular_distance[distance[i][1]] = wake.crosswind_distance(
                radians(angle3), layout_xD[distance[turbine][1]],
                layout_yD[distance[turbine][1]], layout_xD[distance[i][1]],
                layout_yD[distance[i][1]])

            if perpendicular_distance[
                    distance[i]
                [1]] <= 1.7 and parallel_distance[distance[i][
                    1]] > 0.0:  ## 1.7 gives same results as a bigger distance, many times faster.

                wake_deficit_matrix[distance[i][1]][
                    distance[turbine][1]] = ainslie(
                        Ct(U[distance[turbine][1]]), U[distance[turbine][1]],
                        parallel_distance[distance[i][1]],
                        perpendicular_distance[distance[i][1]], TI)
            else:
                wake_deficit_matrix[distance[i][1]][distance[turbine][1]] = 0.0

    return U