@@ -394,3 +394,104 @@ def test_3d_het_and_shear():
394
394
wind_directions = [270.0 ], wind_speeds = [wind_speed ]
395
395
),
396
396
)
397
+
398
+
399
+ def test_run_2d_het_map ():
400
+ # Define a 2D het map and confirm the results are as expected
401
+ # when applied to FLORIS
402
+
403
+ # The side of the flow which is accelerated reverses for east versus west
404
+ het_map = HeterogeneousMap (
405
+ x = np .array ([0.0 , 0.0 , 500.0 , 500.0 ]),
406
+ y = np .array ([0.0 , 500.0 , 0.0 , 500.0 ]),
407
+ speed_multipliers = np .array (
408
+ [
409
+ [1.0 , 2.0 , 1.0 , 2.0 ], # Top accelerated
410
+ [2.0 , 1.0 , 2.0 , 1.0 ], # Bottom accelerated
411
+ ]
412
+ ),
413
+ wind_directions = np .array ([270.0 , 90.0 ]),
414
+ wind_speeds = np .array ([8.0 , 8.0 ]),
415
+ )
416
+
417
+ # Get the FLORIS model
418
+ fmodel = FlorisModel (configuration = YAML_INPUT )
419
+
420
+ from floris import TimeSeries
421
+
422
+ time_series = TimeSeries (
423
+ wind_directions = np .array ([270.0 , 90.0 ]),
424
+ wind_speeds = 8.0 ,
425
+ turbulence_intensities = 0.06 ,
426
+ heterogeneous_map = het_map ,
427
+ )
428
+
429
+ # Set the model to a turbines perpinducluar to
430
+ # east/west flow with 0 turbine closer to bottom and
431
+ # turbine 1 closer to top
432
+ fmodel .set (
433
+ wind_data = time_series ,
434
+ layout_x = [250.0 , 250.0 ],
435
+ layout_y = [100.0 , 400.0 ],
436
+ )
437
+
438
+ # Run the model
439
+ fmodel .run ()
440
+
441
+ # Get the turbine powers
442
+ powers = fmodel .get_turbine_powers ()
443
+
444
+ # Assert that in the first condition, turbine 1 has higher power
445
+ assert powers [0 , 1 ] > powers [0 , 0 ]
446
+
447
+ # Assert that in the second condition, turbine 0 has higher power
448
+ assert powers [1 , 0 ] > powers [1 , 1 ]
449
+
450
+ # Assert that the power of turbine 1 equals in the first condition
451
+ # equals the power of turbine 0 in the second condition
452
+ assert powers [0 , 1 ] == powers [1 , 0 ]
453
+
454
+
455
+ def test_het_config ():
456
+
457
+ # Test that setting FLORIS with a heterogeneous inflow configuration
458
+ # works as expected and consistent with previous results
459
+
460
+ # Get the FLORIS model
461
+ fmodel = FlorisModel (configuration = YAML_INPUT )
462
+
463
+ # Change the layout to a 4 turbine layout in a box
464
+ fmodel .set (layout_x = [0 , 0 , 500.0 , 500.0 ], layout_y = [0 , 500.0 , 0 , 500.0 ])
465
+
466
+ # Set FLORIS to run for a single condition
467
+ fmodel .set (wind_speeds = [8.0 ], wind_directions = [270.0 ], turbulence_intensities = [0.06 ])
468
+
469
+ # Define the speed-ups of the heterogeneous inflow, and their locations.
470
+ # Note that heterogeneity is only applied within the bounds of the points defined in the
471
+ # heterogeneous_inflow_config dictionary. In this case, set the inflow to be 1.25x the ambient
472
+ # wind speed for the upper turbines at y = 500m.
473
+ speed_ups = [[1.0 , 1.25 , 1.0 , 1.25 ]] # Note speed-ups has dimensions of n_findex X n_points
474
+ x_locs = [- 500.0 , - 500.0 , 1000.0 , 1000.0 ]
475
+ y_locs = [- 500.0 , 1000.0 , - 500.0 , 1000.0 ]
476
+
477
+ # Create the configuration dictionary to be used for the heterogeneous inflow.
478
+ heterogeneous_inflow_config = {
479
+ "speed_multipliers" : speed_ups ,
480
+ "x" : x_locs ,
481
+ "y" : y_locs ,
482
+ }
483
+
484
+ # Set the heterogeneous inflow configuration
485
+ fmodel .set (heterogeneous_inflow_config = heterogeneous_inflow_config )
486
+
487
+ # Run the FLORIS simulation
488
+ fmodel .run ()
489
+
490
+ turbine_powers = fmodel .get_turbine_powers () / 1000.0
491
+
492
+ # Test that the turbine powers are consistent with previous implementation
493
+ # 2248.2, 2800.1, 466.2, 601.5 before the change
494
+ # Using almost equal assert
495
+ assert np .allclose (
496
+ turbine_powers , np .array ([[2248.2 , 2800.0 , 466.2 , 601.4 ]]), atol = 1.0 ,
497
+ )
0 commit comments