def reinitialize_flow_field(self, wind_speed=None, wind_direction=None, wind_shear=None, wind_veer=None, turbulence_intensity=None, air_density=None, wake=None, layout_array=None, with_resolution=None): """ Wrapper to :py:meth:`floris.simlulation.flow_field.reinitialize_flow_field`. All input values are used to update the flow_field instance. Args: wind_speed (float, optional): background wind speed. Defaults to None. wind_direction (float, optional): background wind direction. Defaults to None. wind_shear (float, optional): shear exponent. Defaults to None. wind_veer (float, optional): direction change over rotor. Defaults to None. turbulence_intensity (float, optional): background turbulence intensity. Defaults to None.Defaults to None. (float, optional): ambient air density. Defaults to None. wake (str, optional): wake model type. Defaults to None. layout_array (np.array, optional): array of x- and y-locations of wind turbines. Defaults to None. with_resolution (float, optional): resolution of output flow_field. Defaults to None. """ # Build turbine map (convenience layer for user) if layout_array is not None: turbine_map = TurbineMap( layout_array[0], layout_array[1], \ [copy.deepcopy(self.floris.farm.turbines[0]) \ for ii in range(len(layout_array[0]))]) else: turbine_map = None self.floris.farm.flow_field.reinitialize_flow_field( wind_speed=wind_speed, wind_direction=wind_direction, wind_shear=wind_shear, wind_veer=wind_veer, turbulence_intensity=turbulence_intensity, air_density=air_density, wake=wake, turbine_map=turbine_map, with_resolution=with_resolution)
def _build_input_dict(self): wake = Wake(self.sample_inputs.wake) turbine = Turbine(self.sample_inputs.turbine) turbine_map = TurbineMap( [0.0, 100.0], [0.0, 0.0], [copy.deepcopy(turbine), 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 }
def test_regression_rotation(): """ Turbines in tandem and rotated. The result from 270 degrees should match the results from 360 degrees. """ test_class = JensenJimenezRegressionTest() floris = Floris(input_dict=test_class.input_dict) fresh_turbine = copy.deepcopy(floris.farm.turbine_map.turbines[0]) ### unrotated floris.farm.flow_field.calculate_wake() turbine = floris.farm.turbine_map.turbines[0] unwaked_baseline = (turbine.Cp, turbine.Ct, turbine.power, turbine.aI, turbine.average_velocity) turbine = floris.farm.turbine_map.turbines[1] waked_baseline = (turbine.Cp, turbine.Ct, turbine.power, turbine.aI, turbine.average_velocity) ### rotated new_map = TurbineMap( [0.0, 0.0], [5 * test_class.input_dict["turbine"]["properties"]["rotor_diameter"], 0.0], [copy.deepcopy(fresh_turbine), copy.deepcopy(fresh_turbine)] ) floris.farm.flow_field.reinitialize_flow_field( wind_direction=360, turbine_map=new_map ) floris.farm.flow_field.calculate_wake() turbine = floris.farm.turbine_map.turbines[0] assert pytest.approx(turbine.Cp) == unwaked_baseline[0] assert pytest.approx(turbine.Ct) == unwaked_baseline[1] assert pytest.approx(turbine.power) == unwaked_baseline[2] assert pytest.approx(turbine.aI) == unwaked_baseline[3] assert pytest.approx(turbine.average_velocity) == unwaked_baseline[4] turbine = floris.farm.turbine_map.turbines[1] assert pytest.approx(turbine.Cp) == waked_baseline[0] assert pytest.approx(turbine.Ct) == waked_baseline[1] assert pytest.approx(turbine.power) == waked_baseline[2] assert pytest.approx(turbine.aI) == waked_baseline[3] assert pytest.approx(turbine.average_velocity) == waked_baseline[4]
def flow_field_fixture(sample_inputs_fixture): wake = Wake(sample_inputs_fixture.wake) turbine = Turbine(sample_inputs_fixture.turbine) turbine_map = TurbineMap( [0.0, 100.0], [0.0, 0.0], [copy.deepcopy(turbine), copy.deepcopy(turbine)] ) farm_prop = sample_inputs_fixture.farm["properties"] wind_map = WindMap( wind_speed=farm_prop["wind_speed"], layout_array=(farm_prop["layout_x"], farm_prop["layout_y"]), wind_layout=(farm_prop["wind_x"], farm_prop["wind_y"]), turbulence_intensity=farm_prop["turbulence_intensity"], wind_direction=farm_prop["wind_direction"], ) return FlowField( farm_prop["wind_shear"], farm_prop["wind_veer"], farm_prop["air_density"], wake, turbine_map, wind_map, farm_prop["specified_wind_height"], )
def _build_instance(self): return TurbineMap(self.coordinates[0], self.coordinates[1], self.turbines)
def test_regression_rotation(sample_inputs_fixture): """ Turbines in tandem and rotated. The result from 270 degrees should match the results from 360 degrees. """ sample_inputs_fixture.floris["wake"]["properties"][ "velocity_model" ] = VELOCITY_MODEL sample_inputs_fixture.floris["wake"]["properties"][ "deflection_model" ] = DEFLECTION_MODEL floris = Floris(input_dict=sample_inputs_fixture.floris) fresh_turbine = copy.deepcopy(floris.farm.turbine_map.turbines[0]) wind_map = floris.farm.wind_map # unrotated floris.farm.flow_field.calculate_wake() turbine = floris.farm.turbine_map.turbines[0] unwaked_baseline = ( turbine.Ct, turbine.power, turbine.aI, turbine.average_velocity, ) turbine = floris.farm.turbine_map.turbines[1] first_waked_baseline = ( turbine.Ct, turbine.power, turbine.aI, turbine.average_velocity, ) turbine = floris.farm.turbine_map.turbines[2] second_waked_baseline = ( turbine.Ct, turbine.power, turbine.aI, turbine.average_velocity, ) # rotated wind_map.input_direction = [360] wind_map.calculate_wind_direction() new_map = TurbineMap( [0.0, 0.0, 0.0], [ 10 * sample_inputs_fixture.floris["turbine"]["properties"]["rotor_diameter"], 5 * sample_inputs_fixture.floris["turbine"]["properties"]["rotor_diameter"], 0.0, ], [ copy.deepcopy(fresh_turbine), copy.deepcopy(fresh_turbine), copy.deepcopy(fresh_turbine), ], ) floris.farm.flow_field.reinitialize_flow_field( turbine_map=new_map, wind_map=wind_map ) floris.farm.flow_field.calculate_wake() turbine = floris.farm.turbine_map.turbines[0] assert approx(turbine.Ct) == unwaked_baseline[0] assert approx(turbine.power) == unwaked_baseline[1] assert approx(turbine.aI) == unwaked_baseline[2] assert approx(turbine.average_velocity) == unwaked_baseline[3] turbine = floris.farm.turbine_map.turbines[1] assert approx(turbine.Ct) == first_waked_baseline[0] assert approx(turbine.power) == first_waked_baseline[1] assert approx(turbine.aI) == first_waked_baseline[2] assert approx(turbine.average_velocity) == first_waked_baseline[3] turbine = floris.farm.turbine_map.turbines[2] assert approx(turbine.Ct, rel=1e-5) == second_waked_baseline[0] assert approx(turbine.power, rel=1e-5) == second_waked_baseline[1] assert approx(turbine.aI, rel=1e-5) == second_waked_baseline[2] assert approx(turbine.average_velocity, rel=1e-5) == second_waked_baseline[3]
def test_regression_rotation(): """ Turbines in tandem and rotated. The result from 270 degrees should match the results from 360 degrees. """ test_class = CurlRegressionTest() floris = Floris(input_dict=test_class.input_dict) fresh_turbine = copy.deepcopy(floris.farm.turbine_map.turbines[0]) wind_map = floris.farm.wind_map ### unrotated floris.farm.flow_field.calculate_wake() turbine = floris.farm.turbine_map.turbines[0] unwaked_baseline = ( turbine.Cp, turbine.Ct, turbine.power, turbine.aI, turbine.average_velocity, ) turbine = floris.farm.turbine_map.turbines[1] first_waked_baseline = ( turbine.Cp, turbine.Ct, turbine.power, turbine.aI, turbine.average_velocity, ) turbine = floris.farm.turbine_map.turbines[2] second_waked_baseline = ( turbine.Cp, turbine.Ct, turbine.power, turbine.aI, turbine.average_velocity, ) ### rotated wind_map.input_direction = [360] wind_map.calculate_wind_direction() new_map = TurbineMap( [0.0, 0.0, 0.0], [ 10 * test_class.input_dict["turbine"]["properties"]["rotor_diameter"], 5 * test_class.input_dict["turbine"]["properties"]["rotor_diameter"], 0.0, ], [ copy.deepcopy(fresh_turbine), copy.deepcopy(fresh_turbine), copy.deepcopy(fresh_turbine), ], ) floris.farm.flow_field.reinitialize_flow_field(turbine_map=new_map, wind_map=wind_map) floris.farm.flow_field.calculate_wake() turbine = floris.farm.turbine_map.turbines[0] if test_class.debug: print("({:.7f}, {:.7f}, {:.7f}, {:.7f}, {:.7f})".format( turbine.Cp, turbine.Ct, turbine.power, turbine.aI, turbine.average_velocity, )) assert pytest.approx(turbine.Cp) == unwaked_baseline[0] assert pytest.approx(turbine.Ct) == unwaked_baseline[1] assert pytest.approx(turbine.power) == unwaked_baseline[2] assert pytest.approx(turbine.aI) == unwaked_baseline[3] assert pytest.approx(turbine.average_velocity) == unwaked_baseline[4] turbine = floris.farm.turbine_map.turbines[1] if test_class.debug: print("({:.7f}, {:.7f}, {:.7f}, {:.7f}, {:.7f})".format( turbine.Cp, turbine.Ct, turbine.power, turbine.aI, turbine.average_velocity, )) assert pytest.approx(turbine.Cp) == first_waked_baseline[0] assert pytest.approx(turbine.Ct) == first_waked_baseline[1] assert pytest.approx(turbine.power) == first_waked_baseline[2] assert pytest.approx(turbine.aI) == first_waked_baseline[3] assert pytest.approx(turbine.average_velocity) == first_waked_baseline[4] turbine = floris.farm.turbine_map.turbines[2] if test_class.debug: print("({:.7f}, {:.7f}, {:.7f}, {:.7f}, {:.7f})".format( turbine.Cp, turbine.Ct, turbine.power, turbine.aI, turbine.average_velocity, )) # TODO: this is a hack and you know it :( assert pytest.approx(turbine.Cp, rel=1e-4) == second_waked_baseline[0] assert pytest.approx(turbine.Ct, rel=1e-4) == second_waked_baseline[1] assert pytest.approx(turbine.power, rel=1e-3) == second_waked_baseline[2] assert pytest.approx(turbine.aI, rel=1e-3) == second_waked_baseline[3] assert pytest.approx(turbine.average_velocity, rel=1e-3) == second_waked_baseline[4]
def turbine_map_fixture(sample_inputs_fixture): return TurbineMap( sample_inputs_fixture.farm["properties"]["layout_x"], sample_inputs_fixture.farm["properties"]["layout_y"], 3 * [Turbine(sample_inputs_fixture.turbine)], )