예제 #1
0
def test_rotated():
    """
    The class should rotate a turbine when given an angle and center of rotation
    The resulting map should contain turbines at (0, 0) and (-100, 0) when the
    sample map is rotated by pi about (0, 0).
    """
    test_class = TurbineMapTest()
    rotated_map = test_class.instance.rotated(np.pi, Vec3(0, 0, 0))
    baseline_coordinates = [Vec3(0.0, 0.0, 0.0), Vec3(-100.0, 0.0, 0.0)]
    for i, coordinate in enumerate(rotated_map.coords):
        assert pytest.approx(coordinate == baseline_coordinates[i])
예제 #2
0
파일: vec3_test.py 프로젝트: dykesk/FLORIS
def test_rotation_on_origin():
    """
    The class should rotate by pi on the 3rd (z) axis at the origin like so:
        < 1, 2, 3 > becomes < -1, -2, ,3 >
    """
    test_class = Vec3Test()

    baseline = Vec3(-1, -2, 3)
    vec3 = Vec3(test_class.x, test_class.y, test_class.z)
    vec3.rotate_on_x3(np.pi)
    assert \
        vec3.x1prime == pytest.approx(baseline.x1) and \
        vec3.x2prime == pytest.approx(baseline.x2) and \
        vec3.x3prime == pytest.approx(baseline.x3)
예제 #3
0
def test_sorted_in_x_as_list():
    """
    The class should sort its Turbines in ascending order based on the 
    x-component of their associated Vec3. The returned object
    should be [(Vec3, Turbine)].
    The resulting list should be ordered as [(0.0, 0.0, 0.0), (100.0, 0.0, 0.0)]
    when the sample data is sorted.
    """
    test_class = TurbineMapTest()
    sorted_map = test_class.instance.sorted_in_x_as_list()
    baseline_coordinates = [Vec3(0.0, 0.0, 0.0), Vec3(-100.0, 0.0, 0.0)]
    for i, element in enumerate(sorted_map):
        coordinate = element[0]
        assert pytest.approx(coordinate == baseline_coordinates[i])
예제 #4
0
파일: vec3_test.py 프로젝트: dykesk/FLORIS
def test_rotation_off_origin():
    """    
    The class should rotate by pi on the 3rd (z) axis about center of rotation at <0, 10, 0> like so:
        < 1, 2, 3 > becomes < -1, -2, ,3 >
    """
    test_class = Vec3Test()

    baseline = Vec3(5, 4, 3)
    center_of_rotation = Vec3(3, 3, 0)
    vec3 = Vec3(test_class.x, test_class.y, test_class.z)
    vec3.rotate_on_x3(np.pi, center_of_rotation)
    assert \
        vec3.x1prime == pytest.approx(baseline.x1) and \
        vec3.x2prime == pytest.approx(baseline.x2) and \
        vec3.x3prime == pytest.approx(baseline.x3)
예제 #5
0
 def _build_input_dict(self):
     wake = Wake(self.sample_inputs.wake)
     turbine = Turbine(self.sample_inputs.turbine)
     turbine_map = TurbineMap({
         Vec3(0.0, 0.0, 0.0): copy.deepcopy(turbine),
         Vec3(100.0, 0.0, 0.0): copy.deepcopy(turbine)
     })
     return {
         "wind_direction": 270.0,
         "wind_speed": 8.0,
         "wind_shear": 0.0,
         "wind_veer": 0.0,
         "turbulence_intensity": 1.0,
         "air_density": 1.225,
         "wake": wake,
         "turbine_map": turbine_map
     }
예제 #6
0
파일: vec3_test.py 프로젝트: dykesk/FLORIS
def test_instantiation_with_list():
    """
    The class should initialize with a list of length 3.
    """
    test_class = Vec3Test()

    vec3 = Vec3(test_class.list)
    assert vec3 is not None and \
        vec3.x1 == test_class.x and \
        vec3.x2 == test_class.y and \
        vec3.x3 == test_class.z
예제 #7
0
파일: vec3_test.py 프로젝트: dykesk/FLORIS
def test_instantiation_with_args():
    """
    The class should initialize with three positional arguments.
    """
    test_class = Vec3Test()

    vec3 = Vec3(test_class.x, test_class.y, test_class.z)
    assert vec3 is not None and \
        vec3.x1 == test_class.x and \
        vec3.x2 == test_class.y and \
        vec3.x3 == test_class.z
예제 #8
0
 def __init__(self):
     self.sample_inputs = SampleInputs()
     self.coordinates = [Vec3(0.0, 0.0, 0.0), Vec3(100.0, 0.0, 0.0)]
     self.turbine_map_dict = self._build_turbine_map_dict()
     self.instance = self._build_instance()