55
66import windpowerlib .wind_farm as wf
77import windpowerlib .wind_turbine as wt
8+ import windpowerlib .wind_turbine_cluster as wtc
89import windpowerlib .turbine_cluster_modelchain as tc_mc
910
1011
1112class TestTurbineClusterModelChain :
1213
1314 @classmethod
1415 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' }
3016 temperature_2m = np .array ([[267 ], [268 ]])
3117 temperature_10m = np .array ([[267 ], [266 ]])
3218 pressure_0m = np .array ([[101125 ], [101000 ]])
3319 wind_speed_8m = np .array ([[4.0 ], [5.0 ]])
3420 wind_speed_10m = np .array ([[5.0 ], [6.5 ]])
3521 roughness_length = np .array ([[0.15 ], [0.15 ]])
36- weather_df = pd .DataFrame (np .hstack ((temperature_2m ,
22+ self . weather_df = pd .DataFrame (np .hstack ((temperature_2m ,
3723 temperature_10m ,
3824 pressure_0m ,
3925 wind_speed_8m ,
@@ -47,14 +33,44 @@ def test_run_model(self):
4733 'wind_speed' ,
4834 'roughness_length' ]),
4935 np .array ([2 , 10 , 0 , 8 , 10 , 0 ])])
36+ self .test_turbine = {'hub_height' : 100 ,
37+ 'rotor_diameter' : 80 ,
38+ 'name' : 'ENERCON E 126 7500' ,
39+ 'fetch_curve' : 'power_curve' }
40+ self .test_turbine_2 = {'hub_height' : 90 ,
41+ 'rotor_diameter' : 60 ,
42+ 'name' : 'VESTAS V 90 1800' ,
43+ 'fetch_curve' : 'power_curve' }
44+ self .test_farm = {'name' : 'test farm' ,
45+ 'wind_turbine_fleet' : [
46+ {'wind_turbine' :
47+ wt .WindTurbine (** self .test_turbine ),
48+ 'number_of_turbines' : 3 }]}
49+ self .test_farm_2 = {'name' : 'test farm' ,
50+ 'wind_turbine_fleet' :
51+ [{'wind_turbine' :
52+ wt .WindTurbine (** self .test_turbine ),
53+ 'number_of_turbines' : 3 },
54+ {'wind_turbine' :
55+ wt .WindTurbine (** self .test_turbine_2 ),
56+ 'number_of_turbines' : 3 }]}
57+ self .test_cluster = {'name' : 'example_cluster' ,
58+ 'wind_farms' : [wf .WindFarm (** self .test_farm ),
59+ wf .WindFarm (** self .test_farm_2 )]}
60+
61+ def test_run_model (self ):
62+ parameters = {'wake_losses_model' : 'dena_mean' ,
63+ 'smoothing' : False ,
64+ 'standard_deviation_method' : 'turbulence_intensity' ,
65+ 'smoothing_order' : 'wind_farm_power_curves' }
5066
5167 # Test modelchain with default values
5268 power_output_exp = pd .Series (data = [4409211.803349806 ,
5369 10212484.219845157 ],
5470 name = 'feedin_power_plant' )
5571 test_tc_mc = tc_mc .TurbineClusterModelChain (
5672 power_plant = wf .WindFarm (** self .test_farm ), ** parameters )
57- test_tc_mc .run_model (weather_df )
73+ test_tc_mc .run_model (self . weather_df )
5874 assert_series_equal (test_tc_mc .power_output , power_output_exp )
5975
6076 # Test constant efficiency
@@ -66,7 +82,7 @@ def test_run_model(self):
6682 name = 'feedin_power_plant' )
6783 test_tc_mc = tc_mc .TurbineClusterModelChain (
6884 power_plant = test_wind_farm , ** parameters )
69- test_tc_mc .run_model (weather_df )
85+ test_tc_mc .run_model (self . weather_df )
7086 assert_series_equal (test_tc_mc .power_output , power_output_exp )
7187
7288 # TODO: Test power efficiency curve?
@@ -80,20 +96,95 @@ def test_run_model(self):
8096 name = 'feedin_power_plant' )
8197 test_tc_mc = tc_mc .TurbineClusterModelChain (
8298 power_plant = test_wind_farm , ** parameters )
83- test_tc_mc .run_model (weather_df )
99+ test_tc_mc .run_model (self .weather_df )
100+ assert_series_equal (test_tc_mc .power_output , power_output_exp )
101+
102+ # Test wind farm with different turbine types (smoothing)
103+ test_wind_farm = wf .WindFarm (** self .test_farm_2 )
104+ test_wind_farm .efficiency = 0.9
105+ power_output_exp = pd .Series (data = [7035990.555719288 ,
106+ 14104709.373232642 ],
107+ name = 'feedin_power_plant' )
108+ test_tc_mc = tc_mc .TurbineClusterModelChain (
109+ power_plant = test_wind_farm , ** parameters )
110+ test_tc_mc .run_model (self .weather_df )
84111 assert_series_equal (test_tc_mc .power_output , power_output_exp )
85112
86- # Test other smoothing order # TODO: Test different wind turbines
113+ # Test other smoothing order
87114 parameters ['smoothing_order' ] = 'turbine_power_curves'
88- test_wind_farm = wf .WindFarm (** self .test_farm )
115+ test_wind_farm = wf .WindFarm (** self .test_farm_2 )
89116 test_wind_farm .efficiency = 0.9
90- power_output_exp = pd .Series (data = [5015168.554748144 ,
91- 10389592.995632712 ],
117+ power_output_exp = pd .Series (data = [7067892.325652927 ,
118+ 14103159.481573664 ],
92119 name = 'feedin_power_plant' )
93120 test_tc_mc = tc_mc .TurbineClusterModelChain (
94121 power_plant = test_wind_farm , ** parameters )
95- test_tc_mc .run_model (weather_df )
122+ test_tc_mc .run_model (self .weather_df )
123+ assert_series_equal (test_tc_mc .power_output , power_output_exp )
124+
125+ def test_run_model_turbine_cluster (self ):
126+ parameters = {'wake_losses_model' : 'dena_mean' ,
127+ 'smoothing' : False ,
128+ 'standard_deviation_method' : 'turbulence_intensity' ,
129+ 'smoothing_order' : 'wind_farm_power_curves' }
130+
131+ # Test modelchain with default values
132+ power_output_exp = pd .Series (data = [10683892.759175435 ,
133+ 24399645.35183305 ],
134+ name = 'feedin_power_plant' )
135+ test_tc_mc = tc_mc .TurbineClusterModelChain (
136+ power_plant = wtc .WindTurbineCluster (** self .test_cluster ),
137+ ** parameters )
138+ test_tc_mc .run_model (self .weather_df )
139+ assert_series_equal (test_tc_mc .power_output , power_output_exp )
140+
141+ # Test constant efficiency
142+ parameters ['wake_losses_model' ] = 'constant_efficiency'
143+ test_cluster = wtc .WindTurbineCluster (** self .test_cluster )
144+ for farm in test_cluster .wind_farms :
145+ farm .efficiency = 0.9
146+ power_output_exp = pd .Series (data = [11333638.728757974 ,
147+ 24561046.12113034 ],
148+ name = 'feedin_power_plant' )
149+ test_tc_mc = tc_mc .TurbineClusterModelChain (
150+ power_plant = test_cluster , ** parameters )
151+ test_tc_mc .run_model (self .weather_df )
96152 assert_series_equal (test_tc_mc .power_output , power_output_exp )
97153
154+ # Test smoothing
155+ parameters ['smoothing' ] = 'True'
156+ test_cluster = wtc .WindTurbineCluster (** self .test_cluster )
157+ for farm in test_cluster .wind_farms :
158+ farm .efficiency = 0.9
159+ power_output_exp = pd .Series (data = [12055848.06813206 ,
160+ 24494381.45222553 ],
161+ name = 'feedin_power_plant' )
162+ test_tc_mc = tc_mc .TurbineClusterModelChain (
163+ power_plant = test_cluster , ** parameters )
164+ test_tc_mc .run_model (self .weather_df )
165+ assert_series_equal (test_tc_mc .power_output , power_output_exp )
98166
99- # TODO: test turbine cluster
167+ # Test wind farm with different turbine types (smoothing)
168+ test_cluster = wtc .WindTurbineCluster (** self .test_cluster )
169+ for farm in test_cluster .wind_farms :
170+ farm .efficiency = 0.9
171+ power_output_exp = pd .Series (data = [12055848.06813206 ,
172+ 24494381.45222553 ],
173+ name = 'feedin_power_plant' )
174+ test_tc_mc = tc_mc .TurbineClusterModelChain (
175+ power_plant = test_cluster , ** parameters )
176+ test_tc_mc .run_model (self .weather_df )
177+ assert_series_equal (test_tc_mc .power_output , power_output_exp )
178+
179+ # Test other smoothing order
180+ parameters ['smoothing_order' ] = 'turbine_power_curves'
181+ test_cluster = wtc .WindTurbineCluster (** self .test_cluster )
182+ for farm in test_cluster .wind_farms :
183+ farm .efficiency = 0.9
184+ power_output_exp = pd .Series (data = [12086527.665961245 ,
185+ 24492153.631181397 ],
186+ name = 'feedin_power_plant' )
187+ test_tc_mc = tc_mc .TurbineClusterModelChain (
188+ power_plant = test_cluster , ** parameters )
189+ test_tc_mc .run_model (self .weather_df )
190+ assert_series_equal (test_tc_mc .power_output , power_output_exp )
0 commit comments