def test_power(): N_TURBINES = 4 AIR_DENSITY = 1.225 turbine_data = SampleInputs().turbine turbine = Turbine.from_dict(turbine_data) turbine_type_map = np.array(N_TURBINES * [turbine.turbine_type]) turbine_type_map = turbine_type_map[None, None, :] # Single turbine wind_speed = 10.0 p = power( air_density=AIR_DENSITY, velocities=wind_speed * np.ones((1, 1, 1, 3, 3)), yaw_angle=np.zeros((1, 1, 1)), pP=turbine.pP * np.ones((1, 1, 1)), power_interp=np.array([(turbine.turbine_type, turbine.fCp_interp)]), turbine_type_map=turbine_type_map[:,:,0] ) # calculate power again effective_velocity_trurth = ((AIR_DENSITY/1.225)**(1/3)) * wind_speed truth_index = turbine_data["power_thrust_table"]["wind_speed"].index(effective_velocity_trurth) cp_truth = turbine_data["power_thrust_table"]["power"][truth_index] power_truth = 0.5 * turbine.rotor_area * cp_truth * turbine.generator_efficiency * effective_velocity_trurth ** 3 np.testing.assert_allclose(p,cp_truth,power_truth )
def test_regression_tandem(sample_inputs_fixture): """ Tandem turbines """ sample_inputs_fixture.floris["wake"]["model_strings"]["velocity_model"] = VELOCITY_MODEL sample_inputs_fixture.floris["wake"]["model_strings"]["deflection_model"] = DEFLECTION_MODEL sample_inputs_fixture.floris["wake"]["model_strings"]["combination_model"] = COMBINATION_MODEL floris = Floris.from_dict(sample_inputs_fixture.floris) floris.initialize_domain() floris.steady_state_atmospheric_condition() n_turbines = floris.farm.n_turbines n_wind_speeds = floris.flow_field.n_wind_speeds n_wind_directions = floris.flow_field.n_wind_directions velocities = floris.flow_field.u yaw_angles = floris.farm.yaw_angles test_results = np.zeros((n_wind_directions, n_wind_speeds, n_turbines, 4)) farm_avg_velocities = average_velocity( velocities, ) farm_cts = Ct( velocities, yaw_angles, floris.farm.turbine_fCts, floris.farm.turbine_type_map, ) farm_powers = power( floris.flow_field.air_density, velocities, yaw_angles, floris.farm.pPs, floris.farm.turbine_power_interps, floris.farm.turbine_type_map, ) farm_axial_inductions = axial_induction( velocities, yaw_angles, floris.farm.turbine_fCts, floris.farm.turbine_type_map, ) for i in range(n_wind_directions): for j in range(n_wind_speeds): for k in range(n_turbines): test_results[i, j, k, 0] = farm_avg_velocities[i, j, k] test_results[i, j, k, 1] = farm_cts[i, j, k] test_results[i, j, k, 2] = farm_powers[i, j, k] test_results[i, j, k, 3] = farm_axial_inductions[i, j, k] if DEBUG: print_test_values( farm_avg_velocities, farm_cts, farm_powers, farm_axial_inductions, ) assert_results_arrays(test_results[0], baseline)
def test_regression_small_grid_rotation(sample_inputs_fixture): """ Where wake models are masked based on the x-location of a turbine, numerical precision can cause masking to fail unexpectedly. For example, in the configuration here one of the turbines has these delta x values; [[4.54747351e-13 4.54747351e-13 4.54747351e-13 4.54747351e-13 4.54747351e-13] [4.54747351e-13 4.54747351e-13 4.54747351e-13 4.54747351e-13 4.54747351e-13] [4.54747351e-13 4.54747351e-13 4.54747351e-13 4.54747351e-13 4.54747351e-13] [4.54747351e-13 4.54747351e-13 4.54747351e-13 4.54747351e-13 4.54747351e-13] [4.54747351e-13 4.54747351e-13 4.54747351e-13 4.54747351e-13 4.54747351e-13]] and therefore the masking statement is False when it should be True. This causes the current turbine to be affected by its own wake. This test requires that at least in this particular configuration the masking correctly filters grid points. """ sample_inputs_fixture.floris["wake"]["model_strings"]["velocity_model"] = VELOCITY_MODEL sample_inputs_fixture.floris["wake"]["model_strings"]["deflection_model"] = DEFLECTION_MODEL sample_inputs_fixture.floris["wake"]["model_strings"]["combination_model"] = COMBINATION_MODEL X, Y = np.meshgrid( 6.0 * 126.0 * np.arange(0, 5, 1), 6.0 * 126.0 * np.arange(0, 5, 1) ) X = X.flatten() Y = Y.flatten() sample_inputs_fixture.floris["farm"]["layout_x"] = X sample_inputs_fixture.floris["farm"]["layout_y"] = Y floris = Floris.from_dict(sample_inputs_fixture.floris) floris.initialize_domain() floris.steady_state_atmospheric_condition() # farm_avg_velocities = average_velocity(floris.flow_field.u) velocities = floris.flow_field.u yaw_angles = floris.farm.yaw_angles farm_powers = power( floris.flow_field.air_density, velocities, yaw_angles, floris.farm.pPs, floris.farm.turbine_power_interps, floris.farm.turbine_type_map, ) # A "column" is oriented parallel to the wind direction # Columns 1 - 4 should have the same power profile # Column 5 leading turbine is completely unwaked # and the rest of the turbines have a partial wake from their immediate upstream turbine assert np.allclose(farm_powers[2,0,0:5], farm_powers[2,0,5:10]) assert np.allclose(farm_powers[2,0,0:5], farm_powers[2,0,10:15]) assert np.allclose(farm_powers[2,0,0:5], farm_powers[2,0,15:20]) assert np.allclose(farm_powers[2,0,20], farm_powers[2,0,0]) assert np.allclose(farm_powers[2,0,21], farm_powers[2,0,21:25])
def test_regression_secondary_steering(sample_inputs_fixture): """ Tandem turbines with the upstream turbine yawed and secondary steering enabled """ sample_inputs_fixture.floris["wake"]["model_strings"]["velocity_model"] = VELOCITY_MODEL sample_inputs_fixture.floris["wake"]["model_strings"]["deflection_model"] = DEFLECTION_MODEL sample_inputs_fixture.floris["wake"]["enable_transverse_velocities"] = True sample_inputs_fixture.floris["wake"]["enable_secondary_steering"] = True sample_inputs_fixture.floris["wake"]["enable_yaw_added_recovery"] = False floris = Floris.from_dict(sample_inputs_fixture.floris) yaw_angles = np.zeros((N_WIND_DIRECTIONS, N_WIND_SPEEDS, N_TURBINES)) yaw_angles[:,:,0] = 5.0 floris.farm.yaw_angles = yaw_angles floris.initialize_domain() floris.steady_state_atmospheric_condition() n_turbines = floris.farm.n_turbines n_wind_speeds = floris.flow_field.n_wind_speeds n_wind_directions = floris.flow_field.n_wind_directions velocities = floris.flow_field.u yaw_angles = floris.farm.yaw_angles test_results = np.zeros((n_wind_directions, n_wind_speeds, n_turbines, 4)) farm_avg_velocities = average_velocity( velocities, ) farm_cts = Ct( velocities, yaw_angles, floris.farm.turbine_fCts, floris.farm.turbine_type_map, ) farm_powers = power( floris.flow_field.air_density, velocities, yaw_angles, floris.farm.pPs, floris.farm.turbine_power_interps, floris.farm.turbine_type_map, ) farm_axial_inductions = axial_induction( velocities, yaw_angles, floris.farm.turbine_fCts, floris.farm.turbine_type_map, ) for i in range(n_wind_directions): for j in range(n_wind_speeds): for k in range(n_turbines): test_results[i, j, k, 0] = farm_avg_velocities[i, j, k] test_results[i, j, k, 1] = farm_cts[i, j, k] test_results[i, j, k, 2] = farm_powers[i, j, k] test_results[i, j, k, 3] = farm_axial_inductions[i, j, k] if DEBUG: print_test_values( farm_avg_velocities, farm_cts, farm_powers, farm_axial_inductions, ) assert_results_arrays(test_results[0], secondary_steering_baseline)