def test_regression_triangle_farm(): """ Triangle farm where wind direction of 270 and 360 should result in the same power """ test_class = JensenJimenezRegressionTest() distance = 5 * \ test_class.input_dict["turbine"]["properties"]["rotor_diameter"] test_class.input_dict["farm"]["properties"]["layout_x"] = [ 0.0, distance, 0.0 ] test_class.input_dict["farm"]["properties"]["layout_y"] = [ distance, distance, 0.0 ] floris = Floris(input_dict=test_class.input_dict) ### unrotated floris.farm.flow_field.calculate_wake() # turbine 1 - unwaked turbine = floris.farm.turbine_map.turbines[0] local = (turbine.Cp, turbine.Ct, turbine.power, turbine.aI, turbine.average_velocity) assert pytest.approx(local) == test_class.baseline(0) # turbine 2 - waked turbine = floris.farm.turbine_map.turbines[1] local = (turbine.Cp, turbine.Ct, turbine.power, turbine.aI, turbine.average_velocity) assert pytest.approx(local) == test_class.baseline(1) # turbine 3 - unwaked turbine = floris.farm.turbine_map.turbines[2] local = (turbine.Cp, turbine.Ct, turbine.power, turbine.aI, turbine.average_velocity) assert pytest.approx(local) == test_class.baseline(0) ### rotated floris.farm.flow_field.reinitialize_flow_field(wind_direction=360) floris.calculate_wake() # turbine 1 - unwaked turbine = floris.farm.turbine_map.turbines[0] local = (turbine.Cp, turbine.Ct, turbine.power, turbine.aI, turbine.average_velocity) assert pytest.approx(local) == test_class.baseline(0) # turbine 2 - unwaked turbine = floris.farm.turbine_map.turbines[1] local = (turbine.Cp, turbine.Ct, turbine.power, turbine.aI, turbine.average_velocity) assert pytest.approx(local) == test_class.baseline(0) # turbine 3 - waked turbine = floris.farm.turbine_map.turbines[2] local = (turbine.Cp, turbine.Ct, turbine.power, turbine.aI, turbine.average_velocity) assert pytest.approx(local) == test_class.baseline(1)
def test_regression_tandem(): """ Tandem turbines """ test_class = CurlRegressionTest() floris = Floris(input_dict=test_class.input_dict) floris.calculate_wake() for i, turbine in enumerate(floris.farm.turbine_map.turbines): if test_class.debug: print("({:.7f}, {:.7f}, {:.7f}, {:.7f}, {:.7f})".format(turbine.Cp, turbine.Ct, turbine.power, turbine.aI, turbine.average_velocity)) baseline = test_class.baseline(i) assert pytest.approx(turbine.Cp) == baseline[0] assert pytest.approx(turbine.Ct) == baseline[1] assert pytest.approx(turbine.power) == baseline[2] assert pytest.approx(turbine.aI) == baseline[3] assert pytest.approx(turbine.average_velocity) == baseline[4]
class FlorisInterface(): """ The interface from FLORIS to the wfc tools """ def __init__(self, input_file): self.input_file = input_file self.floris = Floris(input_file=input_file) def run_floris(self): self.floris.calculate_wake() def get_flow_field(self, resolution): if resolution is None: raise "No resolution given" flow_field = self.floris.farm.flow_field _, _, _ = flow_field.get_flow_field_with_resolution(resolution) flow_field.calculate_wake() order = "f" x = flow_field.x.flatten(order=order) y = flow_field.y.flatten(order=order) z = flow_field.z.flatten(order=order) u = flow_field.u.flatten(order=order) v = flow_field.v.flatten(order=order) w = flow_field.w.flatten(order=order) # 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 FlowField(x, y, z, u, v, w, spacing=spacing, dimensions=dimensions, origin=origin) def get_yaw_angles(self): yaw_angles = [turbine.yaw_angle for turbine in self.floris.farm.turbine_map.turbines] return yaw_angles
def test_regression_yaw(): """ Tandem turbines with the upstream turbine yawed """ test_class = CurlRegressionTest() floris = Floris(input_dict=test_class.input_dict) # yaw the upstream turbine 5 degrees rotation_angle = 5.0 floris.farm.set_yaw_angles([np.radians(rotation_angle), 0.0]) floris.calculate_wake() for i, turbine in enumerate(floris.farm.turbine_map.turbines): if test_class.debug: print("({:.7f}, {:.7f}, {:.7f}, {:.7f}, {:.7f})".format(turbine.Cp, turbine.Ct, turbine.power, turbine.aI, turbine.average_velocity)) baseline = test_class.yawed_baseline(i) assert pytest.approx(turbine.Cp) == baseline[0] assert pytest.approx(turbine.Ct) == baseline[1] assert pytest.approx(turbine.power) == baseline[2] assert pytest.approx(turbine.aI) == baseline[3] assert pytest.approx(turbine.average_velocity) == baseline[4]