1 | !> @file wind_turbine_model_mod.f90 |
---|
2 | !------------------------------------------------------------------------------! |
---|
3 | ! This file is part of PALM. |
---|
4 | ! |
---|
5 | ! PALM is free software: you can redistribute it and/or modify it under the |
---|
6 | ! terms of the GNU General Public License as published by the Free Software |
---|
7 | ! Foundation, either version 3 of the License, or (at your option) any later |
---|
8 | ! version. |
---|
9 | ! |
---|
10 | ! PALM is distributed in the hope that it will be useful, but WITHOUT ANY |
---|
11 | ! WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR |
---|
12 | ! A PARTICULAR PURPOSE. See the GNU General Public License for more details. |
---|
13 | ! |
---|
14 | ! You should have received a copy of the GNU General Public License along with |
---|
15 | ! PALM. If not, see <http://www.gnu.org/licenses/>. |
---|
16 | ! |
---|
17 | ! Copyright 2009-2017 Carl von Ossietzky Universitaet Oldenburg |
---|
18 | ! Copyright 1997-2017 Leibniz Universitaet Hannover |
---|
19 | !------------------------------------------------------------------------------! |
---|
20 | ! |
---|
21 | ! Current revisions: |
---|
22 | ! ----------------- |
---|
23 | ! |
---|
24 | ! |
---|
25 | ! Former revisions: |
---|
26 | ! ----------------- |
---|
27 | ! $Id: wind_turbine_model_mod.f90 2563 2017-10-19 15:36:10Z scharf $ |
---|
28 | ! Restart runs with wind turbine model are possible now. For this purpose, two |
---|
29 | ! new subroutines wtm_write_restart_data and wtm_read_restart_data had to be |
---|
30 | ! defined |
---|
31 | ! |
---|
32 | ! 2553 2017-10-18 08:03:45Z Giersch |
---|
33 | ! Bugfix of vertical loop in wtm_tendencies to account for different turbine |
---|
34 | ! heights, bugfix of the interpolation of the u-component concerning the |
---|
35 | ! vertical index and further small adjustments of the programming style |
---|
36 | ! |
---|
37 | ! 2410 2017-09-06 08:16:30Z Giersch |
---|
38 | ! Revise error message PA0462 |
---|
39 | ! |
---|
40 | ! 2349 2017-08-10 15:44:04Z Giersch |
---|
41 | ! Add parameter pitch_rate to namelist and revise/add error messages |
---|
42 | ! |
---|
43 | ! 2343 2017-08-08 11:28:43Z Giersch |
---|
44 | ! Unit correction in Doxygen comments |
---|
45 | ! |
---|
46 | ! 2323 2017-07-26 12:57:38Z Giersch |
---|
47 | ! Change unit number of file WTM_DATA from 201 to 90 |
---|
48 | ! |
---|
49 | ! 2322 2017-07-26 08:30:28Z Giersch |
---|
50 | ! Bugfix of error message and assign error numbers |
---|
51 | ! |
---|
52 | ! 2257 2017-06-07 14:07:05Z witha |
---|
53 | ! Bugfix: turb_cl_tab and turb_cd_tab were set to zero before being allocated |
---|
54 | ! |
---|
55 | ! 2233 2017-05-30 18:08:54Z suehring |
---|
56 | ! |
---|
57 | ! 2232 2017-05-30 17:47:52Z suehring |
---|
58 | ! Adjustments to new topography concept |
---|
59 | ! |
---|
60 | ! 2152 2017-02-17 13:27:24Z lvollmer |
---|
61 | ! Bugfix in subroutine wtm_read_blade_tables |
---|
62 | ! Addition of a tip loss model |
---|
63 | ! |
---|
64 | ! 2015 2016-09-28 08:45:18Z lvollmer |
---|
65 | ! Bugfix of pitch control |
---|
66 | ! |
---|
67 | ! 2000 2016-08-20 18:09:15Z knoop |
---|
68 | ! Forced header and separation lines into 80 columns |
---|
69 | ! |
---|
70 | ! 1929 2016-06-09 16:25:25Z suehring |
---|
71 | ! Bugfix: added preprocessor directives for parallel and serial mode |
---|
72 | ! |
---|
73 | ! 1914 2016-05-26 14:44:07Z witha |
---|
74 | ! Initial revision |
---|
75 | ! |
---|
76 | ! |
---|
77 | ! Description: |
---|
78 | ! ------------ |
---|
79 | !> This module calculates the effect of wind turbines on the flow fields. The |
---|
80 | !> initial version contains only the advanced actuator disk with rotation method |
---|
81 | !> (ADM-R). |
---|
82 | !> The wind turbines include the tower effect, can be yawed and tilted. |
---|
83 | !> The wind turbine model includes controllers for rotational speed, pitch and |
---|
84 | !> yaw. |
---|
85 | !> Currently some specifications of the NREL 5 MW reference turbine |
---|
86 | !> are hardcoded whereas most input data comes from separate files (currently |
---|
87 | !> external, planned to be included as namelist which will be read in |
---|
88 | !> automatically). |
---|
89 | !> |
---|
90 | !> @todo Revise code according to PALM Coding Standard |
---|
91 | !> @todo Implement ADM and ALM turbine models |
---|
92 | !> @todo Generate header information |
---|
93 | !> @todo Implement further parameter checks and error messages |
---|
94 | !> @todo Revise and add code documentation |
---|
95 | !> @todo Output turbine parameters as timeseries |
---|
96 | !> @todo Include additional output variables |
---|
97 | !> @todo Revise smearing the forces for turbines in yaw |
---|
98 | !> @todo Revise nacelle and tower parameterization |
---|
99 | !> @todo Allow different turbine types in one simulation |
---|
100 | ! |
---|
101 | !------------------------------------------------------------------------------! |
---|
102 | MODULE wind_turbine_model_mod |
---|
103 | |
---|
104 | USE arrays_3d, & |
---|
105 | ONLY: tend, u, v, w, zu, zw |
---|
106 | |
---|
107 | USE constants, & |
---|
108 | ONLY: pi |
---|
109 | |
---|
110 | USE control_parameters, & |
---|
111 | ONLY: dt_3d, dz, message_string, simulated_time, wind_turbine, & |
---|
112 | initializing_actions |
---|
113 | |
---|
114 | USE cpulog, & |
---|
115 | ONLY: cpu_log, log_point_s |
---|
116 | |
---|
117 | USE grid_variables, & |
---|
118 | ONLY: ddx, dx, ddy, dy |
---|
119 | |
---|
120 | USE indices, & |
---|
121 | ONLY: nbgp, nx, nxl, nxlg, nxr, nxrg, ny, nyn, nyng, nys, nysg, nz, & |
---|
122 | nzb, nzt, wall_flags_0 |
---|
123 | |
---|
124 | USE kinds |
---|
125 | |
---|
126 | USE pegrid |
---|
127 | |
---|
128 | |
---|
129 | IMPLICIT NONE |
---|
130 | |
---|
131 | PRIVATE |
---|
132 | |
---|
133 | ! |
---|
134 | !-- Variables specified in the namelist wind_turbine_par |
---|
135 | |
---|
136 | INTEGER(iwp) :: nairfoils = 8 !< number of airfoils of the used turbine model (for ADM-R and ALM) |
---|
137 | INTEGER(iwp) :: nturbines = 1 !< number of turbines |
---|
138 | |
---|
139 | LOGICAL :: pitch_control = .FALSE. !< switch for use of pitch controller |
---|
140 | LOGICAL :: speed_control = .FALSE. !< switch for use of speed controller |
---|
141 | LOGICAL :: yaw_control = .FALSE. !< switch for use of yaw controller |
---|
142 | LOGICAL :: tl_cor = .FALSE. !< switch for use of tip loss correct. |
---|
143 | |
---|
144 | REAL(wp) :: segment_length = 1.0_wp !< length of the segments, the rotor area is divided into |
---|
145 | !< (in tangential direction, as factor of MIN(dx,dy,dz)) |
---|
146 | REAL(wp) :: segment_width = 0.5_wp !< width of the segments, the rotor area is divided into |
---|
147 | !< (in radial direction, as factor of MIN(dx,dy,dz)) |
---|
148 | REAL(wp) :: time_turbine_on = 0.0_wp !< time at which turbines are started |
---|
149 | REAL(wp) :: tilt = 0.0_wp !< vertical tilt of the rotor [degree] ( positive = backwards ) |
---|
150 | |
---|
151 | REAL(wp), DIMENSION(1:100) :: dtow = 0.0_wp !< tower diameter [m] |
---|
152 | REAL(wp), DIMENSION(1:100) :: omega_rot = 0.9_wp !< inital or constant rotor speed [rad/s] |
---|
153 | REAL(wp), DIMENSION(1:100) :: phi_yaw = 0.0_wp !< yaw angle [degree] ( clockwise, 0 = facing west ) |
---|
154 | REAL(wp), DIMENSION(1:100) :: pitch_add = 0.0_wp !< constant pitch angle |
---|
155 | REAL(wp), DIMENSION(1:100) :: rcx = 9999999.9_wp !< position of hub in x-direction |
---|
156 | REAL(wp), DIMENSION(1:100) :: rcy = 9999999.9_wp !< position of hub in y-direction |
---|
157 | REAL(wp), DIMENSION(1:100) :: rcz = 9999999.9_wp !< position of hub in z-direction |
---|
158 | REAL(wp), DIMENSION(1:100) :: rnac = 0.0_wp !< nacelle diameter [m] |
---|
159 | REAL(wp), DIMENSION(1:100) :: rr = 63.0_wp !< rotor radius [m] |
---|
160 | REAL(wp), DIMENSION(1:100) :: turb_cd_nacelle = 0.85_wp !< drag coefficient for nacelle |
---|
161 | REAL(wp), DIMENSION(1:100) :: turb_cd_tower = 1.2_wp !< drag coefficient for tower |
---|
162 | |
---|
163 | ! |
---|
164 | !-- Variables specified in the namelist for speed controller |
---|
165 | !-- Default values are from the NREL 5MW research turbine (Jonkman, 2008) |
---|
166 | |
---|
167 | REAL(wp) :: rated_power = 5296610.0_wp !< rated turbine power [W] |
---|
168 | REAL(wp) :: gear_ratio = 97.0_wp !< Gear ratio from rotor to generator |
---|
169 | REAL(wp) :: inertia_rot = 34784179.0_wp !< Inertia of the rotor [kg*m2] |
---|
170 | REAL(wp) :: inertia_gen = 534.116_wp !< Inertia of the generator [kg*m2] |
---|
171 | REAL(wp) :: gen_eff = 0.944_wp !< Electric efficiency of the generator |
---|
172 | REAL(wp) :: gear_eff = 1.0_wp !< Loss between rotor and generator |
---|
173 | REAL(wp) :: air_dens = 1.225_wp !< Air density to convert to W [kg/m3] |
---|
174 | REAL(wp) :: rated_genspeed = 121.6805_wp !< Rated generator speed [rad/s] |
---|
175 | REAL(wp) :: max_torque_gen = 47402.91_wp !< Maximum of the generator torque [Nm] |
---|
176 | REAL(wp) :: slope2 = 2.332287_wp !< Slope constant for region 2 |
---|
177 | REAL(wp) :: min_reg2 = 91.21091_wp !< Lower generator speed boundary of region 2 [rad/s] |
---|
178 | REAL(wp) :: min_reg15 = 70.16224_wp !< Lower generator speed boundary of region 1.5 [rad/s] |
---|
179 | REAL(wp) :: max_trq_rate = 15000.0_wp !< Max generator torque increase [Nm/s] |
---|
180 | REAL(wp) :: pitch_rate = 8.0_wp !< Max pitch rate [degree/s] |
---|
181 | |
---|
182 | |
---|
183 | ! |
---|
184 | !-- Variables specified in the namelist for yaw control |
---|
185 | |
---|
186 | REAL(wp) :: yaw_speed = 0.005236_wp !< speed of the yaw actuator [rad/s] |
---|
187 | REAL(wp) :: max_miss = 0.08726_wp !< maximum tolerated yaw missalignment [rad] |
---|
188 | REAL(wp) :: min_miss = 0.008726_wp !< minimum yaw missalignment for which the actuator stops [rad] |
---|
189 | |
---|
190 | ! |
---|
191 | !-- Set flag for output files TURBINE_PARAMETERS |
---|
192 | TYPE file_status |
---|
193 | LOGICAL :: opened, opened_before |
---|
194 | END TYPE file_status |
---|
195 | |
---|
196 | TYPE(file_status), DIMENSION(500) :: openfile_turb_mod = & |
---|
197 | file_status(.FALSE.,.FALSE.) |
---|
198 | |
---|
199 | ! |
---|
200 | !-- Variables for initialization of the turbine model |
---|
201 | |
---|
202 | INTEGER(iwp) :: inot !< turbine loop index (turbine id) |
---|
203 | INTEGER(iwp) :: nsegs_max !< maximum number of segments (all turbines, required for allocation of arrays) |
---|
204 | INTEGER(iwp) :: nrings_max !< maximum number of rings (all turbines, required for allocation of arrays) |
---|
205 | INTEGER(iwp) :: ring !< ring loop index (ring number) |
---|
206 | INTEGER(iwp) :: rr_int !< |
---|
207 | INTEGER(iwp) :: upper_end !< |
---|
208 | |
---|
209 | INTEGER(iwp), DIMENSION(1) :: lct !< |
---|
210 | |
---|
211 | INTEGER(iwp), DIMENSION(:), ALLOCATABLE :: i_hub !< index belonging to x-position of the turbine |
---|
212 | INTEGER(iwp), DIMENSION(:), ALLOCATABLE :: i_smear !< index defining the area for the smearing of the forces (x-direction) |
---|
213 | INTEGER(iwp), DIMENSION(:), ALLOCATABLE :: j_hub !< index belonging to y-position of the turbine |
---|
214 | INTEGER(iwp), DIMENSION(:), ALLOCATABLE :: j_smear !< index defining the area for the smearing of the forces (y-direction) |
---|
215 | INTEGER(iwp), DIMENSION(:), ALLOCATABLE :: k_hub !< index belonging to hub height |
---|
216 | INTEGER(iwp), DIMENSION(:), ALLOCATABLE :: k_smear !< index defining the area for the smearing of the forces (z-direction) |
---|
217 | INTEGER(iwp), DIMENSION(:), ALLOCATABLE :: nrings !< number of rings per turbine |
---|
218 | INTEGER(iwp), DIMENSION(:), ALLOCATABLE :: nsegs_total !< total number of segments per turbine |
---|
219 | |
---|
220 | INTEGER(iwp), DIMENSION(:,:), ALLOCATABLE :: nsegs !< number of segments per ring and turbine |
---|
221 | |
---|
222 | ! |
---|
223 | !- parameters for the smearing from the rotor to the cartesian grid |
---|
224 | REAL(wp) :: pol_a !< parameter for the polynomial smearing fct |
---|
225 | REAL(wp) :: pol_b !< parameter for the polynomial smearing fct |
---|
226 | REAL(wp) :: delta_t_factor !< |
---|
227 | REAL(wp) :: eps_factor !< |
---|
228 | REAL(wp) :: eps_min !< |
---|
229 | REAL(wp) :: eps_min2 !< |
---|
230 | REAL(wp) :: sqrt_arg !< |
---|
231 | |
---|
232 | ! |
---|
233 | !-- Variables for the calculation of lift and drag coefficients |
---|
234 | REAL(wp), DIMENSION(:), ALLOCATABLE :: ard !< |
---|
235 | REAL(wp), DIMENSION(:), ALLOCATABLE :: crd !< |
---|
236 | REAL(wp), DIMENSION(:), ALLOCATABLE :: delta_r !< radial segment length |
---|
237 | REAL(wp), DIMENSION(:), ALLOCATABLE :: lrd !< |
---|
238 | |
---|
239 | REAL(wp) :: accu_cl_cd_tab = 0.1_wp !< Accuracy of the interpolation of |
---|
240 | !< the lift and drag coeff [deg] |
---|
241 | |
---|
242 | REAL(wp), DIMENSION(:,:), ALLOCATABLE :: turb_cd_tab !< table of the blade drag coefficient |
---|
243 | REAL(wp), DIMENSION(:,:), ALLOCATABLE :: turb_cl_tab !< table of the blade lift coefficient |
---|
244 | |
---|
245 | REAL(wp), DIMENSION(:,:,:), ALLOCATABLE :: nac_cd_surf !< 3d field of the tower drag coefficient |
---|
246 | REAL(wp), DIMENSION(:,:,:), ALLOCATABLE :: tow_cd_surf !< 3d field of the nacelle drag coefficient |
---|
247 | |
---|
248 | ! |
---|
249 | !-- Variables for the calculation of the forces |
---|
250 | |
---|
251 | REAL(wp) :: cur_r !< |
---|
252 | REAL(wp) :: phi_rotor !< |
---|
253 | REAL(wp) :: pre_factor !< |
---|
254 | REAL(wp) :: torque_seg !< |
---|
255 | REAL(wp) :: u_int_l !< |
---|
256 | REAL(wp) :: u_int_u !< |
---|
257 | REAL(wp) :: u_rot !< |
---|
258 | REAL(wp) :: v_int_l !< |
---|
259 | REAL(wp) :: v_int_u !< |
---|
260 | REAL(wp) :: w_int_l !< |
---|
261 | REAL(wp) :: w_int_u !< |
---|
262 | ! |
---|
263 | !- Tendencies from the nacelle and tower thrust |
---|
264 | REAL(wp) :: tend_nac_x = 0.0_wp !< |
---|
265 | REAL(wp) :: tend_tow_x = 0.0_wp !< |
---|
266 | REAL(wp) :: tend_nac_y = 0.0_wp !< |
---|
267 | REAL(wp) :: tend_tow_y = 0.0_wp !< |
---|
268 | |
---|
269 | REAL(wp), DIMENSION(:), ALLOCATABLE :: alpha_attack !< |
---|
270 | REAL(wp), DIMENSION(:), ALLOCATABLE :: chord !< |
---|
271 | REAL(wp), DIMENSION(:), ALLOCATABLE :: phi_rel !< |
---|
272 | REAL(wp), DIMENSION(:), ALLOCATABLE :: torque_total !< |
---|
273 | REAL(wp), DIMENSION(:), ALLOCATABLE :: thrust_rotor !< |
---|
274 | REAL(wp), DIMENSION(:), ALLOCATABLE :: turb_cl !< |
---|
275 | REAL(wp), DIMENSION(:), ALLOCATABLE :: turb_cd !< |
---|
276 | REAL(wp), DIMENSION(:), ALLOCATABLE :: vrel !< |
---|
277 | REAL(wp), DIMENSION(:), ALLOCATABLE :: vtheta !< |
---|
278 | |
---|
279 | REAL(wp), DIMENSION(:,:), ALLOCATABLE :: rbx, rby, rbz !< coordinates of the blade elements |
---|
280 | REAL(wp), DIMENSION(:,:), ALLOCATABLE :: rotx, roty, rotz !< normal vectors to the rotor coordinates |
---|
281 | |
---|
282 | ! |
---|
283 | !- Fields for the interpolation of velocities on the rotor grid |
---|
284 | REAL(wp), DIMENSION(:,:,:), ALLOCATABLE :: u_int !< |
---|
285 | REAL(wp), DIMENSION(:,:,:), ALLOCATABLE :: u_int_1_l !< |
---|
286 | REAL(wp), DIMENSION(:,:,:), ALLOCATABLE :: v_int !< |
---|
287 | REAL(wp), DIMENSION(:,:,:), ALLOCATABLE :: v_int_1_l !< |
---|
288 | REAL(wp), DIMENSION(:,:,:), ALLOCATABLE :: w_int !< |
---|
289 | REAL(wp), DIMENSION(:,:,:), ALLOCATABLE :: w_int_1_l !< |
---|
290 | |
---|
291 | ! |
---|
292 | !- rotor tendencies on the segments |
---|
293 | REAL(wp), DIMENSION(:), ALLOCATABLE :: thrust_seg !< |
---|
294 | REAL(wp), DIMENSION(:), ALLOCATABLE :: torque_seg_y !< |
---|
295 | REAL(wp), DIMENSION(:), ALLOCATABLE :: torque_seg_z !< |
---|
296 | |
---|
297 | ! |
---|
298 | !- rotor tendencies on the rings |
---|
299 | REAL(wp), DIMENSION(:,:), ALLOCATABLE :: thrust_ring !< |
---|
300 | REAL(wp), DIMENSION(:,:), ALLOCATABLE :: torque_ring_y !< |
---|
301 | REAL(wp), DIMENSION(:,:), ALLOCATABLE :: torque_ring_z !< |
---|
302 | |
---|
303 | ! |
---|
304 | !- rotor tendencies on rotor grids for all turbines |
---|
305 | REAL(wp), DIMENSION(:,:,:), ALLOCATABLE :: thrust !< |
---|
306 | REAL(wp), DIMENSION(:,:,:), ALLOCATABLE :: torque_y !< |
---|
307 | REAL(wp), DIMENSION(:,:,:), ALLOCATABLE :: torque_z !< |
---|
308 | |
---|
309 | ! |
---|
310 | !- rotor tendencies on coordinate grid |
---|
311 | REAL(wp), DIMENSION(:,:,:), ALLOCATABLE :: rot_tend_x !< |
---|
312 | REAL(wp), DIMENSION(:,:,:), ALLOCATABLE :: rot_tend_y !< |
---|
313 | REAL(wp), DIMENSION(:,:,:), ALLOCATABLE :: rot_tend_z !< |
---|
314 | ! |
---|
315 | !- variables for the rotation of the rotor coordinates |
---|
316 | REAL(wp), DIMENSION(1:100,1:3,1:3) :: rot_coord_trans !< matrix for rotation of rotor coordinates |
---|
317 | |
---|
318 | REAL(wp), DIMENSION(1:3) :: rot_eigen_rad !< |
---|
319 | REAL(wp), DIMENSION(1:3) :: rot_eigen_azi !< |
---|
320 | REAL(wp), DIMENSION(1:3) :: rot_eigen_nor !< |
---|
321 | REAL(wp), DIMENSION(1:3) :: re !< |
---|
322 | REAL(wp), DIMENSION(1:3) :: rea !< |
---|
323 | REAL(wp), DIMENSION(1:3) :: ren !< |
---|
324 | REAL(wp), DIMENSION(1:3) :: rote !< |
---|
325 | REAL(wp), DIMENSION(1:3) :: rota !< |
---|
326 | REAL(wp), DIMENSION(1:3) :: rotn !< |
---|
327 | |
---|
328 | ! |
---|
329 | !-- Fixed variables for the speed controller |
---|
330 | |
---|
331 | LOGICAL :: start_up = .TRUE. !< |
---|
332 | |
---|
333 | REAL(wp) :: Fcorner !< corner freq for the controller low pass filter |
---|
334 | REAL(wp) :: min_reg25 !< min region 2.5 |
---|
335 | REAL(wp) :: om_rate !< rotor speed change |
---|
336 | REAL(wp) :: slope15 !< slope in region 1.5 |
---|
337 | REAL(wp) :: slope25 !< slope in region 2.5 |
---|
338 | REAL(wp) :: trq_rate !< torque change |
---|
339 | REAL(wp) :: vs_sysp !< |
---|
340 | REAL(wp) :: lp_coeff !< coeff for the controller low pass filter |
---|
341 | |
---|
342 | REAL(wp), DIMENSION(100) :: omega_rot_l = 0.0_wp !< local rot speed [rad/s] |
---|
343 | |
---|
344 | ! |
---|
345 | !-- Fixed variables for the yaw controller |
---|
346 | |
---|
347 | REAL(wp), DIMENSION(:) , ALLOCATABLE :: yawdir !< direction to yaw |
---|
348 | REAL(wp), DIMENSION(:) , ALLOCATABLE :: phi_yaw_l !< local (cpu) yaw angle |
---|
349 | REAL(wp), DIMENSION(:) , ALLOCATABLE :: wd30_l !< local (cpu) long running avg of the wd |
---|
350 | REAL(wp), DIMENSION(:) , ALLOCATABLE :: wd2_l !< local (cpu) short running avg of the wd |
---|
351 | REAL(wp), DIMENSION(:) , ALLOCATABLE :: wdir !< wind direction at hub |
---|
352 | REAL(wp), DIMENSION(:) , ALLOCATABLE :: u_inflow !< wind speed at hub |
---|
353 | REAL(wp), DIMENSION(:) , ALLOCATABLE :: wdir_l !< |
---|
354 | REAL(wp), DIMENSION(:) , ALLOCATABLE :: u_inflow_l !< |
---|
355 | REAL(wp), DIMENSION(:,:), ALLOCATABLE :: wd30 !< |
---|
356 | REAL(wp), DIMENSION(:,:), ALLOCATABLE :: wd2 !< |
---|
357 | LOGICAL, DIMENSION(1:100) :: doyaw = .FALSE. !< |
---|
358 | INTEGER(iwp) :: WDLON !< |
---|
359 | INTEGER(iwp) :: WDSHO !< |
---|
360 | |
---|
361 | ! |
---|
362 | !-- Variables that have to be saved in the binary file for restarts |
---|
363 | REAL(wp), DIMENSION(1:100) :: pitch_add_old = 0.0_wp !< old constant pitch angle |
---|
364 | REAL(wp), DIMENSION(1:100) :: omega_gen = 0.0_wp !< curr. generator speed |
---|
365 | REAL(wp), DIMENSION(1:100) :: omega_gen_f = 0.0_wp !< filtered generator speed |
---|
366 | REAL(wp), DIMENSION(1:100) :: omega_gen_old = 0.0_wp !< last generator speed |
---|
367 | REAL(wp), DIMENSION(1:100) :: omega_gen_f_old = 0.0_wp !< last filtered generator speed |
---|
368 | REAL(wp), DIMENSION(1:100) :: torque_gen = 0.0_wp !< generator torque |
---|
369 | REAL(wp), DIMENSION(1:100) :: torque_gen_old = 0.0_wp !< last generator torque |
---|
370 | |
---|
371 | |
---|
372 | SAVE |
---|
373 | |
---|
374 | |
---|
375 | INTERFACE wtm_parin |
---|
376 | MODULE PROCEDURE wtm_parin |
---|
377 | END INTERFACE wtm_parin |
---|
378 | |
---|
379 | INTERFACE wtm_write_restart_data |
---|
380 | MODULE PROCEDURE wtm_write_restart_data |
---|
381 | END INTERFACE wtm_write_restart_data |
---|
382 | |
---|
383 | INTERFACE wtm_read_restart_data |
---|
384 | MODULE PROCEDURE wtm_read_restart_data |
---|
385 | END INTERFACE wtm_read_restart_data |
---|
386 | |
---|
387 | INTERFACE wtm_check_parameters |
---|
388 | MODULE PROCEDURE wtm_check_parameters |
---|
389 | END INTERFACE wtm_check_parameters |
---|
390 | |
---|
391 | INTERFACE wtm_init_arrays |
---|
392 | MODULE PROCEDURE wtm_init_arrays |
---|
393 | END INTERFACE wtm_init_arrays |
---|
394 | |
---|
395 | INTERFACE wtm_init |
---|
396 | MODULE PROCEDURE wtm_init |
---|
397 | END INTERFACE wtm_init |
---|
398 | |
---|
399 | INTERFACE wtm_read_blade_tables |
---|
400 | MODULE PROCEDURE wtm_read_blade_tables |
---|
401 | END INTERFACE wtm_read_blade_tables |
---|
402 | |
---|
403 | INTERFACE wtm_forces |
---|
404 | MODULE PROCEDURE wtm_forces |
---|
405 | END INTERFACE wtm_forces |
---|
406 | |
---|
407 | INTERFACE wtm_yawcontrol |
---|
408 | MODULE PROCEDURE wtm_yawcontrol |
---|
409 | END INTERFACE wtm_yawcontrol |
---|
410 | |
---|
411 | INTERFACE wtm_rotate_rotor |
---|
412 | MODULE PROCEDURE wtm_rotate_rotor |
---|
413 | END INTERFACE wtm_rotate_rotor |
---|
414 | |
---|
415 | INTERFACE wtm_speed_control |
---|
416 | MODULE PROCEDURE wtm_init_speed_control |
---|
417 | MODULE PROCEDURE wtm_speed_control |
---|
418 | END INTERFACE wtm_speed_control |
---|
419 | |
---|
420 | INTERFACE wtm_tendencies |
---|
421 | MODULE PROCEDURE wtm_tendencies |
---|
422 | MODULE PROCEDURE wtm_tendencies_ij |
---|
423 | END INTERFACE wtm_tendencies |
---|
424 | |
---|
425 | |
---|
426 | PUBLIC wtm_check_parameters, wtm_forces, wtm_init, wtm_init_arrays, & |
---|
427 | wtm_parin, wtm_write_restart_data, wtm_tendencies |
---|
428 | |
---|
429 | |
---|
430 | CONTAINS |
---|
431 | |
---|
432 | |
---|
433 | !------------------------------------------------------------------------------! |
---|
434 | ! Description: |
---|
435 | ! ------------ |
---|
436 | !> Parin for &wind_turbine_par for wind turbine model |
---|
437 | !------------------------------------------------------------------------------! |
---|
438 | SUBROUTINE wtm_parin |
---|
439 | |
---|
440 | |
---|
441 | IMPLICIT NONE |
---|
442 | |
---|
443 | INTEGER(iwp) :: ierrn !< |
---|
444 | |
---|
445 | CHARACTER (LEN=80) :: line !< dummy string that contains the current line of the parameter file |
---|
446 | |
---|
447 | NAMELIST /wind_turbine_par/ air_dens, dtow, gear_eff, gear_ratio, & |
---|
448 | gen_eff, inertia_gen, inertia_rot, max_miss, & |
---|
449 | max_torque_gen, max_trq_rate, min_miss, & |
---|
450 | min_reg15, min_reg2, nairfoils, nturbines, & |
---|
451 | omega_rot, phi_yaw, pitch_add, pitch_control,& |
---|
452 | rated_genspeed, rated_power, rcx, rcy, rcz, & |
---|
453 | rnac, rr, segment_length, segment_width, & |
---|
454 | slope2, speed_control, tilt, time_turbine_on,& |
---|
455 | turb_cd_nacelle, turb_cd_tower, pitch_rate, & |
---|
456 | yaw_control, yaw_speed, tl_cor |
---|
457 | |
---|
458 | ! |
---|
459 | !-- Try to find wind turbine model package |
---|
460 | REWIND ( 11 ) |
---|
461 | line = ' ' |
---|
462 | DO WHILE ( INDEX( line, '&wind_turbine_par' ) == 0 ) |
---|
463 | READ ( 11, '(A)', END=10 ) line |
---|
464 | ENDDO |
---|
465 | BACKSPACE ( 11 ) |
---|
466 | |
---|
467 | ! |
---|
468 | !-- Read user-defined namelist |
---|
469 | READ ( 11, wind_turbine_par, IOSTAT=ierrn ) |
---|
470 | |
---|
471 | IF ( ierrn < 0 ) THEN |
---|
472 | message_string = 'no wind_turbine_par-NAMELIST found: ' // & |
---|
473 | 'End of file has reached' |
---|
474 | CALL message( 'wtm_parin', 'PA0460', 1, 2, 0, 6, 0 ) |
---|
475 | ELSEIF ( ierrn > 0 ) THEN |
---|
476 | message_string = 'errors in wind_turbine_par-NAMELIST: ' // & |
---|
477 | 'some variables for steering may not be properly set' |
---|
478 | CALL message( 'wtm_parin', 'PA0466', 1, 2, 0, 6, 0 ) |
---|
479 | ENDIF |
---|
480 | |
---|
481 | ! |
---|
482 | !-- Set flag that indicates that the wind turbine model is switched on |
---|
483 | wind_turbine = .TRUE. |
---|
484 | |
---|
485 | IF ( TRIM( initializing_actions ) == 'read_restart_data' ) THEN |
---|
486 | CALL wtm_read_restart_data |
---|
487 | ENDIF |
---|
488 | |
---|
489 | 10 CONTINUE ! TBD Change from continue, mit ierrn machen |
---|
490 | |
---|
491 | |
---|
492 | END SUBROUTINE wtm_parin |
---|
493 | |
---|
494 | |
---|
495 | !------------------------------------------------------------------------------! |
---|
496 | ! Description: |
---|
497 | ! ------------ |
---|
498 | !> This routine writes the respective restart data. |
---|
499 | !------------------------------------------------------------------------------! |
---|
500 | SUBROUTINE wtm_write_restart_data |
---|
501 | |
---|
502 | IMPLICIT NONE |
---|
503 | |
---|
504 | WRITE ( 14 ) 'omega_gen ' |
---|
505 | WRITE ( 14 ) omega_gen |
---|
506 | WRITE ( 14 ) 'omega_gen_f ' |
---|
507 | WRITE ( 14 ) omega_gen_f |
---|
508 | WRITE ( 14 ) 'omega_gen_f_old ' |
---|
509 | WRITE ( 14 ) omega_gen_f_old |
---|
510 | WRITE ( 14 ) 'omega_gen_old ' |
---|
511 | WRITE ( 14 ) omega_gen_old |
---|
512 | WRITE ( 14 ) 'omega_rot ' |
---|
513 | WRITE ( 14 ) omega_rot |
---|
514 | WRITE ( 14 ) 'phi_yaw ' |
---|
515 | WRITE ( 14 ) phi_yaw(:) |
---|
516 | WRITE ( 14 ) 'pitch_add ' |
---|
517 | WRITE ( 14 ) pitch_add |
---|
518 | WRITE ( 14 ) 'pitch_add_old ' |
---|
519 | WRITE ( 14 ) pitch_add_old |
---|
520 | WRITE ( 14 ) 'torque_gen ' |
---|
521 | WRITE ( 14 ) torque_gen |
---|
522 | WRITE ( 14 ) 'torque_gen_old ' |
---|
523 | WRITE ( 14 ) torque_gen_old |
---|
524 | |
---|
525 | WRITE ( 14 ) '*** end wtm *** ' |
---|
526 | |
---|
527 | END SUBROUTINE wtm_write_restart_data |
---|
528 | |
---|
529 | |
---|
530 | !------------------------------------------------------------------------------! |
---|
531 | ! Description: |
---|
532 | ! ------------ |
---|
533 | !> This routine reads the respective restart data. |
---|
534 | !------------------------------------------------------------------------------! |
---|
535 | SUBROUTINE wtm_read_restart_data |
---|
536 | |
---|
537 | |
---|
538 | IMPLICIT NONE |
---|
539 | |
---|
540 | CHARACTER (LEN=30) :: variable_chr !< dummy variable to read string |
---|
541 | |
---|
542 | |
---|
543 | READ ( 13 ) variable_chr |
---|
544 | DO WHILE ( TRIM( variable_chr ) /= '*** end wtm ***' ) |
---|
545 | |
---|
546 | SELECT CASE ( TRIM( variable_chr ) ) |
---|
547 | |
---|
548 | CASE ( 'omega_gen' ) |
---|
549 | READ ( 13 ) omega_gen |
---|
550 | CASE ( 'omega_gen_f' ) |
---|
551 | READ ( 13 ) omega_gen_f |
---|
552 | CASE ( 'omega_gen_old' ) |
---|
553 | READ ( 13 ) omega_gen_old |
---|
554 | CASE ( 'omega_gen_f_old' ) |
---|
555 | READ ( 13 ) omega_gen_f_old |
---|
556 | CASE ( 'omega_rot' ) |
---|
557 | READ ( 13 ) omega_rot |
---|
558 | CASE ( 'phi_yaw' ) |
---|
559 | READ ( 13 ) phi_yaw |
---|
560 | CASE ( 'pitch_add' ) |
---|
561 | READ ( 13 ) pitch_add |
---|
562 | CASE ( 'pitch_add_old' ) |
---|
563 | READ ( 13 ) pitch_add_old |
---|
564 | CASE ( 'torque_gen' ) |
---|
565 | READ ( 13 ) torque_gen |
---|
566 | CASE ( 'torque_gen_old' ) |
---|
567 | READ ( 13 ) torque_gen_old |
---|
568 | |
---|
569 | END SELECT |
---|
570 | |
---|
571 | READ ( 13 ) variable_chr |
---|
572 | |
---|
573 | ENDDO |
---|
574 | |
---|
575 | END SUBROUTINE wtm_read_restart_data |
---|
576 | |
---|
577 | |
---|
578 | !------------------------------------------------------------------------------! |
---|
579 | ! Description: |
---|
580 | ! ------------ |
---|
581 | !> Check namelist parameter |
---|
582 | !------------------------------------------------------------------------------! |
---|
583 | SUBROUTINE wtm_check_parameters |
---|
584 | |
---|
585 | |
---|
586 | IMPLICIT NONE |
---|
587 | |
---|
588 | IF ( ( .NOT.speed_control ) .AND. pitch_control ) THEN |
---|
589 | message_string = 'pitch_control = .TRUE. requires '// & |
---|
590 | 'speed_control = .TRUE.' |
---|
591 | CALL message( 'wtm_check_parameters', 'PA0461', 1, 2, 0, 6, 0 ) |
---|
592 | ENDIF |
---|
593 | |
---|
594 | IF ( ANY( omega_rot(1:nturbines) < 0.0 ) ) THEN |
---|
595 | message_string = 'omega_rot < 0.0, Please set omega_rot to ' // & |
---|
596 | 'a value larger than or equal to zero' |
---|
597 | CALL message( 'wtm_check_parameters', 'PA0462', 1, 2, 0, 6, 0 ) |
---|
598 | ENDIF |
---|
599 | |
---|
600 | |
---|
601 | IF ( ANY( rcx(1:nturbines) == 9999999.9_wp ) .OR. & |
---|
602 | ANY( rcy(1:nturbines) == 9999999.9_wp ) .OR. & |
---|
603 | ANY( rcz(1:nturbines) == 9999999.9_wp ) ) THEN |
---|
604 | |
---|
605 | message_string = 'rcx, rcy, rcz ' // & |
---|
606 | 'have to be given for each turbine.' |
---|
607 | CALL message( 'wtm_check_parameters', 'PA0463', 1, 2, 0, 6, 0 ) |
---|
608 | |
---|
609 | ENDIF |
---|
610 | |
---|
611 | |
---|
612 | END SUBROUTINE wtm_check_parameters |
---|
613 | |
---|
614 | |
---|
615 | !------------------------------------------------------------------------------! |
---|
616 | ! Description: |
---|
617 | ! ------------ |
---|
618 | !> Allocate wind turbine model arrays |
---|
619 | !------------------------------------------------------------------------------! |
---|
620 | SUBROUTINE wtm_init_arrays |
---|
621 | |
---|
622 | |
---|
623 | IMPLICIT NONE |
---|
624 | |
---|
625 | REAL(wp) :: delta_r_factor !< |
---|
626 | REAL(wp) :: delta_r_init !< |
---|
627 | |
---|
628 | ! |
---|
629 | !-- To be able to allocate arrays with dimension of rotor rings and segments, |
---|
630 | !-- the maximum possible numbers of rings and segments have to be calculated: |
---|
631 | |
---|
632 | ALLOCATE( nrings(1:nturbines) ) |
---|
633 | ALLOCATE( delta_r(1:nturbines) ) |
---|
634 | |
---|
635 | nrings(:) = 0 |
---|
636 | delta_r(:) = 0.0_wp |
---|
637 | |
---|
638 | ! |
---|
639 | !-- Thickness (radial) of each ring and length (tangential) of each segment: |
---|
640 | delta_r_factor = segment_width |
---|
641 | delta_t_factor = segment_length |
---|
642 | delta_r_init = delta_r_factor * MIN( dx, dy, dz) |
---|
643 | |
---|
644 | DO inot = 1, nturbines |
---|
645 | ! |
---|
646 | !-- Determine number of rings: |
---|
647 | nrings(inot) = NINT( rr(inot) / delta_r_init ) |
---|
648 | |
---|
649 | delta_r(inot) = rr(inot) / nrings(inot) |
---|
650 | |
---|
651 | ENDDO |
---|
652 | |
---|
653 | nrings_max = MAXVAL(nrings) |
---|
654 | |
---|
655 | ALLOCATE( nsegs(1:nrings_max,1:nturbines) ) |
---|
656 | ALLOCATE( nsegs_total(1:nturbines) ) |
---|
657 | |
---|
658 | nsegs(:,:) = 0 |
---|
659 | nsegs_total(:) = 0 |
---|
660 | |
---|
661 | |
---|
662 | DO inot = 1, nturbines |
---|
663 | DO ring = 1, nrings(inot) |
---|
664 | ! |
---|
665 | !-- Determine number of segments for each ring: |
---|
666 | nsegs(ring,inot) = MAX( 8, CEILING( delta_r_factor * pi * & |
---|
667 | ( 2.0_wp * ring - 1.0_wp ) / & |
---|
668 | delta_t_factor ) ) |
---|
669 | ENDDO |
---|
670 | ! |
---|
671 | !-- Total sum of all rotor segments: |
---|
672 | nsegs_total(inot) = SUM( nsegs(:,inot) ) |
---|
673 | |
---|
674 | ENDDO |
---|
675 | |
---|
676 | ! |
---|
677 | !-- Maximum number of segments per ring: |
---|
678 | nsegs_max = MAXVAL(nsegs) |
---|
679 | |
---|
680 | !! |
---|
681 | !!-- TODO: Folgendes im Header ausgeben! |
---|
682 | ! IF ( myid == 0 ) THEN |
---|
683 | ! PRINT*, 'nrings(1) = ', nrings(1) |
---|
684 | ! PRINT*, '--------------------------------------------------' |
---|
685 | ! PRINT*, 'nsegs(:,1) = ', nsegs(:,1) |
---|
686 | ! PRINT*, '--------------------------------------------------' |
---|
687 | ! PRINT*, 'nrings_max = ', nrings_max |
---|
688 | ! PRINT*, 'nsegs_max = ', nsegs_max |
---|
689 | ! PRINT*, 'nsegs_total(1) = ', nsegs_total(1) |
---|
690 | ! ENDIF |
---|
691 | |
---|
692 | |
---|
693 | ! |
---|
694 | !-- Allocate 1D arrays (dimension = number of turbines) |
---|
695 | ALLOCATE( i_hub(1:nturbines) ) |
---|
696 | ALLOCATE( i_smear(1:nturbines) ) |
---|
697 | ALLOCATE( j_hub(1:nturbines) ) |
---|
698 | ALLOCATE( j_smear(1:nturbines) ) |
---|
699 | ALLOCATE( k_hub(1:nturbines) ) |
---|
700 | ALLOCATE( k_smear(1:nturbines) ) |
---|
701 | ALLOCATE( torque_total(1:nturbines) ) |
---|
702 | ALLOCATE( thrust_rotor(1:nturbines) ) |
---|
703 | |
---|
704 | ! |
---|
705 | !-- Allocation of the 1D arrays for yaw control |
---|
706 | ALLOCATE( yawdir(1:nturbines) ) |
---|
707 | ALLOCATE( u_inflow(1:nturbines) ) |
---|
708 | ALLOCATE( wdir(1:nturbines) ) |
---|
709 | ALLOCATE( u_inflow_l(1:nturbines) ) |
---|
710 | ALLOCATE( wdir_l(1:nturbines) ) |
---|
711 | ALLOCATE( phi_yaw_l(1:nturbines) ) |
---|
712 | |
---|
713 | ! |
---|
714 | !-- Allocate 1D arrays (dimension = number of rotor segments) |
---|
715 | ALLOCATE( alpha_attack(1:nsegs_max) ) |
---|
716 | ALLOCATE( chord(1:nsegs_max) ) |
---|
717 | ALLOCATE( phi_rel(1:nsegs_max) ) |
---|
718 | ALLOCATE( thrust_seg(1:nsegs_max) ) |
---|
719 | ALLOCATE( torque_seg_y(1:nsegs_max) ) |
---|
720 | ALLOCATE( torque_seg_z(1:nsegs_max) ) |
---|
721 | ALLOCATE( turb_cd(1:nsegs_max) ) |
---|
722 | ALLOCATE( turb_cl(1:nsegs_max) ) |
---|
723 | ALLOCATE( vrel(1:nsegs_max) ) |
---|
724 | ALLOCATE( vtheta(1:nsegs_max) ) |
---|
725 | |
---|
726 | ! |
---|
727 | !-- Allocate 2D arrays (dimension = number of rotor rings and segments) |
---|
728 | ALLOCATE( rbx(1:nrings_max,1:nsegs_max) ) |
---|
729 | ALLOCATE( rby(1:nrings_max,1:nsegs_max) ) |
---|
730 | ALLOCATE( rbz(1:nrings_max,1:nsegs_max) ) |
---|
731 | ALLOCATE( thrust_ring(1:nrings_max,1:nsegs_max) ) |
---|
732 | ALLOCATE( torque_ring_y(1:nrings_max,1:nsegs_max) ) |
---|
733 | ALLOCATE( torque_ring_z(1:nrings_max,1:nsegs_max) ) |
---|
734 | |
---|
735 | ! |
---|
736 | !-- Allocate additional 2D arrays |
---|
737 | ALLOCATE( rotx(1:nturbines,1:3) ) |
---|
738 | ALLOCATE( roty(1:nturbines,1:3) ) |
---|
739 | ALLOCATE( rotz(1:nturbines,1:3) ) |
---|
740 | |
---|
741 | ! |
---|
742 | !-- Allocate 3D arrays (dimension = number of grid points) |
---|
743 | ALLOCATE( nac_cd_surf(nzb:nzt+1,nysg:nyng,nxlg:nxrg) ) |
---|
744 | ALLOCATE( rot_tend_x(nzb:nzt+1,nysg:nyng,nxlg:nxrg) ) |
---|
745 | ALLOCATE( rot_tend_y(nzb:nzt+1,nysg:nyng,nxlg:nxrg) ) |
---|
746 | ALLOCATE( rot_tend_z(nzb:nzt+1,nysg:nyng,nxlg:nxrg) ) |
---|
747 | ALLOCATE( thrust(nzb:nzt+1,nysg:nyng,nxlg:nxrg) ) |
---|
748 | ALLOCATE( torque_y(nzb:nzt+1,nysg:nyng,nxlg:nxrg) ) |
---|
749 | ALLOCATE( torque_z(nzb:nzt+1,nysg:nyng,nxlg:nxrg) ) |
---|
750 | ALLOCATE( tow_cd_surf(nzb:nzt+1,nysg:nyng,nxlg:nxrg) ) |
---|
751 | |
---|
752 | ! |
---|
753 | !-- Allocate additional 3D arrays |
---|
754 | ALLOCATE( u_int(1:nturbines,1:nrings_max,1:nsegs_max) ) |
---|
755 | ALLOCATE( u_int_1_l(1:nturbines,1:nrings_max,1:nsegs_max) ) |
---|
756 | ALLOCATE( v_int(1:nturbines,1:nrings_max,1:nsegs_max) ) |
---|
757 | ALLOCATE( v_int_1_l(1:nturbines,1:nrings_max,1:nsegs_max) ) |
---|
758 | ALLOCATE( w_int(1:nturbines,1:nrings_max,1:nsegs_max) ) |
---|
759 | ALLOCATE( w_int_1_l(1:nturbines,1:nrings_max,1:nsegs_max) ) |
---|
760 | |
---|
761 | ! |
---|
762 | !-- All of the arrays are initialized with a value of zero: |
---|
763 | i_hub(:) = 0 |
---|
764 | i_smear(:) = 0 |
---|
765 | j_hub(:) = 0 |
---|
766 | j_smear(:) = 0 |
---|
767 | k_hub(:) = 0 |
---|
768 | k_smear(:) = 0 |
---|
769 | |
---|
770 | torque_total(:) = 0.0_wp |
---|
771 | thrust_rotor(:) = 0.0_wp |
---|
772 | |
---|
773 | IF ( TRIM( initializing_actions ) /= 'read_restart_data' ) THEN |
---|
774 | omega_gen(:) = 0.0_wp |
---|
775 | omega_gen_old(:) = 0.0_wp |
---|
776 | omega_gen_f(:) = 0.0_wp |
---|
777 | omega_gen_f_old(:) = 0.0_wp |
---|
778 | pitch_add_old(:) = 0.0_wp |
---|
779 | torque_gen(:) = 0.0_wp |
---|
780 | torque_gen_old(:) = 0.0_wp |
---|
781 | ENDIF |
---|
782 | |
---|
783 | yawdir(:) = 0.0_wp |
---|
784 | wdir(:) = 0.0_wp |
---|
785 | u_inflow(:) = 0.0_wp |
---|
786 | |
---|
787 | ! |
---|
788 | !-- Allocate 1D arrays (dimension = number of rotor segments) |
---|
789 | alpha_attack(:) = 0.0_wp |
---|
790 | chord(:) = 0.0_wp |
---|
791 | phi_rel(:) = 0.0_wp |
---|
792 | thrust_seg(:) = 0.0_wp |
---|
793 | torque_seg_y(:) = 0.0_wp |
---|
794 | torque_seg_z(:) = 0.0_wp |
---|
795 | turb_cd(:) = 0.0_wp |
---|
796 | turb_cl(:) = 0.0_wp |
---|
797 | vrel(:) = 0.0_wp |
---|
798 | vtheta(:) = 0.0_wp |
---|
799 | |
---|
800 | rbx(:,:) = 0.0_wp |
---|
801 | rby(:,:) = 0.0_wp |
---|
802 | rbz(:,:) = 0.0_wp |
---|
803 | thrust_ring(:,:) = 0.0_wp |
---|
804 | torque_ring_y(:,:) = 0.0_wp |
---|
805 | torque_ring_z(:,:) = 0.0_wp |
---|
806 | |
---|
807 | rotx(:,:) = 0.0_wp |
---|
808 | roty(:,:) = 0.0_wp |
---|
809 | rotz(:,:) = 0.0_wp |
---|
810 | |
---|
811 | nac_cd_surf(:,:,:) = 0.0_wp |
---|
812 | rot_tend_x(:,:,:) = 0.0_wp |
---|
813 | rot_tend_y(:,:,:) = 0.0_wp |
---|
814 | rot_tend_z(:,:,:) = 0.0_wp |
---|
815 | thrust(:,:,:) = 0.0_wp |
---|
816 | torque_y(:,:,:) = 0.0_wp |
---|
817 | torque_z(:,:,:) = 0.0_wp |
---|
818 | tow_cd_surf(:,:,:) = 0.0_wp |
---|
819 | |
---|
820 | u_int(:,:,:) = 0.0_wp |
---|
821 | u_int_1_l(:,:,:) = 0.0_wp |
---|
822 | v_int(:,:,:) = 0.0_wp |
---|
823 | v_int_1_l(:,:,:) = 0.0_wp |
---|
824 | w_int(:,:,:) = 0.0_wp |
---|
825 | w_int_1_l(:,:,:) = 0.0_wp |
---|
826 | |
---|
827 | |
---|
828 | END SUBROUTINE wtm_init_arrays |
---|
829 | |
---|
830 | |
---|
831 | !------------------------------------------------------------------------------! |
---|
832 | ! Description: |
---|
833 | ! ------------ |
---|
834 | !> Initialization of the wind turbine model |
---|
835 | !------------------------------------------------------------------------------! |
---|
836 | SUBROUTINE wtm_init |
---|
837 | |
---|
838 | |
---|
839 | IMPLICIT NONE |
---|
840 | |
---|
841 | INTEGER(iwp) :: i !< running index |
---|
842 | INTEGER(iwp) :: j !< running index |
---|
843 | INTEGER(iwp) :: k !< running index |
---|
844 | |
---|
845 | ! |
---|
846 | !-- Help variables for the smearing function |
---|
847 | REAL(wp) :: eps_kernel !< |
---|
848 | |
---|
849 | ! |
---|
850 | !-- Help variables for calculation of the tower drag |
---|
851 | INTEGER(iwp) :: tower_n !< |
---|
852 | INTEGER(iwp) :: tower_s !< |
---|
853 | ! |
---|
854 | !-- Help variables for the calulaction of the nacelle drag |
---|
855 | INTEGER(iwp) :: i_ip !< |
---|
856 | INTEGER(iwp) :: i_ipg !< |
---|
857 | |
---|
858 | REAL(wp) :: yvalue |
---|
859 | REAL(wp) :: dy_int !< |
---|
860 | REAL(wp) :: dz_int !< |
---|
861 | |
---|
862 | REAL(wp), DIMENSION(:,:), ALLOCATABLE :: circle_points !< |
---|
863 | |
---|
864 | INTEGER(iwp), DIMENSION(:), ALLOCATABLE :: index_nacb !< |
---|
865 | INTEGER(iwp), DIMENSION(:), ALLOCATABLE :: index_nacl !< |
---|
866 | INTEGER(iwp), DIMENSION(:), ALLOCATABLE :: index_nacr !< |
---|
867 | INTEGER(iwp), DIMENSION(:), ALLOCATABLE :: index_nact !< |
---|
868 | |
---|
869 | ALLOCATE( index_nacb(1:nturbines) ) |
---|
870 | ALLOCATE( index_nacl(1:nturbines) ) |
---|
871 | ALLOCATE( index_nacr(1:nturbines) ) |
---|
872 | ALLOCATE( index_nact(1:nturbines) ) |
---|
873 | |
---|
874 | |
---|
875 | IF ( speed_control) THEN |
---|
876 | |
---|
877 | CALL wtm_speed_control |
---|
878 | |
---|
879 | IF ( TRIM( initializing_actions ) == 'read_restart_data' ) THEN |
---|
880 | |
---|
881 | DO inot = 1, nturbines |
---|
882 | |
---|
883 | IF ( nxl > i_hub(inot) ) THEN |
---|
884 | torque_gen(inot) = 0.0_wp |
---|
885 | omega_gen_f(inot) = 0.0_wp |
---|
886 | omega_rot_l(inot) = 0.0_wp |
---|
887 | ENDIF |
---|
888 | |
---|
889 | IF ( nxr < i_hub(inot) ) THEN |
---|
890 | torque_gen(inot) = 0.0_wp |
---|
891 | omega_gen_f(inot) = 0.0_wp |
---|
892 | omega_rot_l(inot) = 0.0_wp |
---|
893 | ENDIF |
---|
894 | |
---|
895 | IF ( nys > j_hub(inot) ) THEN |
---|
896 | torque_gen(inot) = 0.0_wp |
---|
897 | omega_gen_f(inot) = 0.0_wp |
---|
898 | omega_rot_l(inot) = 0.0_wp |
---|
899 | ENDIF |
---|
900 | |
---|
901 | IF ( nyn < j_hub(inot) ) THEN |
---|
902 | torque_gen(inot) = 0.0_wp |
---|
903 | omega_gen_f(inot) = 0.0_wp |
---|
904 | omega_rot_l(inot) = 0.0_wp |
---|
905 | ENDIF |
---|
906 | |
---|
907 | IF ( ( nxl <= i_hub(inot) ) .AND. ( nxr >= i_hub(inot) ) ) THEN |
---|
908 | IF ( ( nys <= j_hub(inot) ) .AND. ( nyn >= j_hub(inot) ) ) THEN |
---|
909 | |
---|
910 | omega_rot_l(inot) = omega_gen(inot) / gear_ratio |
---|
911 | |
---|
912 | ENDIF |
---|
913 | ENDIF |
---|
914 | |
---|
915 | END DO |
---|
916 | |
---|
917 | ENDIF |
---|
918 | |
---|
919 | ENDIF |
---|
920 | |
---|
921 | ! |
---|
922 | !------------------------------------------------------------------------------! |
---|
923 | !-- Calculation of parameters for the regularization kernel |
---|
924 | !-- (smearing of the forces) |
---|
925 | !------------------------------------------------------------------------------! |
---|
926 | ! |
---|
927 | !-- In the following, some of the required parameters for the smearing will |
---|
928 | !-- be calculated: |
---|
929 | |
---|
930 | !-- The kernel is set equal to twice the grid spacing which has turned out to |
---|
931 | !-- be a reasonable value (see e.g. Troldborg et al. (2013), Wind Energy, |
---|
932 | !-- DOI: 10.1002/we.1608): |
---|
933 | eps_kernel = 2.0_wp * dx |
---|
934 | ! |
---|
935 | !-- The zero point (eps_min) of the polynomial function must be the following |
---|
936 | !-- if the integral of the polynomial function (for values < eps_min) shall |
---|
937 | !-- be equal to the integral of the Gaussian function used before: |
---|
938 | eps_min = ( 105.0_wp / 32.0_wp )**( 1.0_wp / 3.0_wp ) * & |
---|
939 | pi**( 1.0_wp / 6.0_wp ) * eps_kernel |
---|
940 | ! |
---|
941 | !-- Square of eps_min: |
---|
942 | eps_min2 = eps_min**2 |
---|
943 | ! |
---|
944 | !-- Parameters in the polynomial function: |
---|
945 | pol_a = 1.0_wp / eps_min**4 |
---|
946 | pol_b = 2.0_wp / eps_min**2 |
---|
947 | ! |
---|
948 | !-- Normalization factor which is the inverse of the integral of the smearing |
---|
949 | !-- function: |
---|
950 | eps_factor = 105.0_wp / ( 32.0_wp * pi * eps_min**3 ) |
---|
951 | |
---|
952 | !-- Change tilt angle to rad: |
---|
953 | tilt = tilt * pi / 180.0_wp |
---|
954 | |
---|
955 | ! |
---|
956 | !-- Change yaw angle to rad: |
---|
957 | IF ( TRIM( initializing_actions ) /= 'read_restart_data' ) THEN |
---|
958 | phi_yaw(:) = phi_yaw(:) * pi / 180.0_wp |
---|
959 | ENDIF |
---|
960 | |
---|
961 | |
---|
962 | DO inot = 1, nturbines |
---|
963 | ! |
---|
964 | !-- Rotate the rotor coordinates in case yaw and tilt are defined |
---|
965 | CALL wtm_rotate_rotor( inot ) |
---|
966 | |
---|
967 | ! |
---|
968 | !-- Determine the indices of the hub height |
---|
969 | i_hub(inot) = INT( rcx(inot) / dx ) |
---|
970 | j_hub(inot) = INT( ( rcy(inot) + 0.5_wp * dy ) / dy ) |
---|
971 | k_hub(inot) = INT( ( rcz(inot) + 0.5_wp * dz ) / dz ) |
---|
972 | |
---|
973 | ! |
---|
974 | !-- Determining the area to which the smearing of the forces is applied. |
---|
975 | !-- As smearing now is effectively applied only for distances smaller than |
---|
976 | !-- eps_min, the smearing area can be further limited and regarded as a |
---|
977 | !-- function of eps_min: |
---|
978 | i_smear(inot) = CEILING( ( rr(inot) + eps_min ) / dx ) |
---|
979 | j_smear(inot) = CEILING( ( rr(inot) + eps_min ) / dy ) |
---|
980 | k_smear(inot) = CEILING( ( rr(inot) + eps_min ) / dz ) |
---|
981 | |
---|
982 | ENDDO |
---|
983 | |
---|
984 | ! |
---|
985 | !------------------------------------------------------------------------------! |
---|
986 | !-- Determine the area within each grid cell that overlaps with the area |
---|
987 | !-- of the nacelle and the tower (needed for calculation of the forces) |
---|
988 | !------------------------------------------------------------------------------! |
---|
989 | ! |
---|
990 | !-- Note: so far this is only a 2D version, in that the mean flow is |
---|
991 | !-- perpendicular to the rotor area. |
---|
992 | |
---|
993 | ! |
---|
994 | !-- Allocation of the array containing information on the intersection points |
---|
995 | !-- between rotor disk and the numerical grid: |
---|
996 | upper_end = ( ny + 1 ) * 10000 |
---|
997 | |
---|
998 | ALLOCATE( circle_points(1:2,1:upper_end) ) |
---|
999 | |
---|
1000 | circle_points(:,:) = 0.0_wp |
---|
1001 | |
---|
1002 | |
---|
1003 | DO inot = 1, nturbines ! loop over number of turbines |
---|
1004 | ! |
---|
1005 | !-- Determine the grid index (u-grid) that corresponds to the location of |
---|
1006 | !-- the rotor center (reduces the amount of calculations in the case that |
---|
1007 | !-- the mean flow is perpendicular to the rotor area): |
---|
1008 | i = i_hub(inot) |
---|
1009 | |
---|
1010 | ! |
---|
1011 | !-- Determine the left and the right edge of the nacelle (corresponding |
---|
1012 | !-- grid point indices): |
---|
1013 | index_nacl(inot) = INT( ( rcy(inot) - rnac(inot) + 0.5_wp * dy ) / dy ) |
---|
1014 | index_nacr(inot) = INT( ( rcy(inot) + rnac(inot) + 0.5_wp * dy ) / dy ) |
---|
1015 | ! |
---|
1016 | !-- Determine the bottom and the top edge of the nacelle (corresponding |
---|
1017 | !-- grid point indices).The grid point index has to be increased by 1, as |
---|
1018 | !-- the first level for the u-component (index 0) is situated below the |
---|
1019 | !-- surface. All points between z=0 and z=dz/s would already be contained |
---|
1020 | !-- in grid box 1. |
---|
1021 | index_nacb(inot) = INT( ( rcz(inot) - rnac(inot) ) / dz ) + 1 |
---|
1022 | index_nact(inot) = INT( ( rcz(inot) + rnac(inot) ) / dz ) + 1 |
---|
1023 | |
---|
1024 | ! |
---|
1025 | !-- Determine the indices of the grid boxes containing the left and |
---|
1026 | !-- the right boundaries of the tower: |
---|
1027 | tower_n = ( rcy(inot) + 0.5_wp * dtow(inot) - 0.5_wp * dy ) / dy |
---|
1028 | tower_s = ( rcy(inot) - 0.5_wp * dtow(inot) - 0.5_wp * dy ) / dy |
---|
1029 | |
---|
1030 | ! |
---|
1031 | !-- Determine the fraction of the grid box area overlapping with the tower |
---|
1032 | !-- area and multiply it with the drag of the tower: |
---|
1033 | IF ( ( nxlg <= i ) .AND. ( nxrg >= i ) ) THEN |
---|
1034 | |
---|
1035 | DO j = nys, nyn |
---|
1036 | ! |
---|
1037 | !-- Loop from south to north boundary of tower |
---|
1038 | IF ( ( j >= tower_s ) .AND. ( j <= tower_n ) ) THEN |
---|
1039 | |
---|
1040 | DO k = nzb, nzt |
---|
1041 | |
---|
1042 | IF ( k == k_hub(inot) ) THEN |
---|
1043 | IF ( tower_n - tower_s >= 1 ) THEN |
---|
1044 | ! |
---|
1045 | !-- leftmost and rightmost grid box: |
---|
1046 | IF ( j == tower_s ) THEN |
---|
1047 | tow_cd_surf(k,j,i) = ( rcz(inot) - & |
---|
1048 | ( k_hub(inot) * dz - 0.5_wp * dz ) ) * & ! extension in z-direction |
---|
1049 | ( ( tower_s + 1.0_wp + 0.5_wp ) * dy - & |
---|
1050 | ( rcy(inot) - 0.5_wp * dtow(inot) ) ) * & ! extension in y-direction |
---|
1051 | turb_cd_tower(inot) |
---|
1052 | ELSEIF ( j == tower_n ) THEN |
---|
1053 | tow_cd_surf(k,j,i) = ( rcz(inot) - & |
---|
1054 | ( k_hub(inot) * dz - 0.5_wp * dz ) ) * & ! extension in z-direction |
---|
1055 | ( ( rcy(inot) + 0.5_wp * dtow(inot) ) - & |
---|
1056 | ( tower_n + 0.5_wp ) * dy ) * & ! extension in y-direction |
---|
1057 | turb_cd_tower(inot) |
---|
1058 | ! |
---|
1059 | !-- grid boxes inbetween |
---|
1060 | !-- (where tow_cd_surf = grid box area): |
---|
1061 | ELSE |
---|
1062 | tow_cd_surf(k,j,i) = ( rcz(inot) - & |
---|
1063 | ( k_hub(inot) * dz - 0.5_wp * dz ) ) * & |
---|
1064 | dy * turb_cd_tower(inot) |
---|
1065 | ENDIF |
---|
1066 | ! |
---|
1067 | !-- tower lies completely within one grid box: |
---|
1068 | ELSE |
---|
1069 | tow_cd_surf(k,j,i) = ( rcz(inot) - & |
---|
1070 | ( k_hub(inot) * dz - 0.5_wp * dz ) ) * & |
---|
1071 | dtow(inot) * turb_cd_tower(inot) |
---|
1072 | ENDIF |
---|
1073 | ! |
---|
1074 | !-- In case that k is smaller than k_hub the following actions |
---|
1075 | !-- are carried out: |
---|
1076 | ELSEIF ( k < k_hub(inot) ) THEN |
---|
1077 | |
---|
1078 | IF ( ( tower_n - tower_s ) >= 1 ) THEN |
---|
1079 | ! |
---|
1080 | !-- leftmost and rightmost grid box: |
---|
1081 | IF ( j == tower_s ) THEN |
---|
1082 | tow_cd_surf(k,j,i) = dz * ( & |
---|
1083 | ( tower_s + 1 + 0.5_wp ) * dy - & |
---|
1084 | ( rcy(inot) - 0.5_wp * dtow(inot) ) & |
---|
1085 | ) * turb_cd_tower(inot) |
---|
1086 | ELSEIF ( j == tower_n ) THEN |
---|
1087 | tow_cd_surf(k,j,i) = dz * ( & |
---|
1088 | ( rcy(inot) + 0.5_wp * dtow(inot) ) - & |
---|
1089 | ( tower_n + 0.5_wp ) * dy & |
---|
1090 | ) * turb_cd_tower(inot) |
---|
1091 | ! |
---|
1092 | !-- grid boxes inbetween |
---|
1093 | !-- (where tow_cd_surf = grid box area): |
---|
1094 | ELSE |
---|
1095 | tow_cd_surf(k,j,i) = dz * dy * turb_cd_tower(inot) |
---|
1096 | ENDIF |
---|
1097 | ! |
---|
1098 | !-- tower lies completely within one grid box: |
---|
1099 | ELSE |
---|
1100 | tow_cd_surf(k,j,i) = dz * dtow(inot) * & |
---|
1101 | turb_cd_tower(inot) |
---|
1102 | ENDIF ! end if larger than grid box |
---|
1103 | |
---|
1104 | ENDIF ! end if k == k_hub |
---|
1105 | |
---|
1106 | ENDDO ! end loop over k |
---|
1107 | |
---|
1108 | ENDIF ! end if inside north and south boundary of tower |
---|
1109 | |
---|
1110 | ENDDO ! end loop over j |
---|
1111 | |
---|
1112 | ENDIF ! end if hub inside domain + ghostpoints |
---|
1113 | |
---|
1114 | |
---|
1115 | CALL exchange_horiz( tow_cd_surf, nbgp ) |
---|
1116 | |
---|
1117 | ! |
---|
1118 | !-- Calculation of the nacelle area |
---|
1119 | !-- CAUTION: Currently disabled due to segmentation faults on the FLOW HPC |
---|
1120 | !-- cluster (Oldenburg) |
---|
1121 | !! |
---|
1122 | !!-- Tabulate the points on the circle that are required in the following for |
---|
1123 | !!-- the calculation of the Riemann integral (node points; they are called |
---|
1124 | !!-- circle_points in the following): |
---|
1125 | ! |
---|
1126 | ! dy_int = dy / 10000.0_wp |
---|
1127 | ! |
---|
1128 | ! DO i_ip = 1, upper_end |
---|
1129 | ! yvalue = dy_int * ( i_ip - 0.5_wp ) + 0.5_wp * dy !<--- segmentation fault |
---|
1130 | ! sqrt_arg = rnac(inot)**2 - ( yvalue - rcy(inot) )**2 !<--- segmentation fault |
---|
1131 | ! IF ( sqrt_arg >= 0.0_wp ) THEN |
---|
1132 | !! |
---|
1133 | !!-- bottom intersection point |
---|
1134 | ! circle_points(1,i_ip) = rcz(inot) - SQRT( sqrt_arg ) |
---|
1135 | !! |
---|
1136 | !!-- top intersection point |
---|
1137 | ! circle_points(2,i_ip) = rcz(inot) + SQRT( sqrt_arg ) !<--- segmentation fault |
---|
1138 | ! ELSE |
---|
1139 | ! circle_points(:,i_ip) = -111111 !<--- segmentation fault |
---|
1140 | ! ENDIF |
---|
1141 | ! ENDDO |
---|
1142 | ! |
---|
1143 | ! |
---|
1144 | ! DO j = nys, nyn |
---|
1145 | !! |
---|
1146 | !!-- In case that the grid box is located completely outside the nacelle |
---|
1147 | !!-- (y) it can automatically be stated that there is no overlap between |
---|
1148 | !!-- the grid box and the nacelle and consequently we can set |
---|
1149 | !!-- nac_cd_surf(:,j,i) = 0.0: |
---|
1150 | ! IF ( ( j >= index_nacl(inot) ) .AND. ( j <= index_nacr(inot) ) ) THEN |
---|
1151 | ! DO k = nzb+1, nzt |
---|
1152 | !! |
---|
1153 | !!-- In case that the grid box is located completely outside the |
---|
1154 | !!-- nacelle (z) it can automatically be stated that there is no |
---|
1155 | !!-- overlap between the grid box and the nacelle and consequently |
---|
1156 | !!-- we can set nac_cd_surf(k,j,i) = 0.0: |
---|
1157 | ! IF ( ( k >= index_nacb(inot) ) .OR. & |
---|
1158 | ! ( k <= index_nact(inot) ) ) THEN |
---|
1159 | !! |
---|
1160 | !!-- For all other cases Riemann integrals are calculated. |
---|
1161 | !!-- Here, the points on the circle that have been determined |
---|
1162 | !!-- above are used in order to calculate the overlap between the |
---|
1163 | !!-- gridbox and the nacelle area (area approached by 10000 |
---|
1164 | !!-- rectangulars dz_int * dy_int): |
---|
1165 | ! DO i_ipg = 1, 10000 |
---|
1166 | ! dz_int = dz |
---|
1167 | ! i_ip = j * 10000 + i_ipg |
---|
1168 | !! |
---|
1169 | !!-- Determine the vertical extension dz_int of the circle |
---|
1170 | !!-- within the current grid box: |
---|
1171 | ! IF ( ( circle_points(2,i_ip) < zw(k) ) .AND. & !<--- segmentation fault |
---|
1172 | ! ( circle_points(2,i_ip) >= zw(k-1) ) ) THEN |
---|
1173 | ! dz_int = dz_int - & !<--- segmentation fault |
---|
1174 | ! ( zw(k) - circle_points(2,i_ip) ) |
---|
1175 | ! ENDIF |
---|
1176 | ! IF ( ( circle_points(1,i_ip) <= zw(k) ) .AND. & !<--- segmentation fault |
---|
1177 | ! ( circle_points(1,i_ip) > zw(k-1) ) ) THEN |
---|
1178 | ! dz_int = dz_int - & |
---|
1179 | ! ( circle_points(1,i_ip) - zw(k-1) ) |
---|
1180 | ! ENDIF |
---|
1181 | ! IF ( zw(k-1) > circle_points(2,i_ip) ) THEN |
---|
1182 | ! dz_int = 0.0_wp |
---|
1183 | ! ENDIF |
---|
1184 | ! IF ( zw(k) < circle_points(1,i_ip) ) THEN |
---|
1185 | ! dz_int = 0.0_wp |
---|
1186 | ! ENDIF |
---|
1187 | ! IF ( ( nxlg <= i ) .AND. ( nxrg >= i ) ) THEN |
---|
1188 | ! nac_cd_surf(k,j,i) = nac_cd_surf(k,j,i) + & !<--- segmentation fault |
---|
1189 | ! dy_int * dz_int * turb_cd_nacelle(inot) |
---|
1190 | ! ENDIF |
---|
1191 | ! ENDDO |
---|
1192 | ! ENDIF |
---|
1193 | ! ENDDO |
---|
1194 | ! ENDIF |
---|
1195 | ! |
---|
1196 | ! ENDDO |
---|
1197 | ! |
---|
1198 | ! CALL exchange_horiz( nac_cd_surf, nbgp ) !<--- segmentation fault |
---|
1199 | |
---|
1200 | ENDDO ! end of loop over turbines |
---|
1201 | |
---|
1202 | tow_cd_surf = tow_cd_surf / ( dx * dy * dz ) ! Normalize tower drag |
---|
1203 | nac_cd_surf = nac_cd_surf / ( dx * dy * dz ) ! Normalize nacelle drag |
---|
1204 | |
---|
1205 | CALL wtm_read_blade_tables |
---|
1206 | |
---|
1207 | END SUBROUTINE wtm_init |
---|
1208 | |
---|
1209 | |
---|
1210 | !------------------------------------------------------------------------------! |
---|
1211 | ! Description: |
---|
1212 | ! ------------ |
---|
1213 | !> Read in layout of the rotor blade , the lift and drag tables |
---|
1214 | !> and the distribution of lift and drag tables along the blade |
---|
1215 | !------------------------------------------------------------------------------! |
---|
1216 | ! |
---|
1217 | SUBROUTINE wtm_read_blade_tables |
---|
1218 | |
---|
1219 | |
---|
1220 | IMPLICIT NONE |
---|
1221 | |
---|
1222 | INTEGER(iwp) :: ii !< running index |
---|
1223 | INTEGER(iwp) :: jj !< running index |
---|
1224 | |
---|
1225 | INTEGER(iwp) :: ierrn !< |
---|
1226 | |
---|
1227 | CHARACTER(200) :: chmess !< Read in string |
---|
1228 | |
---|
1229 | INTEGER(iwp) :: dlen !< no. rows of local table |
---|
1230 | INTEGER(iwp) :: dlenbl !< no. rows of cd, cl table |
---|
1231 | INTEGER(iwp) :: ialpha !< table position of current alpha value |
---|
1232 | INTEGER(iwp) :: iialpha !< |
---|
1233 | INTEGER(iwp) :: iir !< |
---|
1234 | INTEGER(iwp) :: radres !< radial resolution |
---|
1235 | INTEGER(iwp) :: t1 !< no. of airfoil |
---|
1236 | INTEGER(iwp) :: t2 !< no. of airfoil |
---|
1237 | INTEGER(iwp) :: trow !< |
---|
1238 | INTEGER(iwp) :: dlenbl_int !< no. rows of interpolated cd, cl tables |
---|
1239 | |
---|
1240 | REAL(wp) :: alpha_attack_i !< |
---|
1241 | REAL(wp) :: weight_a !< |
---|
1242 | REAL(wp) :: weight_b !< |
---|
1243 | |
---|
1244 | INTEGER(iwp), DIMENSION(:), ALLOCATABLE :: ttoint1 !< |
---|
1245 | INTEGER(iwp), DIMENSION(:), ALLOCATABLE :: ttoint2 !< |
---|
1246 | |
---|
1247 | REAL(wp), DIMENSION(:), ALLOCATABLE :: turb_cd_sel1 !< |
---|
1248 | REAL(wp), DIMENSION(:), ALLOCATABLE :: turb_cd_sel2 !< |
---|
1249 | REAL(wp), DIMENSION(:), ALLOCATABLE :: turb_cl_sel1 !< |
---|
1250 | REAL(wp), DIMENSION(:), ALLOCATABLE :: turb_cl_sel2 !< |
---|
1251 | REAL(wp), DIMENSION(:), ALLOCATABLE :: read_cl_cd !< read in var array |
---|
1252 | |
---|
1253 | REAL(wp), DIMENSION(:), ALLOCATABLE :: alpha_attack_tab !< |
---|
1254 | REAL(wp), DIMENSION(:), ALLOCATABLE :: trad1 !< |
---|
1255 | REAL(wp), DIMENSION(:), ALLOCATABLE :: trad2 !< |
---|
1256 | REAL(wp), DIMENSION(:,:), ALLOCATABLE :: turb_cd_table !< |
---|
1257 | REAL(wp), DIMENSION(:,:), ALLOCATABLE :: turb_cl_table !< |
---|
1258 | |
---|
1259 | ALLOCATE ( read_cl_cd(1:2*nairfoils+1) ) |
---|
1260 | |
---|
1261 | ! |
---|
1262 | !-- Read in the distribution of lift and drag tables along the blade, the |
---|
1263 | !-- layout of the rotor blade and the lift and drag tables: |
---|
1264 | |
---|
1265 | OPEN ( 90, FILE='WTM_DATA', STATUS='OLD', FORM='FORMATTED', IOSTAT=ierrn ) |
---|
1266 | |
---|
1267 | IF ( ierrn /= 0 ) THEN |
---|
1268 | message_string = 'file WTM_DATA does not exist' |
---|
1269 | CALL message( 'wtm_init', 'PA0464', 1, 2, 0, 6, 0 ) |
---|
1270 | ENDIF |
---|
1271 | ! |
---|
1272 | !-- Read distribution table: |
---|
1273 | |
---|
1274 | dlen = 0 |
---|
1275 | |
---|
1276 | READ ( 90, '(3/)' ) |
---|
1277 | |
---|
1278 | rloop3: DO |
---|
1279 | READ ( 90, *, IOSTAT=ierrn ) chmess |
---|
1280 | IF ( ierrn < 0 .OR. chmess == '#' .OR. chmess == '') EXIT rloop3 |
---|
1281 | dlen = dlen + 1 |
---|
1282 | ENDDO rloop3 |
---|
1283 | |
---|
1284 | ALLOCATE( trad1(1:dlen), trad2(1:dlen), ttoint1(1:dlen), ttoint2(1:dlen)) |
---|
1285 | |
---|
1286 | DO jj = 1,dlen+1 |
---|
1287 | BACKSPACE ( 90, IOSTAT=ierrn ) |
---|
1288 | ENDDO |
---|
1289 | |
---|
1290 | DO jj = 1,dlen |
---|
1291 | READ ( 90, * ) trad1(jj), trad2(jj), ttoint1(jj), ttoint2(jj) |
---|
1292 | ENDDO |
---|
1293 | |
---|
1294 | ! |
---|
1295 | !-- Read layout table: |
---|
1296 | |
---|
1297 | dlen = 0 |
---|
1298 | |
---|
1299 | READ ( 90, '(3/)') |
---|
1300 | |
---|
1301 | rloop1: DO |
---|
1302 | READ ( 90, *, IOSTAT=ierrn ) chmess |
---|
1303 | IF ( ierrn < 0 .OR. chmess == '#' .OR. chmess == '') EXIT rloop1 |
---|
1304 | dlen = dlen + 1 |
---|
1305 | ENDDO rloop1 |
---|
1306 | |
---|
1307 | ALLOCATE( lrd(1:dlen), ard(1:dlen), crd(1:dlen) ) |
---|
1308 | DO jj = 1, dlen+1 |
---|
1309 | BACKSPACE ( 90, IOSTAT=ierrn ) |
---|
1310 | ENDDO |
---|
1311 | DO jj = 1, dlen |
---|
1312 | READ ( 90, * ) lrd(jj), ard(jj), crd(jj) |
---|
1313 | ENDDO |
---|
1314 | |
---|
1315 | ! |
---|
1316 | !-- Read tables (turb_cl(alpha),turb_cd(alpha) for the different profiles: |
---|
1317 | |
---|
1318 | dlen = 0 |
---|
1319 | |
---|
1320 | READ ( 90, '(3/)' ) |
---|
1321 | |
---|
1322 | rloop2: DO |
---|
1323 | READ ( 90, *, IOSTAT=ierrn ) chmess |
---|
1324 | IF ( ierrn < 0 .OR. chmess == '#' .OR. chmess == '') EXIT rloop2 |
---|
1325 | dlen = dlen + 1 |
---|
1326 | ENDDO rloop2 |
---|
1327 | |
---|
1328 | ALLOCATE( alpha_attack_tab(1:dlen), turb_cl_table(1:dlen,1:nairfoils), & |
---|
1329 | turb_cd_table(1:dlen,1:nairfoils) ) |
---|
1330 | |
---|
1331 | DO jj = 1,dlen+1 |
---|
1332 | BACKSPACE ( 90, IOSTAT=ierrn ) |
---|
1333 | ENDDO |
---|
1334 | |
---|
1335 | DO jj = 1,dlen |
---|
1336 | READ ( 90, * ) read_cl_cd |
---|
1337 | alpha_attack_tab(jj) = read_cl_cd(1) |
---|
1338 | DO ii= 1, nairfoils |
---|
1339 | turb_cl_table(jj,ii) = read_cl_cd(ii*2) |
---|
1340 | turb_cd_table(jj,ii) = read_cl_cd(ii*2+1) |
---|
1341 | ENDDO |
---|
1342 | |
---|
1343 | ENDDO |
---|
1344 | |
---|
1345 | dlenbl = dlen |
---|
1346 | |
---|
1347 | CLOSE ( 90 ) |
---|
1348 | |
---|
1349 | ! |
---|
1350 | !-- For each possible radial position (resolution: 0.1 m --> 630 values) and |
---|
1351 | !-- each possible angle of attack (resolution: 0.01 degrees --> 36000 values!) |
---|
1352 | !-- determine the lift and drag coefficient by interpolating between the |
---|
1353 | !-- tabulated values of each table (interpolate to current angle of attack) |
---|
1354 | !-- and between the tables (interpolate to current radial position): |
---|
1355 | |
---|
1356 | ALLOCATE( turb_cl_sel1(0:dlenbl) ) |
---|
1357 | ALLOCATE( turb_cl_sel2(0:dlenbl) ) |
---|
1358 | ALLOCATE( turb_cd_sel1(0:dlenbl) ) |
---|
1359 | ALLOCATE( turb_cd_sel2(0:dlenbl) ) |
---|
1360 | |
---|
1361 | radres = INT( rr(1) * 10.0_wp ) + 1_iwp |
---|
1362 | dlenbl_int = INT( 360.0_wp / accu_cl_cd_tab ) + 1_iwp |
---|
1363 | |
---|
1364 | |
---|
1365 | ALLOCATE( turb_cl_tab(0:dlenbl_int,1:radres) ) |
---|
1366 | ALLOCATE( turb_cd_tab(0:dlenbl_int,1:radres) ) |
---|
1367 | |
---|
1368 | |
---|
1369 | DO iir = 1, radres ! loop over radius |
---|
1370 | |
---|
1371 | DO iialpha = 1, dlenbl_int ! loop over angles |
---|
1372 | |
---|
1373 | cur_r = ( iir - 1_iwp ) * 0.1_wp |
---|
1374 | alpha_attack_i = -180.0_wp + REAL( iialpha-1 ) * accu_cl_cd_tab |
---|
1375 | ialpha = 1 |
---|
1376 | |
---|
1377 | DO WHILE ( ( alpha_attack_i > alpha_attack_tab(ialpha) ) .AND. (ialpha <= dlen ) ) |
---|
1378 | ialpha = ialpha + 1 |
---|
1379 | ENDDO |
---|
1380 | ! |
---|
1381 | !-- Find position in table |
---|
1382 | lct = MINLOC( ABS( trad1 - cur_r ) ) |
---|
1383 | ! lct(1) = lct(1) |
---|
1384 | |
---|
1385 | IF ( ( trad1(lct(1)) - cur_r ) .GT. 0.0 ) THEN |
---|
1386 | lct(1) = lct(1) - 1 |
---|
1387 | ENDIF |
---|
1388 | |
---|
1389 | trow = lct(1) |
---|
1390 | ! |
---|
1391 | !-- Calculate weights for interpolation |
---|
1392 | weight_a = ( trad2(trow) - cur_r ) / ( trad2(trow) - trad1(trow) ) |
---|
1393 | weight_b = ( cur_r - trad1(trow) ) / ( trad2(trow) - trad1(trow) ) |
---|
1394 | t1 = ttoint1(trow) |
---|
1395 | t2 = ttoint2(trow) |
---|
1396 | |
---|
1397 | IF ( t1 .EQ. t2 ) THEN ! if both are the same, the weights are NaN |
---|
1398 | weight_a = 0.5_wp ! then do interpolate in between same twice |
---|
1399 | weight_b = 0.5_wp ! using 0.5 as weight |
---|
1400 | ENDIF |
---|
1401 | |
---|
1402 | IF ( t1 == 0 .AND. t2 == 0 ) THEN |
---|
1403 | turb_cd_sel1 = 0.0_wp |
---|
1404 | turb_cd_sel2 = 0.0_wp |
---|
1405 | turb_cl_sel1 = 0.0_wp |
---|
1406 | turb_cl_sel2 = 0.0_wp |
---|
1407 | ELSE |
---|
1408 | turb_cd_sel1 = turb_cd_table(:,t1) |
---|
1409 | turb_cd_sel2 = turb_cd_table(:,t2) |
---|
1410 | turb_cl_sel1 = turb_cl_table(:,t1) |
---|
1411 | turb_cl_sel2 = turb_cl_table(:,t2) |
---|
1412 | ENDIF |
---|
1413 | |
---|
1414 | ! |
---|
1415 | !-- Interpolation of lift and drag coefficiencts on fine grid of radius |
---|
1416 | !-- segments and angles of attack |
---|
1417 | |
---|
1418 | turb_cl_tab(iialpha,iir) = ( alpha_attack_tab(ialpha) - & |
---|
1419 | alpha_attack_i ) / & |
---|
1420 | ( alpha_attack_tab(ialpha) - & |
---|
1421 | alpha_attack_tab(ialpha-1) ) * & |
---|
1422 | ( weight_a * turb_cl_sel1(ialpha-1) + & |
---|
1423 | weight_b * turb_cl_sel2(ialpha-1) ) +& |
---|
1424 | ( alpha_attack_i - & |
---|
1425 | alpha_attack_tab(ialpha-1) ) / & |
---|
1426 | ( alpha_attack_tab(ialpha) - & |
---|
1427 | alpha_attack_tab(ialpha-1) ) * & |
---|
1428 | ( weight_a * turb_cl_sel1(ialpha) + & |
---|
1429 | weight_b * turb_cl_sel2(ialpha) ) |
---|
1430 | turb_cd_tab(iialpha,iir) = ( alpha_attack_tab(ialpha) - & |
---|
1431 | alpha_attack_i ) / & |
---|
1432 | ( alpha_attack_tab(ialpha) - & |
---|
1433 | alpha_attack_tab(ialpha-1) ) * & |
---|
1434 | ( weight_a * turb_cd_sel1(ialpha-1) + & |
---|
1435 | weight_b * turb_cd_sel2(ialpha-1) ) +& |
---|
1436 | ( alpha_attack_i - & |
---|
1437 | alpha_attack_tab(ialpha-1) ) / & |
---|
1438 | ( alpha_attack_tab(ialpha) - & |
---|
1439 | alpha_attack_tab(ialpha-1) ) * & |
---|
1440 | ( weight_a * turb_cd_sel1(ialpha) + & |
---|
1441 | weight_b * turb_cd_sel2(ialpha) ) |
---|
1442 | |
---|
1443 | ENDDO ! end loop over angles of attack |
---|
1444 | |
---|
1445 | ENDDO ! end loop over radius |
---|
1446 | |
---|
1447 | END SUBROUTINE wtm_read_blade_tables |
---|
1448 | |
---|
1449 | |
---|
1450 | !------------------------------------------------------------------------------! |
---|
1451 | ! Description: |
---|
1452 | ! ------------ |
---|
1453 | !> The projection matrix for the coordinate system of therotor disc in respect |
---|
1454 | !> to the yaw and tilt angle of the rotor is calculated |
---|
1455 | !------------------------------------------------------------------------------! |
---|
1456 | SUBROUTINE wtm_rotate_rotor( inot ) |
---|
1457 | |
---|
1458 | |
---|
1459 | IMPLICIT NONE |
---|
1460 | |
---|
1461 | INTEGER(iwp) :: inot |
---|
1462 | ! |
---|
1463 | !-- Calculation of the rotation matrix for the application of the tilt to |
---|
1464 | !-- the rotors |
---|
1465 | rot_eigen_rad(1) = SIN( phi_yaw(inot) ) ! x-component of the radial eigenvector |
---|
1466 | rot_eigen_rad(2) = COS( phi_yaw(inot) ) ! y-component of the radial eigenvector |
---|
1467 | rot_eigen_rad(3) = 0.0_wp ! z-component of the radial eigenvector |
---|
1468 | |
---|
1469 | rot_eigen_azi(1) = 0.0_wp ! x-component of the azimuth eigenvector |
---|
1470 | rot_eigen_azi(2) = 0.0_wp ! y-component of the azimuth eigenvector |
---|
1471 | rot_eigen_azi(3) = 1.0_wp ! z-component of the azimuth eigenvector |
---|
1472 | |
---|
1473 | rot_eigen_nor(1) = COS( phi_yaw(inot) ) ! x-component of the normal eigenvector |
---|
1474 | rot_eigen_nor(2) = -SIN( phi_yaw(inot) ) ! y-component of the normal eigenvector |
---|
1475 | rot_eigen_nor(3) = 0.0_wp ! z-component of the normal eigenvector |
---|
1476 | |
---|
1477 | ! |
---|
1478 | !-- Calculation of the coordinate transformation matrix to apply a tilt to |
---|
1479 | !-- the rotor. If tilt = 0, rot_coord_trans is a unit matrix. |
---|
1480 | |
---|
1481 | rot_coord_trans(inot,1,1) = rot_eigen_rad(1)**2 * & |
---|
1482 | ( 1.0_wp - COS( tilt ) ) + COS( tilt ) |
---|
1483 | rot_coord_trans(inot,1,2) = rot_eigen_rad(1) * rot_eigen_rad(2) * & |
---|
1484 | ( 1.0_wp - COS( tilt ) ) - & |
---|
1485 | rot_eigen_rad(3) * SIN( tilt ) |
---|
1486 | rot_coord_trans(inot,1,3) = rot_eigen_rad(1) * rot_eigen_rad(3) * & |
---|
1487 | ( 1.0_wp - COS( tilt ) ) + & |
---|
1488 | rot_eigen_rad(2) * SIN( tilt ) |
---|
1489 | rot_coord_trans(inot,2,1) = rot_eigen_rad(2) * rot_eigen_rad(1) * & |
---|
1490 | ( 1.0_wp - COS( tilt ) ) + & |
---|
1491 | rot_eigen_rad(3) * SIN( tilt ) |
---|
1492 | rot_coord_trans(inot,2,2) = rot_eigen_rad(2)**2 * & |
---|
1493 | ( 1.0_wp - COS( tilt ) ) + COS( tilt ) |
---|
1494 | rot_coord_trans(inot,2,3) = rot_eigen_rad(2) * rot_eigen_rad(3) * & |
---|
1495 | ( 1.0_wp - COS( tilt ) ) - & |
---|
1496 | rot_eigen_rad(1) * SIN( tilt ) |
---|
1497 | rot_coord_trans(inot,3,1) = rot_eigen_rad(3) * rot_eigen_rad(1) * & |
---|
1498 | ( 1.0_wp - COS( tilt ) ) - & |
---|
1499 | rot_eigen_rad(2) * SIN( tilt ) |
---|
1500 | rot_coord_trans(inot,3,2) = rot_eigen_rad(3) * rot_eigen_rad(2) * & |
---|
1501 | ( 1.0_wp - COS( tilt ) ) + & |
---|
1502 | rot_eigen_rad(1) * SIN( tilt ) |
---|
1503 | rot_coord_trans(inot,3,3) = rot_eigen_rad(3)**2 * & |
---|
1504 | ( 1.0_wp - COS( tilt ) ) + COS( tilt ) |
---|
1505 | |
---|
1506 | ! |
---|
1507 | !-- Vectors for the Transformation of forces from the rotor's spheric |
---|
1508 | !-- coordinate system to the cartesian coordinate system |
---|
1509 | rotx(inot,:) = MATMUL( rot_coord_trans(inot,:,:), rot_eigen_nor ) |
---|
1510 | roty(inot,:) = MATMUL( rot_coord_trans(inot,:,:), rot_eigen_rad ) |
---|
1511 | rotz(inot,:) = MATMUL( rot_coord_trans(inot,:,:), rot_eigen_azi ) |
---|
1512 | |
---|
1513 | END SUBROUTINE wtm_rotate_rotor |
---|
1514 | |
---|
1515 | |
---|
1516 | !------------------------------------------------------------------------------! |
---|
1517 | ! Description: |
---|
1518 | ! ------------ |
---|
1519 | !> Calculation of the forces generated by the wind turbine |
---|
1520 | !------------------------------------------------------------------------------! |
---|
1521 | SUBROUTINE wtm_forces |
---|
1522 | |
---|
1523 | |
---|
1524 | IMPLICIT NONE |
---|
1525 | |
---|
1526 | CHARACTER (LEN=2) :: turbine_id |
---|
1527 | |
---|
1528 | INTEGER(iwp) :: i, j, k !< loop indices |
---|
1529 | INTEGER(iwp) :: inot !< turbine loop index (turbine id) |
---|
1530 | INTEGER(iwp) :: iialpha, iir !< |
---|
1531 | INTEGER(iwp) :: rseg, rseg_int !< |
---|
1532 | INTEGER(iwp) :: ring, ring_int !< |
---|
1533 | INTEGER(iwp) :: ii, jj, kk !< |
---|
1534 | |
---|
1535 | REAL(wp) :: flag !< flag to mask topography grid points |
---|
1536 | REAL(wp) :: sin_rot, cos_rot !< |
---|
1537 | REAL(wp) :: sin_yaw, cos_yaw !< |
---|
1538 | |
---|
1539 | REAL(wp) :: aa, bb, cc, dd !< interpolation distances |
---|
1540 | REAL(wp) :: gg !< interpolation volume var |
---|
1541 | |
---|
1542 | REAL(wp) :: dist_u_3d, dist_v_3d, dist_w_3d !< smearing distances |
---|
1543 | |
---|
1544 | |
---|
1545 | ! |
---|
1546 | ! Variables for pitch control |
---|
1547 | REAL(wp) :: torque_max=0.0_wp |
---|
1548 | LOGICAL :: pitch_sw=.FALSE. |
---|
1549 | |
---|
1550 | INTEGER(iwp), DIMENSION(1) :: lct=0 |
---|
1551 | REAL(wp), DIMENSION(1) :: rad_d=0.0_wp |
---|
1552 | |
---|
1553 | REAL(wp) :: tl_factor !< factor for tip loss correction |
---|
1554 | |
---|
1555 | |
---|
1556 | CALL cpu_log( log_point_s(61), 'wtm_forces', 'start' ) |
---|
1557 | |
---|
1558 | |
---|
1559 | IF ( simulated_time >= time_turbine_on ) THEN |
---|
1560 | |
---|
1561 | ! |
---|
1562 | !-- Set forces to zero for each new time step: |
---|
1563 | thrust(:,:,:) = 0.0_wp |
---|
1564 | torque_y(:,:,:) = 0.0_wp |
---|
1565 | torque_z(:,:,:) = 0.0_wp |
---|
1566 | torque_total(:) = 0.0_wp |
---|
1567 | rot_tend_x(:,:,:) = 0.0_wp |
---|
1568 | rot_tend_y(:,:,:) = 0.0_wp |
---|
1569 | rot_tend_z(:,:,:) = 0.0_wp |
---|
1570 | thrust_rotor(:) = 0.0_wp |
---|
1571 | ! |
---|
1572 | !-- Loop over number of turbines: |
---|
1573 | DO inot = 1, nturbines |
---|
1574 | |
---|
1575 | cos_yaw = COS(phi_yaw(inot)) |
---|
1576 | sin_yaw = SIN(phi_yaw(inot)) |
---|
1577 | ! |
---|
1578 | !-- Loop over rings of each turbine: |
---|
1579 | DO ring = 1, nrings(inot) |
---|
1580 | |
---|
1581 | thrust_seg(:) = 0.0_wp |
---|
1582 | torque_seg_y(:) = 0.0_wp |
---|
1583 | torque_seg_z(:) = 0.0_wp |
---|
1584 | ! |
---|
1585 | !-- Determine distance between each ring (center) and the hub: |
---|
1586 | cur_r = (ring - 0.5_wp) * delta_r(inot) |
---|
1587 | |
---|
1588 | ! |
---|
1589 | !-- Loop over segments of each ring of each turbine: |
---|
1590 | DO rseg = 1, nsegs(ring,inot) |
---|
1591 | ! |
---|
1592 | !-- !-----------------------------------------------------------! |
---|
1593 | !-- !-- Determine coordinates of the ring segments --! |
---|
1594 | !-- !-----------------------------------------------------------! |
---|
1595 | ! |
---|
1596 | !-- Determine angle of ring segment towards zero degree angle of |
---|
1597 | !-- rotor system (at zero degree rotor direction vectors aligned |
---|
1598 | !-- with y-axis): |
---|
1599 | phi_rotor = rseg * 2.0_wp * pi / nsegs(ring,inot) |
---|
1600 | cos_rot = COS( phi_rotor ) |
---|
1601 | sin_rot = SIN( phi_rotor ) |
---|
1602 | |
---|
1603 | !-- Now the direction vectors can be determined with respect to |
---|
1604 | !-- the yaw and tilt angle: |
---|
1605 | re(1) = cos_rot * sin_yaw |
---|
1606 | re(2) = cos_rot * cos_yaw |
---|
1607 | re(3) = sin_rot |
---|
1608 | |
---|
1609 | rote = MATMUL( rot_coord_trans(inot,:,:), re ) |
---|
1610 | ! |
---|
1611 | !-- Coordinates of the single segments (center points): |
---|
1612 | rbx(ring,rseg) = rcx(inot) + cur_r * rote(1) |
---|
1613 | rby(ring,rseg) = rcy(inot) + cur_r * rote(2) |
---|
1614 | rbz(ring,rseg) = rcz(inot) + cur_r * rote(3) |
---|
1615 | |
---|
1616 | !-- !-----------------------------------------------------------! |
---|
1617 | !-- !-- Interpolation of the velocity components from the --! |
---|
1618 | !-- !-- cartesian grid point to the coordinates of each ring --! |
---|
1619 | !-- !-- segment (follows a method used in the particle model) --! |
---|
1620 | !-- !-----------------------------------------------------------! |
---|
1621 | |
---|
1622 | u_int(inot,ring,rseg) = 0.0_wp |
---|
1623 | u_int_1_l(inot,ring,rseg) = 0.0_wp |
---|
1624 | |
---|
1625 | v_int(inot,ring,rseg) = 0.0_wp |
---|
1626 | v_int_1_l(inot,ring,rseg) = 0.0_wp |
---|
1627 | |
---|
1628 | w_int(inot,ring,rseg) = 0.0_wp |
---|
1629 | w_int_1_l(inot,ring,rseg) = 0.0_wp |
---|
1630 | |
---|
1631 | ! |
---|
1632 | !-- Interpolation of the u-component: |
---|
1633 | |
---|
1634 | ii = rbx(ring,rseg) * ddx |
---|
1635 | jj = ( rby(ring,rseg) - 0.5_wp * dy ) * ddy |
---|
1636 | kk = ( rbz(ring,rseg) + 0.5_wp * dz ) / dz |
---|
1637 | ! |
---|
1638 | !-- Interpolate only if all required information is available on |
---|
1639 | !-- the current PE: |
---|
1640 | IF ( ( ii >= nxl ) .AND. ( ii <= nxr ) ) THEN |
---|
1641 | IF ( ( jj >= nys ) .AND. ( jj <= nyn ) ) THEN |
---|
1642 | |
---|
1643 | aa = ( ( ii + 1 ) * dx - rbx(ring,rseg) ) * & |
---|
1644 | ( ( jj + 1 + 0.5_wp ) * dy - rby(ring,rseg) ) |
---|
1645 | bb = ( rbx(ring,rseg) - ii * dx ) * & |
---|
1646 | ( ( jj + 1 + 0.5_wp ) * dy - rby(ring,rseg) ) |
---|
1647 | cc = ( ( ii+1 ) * dx - rbx(ring,rseg) ) * & |
---|
1648 | ( rby(ring,rseg) - ( jj + 0.5_wp ) * dy ) |
---|
1649 | dd = ( rbx(ring,rseg) - ii * dx ) * & |
---|
1650 | ( rby(ring,rseg) - ( jj + 0.5_wp ) * dy ) |
---|
1651 | gg = dx * dy |
---|
1652 | |
---|
1653 | u_int_l = ( aa * u(kk,jj,ii) + & |
---|
1654 | bb * u(kk,jj,ii+1) + & |
---|
1655 | cc * u(kk,jj+1,ii) + & |
---|
1656 | dd * u(kk,jj+1,ii+1) & |
---|
1657 | ) / gg |
---|
1658 | |
---|
1659 | u_int_u = ( aa * u(kk+1,jj,ii) + & |
---|
1660 | bb * u(kk+1,jj,ii+1) + & |
---|
1661 | cc * u(kk+1,jj+1,ii) + & |
---|
1662 | dd * u(kk+1,jj+1,ii+1) & |
---|
1663 | ) / gg |
---|
1664 | |
---|
1665 | u_int_1_l(inot,ring,rseg) = u_int_l + & |
---|
1666 | ( rbz(ring,rseg) - zu(kk) ) / dz * & |
---|
1667 | ( u_int_u - u_int_l ) |
---|
1668 | |
---|
1669 | ELSE |
---|
1670 | u_int_1_l(inot,ring,rseg) = 0.0_wp |
---|
1671 | ENDIF |
---|
1672 | ELSE |
---|
1673 | u_int_1_l(inot,ring,rseg) = 0.0_wp |
---|
1674 | ENDIF |
---|
1675 | |
---|
1676 | |
---|
1677 | ! |
---|
1678 | !-- Interpolation of the v-component: |
---|
1679 | ii = ( rbx(ring,rseg) - 0.5_wp * dx ) * ddx |
---|
1680 | jj = rby(ring,rseg) * ddy |
---|
1681 | kk = ( rbz(ring,rseg) + 0.5_wp * dz ) / dz |
---|
1682 | ! |
---|
1683 | !-- Interpolate only if all required information is available on |
---|
1684 | !-- the current PE: |
---|
1685 | IF ( ( ii >= nxl ) .AND. ( ii <= nxr ) ) THEN |
---|
1686 | IF ( ( jj >= nys ) .AND. ( jj <= nyn ) ) THEN |
---|
1687 | |
---|
1688 | aa = ( ( ii + 1 + 0.5_wp ) * dx - rbx(ring,rseg) ) * & |
---|
1689 | ( ( jj + 1 ) * dy - rby(ring,rseg) ) |
---|
1690 | bb = ( rbx(ring,rseg) - ( ii + 0.5_wp ) * dx ) * & |
---|
1691 | ( ( jj + 1 ) * dy - rby(ring,rseg) ) |
---|
1692 | cc = ( ( ii + 1 + 0.5_wp ) * dx - rbx(ring,rseg) ) * & |
---|
1693 | ( rby(ring,rseg) - jj * dy ) |
---|
1694 | dd = ( rbx(ring,rseg) - ( ii + 0.5_wp ) * dx ) * & |
---|
1695 | ( rby(ring,rseg) - jj * dy ) |
---|
1696 | gg = dx * dy |
---|
1697 | |
---|
1698 | v_int_l = ( aa * v(kk,jj,ii) + & |
---|
1699 | bb * v(kk,jj,ii+1) + & |
---|
1700 | cc * v(kk,jj+1,ii) + & |
---|
1701 | dd * v(kk,jj+1,ii+1) & |
---|
1702 | ) / gg |
---|
1703 | |
---|
1704 | v_int_u = ( aa * v(kk+1,jj,ii) + & |
---|
1705 | bb * v(kk+1,jj,ii+1) + & |
---|
1706 | cc * v(kk+1,jj+1,ii) + & |
---|
1707 | dd * v(kk+1,jj+1,ii+1) & |
---|
1708 | ) / gg |
---|
1709 | |
---|
1710 | v_int_1_l(inot,ring,rseg) = v_int_l + & |
---|
1711 | ( rbz(ring,rseg) - zu(kk) ) / dz * & |
---|
1712 | ( v_int_u - v_int_l ) |
---|
1713 | |
---|
1714 | ELSE |
---|
1715 | v_int_1_l(inot,ring,rseg) = 0.0_wp |
---|
1716 | ENDIF |
---|
1717 | ELSE |
---|
1718 | v_int_1_l(inot,ring,rseg) = 0.0_wp |
---|
1719 | ENDIF |
---|
1720 | |
---|
1721 | |
---|
1722 | ! |
---|
1723 | !-- Interpolation of the w-component: |
---|
1724 | ii = ( rbx(ring,rseg) - 0.5_wp * dx ) * ddx |
---|
1725 | jj = ( rby(ring,rseg) - 0.5_wp * dy ) * ddy |
---|
1726 | kk = rbz(ring,rseg) / dz |
---|
1727 | ! |
---|
1728 | !-- Interpolate only if all required information is available on |
---|
1729 | !-- the current PE: |
---|
1730 | IF ( ( ii >= nxl ) .AND. ( ii <= nxr ) ) THEN |
---|
1731 | IF ( ( jj >= nys ) .AND. ( jj <= nyn ) ) THEN |
---|
1732 | |
---|
1733 | aa = ( ( ii + 1 + 0.5_wp ) * dx - rbx(ring,rseg) ) * & |
---|
1734 | ( ( jj + 1 + 0.5_wp ) * dy - rby(ring,rseg) ) |
---|
1735 | bb = ( rbx(ring,rseg) - ( ii + 0.5_wp ) * dx ) * & |
---|
1736 | ( ( jj + 1 + 0.5_wp ) * dy - rby(ring,rseg) ) |
---|
1737 | cc = ( ( ii + 1 + 0.5_wp ) * dx - rbx(ring,rseg) ) * & |
---|
1738 | ( rby(ring,rseg) - ( jj + 0.5_wp ) * dy ) |
---|
1739 | dd = ( rbx(ring,rseg) - ( ii + 0.5_wp ) * dx ) * & |
---|
1740 | ( rby(ring,rseg) - ( jj + 0.5_wp ) * dy ) |
---|
1741 | gg = dx * dy |
---|
1742 | |
---|
1743 | w_int_l = ( aa * w(kk,jj,ii) + & |
---|
1744 | bb * w(kk,jj,ii+1) + & |
---|
1745 | cc * w(kk,jj+1,ii) + & |
---|
1746 | dd * w(kk,jj+1,ii+1) & |
---|
1747 | ) / gg |
---|
1748 | |
---|
1749 | w_int_u = ( aa * w(kk+1,jj,ii) + & |
---|
1750 | bb * w(kk+1,jj,ii+1) + & |
---|
1751 | cc * w(kk+1,jj+1,ii) + & |
---|
1752 | dd * w(kk+1,jj+1,ii+1) & |
---|
1753 | ) / gg |
---|
1754 | |
---|
1755 | w_int_1_l(inot,ring,rseg) = w_int_l + & |
---|
1756 | ( rbz(ring,rseg) - zw(kk) ) / dz * & |
---|
1757 | ( w_int_u - w_int_l ) |
---|
1758 | ELSE |
---|
1759 | w_int_1_l(inot,ring,rseg) = 0.0_wp |
---|
1760 | ENDIF |
---|
1761 | ELSE |
---|
1762 | w_int_1_l(inot,ring,rseg) = 0.0_wp |
---|
1763 | ENDIF |
---|
1764 | |
---|
1765 | ENDDO |
---|
1766 | ENDDO |
---|
1767 | |
---|
1768 | ENDDO |
---|
1769 | |
---|
1770 | ! |
---|
1771 | !-- Exchange between PEs (information required on each PE): |
---|
1772 | #if defined( __parallel ) |
---|
1773 | CALL MPI_ALLREDUCE( u_int_1_l, u_int, nturbines * MAXVAL(nrings) * & |
---|
1774 | MAXVAL(nsegs), MPI_REAL, MPI_SUM, comm2d, ierr ) |
---|
1775 | CALL MPI_ALLREDUCE( v_int_1_l, v_int, nturbines * MAXVAL(nrings) * & |
---|
1776 | MAXVAL(nsegs), MPI_REAL, MPI_SUM, comm2d, ierr ) |
---|
1777 | CALL MPI_ALLREDUCE( w_int_1_l, w_int, nturbines * MAXVAL(nrings) * & |
---|
1778 | MAXVAL(nsegs), MPI_REAL, MPI_SUM, comm2d, ierr ) |
---|
1779 | #else |
---|
1780 | u_int = u_int_1_l |
---|
1781 | v_int = v_int_1_l |
---|
1782 | w_int = w_int_1_l |
---|
1783 | #endif |
---|
1784 | |
---|
1785 | |
---|
1786 | ! |
---|
1787 | !-- Loop over number of turbines: |
---|
1788 | |
---|
1789 | DO inot = 1, nturbines |
---|
1790 | pit_loop: DO |
---|
1791 | |
---|
1792 | IF ( pitch_sw ) THEN |
---|
1793 | torque_total(inot) = 0.0_wp |
---|
1794 | thrust_rotor(inot) = 0.0_wp |
---|
1795 | pitch_add(inot) = pitch_add(inot) + 0.25_wp |
---|
1796 | ! IF ( myid == 0 ) PRINT*, 'Pitch', inot, pitch_add(inot) |
---|
1797 | ELSE |
---|
1798 | cos_yaw = COS(phi_yaw(inot)) |
---|
1799 | sin_yaw = SIN(phi_yaw(inot)) |
---|
1800 | IF ( pitch_control ) THEN |
---|
1801 | pitch_add(inot) = MAX(pitch_add_old(inot) - pitch_rate * & |
---|
1802 | dt_3d , 0.0_wp ) |
---|
1803 | ENDIF |
---|
1804 | ENDIF |
---|
1805 | |
---|
1806 | ! |
---|
1807 | !-- Loop over rings of each turbine: |
---|
1808 | DO ring = 1, nrings(inot) |
---|
1809 | ! |
---|
1810 | !-- Determine distance between each ring (center) and the hub: |
---|
1811 | cur_r = (ring - 0.5_wp) * delta_r(inot) |
---|
1812 | ! |
---|
1813 | !-- Loop over segments of each ring of each turbine: |
---|
1814 | DO rseg = 1, nsegs(ring,inot) |
---|
1815 | ! |
---|
1816 | !-- Determine angle of ring segment towards zero degree angle of |
---|
1817 | !-- rotor system (at zero degree rotor direction vectors aligned |
---|
1818 | !-- with y-axis): |
---|
1819 | phi_rotor = rseg * 2.0_wp * pi / nsegs(ring,inot) |
---|
1820 | cos_rot = COS(phi_rotor) |
---|
1821 | sin_rot = SIN(phi_rotor) |
---|
1822 | ! |
---|
1823 | !-- Now the direction vectors can be determined with respect to |
---|
1824 | !-- the yaw and tilt angle: |
---|
1825 | re(1) = cos_rot * sin_yaw |
---|
1826 | re(2) = cos_rot * cos_yaw |
---|
1827 | re(3) = sin_rot |
---|
1828 | |
---|
1829 | ! The current unit vector in azimuthal direction: |
---|
1830 | rea(1) = - sin_rot * sin_yaw |
---|
1831 | rea(2) = - sin_rot * cos_yaw |
---|
1832 | rea(3) = cos_rot |
---|
1833 | |
---|
1834 | ! |
---|
1835 | !-- To respect the yawing angle for the calculations of |
---|
1836 | !-- velocities and forces the unit vectors perpendicular to the |
---|
1837 | !-- rotor area in direction of the positive yaw angle are defined: |
---|
1838 | ren(1) = cos_yaw |
---|
1839 | ren(2) = - sin_yaw |
---|
1840 | ren(3) = 0.0_wp |
---|
1841 | ! |
---|
1842 | !-- Multiplication with the coordinate transformation matrix |
---|
1843 | !-- gives the final unit vector with consideration of the rotor |
---|
1844 | !-- tilt: |
---|
1845 | rote = MATMUL( rot_coord_trans(inot,:,:), re ) |
---|
1846 | rota = MATMUL( rot_coord_trans(inot,:,:), rea ) |
---|
1847 | rotn = MATMUL( rot_coord_trans(inot,:,:), ren ) |
---|
1848 | ! |
---|
1849 | !-- Coordinates of the single segments (center points): |
---|
1850 | rbx(ring,rseg) = rcx(inot) + cur_r * rote(1) |
---|
1851 | |
---|
1852 | rby(ring,rseg) = rcy(inot) + cur_r * rote(2) |
---|
1853 | |
---|
1854 | rbz(ring,rseg) = rcz(inot) + cur_r * rote(3) |
---|
1855 | |
---|
1856 | ! |
---|
1857 | !-- !-----------------------------------------------------------! |
---|
1858 | !-- !-- Calculation of various angles and relative velocities --! |
---|
1859 | !-- !-----------------------------------------------------------! |
---|
1860 | ! |
---|
1861 | !-- In the following the 3D-velocity field is projected its |
---|
1862 | !-- components perpendicular and parallel to the rotor area |
---|
1863 | !-- The calculation of forces will be done in the rotor- |
---|
1864 | !-- coordinates y' and z. |
---|
1865 | !-- The yaw angle will be reintroduced when the force is applied |
---|
1866 | !-- on the hydrodynamic equations |
---|
1867 | ! |
---|
1868 | !-- Projection of the xy-velocities relative to the rotor area |
---|
1869 | ! |
---|
1870 | !-- Velocity perpendicular to the rotor area: |
---|
1871 | u_rot = u_int(inot,ring,rseg)*rotn(1) + & |
---|
1872 | v_int(inot,ring,rseg)*rotn(2) + & |
---|
1873 | w_int(inot,ring,rseg)*rotn(3) |
---|
1874 | ! |
---|
1875 | !-- Projection of the 3D-velocity vector in the azimuthal |
---|
1876 | !-- direction: |
---|
1877 | vtheta(rseg) = rota(1) * u_int(inot,ring,rseg) + & |
---|
1878 | rota(2) * v_int(inot,ring,rseg) + & |
---|
1879 | rota(3) * w_int(inot,ring,rseg) |
---|
1880 | ! |
---|
1881 | !-- Determination of the angle phi_rel between the rotor plane |
---|
1882 | !-- and the direction of the flow relative to the rotor: |
---|
1883 | |
---|
1884 | phi_rel(rseg) = ATAN( u_rot / & |
---|
1885 | ( omega_rot(inot) * cur_r - & |
---|
1886 | vtheta(rseg) ) ) |
---|
1887 | |
---|
1888 | ! |
---|
1889 | !-- Interpolation of the local pitch angle from tabulated values |
---|
1890 | !-- to the current radial position: |
---|
1891 | |
---|
1892 | lct=minloc(ABS(cur_r-lrd)) |
---|
1893 | rad_d=cur_r-lrd(lct) |
---|
1894 | |
---|
1895 | IF (cur_r == 0.0_wp) THEN |
---|
1896 | alpha_attack(rseg) = 0.0_wp |
---|
1897 | ELSE IF (cur_r >= lrd(size(ard))) THEN |
---|
1898 | alpha_attack(rseg) = ( ard(size(ard)) + & |
---|
1899 | ard(size(ard)-1) ) / 2.0_wp |
---|
1900 | ELSE |
---|
1901 | alpha_attack(rseg) = ( ard(lct(1)) * & |
---|
1902 | ( ( lrd(lct(1)+1) - cur_r ) / & |
---|
1903 | ( lrd(lct(1)+1) - lrd(lct(1)) ) & |
---|
1904 | ) ) + ( ard(lct(1)+1) * & |
---|
1905 | ( ( cur_r - lrd(lct(1)) ) / & |
---|
1906 | ( lrd(lct(1)+1) - lrd(lct(1)) ) ) ) |
---|
1907 | ENDIF |
---|
1908 | |
---|
1909 | ! |
---|
1910 | !-- In Fortran radian instead of degree is used as unit for all |
---|
1911 | !-- angles. Therefore, a transformation from angles given in |
---|
1912 | !-- degree to angles given in radian is necessary here: |
---|
1913 | alpha_attack(rseg) = alpha_attack(rseg) * & |
---|
1914 | ( (2.0_wp*pi) / 360.0_wp ) |
---|
1915 | ! |
---|
1916 | !-- Substraction of the local pitch angle to obtain the local |
---|
1917 | !-- angle of attack: |
---|
1918 | alpha_attack(rseg) = phi_rel(rseg) - alpha_attack(rseg) |
---|
1919 | ! |
---|
1920 | !-- Preliminary transformation back from angles given in radian |
---|
1921 | !-- to angles given in degree: |
---|
1922 | alpha_attack(rseg) = alpha_attack(rseg) * & |
---|
1923 | ( 360.0_wp / (2.0_wp*pi) ) |
---|
1924 | ! |
---|
1925 | !-- Correct with collective pitch angle: |
---|
1926 | alpha_attack = alpha_attack - pitch_add(inot) |
---|
1927 | |
---|
1928 | ! |
---|
1929 | !-- Determination of the magnitude of the flow velocity relative |
---|
1930 | !-- to the rotor: |
---|
1931 | vrel(rseg) = SQRT( u_rot**2 + & |
---|
1932 | ( omega_rot(inot) * cur_r - & |
---|
1933 | vtheta(rseg) )**2 ) |
---|
1934 | |
---|
1935 | ! |
---|
1936 | !-- !-----------------------------------------------------------! |
---|
1937 | !-- !-- Interpolation of chord as well as lift and drag --! |
---|
1938 | !-- !-- coefficients from tabulated values --! |
---|
1939 | !-- !-----------------------------------------------------------! |
---|
1940 | |
---|
1941 | ! |
---|
1942 | !-- Interpolation of the chord_length from tabulated values to |
---|
1943 | !-- the current radial position: |
---|
1944 | |
---|
1945 | IF (cur_r == 0.0_wp) THEN |
---|
1946 | chord(rseg) = 0.0_wp |
---|
1947 | ELSE IF (cur_r >= lrd(size(crd))) THEN |
---|
1948 | chord(rseg) = (crd(size(crd)) + ard(size(crd)-1)) / 2.0_wp |
---|
1949 | ELSE |
---|
1950 | chord(rseg) = ( crd(lct(1)) * & |
---|
1951 | ( ( lrd(lct(1)+1) - cur_r ) / & |
---|
1952 | ( lrd(lct(1)+1) - lrd(lct(1)) ) ) ) + & |
---|
1953 | ( crd(lct(1)+1) * & |
---|
1954 | ( ( cur_r-lrd(lct(1)) ) / & |
---|
1955 | ( lrd(lct(1)+1) - lrd(lct(1)) ) ) ) |
---|
1956 | ENDIF |
---|
1957 | |
---|
1958 | ! |
---|
1959 | !-- Determine index of current angle of attack, needed for |
---|
1960 | !-- finding the appropriate interpolated values of the lift and |
---|
1961 | !-- drag coefficients (-180.0 degrees = 0, +180.0 degrees = 36000, |
---|
1962 | !-- so one index every 0.01 degrees): |
---|
1963 | iialpha = CEILING( ( alpha_attack(rseg) + 180.0_wp ) & |
---|
1964 | * ( 1.0_wp / accu_cl_cd_tab ) ) |
---|
1965 | ! |
---|
1966 | !-- Determine index of current radial position, needed for |
---|
1967 | !-- finding the appropriate interpolated values of the lift and |
---|
1968 | !-- drag coefficients (one index every 0.1 m): |
---|
1969 | iir = CEILING( cur_r * 10.0_wp ) |
---|
1970 | ! |
---|
1971 | !-- Read in interpolated values of the lift and drag coefficients |
---|
1972 | !-- for the current radial position and angle of attack: |
---|
1973 | turb_cl(rseg) = turb_cl_tab(iialpha,iir) |
---|
1974 | turb_cd(rseg) = turb_cd_tab(iialpha,iir) |
---|
1975 | |
---|
1976 | ! |
---|
1977 | !-- Final transformation back from angles given in degree to |
---|
1978 | !-- angles given in radian: |
---|
1979 | alpha_attack(rseg) = alpha_attack(rseg) * & |
---|
1980 | ( (2.0_wp*pi) / 360.0_wp ) |
---|
1981 | |
---|
1982 | IF ( tl_cor ) THEN |
---|
1983 | |
---|
1984 | !-- Tip loss correction following Schito |
---|
1985 | !-- Schito applies the tip loss correction only to the lift force |
---|
1986 | !-- Therefore, the tip loss correction is only applied to the lift |
---|
1987 | !-- coefficient and not to the drag coefficient in our case |
---|
1988 | !-- |
---|
1989 | tl_factor = ( 2.0 / pi ) * & |
---|
1990 | ACOS( EXP( -1.0 * ( 3.0 * ( rr(inot) - cur_r ) / & |
---|
1991 | ( 2.0 * cur_r * abs( sin( phi_rel(rseg) ) ) ) ) ) ) |
---|
1992 | |
---|
1993 | turb_cl(rseg) = tl_factor * turb_cl(rseg) |
---|
1994 | |
---|
1995 | END IF |
---|
1996 | ! |
---|
1997 | !-- !-----------------------------------------------------! |
---|
1998 | !-- !-- Calculation of the forces --! |
---|
1999 | !-- !-----------------------------------------------------! |
---|
2000 | |
---|
2001 | ! |
---|
2002 | !-- Calculate the pre_factor for the thrust and torque forces: |
---|
2003 | |
---|
2004 | pre_factor = 0.5_wp * (vrel(rseg)**2) * 3.0_wp * & |
---|
2005 | chord(rseg) * delta_r(inot) / nsegs(ring,inot) |
---|
2006 | |
---|
2007 | ! |
---|
2008 | !-- Calculate the thrust force (x-component of the total force) |
---|
2009 | !-- for each ring segment: |
---|
2010 | thrust_seg(rseg) = pre_factor * & |
---|
2011 | ( turb_cl(rseg) * COS(phi_rel(rseg)) + & |
---|
2012 | turb_cd(rseg) * SIN(phi_rel(rseg)) ) |
---|
2013 | |
---|
2014 | ! |
---|
2015 | !-- Determination of the second of the additional forces acting |
---|
2016 | !-- on the flow in the azimuthal direction: force vector as basis |
---|
2017 | !-- for torque (torque itself would be the vector product of the |
---|
2018 | !-- radius vector and the force vector): |
---|
2019 | torque_seg = pre_factor * & |
---|
2020 | ( turb_cl(rseg) * SIN(phi_rel(rseg)) - & |
---|
2021 | turb_cd(rseg) * COS(phi_rel(rseg)) ) |
---|
2022 | ! |
---|
2023 | !-- Decomposition of the force vector into two parts: |
---|
2024 | !-- One acting along the y-direction and one acting along the |
---|
2025 | !-- z-direction of the rotor coordinate system: |
---|
2026 | |
---|
2027 | torque_seg_y(rseg) = -torque_seg * sin_rot |
---|
2028 | torque_seg_z(rseg) = torque_seg * cos_rot |
---|
2029 | |
---|
2030 | ! |
---|
2031 | !-- Add the segment thrust to the thrust of the whole rotor |
---|
2032 | thrust_rotor(inot) = thrust_rotor(inot) + & |
---|
2033 | thrust_seg(rseg) |
---|
2034 | |
---|
2035 | |
---|
2036 | torque_total(inot) = torque_total(inot) + (torque_seg * cur_r) |
---|
2037 | |
---|
2038 | ENDDO !-- end of loop over ring segments |
---|
2039 | |
---|
2040 | ! |
---|
2041 | !-- Restore the forces into arrays containing all the segments of |
---|
2042 | !-- each ring: |
---|
2043 | thrust_ring(ring,:) = thrust_seg(:) |
---|
2044 | torque_ring_y(ring,:) = torque_seg_y(:) |
---|
2045 | torque_ring_z(ring,:) = torque_seg_z(:) |
---|
2046 | |
---|
2047 | |
---|
2048 | ENDDO !-- end of loop over rings |
---|
2049 | |
---|
2050 | |
---|
2051 | CALL cpu_log( log_point_s(62), 'wtm_controller', 'start' ) |
---|
2052 | |
---|
2053 | |
---|
2054 | IF ( speed_control ) THEN |
---|
2055 | ! |
---|
2056 | !-- Calculation of the current generator speed for rotor speed control |
---|
2057 | |
---|
2058 | ! |
---|
2059 | !-- The acceleration of the rotor speed is calculated from |
---|
2060 | !-- the force balance of the accelerating torque |
---|
2061 | !-- and the torque of the rotating rotor and generator |
---|
2062 | om_rate = ( torque_total(inot) * air_dens * gear_eff - & |
---|
2063 | gear_ratio * torque_gen_old(inot) ) / & |
---|
2064 | ( inertia_rot + & |
---|
2065 | gear_ratio * gear_ratio * inertia_gen ) * dt_3d |
---|
2066 | |
---|
2067 | ! |
---|
2068 | !-- The generator speed is given by the product of gear gear_ratio |
---|
2069 | !-- and rotor speed |
---|
2070 | omega_gen(inot) = gear_ratio * ( omega_rot(inot) + om_rate ) |
---|
2071 | |
---|
2072 | ENDIF |
---|
2073 | |
---|
2074 | IF ( pitch_control ) THEN |
---|
2075 | |
---|
2076 | ! |
---|
2077 | !-- If the current generator speed is above rated, the pitch is not |
---|
2078 | !-- saturated and the change from the last time step is within the |
---|
2079 | !-- maximum pitch rate, then the pitch loop is repeated with a pitch |
---|
2080 | !-- gain |
---|
2081 | IF ( ( omega_gen(inot) > rated_genspeed ) .AND. & |
---|
2082 | ( pitch_add(inot) < 25.0_wp ) .AND. & |
---|
2083 | ( pitch_add(inot) < pitch_add_old(inot) + & |
---|
2084 | pitch_rate * dt_3d ) ) THEN |
---|
2085 | pitch_sw = .TRUE. |
---|
2086 | ! |
---|
2087 | !-- Go back to beginning of pit_loop |
---|
2088 | CYCLE pit_loop |
---|
2089 | ENDIF |
---|
2090 | |
---|
2091 | ! |
---|
2092 | !-- The current pitch is saved for the next time step |
---|
2093 | pitch_add_old(inot) = pitch_add(inot) |
---|
2094 | pitch_sw = .FALSE. |
---|
2095 | ENDIF |
---|
2096 | EXIT pit_loop |
---|
2097 | ENDDO pit_loop ! Recursive pitch control loop |
---|
2098 | |
---|
2099 | |
---|
2100 | ! |
---|
2101 | !-- Call the rotor speed controller |
---|
2102 | |
---|
2103 | IF ( speed_control ) THEN |
---|
2104 | ! |
---|
2105 | !-- Find processor at i_hub, j_hub |
---|
2106 | IF ( ( nxl <= i_hub(inot) ) .AND. ( nxr >= i_hub(inot) ) ) & |
---|
2107 | THEN |
---|
2108 | IF ( ( nys <= j_hub(inot) ) .AND. ( nyn >= j_hub(inot) ) )& |
---|
2109 | THEN |
---|
2110 | CALL wtm_speed_control( inot ) |
---|
2111 | ENDIF |
---|
2112 | ENDIF |
---|
2113 | |
---|
2114 | ENDIF |
---|
2115 | |
---|
2116 | |
---|
2117 | CALL cpu_log( log_point_s(62), 'wtm_controller', 'stop' ) |
---|
2118 | |
---|
2119 | CALL cpu_log( log_point_s(63), 'wtm_smearing', 'start' ) |
---|
2120 | |
---|
2121 | |
---|
2122 | !-- !-----------------------------------------------------------------! |
---|
2123 | !-- !-- Regularization kernel --! |
---|
2124 | !-- !-- Smearing of the forces and interpolation to cartesian grid --! |
---|
2125 | !-- !-----------------------------------------------------------------! |
---|
2126 | ! |
---|
2127 | !-- The aerodynamic blade forces need to be distributed smoothly on |
---|
2128 | !-- several mesh points in order to avoid singular behaviour |
---|
2129 | ! |
---|
2130 | !-- Summation over sum of weighted forces. The weighting factor |
---|
2131 | !-- (calculated in user_init) includes information on the distance |
---|
2132 | !-- between the center of the grid cell and the rotor segment under |
---|
2133 | !-- consideration |
---|
2134 | ! |
---|
2135 | !-- To save computing time, apply smearing only for the relevant part |
---|
2136 | !-- of the model domain: |
---|
2137 | ! |
---|
2138 | !-- |
---|
2139 | !-- Calculation of the boundaries: |
---|
2140 | i_smear(inot) = CEILING( ( rr(inot) * ABS( roty(inot,1) ) + & |
---|
2141 | eps_min ) / dx ) |
---|
2142 | j_smear(inot) = CEILING( ( rr(inot) * ABS( roty(inot,2) ) + & |
---|
2143 | eps_min ) / dy ) |
---|
2144 | |
---|
2145 | DO i = MAX( nxl, i_hub(inot) - i_smear(inot) ), & |
---|
2146 | MIN( nxr, i_hub(inot) + i_smear(inot) ) |
---|
2147 | DO j = MAX( nys, j_hub(inot) - j_smear(inot) ), & |
---|
2148 | MIN( nyn, j_hub(inot) + j_smear(inot) ) |
---|
2149 | ! DO k = MAX( nzb_u_inner(j,i)+1, k_hub(inot) - k_smear(inot) ), & |
---|
2150 | ! k_hub(inot) + k_smear(inot) |
---|
2151 | DO k = nzb+1, k_hub(inot) + k_smear(inot) |
---|
2152 | DO ring = 1, nrings(inot) |
---|
2153 | DO rseg = 1, nsegs(ring,inot) |
---|
2154 | ! |
---|
2155 | !-- Predetermine flag to mask topography |
---|
2156 | flag = MERGE( 1.0_wp, 0.0_wp, BTEST( wall_flags_0(k,j,i), 1 ) ) |
---|
2157 | |
---|
2158 | ! |
---|
2159 | !-- Determine the square of the distance between the |
---|
2160 | !-- current grid point and each rotor area segment: |
---|
2161 | dist_u_3d = ( i * dx - rbx(ring,rseg) )**2 + & |
---|
2162 | ( j * dy + 0.5_wp * dy - rby(ring,rseg) )**2 + & |
---|
2163 | ( k * dz - 0.5_wp * dz - rbz(ring,rseg) )**2 |
---|
2164 | dist_v_3d = ( i * dx + 0.5_wp * dx - rbx(ring,rseg) )**2 + & |
---|
2165 | ( j * dy - rby(ring,rseg) )**2 + & |
---|
2166 | ( k * dz - 0.5_wp * dz - rbz(ring,rseg) )**2 |
---|
2167 | dist_w_3d = ( i * dx + 0.5_wp * dx - rbx(ring,rseg) )**2 + & |
---|
2168 | ( j * dy + 0.5_wp * dy - rby(ring,rseg) )**2 + & |
---|
2169 | ( k * dz - rbz(ring,rseg) )**2 |
---|
2170 | |
---|
2171 | ! |
---|
2172 | !-- 3D-smearing of the forces with a polynomial function |
---|
2173 | !-- (much faster than the old Gaussian function), using |
---|
2174 | !-- some parameters that have been calculated in user_init. |
---|
2175 | !-- The function is only similar to Gaussian function for |
---|
2176 | !-- squared distances <= eps_min2: |
---|
2177 | IF ( dist_u_3d <= eps_min2 ) THEN |
---|
2178 | thrust(k,j,i) = thrust(k,j,i) + & |
---|
2179 | thrust_ring(ring,rseg) * & |
---|
2180 | ( ( pol_a * dist_u_3d - pol_b ) * & |
---|
2181 | dist_u_3d + 1.0_wp ) * eps_factor *& |
---|
2182 | flag |
---|
2183 | ENDIF |
---|
2184 | IF ( dist_v_3d <= eps_min2 ) THEN |
---|
2185 | torque_y(k,j,i) = torque_y(k,j,i) + & |
---|
2186 | torque_ring_y(ring,rseg) * & |
---|
2187 | ( ( pol_a * dist_v_3d - pol_b ) * & |
---|
2188 | dist_v_3d + 1.0_wp ) * eps_factor * & |
---|
2189 | flag |
---|
2190 | ENDIF |
---|
2191 | IF ( dist_w_3d <= eps_min2 ) THEN |
---|
2192 | torque_z(k,j,i) = torque_z(k,j,i) + & |
---|
2193 | torque_ring_z(ring,rseg) * & |
---|
2194 | ( ( pol_a * dist_w_3d - pol_b ) * & |
---|
2195 | dist_w_3d + 1.0_wp ) * eps_factor * & |
---|
2196 | flag |
---|
2197 | ENDIF |
---|
2198 | |
---|
2199 | ENDDO ! End of loop over rseg |
---|
2200 | ENDDO ! End of loop over ring |
---|
2201 | |
---|
2202 | ! |
---|
2203 | !-- Rotation of force components: |
---|
2204 | rot_tend_x(k,j,i) = rot_tend_x(k,j,i) + ( & |
---|
2205 | thrust(k,j,i)*rotx(inot,1) + & |
---|
2206 | torque_y(k,j,i)*roty(inot,1) + & |
---|
2207 | torque_z(k,j,i)*rotz(inot,1) & |
---|
2208 | ) * flag |
---|
2209 | |
---|
2210 | rot_tend_y(k,j,i) = rot_tend_y(k,j,i) + ( & |
---|
2211 | thrust(k,j,i)*rotx(inot,2) + & |
---|
2212 | torque_y(k,j,i)*roty(inot,2) + & |
---|
2213 | torque_z(k,j,i)*rotz(inot,2) & |
---|
2214 | ) * flag |
---|
2215 | |
---|
2216 | rot_tend_z(k,j,i) = rot_tend_z(k,j,i) + ( & |
---|
2217 | thrust(k,j,i)*rotx(inot,3) + & |
---|
2218 | torque_y(k,j,i)*roty(inot,3) + & |
---|
2219 | torque_z(k,j,i)*rotz(inot,3) & |
---|
2220 | ) * flag |
---|
2221 | |
---|
2222 | ENDDO ! End of loop over k |
---|
2223 | ENDDO ! End of loop over j |
---|
2224 | ENDDO ! End of loop over i |
---|
2225 | |
---|
2226 | CALL cpu_log( log_point_s(63), 'wtm_smearing', 'stop' ) |
---|
2227 | |
---|
2228 | ENDDO !-- end of loop over turbines |
---|
2229 | |
---|
2230 | |
---|
2231 | IF ( yaw_control ) THEN |
---|
2232 | ! |
---|
2233 | !-- Allocate arrays for yaw control at first call |
---|
2234 | !-- Can't be allocated before dt_3d is set |
---|
2235 | IF ( start_up ) THEN |
---|
2236 | WDLON = NINT( 30.0_wp / dt_3d ) ! 30s running mean array |
---|
2237 | ALLOCATE( wd30(1:nturbines,1:WDLON) ) |
---|
2238 | wd30 = 999.0_wp ! Set to dummy value |
---|
2239 | ALLOCATE( wd30_l(1:WDLON) ) |
---|
2240 | |
---|
2241 | WDSHO = NINT( 2.0_wp / dt_3d ) ! 2s running mean array |
---|
2242 | ALLOCATE( wd2(1:nturbines,1:WDSHO) ) |
---|
2243 | wd2 = 999.0_wp ! Set to dummy value |
---|
2244 | ALLOCATE( wd2_l(1:WDSHO) ) |
---|
2245 | start_up = .FALSE. |
---|
2246 | ENDIF |
---|
2247 | |
---|
2248 | ! |
---|
2249 | !-- Calculate the inflow wind speed |
---|
2250 | !-- |
---|
2251 | !-- Loop over number of turbines: |
---|
2252 | DO inot = 1, nturbines |
---|
2253 | ! |
---|
2254 | !-- Find processor at i_hub, j_hub |
---|
2255 | IF ( ( nxl <= i_hub(inot) ) .AND. ( nxr >= i_hub(inot) ) ) & |
---|
2256 | THEN |
---|
2257 | IF ( ( nys <= j_hub(inot) ) .AND. ( nyn >= j_hub(inot) ) )& |
---|
2258 | THEN |
---|
2259 | |
---|
2260 | u_inflow_l(inot) = u(k_hub(inot),j_hub(inot),i_hub(inot)) |
---|
2261 | |
---|
2262 | wdir_l(inot) = -1.0_wp * ATAN2( & |
---|
2263 | 0.5_wp * ( v(k_hub(inot),j_hub(inot),i_hub(inot)+1) + & |
---|
2264 | v(k_hub(inot),j_hub(inot),i_hub(inot)) ) , & |
---|
2265 | 0.5_wp * ( u(k_hub(inot),j_hub(inot)+1,i_hub(inot)) + & |
---|
2266 | u(k_hub(inot),j_hub(inot),i_hub(inot)) ) ) |
---|
2267 | |
---|
2268 | CALL wtm_yawcontrol( inot ) |
---|
2269 | |
---|
2270 | phi_yaw_l(inot) = phi_yaw(inot) |
---|
2271 | |
---|
2272 | ENDIF |
---|
2273 | ENDIF |
---|
2274 | |
---|
2275 | ENDDO !-- end of loop over turbines |
---|
2276 | |
---|
2277 | ! |
---|
2278 | !-- Transfer of information to the other cpus |
---|
2279 | #if defined( __parallel ) |
---|
2280 | CALL MPI_ALLREDUCE( u_inflow_l, u_inflow, nturbines, MPI_REAL, & |
---|
2281 | MPI_SUM, comm2d, ierr ) |
---|
2282 | CALL MPI_ALLREDUCE( wdir_l, wdir, nturbines, MPI_REAL, MPI_SUM, & |
---|
2283 | comm2d, ierr ) |
---|
2284 | CALL MPI_ALLREDUCE( phi_yaw_l, phi_yaw, nturbines, MPI_REAL, & |
---|
2285 | MPI_SUM, comm2d, ierr ) |
---|
2286 | #else |
---|
2287 | u_inflow = u_inflow_l |
---|
2288 | wdir = wdir_l |
---|
2289 | phi_yaw = phi_yaw_l |
---|
2290 | |
---|
2291 | |
---|
2292 | #endif |
---|
2293 | DO inot = 1, nturbines |
---|
2294 | ! |
---|
2295 | !-- Update rotor orientation |
---|
2296 | CALL wtm_rotate_rotor( inot ) |
---|
2297 | |
---|
2298 | ENDDO ! End of loop over turbines |
---|
2299 | |
---|
2300 | END IF ! end of yaw control |
---|
2301 | |
---|
2302 | IF ( speed_control ) THEN |
---|
2303 | ! |
---|
2304 | !-- Transfer of information to the other cpus |
---|
2305 | ! CALL MPI_ALLREDUCE( omega_gen, omega_gen_old, nturbines, & |
---|
2306 | ! MPI_REAL,MPI_SUM, comm2d, ierr ) |
---|
2307 | #if defined( __parallel ) |
---|
2308 | CALL MPI_ALLREDUCE( torque_gen, torque_gen_old, nturbines, & |
---|
2309 | MPI_REAL, MPI_SUM, comm2d, ierr ) |
---|
2310 | CALL MPI_ALLREDUCE( omega_rot_l, omega_rot, nturbines, & |
---|
2311 | MPI_REAL, MPI_SUM, comm2d, ierr ) |
---|
2312 | CALL MPI_ALLREDUCE( omega_gen_f, omega_gen_f_old, nturbines, & |
---|
2313 | MPI_REAL, MPI_SUM, comm2d, ierr ) |
---|
2314 | #else |
---|
2315 | torque_gen_old = torque_gen |
---|
2316 | omega_rot = omega_rot_l |
---|
2317 | omega_gen_f_old = omega_gen_f |
---|
2318 | #endif |
---|
2319 | |
---|
2320 | ENDIF |
---|
2321 | |
---|
2322 | DO inot = 1, nturbines |
---|
2323 | |
---|
2324 | IF ( myid == 0 ) THEN |
---|
2325 | IF ( openfile_turb_mod(400+inot)%opened ) THEN |
---|
2326 | WRITE ( 400+inot, 106 ) simulated_time, omega_rot(inot), & |
---|
2327 | omega_gen(inot), torque_gen_old(inot), & |
---|
2328 | torque_total(inot), pitch_add(inot), & |
---|
2329 | torque_gen_old(inot)*omega_gen(inot)*gen_eff, & |
---|
2330 | torque_total(inot)*omega_rot(inot)*air_dens, & |
---|
2331 | thrust_rotor(inot), & |
---|
2332 | wdir(inot)*180.0_wp/pi, & |
---|
2333 | (phi_yaw(inot))*180.0_wp/pi |
---|
2334 | |
---|
2335 | ELSE |
---|
2336 | |
---|
2337 | WRITE ( turbine_id,'(I2.2)') inot |
---|
2338 | OPEN ( 400+inot, FILE=( 'TURBINE_PARAMETERS'//turbine_id ), & |
---|
2339 | FORM='FORMATTED' ) |
---|
2340 | WRITE ( 400+inot, 105 ) inot |
---|
2341 | WRITE ( 400+inot, 106 ) simulated_time, omega_rot(inot), & |
---|
2342 | omega_gen(inot), torque_gen_old(inot), & |
---|
2343 | torque_total(inot), pitch_add(inot), & |
---|
2344 | torque_gen_old(inot)*omega_gen(inot)*gen_eff, & |
---|
2345 | torque_total(inot)*omega_rot(inot)*air_dens, & |
---|
2346 | thrust_rotor(inot), & |
---|
2347 | wdir(inot)*180.0_wp/pi, & |
---|
2348 | (phi_yaw(inot))*180.0_wp/pi |
---|
2349 | ENDIF |
---|
2350 | ENDIF |
---|
2351 | |
---|
2352 | !-- Set open flag |
---|
2353 | openfile_turb_mod(400+inot)%opened = .TRUE. |
---|
2354 | ENDDO !-- end of loop over turbines |
---|
2355 | |
---|
2356 | ENDIF |
---|
2357 | |
---|
2358 | CALL cpu_log( log_point_s(61), 'wtm_forces', 'stop' ) |
---|
2359 | |
---|
2360 | ! |
---|
2361 | !-- Formats |
---|
2362 | 105 FORMAT ('Turbine control data for turbine ',I2,1X,':'/ & |
---|
2363 | &'----------------------------------------'/ & |
---|
2364 | &' Time RSpeed GSpeed ', & |
---|
2365 | 'GenTorque AeroTorque Pitch Power(Gen) Power(Rot) ', & |
---|
2366 | 'RotThrust WDirection YawOrient') |
---|
2367 | |
---|
2368 | 106 FORMAT (F9.3,2X,F7.3,2X,F7.2,2X,F9.1,3X,F9.1,1X,F6.2,2X,F10.1,2X, & |
---|
2369 | F10.1,1X,F9.1,2X,F7.2,1X,F7.2) |
---|
2370 | |
---|
2371 | |
---|
2372 | END SUBROUTINE wtm_forces |
---|
2373 | |
---|
2374 | |
---|
2375 | !------------------------------------------------------------------------------! |
---|
2376 | ! Description: |
---|
2377 | ! ------------ |
---|
2378 | !> Yaw controller for the wind turbine model |
---|
2379 | !------------------------------------------------------------------------------! |
---|
2380 | SUBROUTINE wtm_yawcontrol( inot ) |
---|
2381 | |
---|
2382 | USE kinds |
---|
2383 | |
---|
2384 | IMPLICIT NONE |
---|
2385 | |
---|
2386 | INTEGER(iwp) :: inot |
---|
2387 | INTEGER(iwp) :: i_wd_30 |
---|
2388 | REAL(wp) :: missal |
---|
2389 | |
---|
2390 | i_wd_30 = 0_iwp |
---|
2391 | |
---|
2392 | ! |
---|
2393 | !-- The yaw controller computes a 30s running mean of the wind direction. |
---|
2394 | !-- If the difference between turbine alignment and wind direction exceeds |
---|
2395 | !-- 5°, the turbine is yawed. The mechanism stops as soon as the 2s-running |
---|
2396 | !-- mean of the missalignment is smaller than 0.5°. |
---|
2397 | !-- Attention: If the timestep during the simulation changes significantly |
---|
2398 | !-- the lengths of the running means change and it does not correspond to |
---|
2399 | !-- 30s/2s anymore. |
---|
2400 | !-- ! Needs to be modified for these situations ! |
---|
2401 | !-- For wind from the east, the averaging of the wind direction could cause |
---|
2402 | !-- problems and the yaw controller is probably flawed. -> Routine for |
---|
2403 | !-- averaging needs to be improved! |
---|
2404 | ! |
---|
2405 | !-- Check if turbine is not yawing |
---|
2406 | IF ( .NOT. doyaw(inot) ) THEN |
---|
2407 | ! |
---|
2408 | !-- Write current wind direction into array |
---|
2409 | wd30_l = wd30(inot,:) |
---|
2410 | wd30_l = CSHIFT( wd30_l, SHIFT=-1 ) |
---|
2411 | wd30_l(1) = wdir(inot) |
---|
2412 | ! |
---|
2413 | !-- Check if array is full ( no more dummies ) |
---|
2414 | IF ( .NOT. ANY( wd30_l == 999.) ) THEN |
---|
2415 | |
---|
2416 | missal = SUM( wd30_l ) / SIZE( wd30_l ) - phi_yaw(inot) |
---|
2417 | ! |
---|
2418 | !-- Check if turbine is missaligned by more than max_miss |
---|
2419 | IF ( ABS( missal ) > max_miss ) THEN |
---|
2420 | ! |
---|
2421 | !-- Check in which direction to yaw |
---|
2422 | yawdir(inot) = SIGN( 1.0_wp, missal ) |
---|
2423 | ! |
---|
2424 | !-- Start yawing of turbine |
---|
2425 | phi_yaw(inot) = phi_yaw(inot) + yawdir(inot) * yaw_speed * dt_3d |
---|
2426 | doyaw(inot) = .TRUE. |
---|
2427 | wd30_l = 999. ! fill with dummies again |
---|
2428 | ENDIF |
---|
2429 | ENDIF |
---|
2430 | |
---|
2431 | wd30(inot,:) = wd30_l |
---|
2432 | |
---|
2433 | ! |
---|
2434 | !-- If turbine is already yawing: |
---|
2435 | !-- Initialize 2 s running mean and yaw until the missalignment is smaller |
---|
2436 | !-- than min_miss |
---|
2437 | |
---|
2438 | ELSE |
---|
2439 | ! |
---|
2440 | !-- Initialize 2 s running mean |
---|
2441 | wd2_l = wd2(inot,:) |
---|
2442 | wd2_l = CSHIFT( wd2_l, SHIFT = -1 ) |
---|
2443 | wd2_l(1) = wdir(inot) |
---|
2444 | ! |
---|
2445 | !-- Check if array is full ( no more dummies ) |
---|
2446 | IF ( .NOT. ANY( wd2_l == 999.0_wp ) ) THEN |
---|
2447 | ! |
---|
2448 | !-- Calculate missalignment of turbine |
---|
2449 | missal = SUM( wd2_l - phi_yaw(inot) ) / SIZE( wd2_l ) |
---|
2450 | ! |
---|
2451 | !-- Check if missalignment is still larger than 0.5 degree and if the |
---|
2452 | !-- yaw direction is still right |
---|
2453 | IF ( ( ABS( missal ) > min_miss ) .AND. & |
---|
2454 | ( yawdir(inot) == SIGN( 1.0_wp, missal ) ) ) THEN |
---|
2455 | ! |
---|
2456 | !-- Continue yawing |
---|
2457 | phi_yaw(inot) = phi_yaw(inot) + yawdir(inot) * yaw_speed * dt_3d |
---|
2458 | ELSE |
---|
2459 | ! |
---|
2460 | !-- Stop yawing |
---|
2461 | doyaw(inot) = .FALSE. |
---|
2462 | wd2_l = 999.0_wp ! fill with dummies again |
---|
2463 | ENDIF |
---|
2464 | ELSE |
---|
2465 | ! |
---|
2466 | !-- Continue yawing |
---|
2467 | phi_yaw(inot) = phi_yaw(inot) + yawdir(inot) * yaw_speed * dt_3d |
---|
2468 | ENDIF |
---|
2469 | |
---|
2470 | wd2(inot,:) = wd2_l |
---|
2471 | |
---|
2472 | ENDIF |
---|
2473 | |
---|
2474 | END SUBROUTINE wtm_yawcontrol |
---|
2475 | |
---|
2476 | |
---|
2477 | !------------------------------------------------------------------------------! |
---|
2478 | ! Description: |
---|
2479 | ! ------------ |
---|
2480 | !> Initialization of the speed control |
---|
2481 | !------------------------------------------------------------------------------! |
---|
2482 | SUBROUTINE wtm_init_speed_control |
---|
2483 | |
---|
2484 | |
---|
2485 | IMPLICIT NONE |
---|
2486 | |
---|
2487 | ! |
---|
2488 | !-- If speed control is set, remaining variables and control_parameters for |
---|
2489 | !-- the control algorithm are calculated |
---|
2490 | ! |
---|
2491 | !-- Calculate slope constant for region 15 |
---|
2492 | slope15 = ( slope2 * min_reg2 * min_reg2 ) / ( min_reg2 - min_reg15 ) |
---|
2493 | ! |
---|
2494 | !-- Calculate upper limit of slipage region |
---|
2495 | vs_sysp = rated_genspeed / 1.1_wp |
---|
2496 | ! |
---|
2497 | !-- Calculate slope of slipage region |
---|
2498 | slope25 = ( rated_power / rated_genspeed ) / & |
---|
2499 | ( rated_genspeed - vs_sysp ) |
---|
2500 | ! |
---|
2501 | !-- Calculate lower limit of slipage region |
---|
2502 | min_reg25 = ( slope25 - SQRT( slope25 * ( slope25 - 4.0_wp * & |
---|
2503 | slope2 * vs_sysp ) ) ) / & |
---|
2504 | ( 2.0_wp * slope2 ) |
---|
2505 | ! |
---|
2506 | !-- Frequency for the simple low pass filter |
---|
2507 | Fcorner = 0.25_wp |
---|
2508 | ! |
---|
2509 | !-- At the first timestep the torque is set to its maximum to prevent |
---|
2510 | !-- an overspeeding of the rotor |
---|
2511 | IF ( TRIM( initializing_actions ) /= 'read_restart_data' ) THEN |
---|
2512 | torque_gen_old(:) = max_torque_gen |
---|
2513 | ENDIF |
---|
2514 | |
---|
2515 | END SUBROUTINE wtm_init_speed_control |
---|
2516 | |
---|
2517 | |
---|
2518 | !------------------------------------------------------------------------------! |
---|
2519 | ! Description: |
---|
2520 | ! ------------ |
---|
2521 | !> Simple controller for the regulation of the rotor speed |
---|
2522 | !------------------------------------------------------------------------------! |
---|
2523 | SUBROUTINE wtm_speed_control( inot ) |
---|
2524 | |
---|
2525 | |
---|
2526 | IMPLICIT NONE |
---|
2527 | |
---|
2528 | INTEGER(iwp) :: inot |
---|
2529 | |
---|
2530 | |
---|
2531 | |
---|
2532 | ! |
---|
2533 | !-- The controller is based on the fortran script from Jonkman |
---|
2534 | !-- et al. 2009 "Definition of a 5 MW Reference Wind Turbine for |
---|
2535 | !-- offshore system developement" |
---|
2536 | |
---|
2537 | ! |
---|
2538 | !-- The generator speed is filtered by a low pass filter |
---|
2539 | !-- for the control of the generator torque |
---|
2540 | lp_coeff = EXP( -2.0_wp * 3.14_wp * dt_3d * Fcorner ) |
---|
2541 | omega_gen_f(inot) = ( 1.0_wp - lp_coeff ) * omega_gen(inot) + lp_coeff *& |
---|
2542 | omega_gen_f_old(inot) |
---|
2543 | |
---|
2544 | IF ( omega_gen_f(inot) <= min_reg15 ) THEN |
---|
2545 | ! |
---|
2546 | !-- Region 1: Generator torque is set to zero to accelerate the rotor: |
---|
2547 | torque_gen(inot) = 0 |
---|
2548 | |
---|
2549 | ELSEIF ( omega_gen_f(inot) <= min_reg2 ) THEN |
---|
2550 | ! |
---|
2551 | !-- Region 1.5: Generator torque is increasing linearly with rotor speed: |
---|
2552 | torque_gen(inot) = slope15 * ( omega_gen_f(inot) - min_reg15 ) |
---|
2553 | |
---|
2554 | ELSEIF ( omega_gen_f(inot) <= min_reg25 ) THEN |
---|
2555 | ! |
---|
2556 | !-- Region 2: Generator torque is increased by the square of the generator |
---|
2557 | !-- speed to keep the TSR optimal: |
---|
2558 | torque_gen(inot) = slope2 * omega_gen_f(inot) * omega_gen_f(inot) |
---|
2559 | |
---|
2560 | ELSEIF ( omega_gen_f(inot) < rated_genspeed ) THEN |
---|
2561 | ! |
---|
2562 | !-- Region 2.5: Slipage region between 2 and 3: |
---|
2563 | torque_gen(inot) = slope25 * ( omega_gen_f(inot) - vs_sysp ) |
---|
2564 | |
---|
2565 | ELSE |
---|
2566 | ! |
---|
2567 | !-- Region 3: Generator torque is antiproportional to the rotor speed to |
---|
2568 | !-- keep the power constant: |
---|
2569 | torque_gen(inot) = rated_power / omega_gen_f(inot) |
---|
2570 | |
---|
2571 | ENDIF |
---|
2572 | ! |
---|
2573 | !-- Calculate torque rate and confine with a max |
---|
2574 | trq_rate = ( torque_gen(inot) - torque_gen_old(inot) ) / dt_3d |
---|
2575 | trq_rate = MIN( MAX( trq_rate, -1.0_wp * max_trq_rate ), max_trq_rate ) |
---|
2576 | ! |
---|
2577 | !-- Calculate new gen torque and confine with max torque |
---|
2578 | torque_gen(inot) = torque_gen_old(inot) + trq_rate * dt_3d |
---|
2579 | torque_gen(inot) = MIN( torque_gen(inot), max_torque_gen ) |
---|
2580 | ! |
---|
2581 | !-- Overwrite values for next timestep |
---|
2582 | omega_rot_l(inot) = omega_gen(inot) / gear_ratio |
---|
2583 | |
---|
2584 | |
---|
2585 | END SUBROUTINE wtm_speed_control |
---|
2586 | |
---|
2587 | |
---|
2588 | !------------------------------------------------------------------------------! |
---|
2589 | ! Description: |
---|
2590 | ! ------------ |
---|
2591 | !> Application of the additional forces generated by the wind turbine on the |
---|
2592 | !> flow components (tendency terms) |
---|
2593 | !> Call for all grid points |
---|
2594 | !------------------------------------------------------------------------------! |
---|
2595 | SUBROUTINE wtm_tendencies( component ) |
---|
2596 | |
---|
2597 | |
---|
2598 | IMPLICIT NONE |
---|
2599 | |
---|
2600 | INTEGER(iwp) :: component !< prognostic variable (u,v,w) |
---|
2601 | INTEGER(iwp) :: i !< running index |
---|
2602 | INTEGER(iwp) :: j !< running index |
---|
2603 | INTEGER(iwp) :: k !< running index |
---|
2604 | |
---|
2605 | |
---|
2606 | SELECT CASE ( component ) |
---|
2607 | |
---|
2608 | CASE ( 1 ) |
---|
2609 | ! |
---|
2610 | !-- Apply the x-component of the force to the u-component of the flow: |
---|
2611 | IF ( simulated_time >= time_turbine_on ) THEN |
---|
2612 | DO i = nxlg, nxrg |
---|
2613 | DO j = nysg, nyng |
---|
2614 | DO k = nzb+1, MAXVAL(k_hub) + MAXVAL(k_smear) |
---|
2615 | ! |
---|
2616 | !-- Calculate the thrust generated by the nacelle and the tower |
---|
2617 | tend_nac_x = 0.5_wp * nac_cd_surf(k,j,i) * & |
---|
2618 | SIGN( u(k,j,i)**2 , u(k,j,i) ) |
---|
2619 | tend_tow_x = 0.5_wp * tow_cd_surf(k,j,i) * & |
---|
2620 | SIGN( u(k,j,i)**2 , u(k,j,i) ) |
---|
2621 | |
---|
2622 | tend(k,j,i) = tend(k,j,i) + ( - rot_tend_x(k,j,i) & |
---|
2623 | - tend_nac_x - tend_tow_x ) & |
---|
2624 | * MERGE( 1.0_wp, 0.0_wp, & |
---|
2625 | BTEST( wall_flags_0(k,j,i), 1 ) ) |
---|
2626 | ENDDO |
---|
2627 | ENDDO |
---|
2628 | ENDDO |
---|
2629 | ENDIF |
---|
2630 | |
---|
2631 | CASE ( 2 ) |
---|
2632 | ! |
---|
2633 | !-- Apply the y-component of the force to the v-component of the flow: |
---|
2634 | IF ( simulated_time >= time_turbine_on ) THEN |
---|
2635 | DO i = nxlg, nxrg |
---|
2636 | DO j = nysg, nyng |
---|
2637 | DO k = nzb+1, MAXVAL(k_hub) + MAXVAL(k_smear) |
---|
2638 | tend_nac_y = 0.5_wp * nac_cd_surf(k,j,i) * & |
---|
2639 | SIGN( v(k,j,i)**2 , v(k,j,i) ) |
---|
2640 | tend_tow_y = 0.5_wp * tow_cd_surf(k,j,i) * & |
---|
2641 | SIGN( v(k,j,i)**2 , v(k,j,i) ) |
---|
2642 | tend(k,j,i) = tend(k,j,i) + ( - rot_tend_y(k,j,i) & |
---|
2643 | - tend_nac_y - tend_tow_y ) & |
---|
2644 | * MERGE( 1.0_wp, 0.0_wp, & |
---|
2645 | BTEST( wall_flags_0(k,j,i), 2 ) ) |
---|
2646 | ENDDO |
---|
2647 | ENDDO |
---|
2648 | ENDDO |
---|
2649 | ENDIF |
---|
2650 | |
---|
2651 | CASE ( 3 ) |
---|
2652 | ! |
---|
2653 | !-- Apply the z-component of the force to the w-component of the flow: |
---|
2654 | IF ( simulated_time >= time_turbine_on ) THEN |
---|
2655 | DO i = nxlg, nxrg |
---|
2656 | DO j = nysg, nyng |
---|
2657 | DO k = nzb+1, MAXVAL(k_hub) + MAXVAL(k_smear) |
---|
2658 | tend(k,j,i) = tend(k,j,i) - rot_tend_z(k,j,i) & |
---|
2659 | * MERGE( 1.0_wp, 0.0_wp, & |
---|
2660 | BTEST( wall_flags_0(k,j,i), 3 ) ) |
---|
2661 | ENDDO |
---|
2662 | ENDDO |
---|
2663 | ENDDO |
---|
2664 | ENDIF |
---|
2665 | |
---|
2666 | |
---|
2667 | CASE DEFAULT |
---|
2668 | |
---|
2669 | WRITE( message_string, * ) 'unknown prognostic variable: ', component |
---|
2670 | CALL message( 'wtm_tendencies', 'PA04??', 1, 2, 0, 6, 0 ) |
---|
2671 | |
---|
2672 | END SELECT |
---|
2673 | |
---|
2674 | |
---|
2675 | END SUBROUTINE wtm_tendencies |
---|
2676 | |
---|
2677 | |
---|
2678 | !------------------------------------------------------------------------------! |
---|
2679 | ! Description: |
---|
2680 | ! ------------ |
---|
2681 | !> Application of the additional forces generated by the wind turbine on the |
---|
2682 | !> flow components (tendency terms) |
---|
2683 | !> Call for grid point i,j |
---|
2684 | !------------------------------------------------------------------------------! |
---|
2685 | SUBROUTINE wtm_tendencies_ij( i, j, component ) |
---|
2686 | |
---|
2687 | |
---|
2688 | IMPLICIT NONE |
---|
2689 | |
---|
2690 | INTEGER(iwp) :: component !< prognostic variable (u,v,w) |
---|
2691 | INTEGER(iwp) :: i !< running index |
---|
2692 | INTEGER(iwp) :: j !< running index |
---|
2693 | INTEGER(iwp) :: k !< running index |
---|
2694 | |
---|
2695 | SELECT CASE ( component ) |
---|
2696 | |
---|
2697 | CASE ( 1 ) |
---|
2698 | ! |
---|
2699 | !-- Apply the x-component of the force to the u-component of the flow: |
---|
2700 | IF ( simulated_time >= time_turbine_on ) THEN |
---|
2701 | DO k = nzb+1, MAXVAL(k_hub) + MAXVAL(k_smear) |
---|
2702 | ! |
---|
2703 | !-- Calculate the thrust generated by the nacelle and the tower |
---|
2704 | tend_nac_x = 0.5_wp * nac_cd_surf(k,j,i) * & |
---|
2705 | SIGN( u(k,j,i)**2 , u(k,j,i) ) |
---|
2706 | tend_tow_x = 0.5_wp * tow_cd_surf(k,j,i) * & |
---|
2707 | SIGN( u(k,j,i)**2 , u(k,j,i) ) |
---|
2708 | tend(k,j,i) = tend(k,j,i) + ( - rot_tend_x(k,j,i) & |
---|
2709 | - tend_nac_x - tend_tow_x ) & |
---|
2710 | * MERGE( 1.0_wp, 0.0_wp, & |
---|
2711 | BTEST( wall_flags_0(k,j,i), 1 ) ) |
---|
2712 | ENDDO |
---|
2713 | ENDIF |
---|
2714 | |
---|
2715 | CASE ( 2 ) |
---|
2716 | ! |
---|
2717 | !-- Apply the y-component of the force to the v-component of the flow: |
---|
2718 | IF ( simulated_time >= time_turbine_on ) THEN |
---|
2719 | DO k = nzb+1, MAXVAL(k_hub) + MAXVAL(k_smear) |
---|
2720 | tend_nac_y = 0.5_wp * nac_cd_surf(k,j,i) * & |
---|
2721 | SIGN( v(k,j,i)**2 , v(k,j,i) ) |
---|
2722 | tend_tow_y = 0.5_wp * tow_cd_surf(k,j,i) * & |
---|
2723 | SIGN( v(k,j,i)**2 , v(k,j,i) ) |
---|
2724 | tend(k,j,i) = tend(k,j,i) + ( - rot_tend_y(k,j,i) & |
---|
2725 | - tend_nac_y - tend_tow_y ) & |
---|
2726 | * MERGE( 1.0_wp, 0.0_wp, & |
---|
2727 | BTEST( wall_flags_0(k,j,i), 2 ) ) |
---|
2728 | ENDDO |
---|
2729 | ENDIF |
---|
2730 | |
---|
2731 | CASE ( 3 ) |
---|
2732 | ! |
---|
2733 | !-- Apply the z-component of the force to the w-component of the flow: |
---|
2734 | IF ( simulated_time >= time_turbine_on ) THEN |
---|
2735 | DO k = nzb+1, MAXVAL(k_hub) + MAXVAL(k_smear) |
---|
2736 | tend(k,j,i) = tend(k,j,i) - rot_tend_z(k,j,i) & |
---|
2737 | * MERGE( 1.0_wp, 0.0_wp, & |
---|
2738 | BTEST( wall_flags_0(k,j,i), 3 ) ) |
---|
2739 | ENDDO |
---|
2740 | ENDIF |
---|
2741 | |
---|
2742 | |
---|
2743 | CASE DEFAULT |
---|
2744 | |
---|
2745 | WRITE( message_string, * ) 'unknown prognostic variable: ', component |
---|
2746 | CALL message( 'wtm_tendencies', 'PA04??', 1, 2, 0, 6, 0 ) |
---|
2747 | |
---|
2748 | END SELECT |
---|
2749 | |
---|
2750 | |
---|
2751 | END SUBROUTINE wtm_tendencies_ij |
---|
2752 | |
---|
2753 | END MODULE wind_turbine_model_mod |
---|