def create_vertices(low=0.0, high=1000.0, npoints=100):

    if npoints < 3:
        npoints += 3

    # np.random.seed(64)

    points = (np.random.rand(npoints, 2) + low) * high

    print points

    boundaryVertices, boundaryNormals = calculate_boundary(points)

    return boundaryVertices
Example #2
0
def generate_layout(vertices, npoints=60):

    # get unit normals
    boundaryVertices, unit_normals = calculate_boundary(vertices)
    print unit_normals

    # initialize points array
    points = np.zeros([npoints, 2])

    # deterine high and low values for containing rectangle
    highx = max(vertices[:, 0])
    lowx = min(vertices[:, 0])
    highy = max(vertices[:, 1])
    lowy = min(vertices[:, 1])

    print highx
    print lowx
    print highy
    print lowy

    # generate random points within the wind farm boundary
    np.random.seed(101)
    for i in range(0, npoints):

        good_point = False

        while not good_point:

            # generate random point in containing rectangle
            point = np.random.rand(1, 2)
            # print point
            point[:, 0] = point[:, 0]*(highx - lowx) + lowx
            point[:, 1] = point[:, 1]*(highy - lowy) + lowy
            # print point

            # calculate signed distance from the point to each boundary facet
            # distance = calculate_distance(point, vertices, unit_normals)
            distance = calculate_distance(point, boundaryVertices, unit_normals)


            # determine if the point is inside the wind farm boundary
            if all(d >= 0 for d in distance[0]):
                good_point = True
                points[i, :] = point[0, :]

    return points, boundaryVertices
    windRose = np.loadtxt(
        './input_files/windrose_amalia_directionally_averaged_speeds.txt')
    indexes = np.where(windRose[:, 1] > 0.1)
    windDirections = windRose[indexes[0], 0]
    windSpeeds = windRose[indexes[0], 1]
    windFrequencies = windRose[indexes[0], 2]

    nDirections = len(windDirections)

    # load turbine positions
    locations = np.loadtxt('./input_files/layout_amalia.txt')
    turbineX = locations[:, 0]
    turbineY = locations[:, 1]

    # generate boundary constraint
    boundaryVertices, boundaryNormals = calculate_boundary(locations)
    nVertices = boundaryVertices.shape[0]

    # define turbine size
    rotor_diameter = 126.4  # (m)

    # initialize input variable arrays
    nTurbines = turbineX.size
    rotorDiameter = np.zeros(nTurbines)
    axialInduction = np.zeros(nTurbines)
    Ct = np.zeros(nTurbines)
    Cp = np.zeros(nTurbines)
    generatorEfficiency = np.zeros(nTurbines)
    yaw = np.zeros(nTurbines)
    minSpacing = 2.  # number of rotor diameters
    # load wind rose data
    windRose = np.loadtxt('./input_files/windrose_amalia_directionally_averaged_speeds.txt')
    indexes = np.where(windRose[:, 1] > 0.1)
    windDirections = windRose[indexes[0], 0]
    windSpeeds = windRose[indexes[0], 1]
    windFrequencies = windRose[indexes[0], 2]

    nDirections = len(windDirections)

    # load turbine positions
    locations = np.loadtxt('./input_files/layout_amalia.txt')
    turbineX = locations[:, 0]
    turbineY = locations[:, 1]

    # generate boundary constraint
    boundaryVertices, boundaryNormals = calculate_boundary(locations)
    nVertices = boundaryVertices.shape[0]

    # define turbine size
    rotor_diameter = 126.4  # (m)

    # initialize input variable arrays
    nTurbines = turbineX.size
    rotorDiameter = np.zeros(nTurbines)
    axialInduction = np.zeros(nTurbines)
    Ct = np.zeros(nTurbines)
    Cp = np.zeros(nTurbines)
    generatorEfficiency = np.zeros(nTurbines)
    yaw = np.zeros(nTurbines)
    minSpacing = 2.                         # number of rotor diameters