Exemplo n.º 1
0
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)]
    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]] <= 5.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
Exemplo n.º 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)
Exemplo n.º 3
0
def ainslie(a, windrose_angle, windrose_speed, windrose_frequency):

    from wake import crosswind_distance
    from eddy_viscosity_integrate import ainslie
    from math import sqrt, log, cos, sin, tan
    from numpy import deg2rad

    nt = len(a)
    D = 80.0  # Diameter
    summation = 0.0

    layout_x = [0.0 for x in range(nt)]
    layout_y = [0.0 for x in range(nt)]
    for x in range(nt):
        layout_x[x] = float(a[x][0] / D)
        layout_y[x] = float(a[x][1] / D)

    def determine_front(wind_angle, x_t1, y_t1, x_t2, y_t2):
        wind_angle = deg2rad(wind_angle)
        a = (x_t2 - x_t1) * cos(wind_angle) + (y_t2 - y_t1) * sin(wind_angle)
        if a > 0.0:
            return a
        else:
            return 0.0

    def power(U0):
        if U0 < 4.0:
            return 0.0
        elif U0 <= 25.0:
            return - 0.5308414162 * U0 ** 3.0 + 15.4948143381 * U0 ** 2.0 + 13.1508234816 * U0
        else:
            return 0.0

    def Ct(U0):
        if U0 < 4.0:
            return 0.1
        elif U0 <= 25.0:
            return 7.3139922126945e-7 * U0 ** 6.0 - 6.68905596915255e-5 * U0 ** 5.0 + 2.3937885e-3 * U0 ** 4.0 + - 0.0420283143 * U0 ** 3.0 + 0.3716111285 * U0 ** 2.0 - 1.5686969749 * U0 + 3.2991094727
        else:
            return 0.0

    def distance_to_front(x, y, theta, r):
        theta = deg2rad(theta)
        return abs(x + tan(theta) * y - r / cos(theta)) / sqrt(1.0 + tan(theta) ** 2.0)

    for wind in range(0, len(windrose_angle)):
        U1 = windrose_speed[wind]  # Free stream wind speed
        U0 = U1 * (70.0 / 10.0) ** 0.11  # Power or log law for wind shear profile
        angle = windrose_angle[wind]
        angle3 = angle + 180.0
        wake_deficit_matrix = [[0.0 for x in range(nt)] for x in range(nt)]
        distance = [[0.0 for x in range(2)] for x in range(nt)]
        total_deficit = [0.0 for x in range(nt)]
        total_speed = [U0 for x in range(nt)]

        for tur in range(nt):
            distance[tur] = [distance_to_front(layout_x[tur], layout_y[tur], angle, 1000000000.0), 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]])
            total_speed[distance[turbine][1]] = U0 * (1.0 - total_deficit[distance[turbine][1]])
            parallel_distance = [0.0 for x in range(0, nt)]
            perpendicular_distance = [0.0 for x in range(0, nt)]
            for i in range(turbine + 1, nt):
                parallel_distance[distance[i][1]] = determine_front(angle3, layout_x[distance[turbine][1]], layout_y[distance[turbine][1]], layout_x[distance[i][1]], layout_y[distance[i][1]])
                perpendicular_distance[distance[i][1]] = crosswind_distance(deg2rad(angle3), layout_x[distance[turbine][1]], layout_y[distance[turbine][1]], layout_x[distance[i][1]], layout_y[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(total_speed[distance[turbine][1]]), total_speed[distance[turbine][1]], parallel_distance[distance[i][1]], perpendicular_distance[distance[i][1]])
                else:
                    wake_deficit_matrix[distance[i][1]][distance[turbine][1]] = 0.0

        # Farm efficiency
        profit = 0.0
        efficiency_proportion = [0.0 for x in range(len(windrose_frequency))]
        efficiency = 0.0
        for l in range(nt):
            profit += power(total_speed[l])
            efficiency = profit * 100.0 / (nt * power(total_speed[distance[0][1]]))
        efficiency_proportion[wind] = efficiency * windrose_frequency[wind] / 100.0
        summation += efficiency_proportion[wind]
    return 100.0 - summation
Exemplo n.º 4
0
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
    def ainslie_angle(self, wind_speed, angle):

        D = 126.0  # Diameter

        for x in range(len(self.layout_x)):
            self.layout_x[x] = (self.layout_x[x] / D)

        for x in range(len(self.layout_y)):
            self.layout_y[x] = (self.layout_y[x] / D)

        layout_x = self.layout_x
        layout_y = self.layout_y

        nt = len(self.layout_y)
        # turb_data = open('turb1_power_jensen.dat', 'w', 1)
        direction = open('direction_power_ainslie.dat', 'w', 1)
        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)]
        self.U = [U0 for _ in range(nt)]
        U = self.U

        for tur in range(nt):
            distance[tur] = [distance_to_front(layout_x[tur], layout_y[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 x in range(nt)]
            perpendicular_distance = [0.0 for x in range(nt)]

            for i in range(turbine + 1, nt):
                parallel_distance[distance[i][1]] = determine_front(angle3, layout_x[distance[turbine][1]],
                                                                    layout_y[distance[turbine][1]],
                                                                    layout_x[distance[i][1]],
                                                                    layout_y[distance[i][1]])
                perpendicular_distance[distance[i][1]] = wake.crosswind_distance(radians(angle3),
                                                                                 layout_x[distance[turbine][1]],
                                                                                 layout_y[distance[turbine][1]],
                                                                                 layout_x[distance[i][1]],
                                                                                 layout_y[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]])
                else:
                    wake_deficit_matrix[distance[i][1]][distance[turbine][1]] = 0.0
        # turb_data.write('{0:f} {1:f}\n'.format(angle, power(U[14])))
        # Farm efficiency
        profit = 0.0
        for l in range(nt):
            profit += power(U[l])
        self.efficiency = profit * 100.0 / (float(nt) * power(U[distance[0][1]]))
        self.powers = [power(self.U[i]) for i in range(nt)]

        with open('speed_ainslie.dat', 'w') as out:
            for i in range(len(self.U)):
                print U[i]
                out.write('{0:f}\n'.format(self.U[i]))
    def ainslie_windrose(self, windrose_file):

        D = 80.0  # Diameter

        for x in range(len(self.layout_x)):
            self.layout_x[x] = (self.layout_x[x] / D)

        for x in range(len(self.layout_y)):
            self.layout_y[x] = (self.layout_y[x] / D)

        layout_x = self.layout_x
        layout_y = self.layout_y

        windrose = open(windrose_file, 'r')
        windrose_angle = []
        windrose_speed = []
        windrose_frequency = []

        for line in windrose:
            columns = line.split()
            windrose_angle.append(float(columns[0]))
            windrose_speed.append(float(columns[1]))
            windrose_frequency.append(float(columns[2]))

        nt = len(self.layout_y)
        # turb_data = open('turb1_power_jensen.dat', 'w', 1)
        direction = open('direction_power_ainslie.dat', 'w', 1)

        for wind in range(0, len(windrose_angle)):

            U0 = windrose_speed[wind]  # Free stream wind speed
            angle = windrose_angle[wind]
            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_x[tur], layout_y[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 x in range(nt)]
                perpendicular_distance = [0.0 for x in range(nt)]

                for i in range(turbine + 1, nt):
                    parallel_distance[distance[i][1]] = determine_front(angle3, layout_x[distance[turbine][1]],
                                                                        layout_y[distance[turbine][1]],
                                                                        layout_x[distance[i][1]],
                                                                        layout_y[distance[i][1]])
                    perpendicular_distance[distance[i][1]] = wake.crosswind_distance(radians(angle3),
                                                                                layout_x[distance[turbine][1]],
                                                                                layout_y[distance[turbine][1]],
                                                                                layout_x[distance[i][1]],
                                                                                layout_y[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]])
                    else:
                        wake_deficit_matrix[distance[i][1]][distance[turbine][1]] = 0.0
            # turb_data.write('{0:f} {1:f}\n'.format(angle, power(U[14])))
            # Farm efficiency
            profit = 0.0
            efficiency_proportion = [0.0 for _ in range(0, len(windrose_frequency))]
            for l in range(nt):
                profit += power(U[l])
            efficiency = profit * 100.0 / (float(nt) * power(U[distance[0][1]]))
            efficiency_proportion[wind] = efficiency * windrose_frequency[wind] / 100.0
            direction.write('{0:f} {1:f}\n'.format(angle, profit))
            self.summation += efficiency_proportion[wind]
Exemplo n.º 7
0
                def analysis():

                    nt = len(layout_y)
                    summation = 0.0

                    def distance_to_front(x, y, theta, r):
                        theta = deg2rad(theta)
                        return abs(x + tan(theta) * y - r /
                                   cos(theta)) / sqrt(1.0 + tan(theta)**2.0)

                    for wind in range(0, len(windrose_angle)):
                        # print wind
                        # for wind in range(0, 1):
                        U1 = windrose_speed[wind]  # Free stream wind speed
                        U0 = U1 * (
                            70.0 / 10.0
                        )**0.11  # Power or log law for wind shear profile
                        # U0 = U1 * log(70.0 / 0.005) / log(10.0 / 0.005)
                        # U0 = 8.5
                        angle = windrose_angle[wind]
                        angle3 = angle + 180.0
                        wake_deficit_matrix = [[0.0 for x in range(nt)]
                                               for x in range(nt)]
                        distance = [[0.0 for x in range(2)] for x in range(nt)]
                        total_deficit = [0.0 for x in range(nt)]
                        total_speed = [U0 for x in range(nt)]

                        for tur in range(nt):
                            distance[tur] = [
                                distance_to_front(layout_x[tur], layout_y[tur],
                                                  angle, 1000000000.0), 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]])
                            total_speed[distance[turbine][1]] = U0 * (
                                1.0 - total_deficit[distance[turbine][1]])
                            parallel_distance = [0.0 for x in range(nt)]
                            perpendicular_distance = [0.0 for x in range(nt)]
                            for i in range(turbine + 1, nt):
                                parallel_distance[
                                    distance[i][1]] = determine_front(
                                        angle3, layout_x[distance[turbine][1]],
                                        layout_y[distance[turbine][1]],
                                        layout_x[distance[i][1]],
                                        layout_y[distance[i][1]])
                                perpendicular_distance[
                                    distance[i][1]] = crosswind_distance(
                                        deg2rad(angle3),
                                        layout_x[distance[turbine][1]],
                                        layout_y[distance[turbine][1]],
                                        layout_x[distance[i][1]],
                                        layout_y[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(total_speed[distance[turbine]
                                                           [1]]),
                                            total_speed[distance[turbine][1]],
                                            parallel_distance[distance[i][1]],
                                            perpendicular_distance[distance[i]
                                                                   [1]])
                                else:
                                    wake_deficit_matrix[distance[i][1]][
                                        distance[turbine][1]] = 0.0

                        # for turbine in range(0, nt):
                        #     parallel_distance = [0.0 for x in range(0, nt)]
                        #     perpendicular_distance = [0.0 for x in range(0, nt)]
                        #     flag = [False for x in range(nt)]
                        #     for i in range(nt):
                        #         flag[i], parallel_distance[i] = determine_front(angle3, layout_x[turbine], layout_y[turbine], layout_x[i], layout_y[i])
                        #         perpendicular_distance[i] = wake.crosswind_distance(deg2rad(angle3), layout_x[turbine], layout_y[turbine], layout_x[i], layout_y[i])

                        # Matrix with effect of each turbine <i = turbine> on every other turbine <j> of the farm

                        #     output.write('{0:f}\t'.format(wake_deficit_matrix[j][turbine]))
                        # output.write('\n')

                        #     output2.write('{0:d}\t{1:.1f}\t{2:.1f}\t{3:f}\t{4:f}\t{5:d}\t{6:f}\n'.format(j, layout_x[j] * D, layout_y[j] * D, total_deficit[j], total_speed[j], int(angle), power(total_speed[j])))
                        # output2.write('\n')

                        # for n in range(nt):
                        #     aver[n] += power(total_speed[n]) / 360.0
                        # ---------------------------------------TODO UNCOMMENT -----------------------------------------
                        if withdata:
                            turb_data.write('{0:f} {1:f}\n'.format(
                                angle, power(total_speed[14])))

                        # Farm efficiency
                        profit = 0.0
                        efficiency_proportion = [
                            0.0 for x in range(0, len(windrose_frequency))
                        ]
                        for l in range(nt):
                            profit += power(total_speed[l])
                        efficiency = profit * 100.0 / (
                            nt * power(total_speed[distance[0][1]]))
                        efficiency_proportion[
                            wind] = efficiency * windrose_frequency[
                                wind] / 100.0
                        # ---------------------------------------TODO UNCOMMENT ------------------------------------------
                        if withdata:
                            direction.write('{0:f} {1:f}\n'.format(
                                angle, profit))
                        summation += efficiency_proportion[wind]
                    print summation
                def analysis():

                    nt = len(layout_y)
                    summation = 0.0

                    def distance_to_front(x, y, theta, r):
                        theta = deg2rad(theta)
                        return abs(x + tan(theta) * y - r / cos(theta)) / sqrt(1.0 + tan(theta) ** 2.0)

                    for wind in range(0, len(windrose_angle)):
                        # print wind
                    # for wind in range(0, 1):
                        U1 = windrose_speed[wind]  # Free stream wind speed
                        U0 = U1 * (70.0 / 10.0) ** 0.11  # Power or log law for wind shear profile
                        # U0 = U1 * log(70.0 / 0.005) / log(10.0 / 0.005)
                        # U0 = 8.5
                        angle = windrose_angle[wind]
                        angle3 = angle + 180.0
                        wake_deficit_matrix = [[0.0 for x in range(nt)] for x in range(nt)]
                        distance = [[0.0 for x in range(2)] for x in range(nt)]
                        total_deficit = [0.0 for x in range(nt)]
                        total_speed = [U0 for x in range(nt)]

                        for tur in range(nt):
                            distance[tur] = [distance_to_front(layout_x[tur], layout_y[tur], angle, 1000000000.0), 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]])
                            total_speed[distance[turbine][1]] = U0 * (1.0 - total_deficit[distance[turbine][1]])
                            parallel_distance = [0.0 for x in range(nt)]
                            perpendicular_distance = [0.0 for x in range(nt)]
                            for i in range(turbine + 1, nt):
                                parallel_distance[distance[i][1]] = determine_front(angle3, layout_x[distance[turbine][1]], layout_y[distance[turbine][1]], layout_x[distance[i][1]], layout_y[distance[i][1]])
                                perpendicular_distance[distance[i][1]] = crosswind_distance(deg2rad(angle3), layout_x[distance[turbine][1]], layout_y[distance[turbine][1]], layout_x[distance[i][1]], layout_y[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(total_speed[distance[turbine][1]]), total_speed[distance[turbine][1]], parallel_distance[distance[i][1]], perpendicular_distance[distance[i][1]])
                                else:
                                    wake_deficit_matrix[distance[i][1]][distance[turbine][1]] = 0.0

                        # for turbine in range(0, nt):
                        #     parallel_distance = [0.0 for x in range(0, nt)]
                        #     perpendicular_distance = [0.0 for x in range(0, nt)]
                        #     flag = [False for x in range(nt)]
                        #     for i in range(nt):
                        #         flag[i], parallel_distance[i] = determine_front(angle3, layout_x[turbine], layout_y[turbine], layout_x[i], layout_y[i])
                        #         perpendicular_distance[i] = wake.crosswind_distance(deg2rad(angle3), layout_x[turbine], layout_y[turbine], layout_x[i], layout_y[i])

                            # Matrix with effect of each turbine <i = turbine> on every other turbine <j> of the farm

                            #     output.write('{0:f}\t'.format(wake_deficit_matrix[j][turbine]))
                            # output.write('\n')


                        #     output2.write('{0:d}\t{1:.1f}\t{2:.1f}\t{3:f}\t{4:f}\t{5:d}\t{6:f}\n'.format(j, layout_x[j] * D, layout_y[j] * D, total_deficit[j], total_speed[j], int(angle), power(total_speed[j])))
                        # output2.write('\n')

                        # for n in range(nt):
                        #     aver[n] += power(total_speed[n]) / 360.0
                        # ---------------------------------------TODO UNCOMMENT -----------------------------------------
                        if withdata:
                            turb_data.write('{0:f} {1:f}\n'.format(angle, power(total_speed[14])))

                        # Farm efficiency
                        profit = 0.0
                        efficiency_proportion = [0.0 for x in range(0, len(windrose_frequency))]
                        for l in range(nt):
                            profit += power(total_speed[l])
                        efficiency = profit * 100.0 / (nt * power(total_speed[distance[0][1]]))
                        efficiency_proportion[wind] = efficiency * windrose_frequency[wind] / 100.0
                    # ---------------------------------------TODO UNCOMMENT ------------------------------------------
                        if withdata:
                            direction.write('{0:f} {1:f}\n'.format(angle, profit))
                        summation += efficiency_proportion[wind]
                    print summation
Exemplo n.º 9
0
def analysis():
    nt = 80  # Number of turbines
    D = 80.0  # Diameter
    layout_x = []
    layout_y = []
    for line in layout:
        columns = line.split()
        layout_x.append(float(columns[0]) / D)
        layout_y.append(float(columns[1]) / D)

    windrose_angle = []
    windrose_speed = []
    windrose_frequency = []
    for line in windrose:
        columns = line.split()
        windrose_angle.append(float(columns[0]))
        windrose_speed.append(float(columns[1]))
        windrose_frequency.append(float(columns[2]))

    layout.close()
    windrose.close()
    summation = 0.0

    def power(U):
        if U < 4.0:
            return 0.0
        elif U <= 25.0:
            return 0.0003234808 * U**7.0 - 0.0331940121 * U**6.0 + 1.3883148012 * U**5.0 - 30.3162345004 * U**4.0 + 367.6835557011 * U**3.0 - 2441.6860655008 * U**2.0 + 8345.6777042343 * U - 11352.9366182805
        else:
            return 0.0

    def Ct(U):
        return 0.0001923077 * U**4.0 + -0.0075407925 * U**3.0 + 0.096462704 * U**2.0 - 0.5012354312 * U + 1.7184749184

    def distance_to_front(x, y, theta, r):
        theta = deg2rad(theta)
        return abs(x + tan(theta) * y - r / cos(theta)) / sqrt(1.0 +
                                                               tan(theta)**2.0)

    # aver = [0.0 for x in range(nt)]
    for wind in range(0, len(windrose_angle)):
        # print wind
        # for wind in range(0, 1):
        U1 = windrose_speed[wind]  # Free stream wind speed
        U0 = U1 * (70.0 /
                   10.0)**0.11  # Power or log law for wind shear profile
        # U0 = U1 * log(70.0 / 0.005) / log(10.0 / 0.005)
        # U0 = 8.5
        angle = windrose_angle[wind]
        angle3 = angle + 180.0
        wake_deficit_matrix = [[0.0 for x in range(nt)] for x in range(nt)]
        distance = [[0.0 for x in range(2)] for x in range(nt)]
        total_deficit = [0.0 for x in range(nt)]
        total_speed = [U0 for x in range(nt)]

        for tur in range(nt):
            distance[tur] = [
                distance_to_front(layout_x[tur], layout_y[tur], angle,
                                  100000000.0), 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]])
            total_speed[distance[turbine]
                        [1]] = U0 * (1.0 - total_deficit[distance[turbine][1]])
            parallel_distance = [0.0 for x in range(0, nt)]
            perpendicular_distance = [0.0 for x in range(0, nt)]
            for i in range(turbine + 1, nt):
                parallel_distance[distance[i][1]] = determine_front(
                    angle3, layout_x[distance[turbine][1]],
                    layout_y[distance[turbine][1]], layout_x[distance[i][1]],
                    layout_y[distance[i][1]])
                perpendicular_distance[
                    distance[i][1]] = wake.crosswind_distance(
                        deg2rad(angle3), layout_x[distance[turbine][1]],
                        layout_y[distance[turbine][1]],
                        layout_x[distance[i][1]], layout_y[distance[i][1]])
                if perpendicular_distance[
                        distance[i]
                    [1]] <= 1.7:  ## 1.7 gives same results as a bigger distance, many times faster.
                    wake_deficit_matrix[distance[i][1]][
                        distance[turbine][1]] = ainslie(
                            Ct(total_speed[distance[turbine][1]]),
                            total_speed[distance[turbine][1]],
                            parallel_distance[distance[i][1]],
                            perpendicular_distance[distance[i][1]])
                else:
                    wake_deficit_matrix[distance[i][1]][distance[turbine]
                                                        [1]] = 0.0

        # for turbine in range(0, nt):
        #     parallel_distance = [0.0 for x in range(0, nt)]
        #     perpendicular_distance = [0.0 for x in range(0, nt)]
        #     flag = [False for x in range(nt)]
        #     for i in range(nt):
        #         flag[i], parallel_distance[i] = determine_front(angle3, layout_x[turbine], layout_y[turbine], layout_x[i], layout_y[i])
        #         perpendicular_distance[i] = wake.crosswind_distance(deg2rad(angle3), layout_x[turbine], layout_y[turbine], layout_x[i], layout_y[i])

        # Matrix with effect of each turbine <i = turbine> on every other turbine <j> of the farm

        #     output.write('{0:f}\t'.format(wake_deficit_matrix[j][turbine]))
        # output.write('\n')

        #     output2.write('{0:d}\t{1:.1f}\t{2:.1f}\t{3:f}\t{4:f}\t{5:d}\t{6:f}\n'.format(j, layout_x[j] * D, layout_y[j] * D, total_deficit[j], total_speed[j], int(angle), power(total_speed[j])))
        # output2.write('\n')

        # for n in range(nt):
        #     aver[n] += power(total_speed[n]) / 360.0

        turb_data.write('{0:f}\n'.format(power(total_speed[14])))

        # Farm efficiency
        profit = 0.0
        efficiency_proportion = [
            0.0 for x in range(0, len(windrose_frequency))
        ]
        for l in range(nt):
            profit += power(total_speed[l])
        efficiency = profit * 100.0 / (nt * power(total_speed[distance[0][1]]))
        efficiency_proportion[
            wind] = efficiency * windrose_frequency[wind] / 100.0
        # print 'Farm efficiency with wind direction = {0:d} deg: {1:2.2f}%'.format(int(angle), efficiency)
        direction.write('{0:f}\n'.format(profit))
        summation += efficiency_proportion[wind]
    print 'total farm efficiency is {0:f} %'.format(summation)
    # for n in range(nt):
    # turb_data.write('{0:f}\n'.format(aver[n]))
    # print U0, summation

    turb_data.close()
    # output.close()
    # output2.close()
    # draw.close()
    direction.close()