1+ import pandas as pd
2+ import numpy as np
3+ import pytest
4+ from pandas .util .testing import assert_series_equal
5+
6+ import windpowerlib .wind_farm as wf
7+ import windpowerlib .wind_turbine as wt
8+ import windpowerlib .turbine_cluster_modelchain as tc_mc
9+
10+
11+ class TestTurbineClusterModelChain :
12+
13+ @classmethod
14+ def setup_class (self ):
15+ self .test_turbine = {'hub_height' : 100 ,
16+ 'rotor_diameter' : 80 ,
17+ 'name' : 'ENERCON E 126 7500' ,
18+ 'fetch_curve' : 'power_curve' }
19+ self .test_farm = {'name' : 'test farm' ,
20+ 'wind_turbine_fleet' : [
21+ {'wind_turbine' :
22+ wt .WindTurbine (** self .test_turbine ),
23+ 'number_of_turbines' : 3 }]}
24+
25+ def test_run_model (self ):
26+ parameters = {'wake_losses_model' : 'dena_mean' ,
27+ 'smoothing' : False ,
28+ 'standard_deviation_method' : 'turbulence_intensity' ,
29+ 'smoothing_order' : 'wind_farm_power_curves' }
30+ temperature_2m = np .array ([[267 ], [268 ]])
31+ temperature_10m = np .array ([[267 ], [266 ]])
32+ pressure_0m = np .array ([[101125 ], [101000 ]])
33+ wind_speed_8m = np .array ([[4.0 ], [5.0 ]])
34+ wind_speed_10m = np .array ([[5.0 ], [6.5 ]])
35+ roughness_length = np .array ([[0.15 ], [0.15 ]])
36+ weather_df = pd .DataFrame (np .hstack ((temperature_2m ,
37+ temperature_10m ,
38+ pressure_0m ,
39+ wind_speed_8m ,
40+ wind_speed_10m ,
41+ roughness_length )),
42+ index = [0 , 1 ],
43+ columns = [np .array (['temperature' ,
44+ 'temperature' ,
45+ 'pressure' ,
46+ 'wind_speed' ,
47+ 'wind_speed' ,
48+ 'roughness_length' ]),
49+ np .array ([2 , 10 , 0 , 8 , 10 , 0 ])])
50+
51+ # Test modelchain with default values
52+ power_output_exp = pd .Series (data = [4409211.803349806 ,
53+ 10212484.219845157 ],
54+ name = 'feedin_power_plant' )
55+ test_tc_mc = tc_mc .TurbineClusterModelChain (
56+ power_plant = wf .WindFarm (** self .test_farm ), ** parameters )
57+ test_tc_mc .run_model (weather_df )
58+ assert_series_equal (test_tc_mc .power_output , power_output_exp )
59+
60+ # Test constant efficiency
61+ parameters ['wake_losses_model' ] = 'constant_efficiency'
62+ test_wind_farm = wf .WindFarm (** self .test_farm )
63+ test_wind_farm .efficiency = 0.9
64+ power_output_exp = pd .Series (data = [4676095.973725522 ,
65+ 10314411.142196147 ],
66+ name = 'feedin_power_plant' )
67+ test_tc_mc = tc_mc .TurbineClusterModelChain (
68+ power_plant = test_wind_farm , ** parameters )
69+ test_tc_mc .run_model (weather_df )
70+ assert_series_equal (test_tc_mc .power_output , power_output_exp )
71+
72+ # TODO: Test power efficiency curve?
73+
74+ # Test smoothing
75+ parameters ['smoothing' ] = 'True'
76+ test_wind_farm = wf .WindFarm (** self .test_farm )
77+ test_wind_farm .efficiency = 0.9
78+ power_output_exp = pd .Series (data = [5015168.554748144 ,
79+ 10389592.995632712 ],
80+ name = 'feedin_power_plant' )
81+ test_tc_mc = tc_mc .TurbineClusterModelChain (
82+ power_plant = test_wind_farm , ** parameters )
83+ test_tc_mc .run_model (weather_df )
84+ assert_series_equal (test_tc_mc .power_output , power_output_exp )
85+
86+ # Test other smoothing order # TODO: Test different wind turbines
87+ parameters ['smoothing_order' ] = 'turbine_power_curves'
88+ test_wind_farm = wf .WindFarm (** self .test_farm )
89+ test_wind_farm .efficiency = 0.9
90+ power_output_exp = pd .Series (data = [5015168.554748144 ,
91+ 10389592.995632712 ],
92+ name = 'feedin_power_plant' )
93+ test_tc_mc = tc_mc .TurbineClusterModelChain (
94+ power_plant = test_wind_farm , ** parameters )
95+ test_tc_mc .run_model (weather_df )
96+ assert_series_equal (test_tc_mc .power_output , power_output_exp )
97+
98+
99+ # TODO: test turbine cluster
0 commit comments