How to use the floris.utilities.Vec3 function in FLORIS

To help you get started, we’ve selected a few FLORIS examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github NREL / floris / floris / tools / sowfa_utilities.py View on Github external
Read flow array output from SOWFA

        Args:
            filename (str): name of file containing flow data.

        Returns:
            FlowData (pd.DataFrame): a pandas table with the columns,
                of all relavent flow info (e.g. x, y, z, u, v, w).
        """
        # Read the dimension info from the file
        with open(filename, "r") as f:
            for _ in range(10):
                read_data = f.readline()
                if "SPACING" in read_data:
                    splitstring = read_data.rstrip().split(" ")
                    spacing = Vec3(
                        float(splitstring[1]),
                        float(splitstring[2]),
                        float(splitstring[3]),
                    )
                if "DIMENSIONS" in read_data:
                    splitstring = read_data.rstrip().split(" ")
                    dimensions = Vec3(
                        int(splitstring[1]), int(splitstring[2]), int(splitstring[3])
                    )
                if "ORIGIN" in read_data:
                    splitstring = read_data.rstrip().split(" ")
                    origin = Vec3(
                        float(splitstring[1]),
                        float(splitstring[2]),
                        float(splitstring[3]),
                    )
github NREL / floris / floris / tools / sowfa_utilities.py View on Github external
read_data = f.readline()
                if "SPACING" in read_data:
                    splitstring = read_data.rstrip().split(" ")
                    spacing = Vec3(
                        float(splitstring[1]),
                        float(splitstring[2]),
                        float(splitstring[3]),
                    )
                if "DIMENSIONS" in read_data:
                    splitstring = read_data.rstrip().split(" ")
                    dimensions = Vec3(
                        int(splitstring[1]), int(splitstring[2]), int(splitstring[3])
                    )
                if "ORIGIN" in read_data:
                    splitstring = read_data.rstrip().split(" ")
                    origin = Vec3(
                        float(splitstring[1]),
                        float(splitstring[2]),
                        float(splitstring[3]),
                    )

        # Set up x, y, z as lists
        if dimensions.x1 > 1.0:
            xRange = np.arange(0, dimensions.x1 * spacing.x1, spacing.x1)
        else:
            xRange = np.array([0.0])

        if dimensions.x2 > 1.0:
            yRange = np.arange(0, dimensions.x2 * spacing.x2, spacing.x2)
        else:
            yRange = np.array([0.0])
github NREL / floris / floris / tools / sowfa_utilities.py View on Github external
of all relavent flow info (e.g. x, y, z, u, v, w).
        """
        # Read the dimension info from the file
        with open(filename, "r") as f:
            for _ in range(10):
                read_data = f.readline()
                if "SPACING" in read_data:
                    splitstring = read_data.rstrip().split(" ")
                    spacing = Vec3(
                        float(splitstring[1]),
                        float(splitstring[2]),
                        float(splitstring[3]),
                    )
                if "DIMENSIONS" in read_data:
                    splitstring = read_data.rstrip().split(" ")
                    dimensions = Vec3(
                        int(splitstring[1]), int(splitstring[2]), int(splitstring[3])
                    )
                if "ORIGIN" in read_data:
                    splitstring = read_data.rstrip().split(" ")
                    origin = Vec3(
                        float(splitstring[1]),
                        float(splitstring[2]),
                        float(splitstring[3]),
                    )

        # Set up x, y, z as lists
        if dimensions.x1 > 1.0:
            xRange = np.arange(0, dimensions.x1 * spacing.x1, spacing.x1)
        else:
            xRange = np.array([0.0])
github NREL / floris / floris / utilities.py View on Github external
def __sub__(self, arg):
        if type(arg) is Vec3:
            return Vec3(self.x1 - arg.x1, self.x2 - arg.x2, self.x3 - arg.x3)
        else:
            return Vec3(self.x1 - arg, self.x2 - arg, self.x3 - arg)
github NREL / floris / floris / utilities.py View on Github external
def __mul__(self, arg):
        if type(arg) is Vec3:
            return Vec3(self.x1 * arg.x1, self.x2 * arg.x2, self.x3 * arg.x3)
        else:
            return Vec3(self.x1 * arg, self.x2 * arg, self.x3 * arg)
github NREL / floris / floris / tools / floris_interface.py View on Github external
v = (
                abs(v - flow_field.v_initial.flatten(order=order))
                / flow_field.v_initial.flatten(order=order)
                * 100
            )
            w = (
                abs(w - flow_field.w_initial.flatten(order=order))
                / flow_field.w_initial.flatten(order=order)
                * 100
            )

        # Determine spacing, dimensions and origin
        unique_x = np.sort(np.unique(x))
        unique_y = np.sort(np.unique(y))
        unique_z = np.sort(np.unique(z))
        spacing = Vec3(
            unique_x[1] - unique_x[0],
            unique_y[1] - unique_y[0],
            unique_z[1] - unique_z[0],
        )
        dimensions = Vec3(len(unique_x), len(unique_y), len(unique_z))
        origin = Vec3(0.0, 0.0, 0.0)
        return FlowData(
            x, y, z, u, v, w, spacing=spacing, dimensions=dimensions, origin=origin
        )
github NREL / floris / floris / tools / floris_interface.py View on Github external
w = (
                abs(w - flow_field.w_initial.flatten(order=order))
                / flow_field.w_initial.flatten(order=order)
                * 100
            )

        # Determine spacing, dimensions and origin
        unique_x = np.sort(np.unique(x))
        unique_y = np.sort(np.unique(y))
        unique_z = np.sort(np.unique(z))
        spacing = Vec3(
            unique_x[1] - unique_x[0],
            unique_y[1] - unique_y[0],
            unique_z[1] - unique_z[0],
        )
        dimensions = Vec3(len(unique_x), len(unique_y), len(unique_z))
        origin = Vec3(0.0, 0.0, 0.0)
        return FlowData(
            x, y, z, u, v, w, spacing=spacing, dimensions=dimensions, origin=origin
        )
github NREL / floris / floris / utilities.py View on Github external
"""
        Rotates about the `x3` coordinate axis by a given angle
        and center of rotation. This function sets additional attributes on
        the rotated Vec3:

            - x1prime
            - x2prime
            - x3prime

        Args:
            theta (float): Angle of rotation in degrees.
            center_of_rotation (Vec3, optional): Center of rotation.
                Defaults to Vec3(0.0, 0.0, 0.0).
        """
        if center_of_rotation is None:
            center_of_rotation = Vec3(0.0, 0.0, 0.0)
        x1offset = self.x1 - center_of_rotation.x1
        x2offset = self.x2 - center_of_rotation.x2
        self.x1prime = (
            x1offset * cosd(theta) - x2offset * sind(theta) + center_of_rotation.x1
        )
        self.x2prime = (
            x2offset * cosd(theta) + x1offset * sind(theta) + center_of_rotation.x2
        )
        self.x3prime = self.x3
github NREL / floris / floris / simulation / turbine_map.py View on Github external
def __init__(self, layout_x, layout_y, turbines):
        """
        Converts input coordinates into :py:class:`~.utilities.Vec3` and
        constructs the underlying mapping to :py:class:`~.turbine.Turbine`.
        It is assumed that all arguments are of the same length and that the
        Turbine at a particular index corresponds to the coordinate at the same
        index in the layout arguments.

        Args:
            layout_x ( list(float) ): X-coordinate of the turbine locations.
            layout_y ( list(float) ): Y-coordinate of the turbine locations.
            turbines ( list(float) ): Turbine objects corresponding to
                the locations given in layout_x and layout_y.
        """
        coordinates = [Vec3(x1, x2, 0) for x1, x2 in list(zip(layout_x, layout_y))]
        self._turbine_map_dict = self._build_internal_dict(coordinates, turbines)