Skip to content

Commit

Permalink
Updated reg tests; all pass.
Browse files Browse the repository at this point in the history
  • Loading branch information
misi9170 committed Dec 11, 2023
1 parent 7e9a4e0 commit e3ee26f
Showing 1 changed file with 32 additions and 34 deletions.
66 changes: 32 additions & 34 deletions tests/reg_tests/empirical_gauss_regression_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -242,15 +242,15 @@ def test_regression_rotation(sample_inputs_fixture):

farm_avg_velocities = average_velocity(floris.flow_field.u)

t0_270 = farm_avg_velocities[0, 0, 0] # upstream
t1_270 = farm_avg_velocities[0, 0, 1] # upstream
t2_270 = farm_avg_velocities[0, 0, 2] # waked
t3_270 = farm_avg_velocities[0, 0, 3] # waked
t0_270 = farm_avg_velocities[0, 0] # upstream
t1_270 = farm_avg_velocities[0, 1] # upstream
t2_270 = farm_avg_velocities[0, 2] # waked
t3_270 = farm_avg_velocities[0, 3] # waked

t0_360 = farm_avg_velocities[1, 0, 0] # waked
t1_360 = farm_avg_velocities[1, 0, 1] # upstream
t2_360 = farm_avg_velocities[1, 0, 2] # waked
t3_360 = farm_avg_velocities[1, 0, 3] # upstream
t0_360 = farm_avg_velocities[1, 0] # waked
t1_360 = farm_avg_velocities[1, 1] # upstream
t2_360 = farm_avg_velocities[1, 2] # waked
t3_360 = farm_avg_velocities[1, 3] # upstream

assert np.allclose(t0_270, t1_360)
assert np.allclose(t1_270, t3_360)
Expand All @@ -269,24 +269,19 @@ def test_regression_yaw(sample_inputs_fixture):
floris = Floris.from_dict(sample_inputs_fixture.floris)

yaw_angles = np.zeros((N_FINDEX, N_TURBINES))
yaw_angles[:,:,0] = 5.0
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
n_findex = floris.flow_field.n_findex

velocities = floris.flow_field.u
yaw_angles = floris.farm.yaw_angles
tilt_angles = floris.farm.tilt_angles
ref_tilt_cp_cts = (
np.ones((n_wind_directions, n_wind_speeds, n_turbines))
* floris.farm.ref_tilt_cp_cts
)
test_results = np.zeros((n_wind_directions, n_wind_speeds, n_turbines, 4))
test_results = np.zeros((n_findex, n_turbines, 4))

farm_avg_velocities = average_velocity(
velocities,
Expand All @@ -297,7 +292,7 @@ def test_regression_yaw(sample_inputs_fixture):
velocities,
yaw_angles,
tilt_angles,
ref_tilt_cp_cts,
floris.farm.ref_tilt_cp_cts,
floris.farm.pPs,
floris.farm.pTs,
floris.farm.turbine_fTilts,
Expand All @@ -308,7 +303,7 @@ def test_regression_yaw(sample_inputs_fixture):
velocities,
yaw_angles,
tilt_angles,
ref_tilt_cp_cts,
floris.farm.ref_tilt_cp_cts,
floris.farm.turbine_fCts,
floris.farm.turbine_fTilts,
floris.farm.correct_cp_ct_for_tilt,
Expand All @@ -324,19 +319,18 @@ def test_regression_yaw(sample_inputs_fixture):
velocities,
yaw_angles,
tilt_angles,
ref_tilt_cp_cts,
floris.farm.ref_tilt_cp_cts,
floris.farm.turbine_fCts,
floris.farm.turbine_fTilts,
floris.farm.correct_cp_ct_for_tilt,
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]
for i in range(n_findex):
for j in range(n_turbines):
test_results[i, j, 0] = farm_avg_velocities[i, j]
test_results[i, j, 1] = farm_cts[i, j]
test_results[i, j, 2] = farm_powers[i, j]
test_results[i, j, 3] = farm_axial_inductions[i, j]

if DEBUG:
print_test_values(
Expand All @@ -346,11 +340,16 @@ def test_regression_yaw(sample_inputs_fixture):
farm_axial_inductions,
)

assert_results_arrays(test_results[0], yawed_baseline)
assert_results_arrays(test_results[0:4], yawed_baseline)


def test_regression_small_grid_rotation(sample_inputs_fixture):
"""
This utilizes a 5x5 wind farm with the layout in a regular grid oriented along the cardinal
directions. The wind direction in this test is from 285 degrees which is slightly north of
west. The objective of this test is to create a case with a very slight rotation of the wind
farm to target the rotation and masking routines.
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;
Expand Down Expand Up @@ -386,15 +385,14 @@ def test_regression_small_grid_rotation(sample_inputs_fixture):
velocities = floris.flow_field.u
yaw_angles = floris.farm.yaw_angles
tilt_angles = floris.farm.tilt_angles
ref_tilt_cp_cts = np.ones((1, 1, len(X))) * floris.farm.ref_tilt_cp_cts

farm_eff_velocities = rotor_effective_velocity(
floris.flow_field.air_density,
floris.farm.ref_density_cp_cts,
velocities,
yaw_angles,
tilt_angles,
ref_tilt_cp_cts,
floris.farm.ref_tilt_cp_cts,
floris.farm.pPs,
floris.farm.pTs,
floris.farm.turbine_fTilts,
Expand All @@ -411,8 +409,8 @@ def test_regression_small_grid_rotation(sample_inputs_fixture):
# A "column" is oriented parallel to the wind direction
# Columns 1 - 4 should have the same power profile
# Column 5 is completely unwaked in this model
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])
assert np.allclose(farm_powers[8,0:5], farm_powers[8,5:10])
assert np.allclose(farm_powers[8,0:5], farm_powers[8,10:15])
assert np.allclose(farm_powers[8,0:5], farm_powers[8,15:20])
assert np.allclose(farm_powers[8,20], farm_powers[8,0])
assert np.allclose(farm_powers[8,21], farm_powers[8,21:25])

0 comments on commit e3ee26f

Please sign in to comment.