Changeset 4447


Ignore:
Timestamp:
Mar 6, 2020 11:05:30 AM (4 years ago)
Author:
oliver.maas
Message:

renamed wind_turbine_parameters namelist variables

Location:
palm/trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • palm/trunk/SOURCE/wind_turbine_model_mod.f90

    r4438 r4447  
    2626! -----------------
    2727! $Id$
     28! renamed wind_turbine_parameters namelist variables
     29!
     30! 4438 2020-03-03 20:49:28Z suehring
    2831! Bugfix: shifted netcdf preprocessor directive to correct position
    2932!
     
    179182!-- Variables specified in the namelist wind_turbine_par
    180183
    181     INTEGER(iwp) ::  nairfoils = 8   !< number of airfoils of the used turbine model (for ADM-R and ALM)
    182     INTEGER(iwp) ::  nturbines = 1   !< number of turbines
     184    INTEGER(iwp) ::  n_airfoils = 8   !< number of airfoils of the used turbine model (for ADM-R and ALM)
     185    INTEGER(iwp) ::  n_turbines = 1   !< number of turbines
    183186
    184187   
     
    189192    REAL(wp), TARGET                ::  output_values_0d_target !< pointer for 2d output array     
    190193   
    191     LOGICAL ::  pitch_control = .FALSE.   !< switch for use of pitch controller
    192     LOGICAL ::  speed_control = .FALSE.   !< switch for use of speed controller
    193     LOGICAL ::  yaw_control   = .FALSE.   !< switch for use of yaw controller
    194     LOGICAL ::  tl_cor        = .FALSE.    !< switch for use of tip loss correct.
     194    LOGICAL ::  pitch_control       = .FALSE.   !< switch for use of pitch controller
     195    LOGICAL ::  speed_control       = .FALSE.   !< switch for use of speed controller
     196    LOGICAL ::  yaw_control         = .FALSE.   !< switch for use of yaw controller
     197    LOGICAL ::  tip_loss_correction = .FALSE.   !< switch for use of tip loss correct.
    195198   
    196199    LOGICAL ::  initial_write_coordinates = .FALSE.
     
    200203   
    201204   
    202     REAL(wp) ::  segment_length  = 1.0_wp          !< length of the segments, the rotor area is divided into
    203                                                    !< (in tangential direction, as factor of MIN(dx,dy,dz))
    204     REAL(wp) ::  segment_width   = 0.5_wp          !< width of the segments, the rotor area is divided into
    205                                                    !< (in radial direction, as factor of MIN(dx,dy,dz))
    206     REAL(wp) ::  time_turbine_on = 0.0_wp          !< time at which turbines are started
    207     REAL(wp) ::  tilt            = 0.0_wp          !< vertical tilt of the rotor [degree] ( positive = backwards )
    208 
    209 
    210     REAL(wp), DIMENSION(1:100) ::  dtow             = 0.0_wp  !< tower diameter [m]
    211     REAL(wp), DIMENSION(1:100), TARGET ::  omega_rot        = 0.9_wp  !< inital or constant rotor speed [rad/s]
    212     REAL(wp), DIMENSION(1:100) ::  phi_yaw          = 0.0_wp  !< yaw angle [degree] ( clockwise, 0 = facing west )
    213     REAL(wp), DIMENSION(1:100) ::  pitch_add        = 0.0_wp  !< constant pitch angle
    214     REAL(wp), DIMENSION(1:100) ::  rcx        = 9999999.9_wp !< position of hub in x-direction
    215     REAL(wp), DIMENSION(1:100) ::  rcy        = 9999999.9_wp !< position of hub in y-direction
    216     REAL(wp), DIMENSION(1:100) ::  rcz        = 9999999.9_wp !< position of hub in z-direction
    217     REAL(wp), DIMENSION(1:100) ::  rnac             = 0.0_wp  !< nacelle diameter [m]
    218     REAL(wp), DIMENSION(1:100) ::  rr              = 63.0_wp  !< rotor radius [m]
    219 !    REAL(wp), DIMENSION(1:100) ::  turb_cd_nacelle = 0.85_wp  !< drag coefficient for nacelle
    220     REAL(wp), DIMENSION(1:100) ::  turb_cd_tower    = 1.2_wp  !< drag coefficient for tower
     205    REAL(wp) ::  segment_length_tangential  = 1.0_wp  !< length of the segments, the rotor area is divided into
     206                                                      !< (in tangential direction, as factor of MIN(dx,dy,dz))
     207    REAL(wp) ::  segment_width_radial       = 0.5_wp  !< width of the segments, the rotor area is divided into
     208                                                      !< (in radial direction, as factor of MIN(dx,dy,dz))
     209    REAL(wp) ::  time_turbine_on            = 0.0_wp  !< time at which turbines are started
     210    REAL(wp) ::  tilt_angle                       = 0.0_wp  !< vertical tilt_angle of the rotor [degree] ( positive = backwards )
     211
     212
     213    REAL(wp), DIMENSION(1:100) ::  tower_diameter      = 0.0_wp       !< tower diameter [m]
     214    REAL(wp), DIMENSION(1:100), TARGET ::  rotor_speed = 0.9_wp       !< inital or constant rotor speed [rad/s]
     215    REAL(wp), DIMENSION(1:100) ::  yaw_angle           = 0.0_wp       !< yaw angle [degree] ( clockwise, 0 = facing west )
     216    REAL(wp), DIMENSION(1:100) ::  pitch_angle         = 0.0_wp       !< constant pitch angle
     217    REAL(wp), DIMENSION(1:100) ::  hub_x               = 9999999.9_wp !< position of hub in x-direction
     218    REAL(wp), DIMENSION(1:100) ::  hub_y               = 9999999.9_wp !< position of hub in y-direction
     219    REAL(wp), DIMENSION(1:100) ::  hub_z               = 9999999.9_wp !< position of hub in z-direction
     220    REAL(wp), DIMENSION(1:100) ::  nacelle_radius      = 0.0_wp       !< nacelle diameter [m]
     221    REAL(wp), DIMENSION(1:100) ::  rotor_radius                  = 63.0_wp      !< rotor radius [m]
     222!    REAL(wp), DIMENSION(1:100) ::  nacelle_cd     = 0.85_wp      !< drag coefficient for nacelle
     223    REAL(wp), DIMENSION(1:100) ::  tower_cd       = 1.2_wp       !< drag coefficient for tower
    221224
    222225!
     
    224227!-- Default values are from the NREL 5MW research turbine (Jonkman, 2008)
    225228
    226     REAL(wp) ::  rated_power    = 5296610.0_wp    !< rated turbine power [W]
    227     REAL(wp) ::  gear_ratio     = 97.0_wp         !< Gear ratio from rotor to generator
    228     REAL(wp) ::  inertia_rot    = 34784179.0_wp   !< Inertia of the rotor [kg*m2]
    229     REAL(wp) ::  inertia_gen    = 534.116_wp      !< Inertia of the generator [kg*m2]
    230     REAL(wp) ::  gen_eff        = 0.944_wp        !< Electric efficiency of the generator
    231     REAL(wp) ::  gear_eff       = 1.0_wp          !< Loss between rotor and generator
    232     REAL(wp) ::  air_dens       = 1.225_wp        !< Air density to convert to W [kg/m3]
    233     REAL(wp) ::  rated_genspeed = 121.6805_wp     !< Rated generator speed [rad/s]
    234     REAL(wp) ::  max_torque_gen = 47402.91_wp     !< Maximum of the generator torque [Nm]
    235     REAL(wp) ::  slope2         = 2.332287_wp     !< Slope constant for region 2
    236     REAL(wp) ::  min_reg2       = 91.21091_wp     !< Lower generator speed boundary of region 2 [rad/s]
    237     REAL(wp) ::  min_reg15      = 70.16224_wp     !< Lower generator speed boundary of region 1.5 [rad/s]
    238     REAL(wp) ::  max_trq_rate  = 15000.0_wp      !< Max generator torque increase [Nm/s]
    239     REAL(wp) ::  pitch_rate     = 8.0_wp          !< Max pitch rate [degree/s]
     229    REAL(wp) ::  generator_power_rated     = 5296610.0_wp    !< rated turbine power [W]
     230    REAL(wp) ::  gear_ratio                = 97.0_wp         !< Gear ratio from rotor to generator
     231    REAL(wp) ::  rotor_inertia             = 34784179.0_wp   !< Inertia of the rotor [kg*m2]
     232    REAL(wp) ::  generator_inertia         = 534.116_wp      !< Inertia of the generator [kg*m2]
     233    REAL(wp) ::  generator_efficiency      = 0.944_wp        !< Electric efficiency of the generator
     234    REAL(wp) ::  gear_efficiency           = 1.0_wp          !< Loss between rotor and generator
     235    REAL(wp) ::  air_density               = 1.225_wp        !< Air density to convert to W [kg/m3]
     236    REAL(wp) ::  generator_speed_rated    = 121.6805_wp     !< Rated generator speed [rad/s]
     237    REAL(wp) ::  generator_torque_max      = 47402.91_wp     !< Maximum of the generator torque [Nm]
     238    REAL(wp) ::  region_2_slope            = 2.332287_wp     !< Slope constant for region 2
     239    REAL(wp) ::  region_2_min              = 91.21091_wp     !< Lower generator speed boundary of region 2 [rad/s]
     240    REAL(wp) ::  region_15_min             = 70.16224_wp     !< Lower generator speed boundary of region 1.5 [rad/s]
     241    REAL(wp) ::  generator_torque_rate_max = 15000.0_wp      !< Max generator torque increase [Nm/s]
     242    REAL(wp) ::  pitch_rate                = 8.0_wp          !< Max pitch rate [degree/s]
    240243
    241244
     
    243246!-- Variables specified in the namelist for yaw control
    244247
    245     REAL(wp) ::  yaw_speed = 0.005236_wp   !< speed of the yaw actuator [rad/s]
    246     REAL(wp) ::  max_miss = 0.08726_wp     !< maximum tolerated yaw missalignment [rad]
    247     REAL(wp) ::  min_miss = 0.008726_wp    !< minimum yaw missalignment for which the actuator stops [rad]
     248    REAL(wp) ::  yaw_speed            = 0.005236_wp    !< speed of the yaw actuator [rad/s]
     249    REAL(wp) ::  yaw_misalignment_max = 0.08726_wp     !< maximum tolerated yaw missalignment [rad]
     250    REAL(wp) ::  yaw_misalignment_min = 0.008726_wp    !< minimum yaw missalignment for which the actuator stops [rad]
    248251
    249252!
     
    392395   
    393396    REAL(wp) ::  Fcorner             !< corner freq for the controller low pass filter
    394     REAL(wp) ::  min_reg25           !< min region 2.5
     397    REAL(wp) ::  region_25_min       !< min region 2.5
    395398    REAL(wp) ::  om_rate             !< rotor speed change
    396399    REAL(wp) ::  slope15             !< slope in region 1.5
    397     REAL(wp) ::  slope25             !< slope in region 2.5
     400    REAL(wp) ::  region_25_slope     !< slope in region 2.5
    398401    REAL(wp) ::  trq_rate            !< torque change
    399402    REAL(wp) ::  vs_sysp             !<
    400403    REAL(wp) ::  lp_coeff            !< coeff for the controller low pass filter
    401404
    402     REAL(wp), DIMENSION(100) :: omega_rot_l = 0.0_wp !< local rot speed [rad/s]
     405    REAL(wp), DIMENSION(100) :: rotor_speed_l = 0.0_wp !< local rot speed [rad/s]
    403406
    404407!
     
    406409
    407410    REAL(wp), DIMENSION(:)  , ALLOCATABLE ::  yawdir           !< direction to yaw
    408     REAL(wp), DIMENSION(:)  , ALLOCATABLE ::  phi_yaw_l        !< local (cpu) yaw angle
     411    REAL(wp), DIMENSION(:)  , ALLOCATABLE ::  yaw_angle_l      !< local (cpu) yaw angle
    409412    REAL(wp), DIMENSION(:)  , ALLOCATABLE ::  wd30_l           !< local (cpu) long running avg of the wd
    410413    REAL(wp), DIMENSION(:)  , ALLOCATABLE ::  wd2_l            !< local (cpu) short running avg of the wd
     
    421424!
    422425!-- Variables that have to be saved in the binary file for restarts
    423     REAL(wp), DIMENSION(1:100) ::  pitch_add_old           = 0.0_wp  !< old constant pitch angle
    424     REAL(wp), DIMENSION(1:100) ::  omega_gen               = 0.0_wp  !< curr. generator speed
    425     REAL(wp), DIMENSION(1:100) ::  omega_gen_f             = 0.0_wp  !< filtered generator speed
    426     REAL(wp), DIMENSION(1:100) ::  omega_gen_old           = 0.0_wp  !< last generator speed
    427     REAL(wp), DIMENSION(1:100) ::  omega_gen_f_old         = 0.0_wp  !< last filtered generator speed
     426    REAL(wp), DIMENSION(1:100) ::  pitch_angle_old           = 0.0_wp  !< old constant pitch angle
     427    REAL(wp), DIMENSION(1:100) ::  generator_speed         = 0.0_wp  !< curr. generator speed
     428    REAL(wp), DIMENSION(1:100) ::  generator_speed_f       = 0.0_wp  !< filtered generator speed
     429    REAL(wp), DIMENSION(1:100) ::  generator_speed_old     = 0.0_wp  !< last generator speed
     430    REAL(wp), DIMENSION(1:100) ::  generator_speed_f_old   = 0.0_wp  !< last filtered generator speed
    428431    REAL(wp), DIMENSION(1:100) ::  torque_gen              = 0.0_wp  !< generator torque
    429432    REAL(wp), DIMENSION(1:100) ::  torque_gen_old          = 0.0_wp  !< last generator torque
     
    503506
    504507       NAMELIST /wind_turbine_parameters/                                      &
    505                                   air_dens, dtow, dt_data_output_wtm, gear_eff,&
    506                                   gear_ratio,                                  &
    507                                   gen_eff, inertia_gen, inertia_rot, max_miss, &
    508                                   max_torque_gen, max_trq_rate, min_miss,      &
    509                                   min_reg15, min_reg2, nairfoils, nturbines,   &
    510                                   omega_rot, phi_yaw, pitch_add, pitch_control,&
    511                                   rated_genspeed, rated_power, rcx, rcy, rcz,  &
    512                                   rnac, rr, segment_length, segment_width,     &
    513                                   slope2, speed_control, tilt, time_turbine_on,&
    514                                   turb_cd_tower, pitch_rate,                   &
    515                                   yaw_control, yaw_speed, tl_cor
    516 !                                  , turb_cd_nacelle
     508                   air_density, tower_diameter, dt_data_output_wtm,            &
     509                   gear_efficiency, gear_ratio, generator_efficiency,          &
     510                   generator_inertia, rotor_inertia, yaw_misalignment_max,     &
     511                   generator_torque_max, generator_torque_rate_max, yaw_misalignment_min,                     &
     512                   region_15_min, region_2_min, n_airfoils, n_turbines,        &
     513                   rotor_speed, yaw_angle, pitch_angle, pitch_control,         &
     514                   generator_speed_rated, generator_power_rated, hub_x, hub_y, hub_z,&
     515                   nacelle_radius, rotor_radius, segment_length_tangential, segment_width_radial,  &
     516                   region_2_slope, speed_control, tilt_angle, time_turbine_on, &
     517                   tower_cd, pitch_rate,                                  &
     518                   yaw_control, yaw_speed, tip_loss_correction
     519!                   , nacelle_cd
     520
    517521!
    518522!--    Try to find wind turbine model package
     
    553557       
    554558
    555        CALL wrd_write_string( 'omega_gen' )
    556        WRITE ( 14 )  omega_gen
    557 
    558        CALL wrd_write_string( 'omega_gen_f' )
    559        WRITE ( 14 )  omega_gen_f
    560 
    561        CALL wrd_write_string( 'omega_gen_f_old' )
    562        WRITE ( 14 )  omega_gen_f_old
    563 
    564        CALL wrd_write_string( 'omega_gen_old' )
    565        WRITE ( 14 )  omega_gen_old
    566 
    567        CALL wrd_write_string( 'omega_rot' )
    568        WRITE ( 14 )  omega_rot
    569 
    570        CALL wrd_write_string( 'phi_yaw' )
    571        WRITE ( 14 )  phi_yaw
    572 
    573        CALL wrd_write_string( 'pitch_add' )
    574        WRITE ( 14 )  pitch_add
    575 
    576        CALL wrd_write_string( 'pitch_add_old' )
    577        WRITE ( 14 )  pitch_add_old
     559       CALL wrd_write_string( 'generator_speed' )
     560       WRITE ( 14 )  generator_speed
     561
     562       CALL wrd_write_string( 'generator_speed_f' )
     563       WRITE ( 14 )  generator_speed_f
     564
     565       CALL wrd_write_string( 'generator_speed_f_old' )
     566       WRITE ( 14 )  generator_speed_f_old
     567
     568       CALL wrd_write_string( 'generator_speed_old' )
     569       WRITE ( 14 )  generator_speed_old
     570
     571       CALL wrd_write_string( 'rotor_speed' )
     572       WRITE ( 14 )  rotor_speed
     573
     574       CALL wrd_write_string( 'yaw_angle' )
     575       WRITE ( 14 )  yaw_angle
     576
     577       CALL wrd_write_string( 'pitch_angle' )
     578       WRITE ( 14 )  pitch_angle
     579
     580       CALL wrd_write_string( 'pitch_angle_old' )
     581       WRITE ( 14 )  pitch_angle_old
    578582
    579583       CALL wrd_write_string( 'torque_gen' )
     
    609613    SELECT CASE ( restart_string(1:length) )
    610614
    611        CASE ( 'omega_gen' )
    612           READ ( 13 )  omega_gen
    613        CASE ( 'omega_gen_f' )
    614           READ ( 13 )  omega_gen_f
    615        CASE ( 'omega_gen_f_old' )
    616           READ ( 13 )  omega_gen_f_old
    617        CASE ( 'omega_gen_old' )
    618           READ ( 13 )  omega_gen_old
    619        CASE ( 'omega_rot' )
    620           READ ( 13 )  omega_rot
    621        CASE ( 'phi_yaw' )
    622           READ ( 13 )  phi_yaw
    623        CASE ( 'pitch_add' )
    624           READ ( 13 )  pitch_add
    625        CASE ( 'pitch_add_old' )
    626           READ ( 13 )  pitch_add_old
     615       CASE ( 'generator_speed' )
     616          READ ( 13 )  generator_speed
     617       CASE ( 'generator_speed_f' )
     618          READ ( 13 )  generator_speed_f
     619       CASE ( 'generator_speed_f_old' )
     620          READ ( 13 )  generator_speed_f_old
     621       CASE ( 'generator_speed_old' )
     622          READ ( 13 )  generator_speed_old
     623       CASE ( 'rotor_speed' )
     624          READ ( 13 )  rotor_speed
     625       CASE ( 'yaw_angle' )
     626          READ ( 13 )  yaw_angle
     627       CASE ( 'pitch_angle' )
     628          READ ( 13 )  pitch_angle
     629       CASE ( 'pitch_angle_old' )
     630          READ ( 13 )  pitch_angle_old
    627631       CASE ( 'torque_gen' )
    628632          READ ( 13 )  torque_gen
     
    656660          ENDIF
    657661
    658           IF ( ANY( omega_rot(1:nturbines) < 0.0 ) )  THEN
    659              message_string = 'omega_rot < 0.0, Please set omega_rot to '     // &
     662          IF ( ANY( rotor_speed(1:n_turbines) < 0.0 ) )  THEN
     663             message_string = 'rotor_speed < 0.0, Please set rotor_speed to '     // &
    660664                               'a value equal or larger than zero'
    661665             CALL message( 'wtm_check_parameters', 'PA0462', 1, 2, 0, 6, 0 )
     
    663667
    664668
    665           IF ( ANY( rcx(1:nturbines) == 9999999.9_wp ) .OR.                       &
    666                 ANY( rcy(1:nturbines) == 9999999.9_wp ) .OR.                       &
    667                 ANY( rcz(1:nturbines) == 9999999.9_wp ) )  THEN
     669          IF ( ANY( hub_x(1:n_turbines) == 9999999.9_wp ) .OR.                   &
     670                ANY( hub_y(1:n_turbines) == 9999999.9_wp ) .OR.                  &
     671                ANY( hub_z(1:n_turbines) == 9999999.9_wp ) )  THEN
    668672             
    669              message_string = 'rcx, rcy, rcz '                                 // &
     673             message_string = 'hub_x, hub_y, hub_z '                          // &
    670674                               'have to be given for each turbine.'         
    671675             CALL message( 'wtm_check_parameters', 'PA0463', 1, 2, 0, 6, 0 )         
     
    707711!
    708712!--       Input of all wtm parameters
    709           IF ( check_existence( vars_pids, 'dtow' ) )  THEN
    710              CALL get_variable( pids_id, 'dtow', dtow(1:nturbines))
     713          IF ( check_existence( vars_pids, 'tower_diameter' ) )  THEN
     714             CALL get_variable( pids_id, 'tower_diameter', tower_diameter(1:n_turbines))
    711715          ENDIF
    712716
    713           IF ( check_existence( vars_pids, 'omega_rot' ) )  THEN
    714              CALL get_variable( pids_id, 'omega_rot', omega_rot(1:nturbines))
     717          IF ( check_existence( vars_pids, 'rotor_speed' ) )  THEN
     718             CALL get_variable( pids_id, 'rotor_speed', rotor_speed(1:n_turbines))
    715719          ENDIF
    716720
    717           IF ( check_existence( vars_pids, 'pitch_add' ) )  THEN
    718              CALL get_variable( pids_id, 'pitch_add', pitch_add(1:nturbines))
     721          IF ( check_existence( vars_pids, 'pitch_angle' ) )  THEN
     722             CALL get_variable( pids_id, 'pitch_angle', pitch_angle(1:n_turbines))
    719723          ENDIF
    720724
    721           IF ( check_existence( vars_pids, 'phi_yaw' ) )  THEN
    722              CALL get_variable( pids_id, 'phi_yaw', phi_yaw(1:nturbines))
     725          IF ( check_existence( vars_pids, 'yaw_angle' ) )  THEN
     726             CALL get_variable( pids_id, 'yaw_angle', yaw_angle(1:n_turbines))
    723727          ENDIF
    724728
    725           IF ( check_existence( vars_pids, 'rcx' ) )  THEN
    726              CALL get_variable( pids_id, 'rcx', rcx(1:nturbines))
     729          IF ( check_existence( vars_pids, 'hub_x' ) )  THEN
     730             CALL get_variable( pids_id, 'hub_x', hub_x(1:n_turbines))
    727731          ENDIF
    728732
    729           IF ( check_existence( vars_pids, 'rcy' ) )  THEN
    730              CALL get_variable( pids_id, 'rcy', rcy(1:nturbines))
     733          IF ( check_existence( vars_pids, 'hub_y' ) )  THEN
     734             CALL get_variable( pids_id, 'hub_y', hub_y(1:n_turbines))
    731735          ENDIF
    732736
    733           IF ( check_existence( vars_pids, 'rcz' ) )  THEN
    734              CALL get_variable( pids_id, 'rcz', rcz(1:nturbines))
     737          IF ( check_existence( vars_pids, 'hub_z' ) )  THEN
     738             CALL get_variable( pids_id, 'hub_z', hub_z(1:n_turbines))
    735739          ENDIF
    736740
    737           IF ( check_existence( vars_pids, 'rnac' ) )  THEN
    738              CALL get_variable( pids_id, 'rnac', rnac(1:nturbines))
     741          IF ( check_existence( vars_pids, 'nacelle_radius' ) )  THEN
     742             CALL get_variable( pids_id, 'nacelle_radius', nacelle_radius(1:n_turbines))
    739743          ENDIF
    740744
    741           IF ( check_existence( vars_pids, 'rr' ) )  THEN
    742              CALL get_variable( pids_id, 'rr', rr(1:nturbines))
     745          IF ( check_existence( vars_pids, 'rotor_radius' ) )  THEN
     746             CALL get_variable( pids_id, 'rotor_radius', rotor_radius(1:n_turbines))
    743747          ENDIF
    744748!
    745 !           IF ( check_existence( vars_pids, 'turb_cd_nacelle' ) )  THEN
    746 !              CALL get_variable( pids_id, 'turb_cd_nacelle', turb_cd_nacelle(1:nturbines))
     749!           IF ( check_existence( vars_pids, 'nacelle_cd' ) )  THEN
     750!              CALL get_variable( pids_id, 'nacelle_cd', nacelle_cd(1:n_turbines))
    747751!           ENDIF
    748752
    749           IF ( check_existence( vars_pids, 'turb_cd_tower' ) )  THEN
    750              CALL get_variable( pids_id, 'turb_cd_tower', turb_cd_tower(1:nturbines))
     753          IF ( check_existence( vars_pids, 'tower_cd' ) )  THEN
     754             CALL get_variable( pids_id, 'tower_cd', tower_cd(1:n_turbines))
    751755          ENDIF
    752756!
     
    761765!--    the maximum possible numbers of rings and segments have to be calculated:
    762766
    763        ALLOCATE( nrings(1:nturbines) )
    764        ALLOCATE( delta_r(1:nturbines) )
     767       ALLOCATE( nrings(1:n_turbines) )
     768       ALLOCATE( delta_r(1:n_turbines) )
    765769
    766770       nrings(:)  = 0
     
    769773!
    770774!--    Thickness (radial) of each ring and length (tangential) of each segment:
    771        delta_r_factor = segment_width
    772        delta_t_factor = segment_length
     775       delta_r_factor = segment_width_radial
     776       delta_t_factor = segment_length_tangential
    773777       delta_r_init   = delta_r_factor * MIN( dx, dy, dz(1))
    774778
    775        DO inot = 1, nturbines
     779       DO inot = 1, n_turbines
    776780!
    777781!--       Determine number of rings:
    778           nrings(inot) = NINT( rr(inot) / delta_r_init )
    779 
    780           delta_r(inot) = rr(inot) / nrings(inot)
     782          nrings(inot) = NINT( rotor_radius(inot) / delta_r_init )
     783
     784          delta_r(inot) = rotor_radius(inot) / nrings(inot)
    781785
    782786       ENDDO
     
    784788       nrings_max = MAXVAL(nrings)
    785789
    786        ALLOCATE( nsegs(1:nrings_max,1:nturbines) )
    787        ALLOCATE( nsegs_total(1:nturbines) )
     790       ALLOCATE( nsegs(1:nrings_max,1:n_turbines) )
     791       ALLOCATE( nsegs_total(1:n_turbines) )
    788792
    789793       nsegs(:,:)     = 0
     
    791795
    792796
    793        DO inot = 1, nturbines
     797       DO inot = 1, n_turbines
    794798          DO ring = 1, nrings(inot)
    795799!
     
    824828!
    825829!--    Allocate 1D arrays (dimension = number of turbines)
    826        ALLOCATE( i_hub(1:nturbines) )
    827        ALLOCATE( i_smear(1:nturbines) )
    828        ALLOCATE( j_hub(1:nturbines) )
    829        ALLOCATE( j_smear(1:nturbines) )
    830        ALLOCATE( k_hub(1:nturbines) )
    831        ALLOCATE( k_smear(1:nturbines) )
    832        ALLOCATE( torque_total(1:nturbines) )
    833        ALLOCATE( thrust_rotor(1:nturbines) )
     830       ALLOCATE( i_hub(1:n_turbines) )
     831       ALLOCATE( i_smear(1:n_turbines) )
     832       ALLOCATE( j_hub(1:n_turbines) )
     833       ALLOCATE( j_smear(1:n_turbines) )
     834       ALLOCATE( k_hub(1:n_turbines) )
     835       ALLOCATE( k_smear(1:n_turbines) )
     836       ALLOCATE( torque_total(1:n_turbines) )
     837       ALLOCATE( thrust_rotor(1:n_turbines) )
    834838
    835839!
    836840!--    Allocation of the 1D arrays for yaw control
    837        ALLOCATE( yawdir(1:nturbines) )
    838        ALLOCATE( u_inflow(1:nturbines) )
    839        ALLOCATE( wdir(1:nturbines) )
    840        ALLOCATE( u_inflow_l(1:nturbines) )
    841        ALLOCATE( wdir_l(1:nturbines) )
    842        ALLOCATE( phi_yaw_l(1:nturbines) )
     841       ALLOCATE( yawdir(1:n_turbines) )
     842       ALLOCATE( u_inflow(1:n_turbines) )
     843       ALLOCATE( wdir(1:n_turbines) )
     844       ALLOCATE( u_inflow_l(1:n_turbines) )
     845       ALLOCATE( wdir_l(1:n_turbines) )
     846       ALLOCATE( yaw_angle_l(1:n_turbines) )
    843847       
    844848!
     
    866870!
    867871!--    Allocate additional 2D arrays
    868        ALLOCATE( rotx(1:nturbines,1:3) )
    869        ALLOCATE( roty(1:nturbines,1:3) )
    870        ALLOCATE( rotz(1:nturbines,1:3) )
     872       ALLOCATE( rotx(1:n_turbines,1:3) )
     873       ALLOCATE( roty(1:n_turbines,1:3) )
     874       ALLOCATE( rotz(1:n_turbines,1:3) )
    871875
    872876!
     
    883887!
    884888!--    Allocate additional 3D arrays
    885        ALLOCATE( u_int(1:nturbines,1:nrings_max,1:nsegs_max) )
    886        ALLOCATE( u_int_1_l(1:nturbines,1:nrings_max,1:nsegs_max) )
    887        ALLOCATE( v_int(1:nturbines,1:nrings_max,1:nsegs_max) )
    888        ALLOCATE( v_int_1_l(1:nturbines,1:nrings_max,1:nsegs_max) )
    889        ALLOCATE( w_int(1:nturbines,1:nrings_max,1:nsegs_max) )
    890        ALLOCATE( w_int_1_l(1:nturbines,1:nrings_max,1:nsegs_max) )
     889       ALLOCATE( u_int(1:n_turbines,1:nrings_max,1:nsegs_max) )
     890       ALLOCATE( u_int_1_l(1:n_turbines,1:nrings_max,1:nsegs_max) )
     891       ALLOCATE( v_int(1:n_turbines,1:nrings_max,1:nsegs_max) )
     892       ALLOCATE( v_int_1_l(1:n_turbines,1:nrings_max,1:nsegs_max) )
     893       ALLOCATE( w_int(1:n_turbines,1:nrings_max,1:nsegs_max) )
     894       ALLOCATE( w_int_1_l(1:n_turbines,1:nrings_max,1:nsegs_max) )
    891895
    892896!
     
    903907
    904908       IF ( TRIM( initializing_actions ) /= 'read_restart_data' ) THEN
    905           omega_gen(:)             = 0.0_wp
    906           omega_gen_old(:)         = 0.0_wp
    907           omega_gen_f(:)           = 0.0_wp
    908           omega_gen_f_old(:)       = 0.0_wp
    909           pitch_add_old(:)         = 0.0_wp
     909          generator_speed(:)             = 0.0_wp
     910          generator_speed_old(:)         = 0.0_wp
     911          generator_speed_f(:)           = 0.0_wp
     912          generator_speed_f_old(:)       = 0.0_wp
     913          pitch_angle_old(:)         = 0.0_wp
    910914          torque_gen(:)            = 0.0_wp
    911915          torque_gen_old(:)        = 0.0_wp
     
    917921       u_inflow(:)              = 0.0_wp
    918922       u_inflow_l(:)            = 0.0_wp
    919        phi_yaw_l(:)             = 0.0_wp
     923       yaw_angle_l(:)           = 0.0_wp
    920924
    921925!
     
    10011005       IF ( debug_output )  CALL debug_message( 'wtm_init', 'start' )
    10021006       
    1003        ALLOCATE( index_nacb(1:nturbines) )
    1004        ALLOCATE( index_nacl(1:nturbines) )
    1005        ALLOCATE( index_nacr(1:nturbines) )
    1006        ALLOCATE( index_nact(1:nturbines) )
     1007       ALLOCATE( index_nacb(1:n_turbines) )
     1008       ALLOCATE( index_nacl(1:n_turbines) )
     1009       ALLOCATE( index_nacr(1:n_turbines) )
     1010       ALLOCATE( index_nact(1:n_turbines) )
    10071011
    10081012!
     
    10301034!--    the area where the wtm is active. ABS (...) is required because the
    10311035!--    default value of dz_stretch_level_start is -9999999.9_wp (negative).
    1032        IF ( ABS( dz_stretch_level_start(1) ) <= MAXVAL(rcz(1:nturbines)) +     &
    1033                                                 MAXVAL(rr(1:nturbines)) +      &
     1036       IF ( ABS( dz_stretch_level_start(1) ) <= MAXVAL(hub_z(1:n_turbines)) +  &
     1037                                                MAXVAL(rotor_radius(1:n_turbines)) +     &
    10341038                                                eps_min)  THEN
    10351039          WRITE( message_string, * ) 'The lowest level where vertical ',       &
    10361040                                     'stretching is applied &have to be ',     &
    1037                                      'greater than ',MAXVAL(rcz(1:nturbines)) +&
    1038                                       MAXVAL(rr(1:nturbines)) + eps_min
     1041                                     'greater than ',MAXVAL(hub_z(1:n_turbines)) &
     1042                                      + MAXVAL(rotor_radius(1:n_turbines)) + eps_min
    10391043          CALL message( 'wtm_init', 'PA0484', 1, 2, 0, 6, 0 )
    10401044       ENDIF
     
    10521056       
    10531057!--    Change tilt angle to rad:
    1054        tilt = tilt * pi / 180.0_wp
     1058       tilt_angle = tilt_angle * pi / 180.0_wp
    10551059     
    10561060!
    10571061!--    Change yaw angle to rad:
    10581062       IF ( TRIM( initializing_actions ) /= 'read_restart_data' ) THEN
    1059           phi_yaw(:) = phi_yaw(:) * pi / 180.0_wp
     1063          yaw_angle(:) = yaw_angle(:) * pi / 180.0_wp
    10601064       ENDIF
    10611065
    10621066
    1063        DO inot = 1, nturbines
     1067       DO inot = 1, n_turbines
    10641068!
    10651069!--       Rotate the rotor coordinates in case yaw and tilt are defined
     
    10681072!
    10691073!--       Determine the indices of the hub height
    1070           i_hub(inot) = INT(   rcx(inot)                 / dx )
    1071           j_hub(inot) = INT( ( rcy(inot) + 0.5_wp * dy ) / dy )
    1072           k_hub(inot) = INT( ( rcz(inot) + 0.5_wp * dz(1) ) / dz(1) )
     1074          i_hub(inot) = INT(   hub_x(inot)                 / dx )
     1075          j_hub(inot) = INT( ( hub_y(inot) + 0.5_wp * dy ) / dy )
     1076          k_hub(inot) = INT( ( hub_z(inot) + 0.5_wp * dz(1) ) / dz(1) )
    10731077
    10741078!
     
    10771081!--       eps_min, the smearing area can be further limited and regarded as a
    10781082!--       function of eps_min:
    1079           i_smear(inot) = CEILING( ( rr(inot) + eps_min ) / dx )
    1080           j_smear(inot) = CEILING( ( rr(inot) + eps_min ) / dy )
    1081           k_smear(inot) = CEILING( ( rr(inot) + eps_min ) / dz(1) )
     1083          i_smear(inot) = CEILING( ( rotor_radius(inot) + eps_min ) / dx )
     1084          j_smear(inot) = CEILING( ( rotor_radius(inot) + eps_min ) / dy )
     1085          k_smear(inot) = CEILING( ( rotor_radius(inot) + eps_min ) / dz(1) )
    10821086       
    10831087       ENDDO
     
    10851089!
    10861090!--    Call the wtm_init_speed_control subroutine and calculate the local
    1087 !--    omega_rot for the respective processor.
     1091!--    rotor_speed for the respective processor.
    10881092       IF ( speed_control)  THEN
    10891093       
     
    10921096          IF ( TRIM( initializing_actions ) == 'read_restart_data' ) THEN
    10931097
    1094              DO inot = 1, nturbines
     1098             DO inot = 1, n_turbines
    10951099
    10961100                IF ( nxl > i_hub(inot) ) THEN
    10971101                   torque_gen(inot) = 0.0_wp
    1098                    omega_gen_f(inot) = 0.0_wp
    1099                    omega_rot_l(inot) = 0.0_wp
     1102                   generator_speed_f(inot) = 0.0_wp
     1103                   rotor_speed_l(inot) = 0.0_wp
    11001104                ENDIF
    11011105
    11021106                IF ( nxr < i_hub(inot) ) THEN
    11031107                   torque_gen(inot) = 0.0_wp
    1104                    omega_gen_f(inot) = 0.0_wp
    1105                    omega_rot_l(inot) = 0.0_wp
     1108                   generator_speed_f(inot) = 0.0_wp
     1109                   rotor_speed_l(inot) = 0.0_wp
    11061110                ENDIF
    11071111
    11081112                IF ( nys > j_hub(inot) ) THEN
    11091113                   torque_gen(inot) = 0.0_wp
    1110                    omega_gen_f(inot) = 0.0_wp
    1111                    omega_rot_l(inot) = 0.0_wp
     1114                   generator_speed_f(inot) = 0.0_wp
     1115                   rotor_speed_l(inot) = 0.0_wp
    11121116                ENDIF
    11131117
    11141118                IF ( nyn < j_hub(inot) ) THEN
    11151119                   torque_gen(inot) = 0.0_wp
    1116                    omega_gen_f(inot) = 0.0_wp
    1117                    omega_rot_l(inot) = 0.0_wp
     1120                   generator_speed_f(inot) = 0.0_wp
     1121                   rotor_speed_l(inot) = 0.0_wp
    11181122                ENDIF
    11191123
     
    11211125                   IF ( ( nys <= j_hub(inot) ) .AND. ( nyn >= j_hub(inot) ) ) THEN
    11221126
    1123                       omega_rot_l(inot) = omega_gen(inot) / gear_ratio
     1127                      rotor_speed_l(inot) = generator_speed(inot) / gear_ratio
    11241128
    11251129                   ENDIF
     
    11511155
    11521156       
    1153        DO inot = 1, nturbines                     ! loop over number of turbines
     1157       DO inot = 1, n_turbines                     ! loop over number of turbines
    11541158!
    11551159!--       Determine the grid index (u-grid) that corresponds to the location of
     
    11611165!--       Determine the left and the right edge of the nacelle (corresponding
    11621166!--       grid point indices):
    1163           index_nacl(inot) = INT( ( rcy(inot) - rnac(inot) + 0.5_wp * dy ) / dy )
    1164           index_nacr(inot) = INT( ( rcy(inot) + rnac(inot) + 0.5_wp * dy ) / dy )
     1167          index_nacl(inot) = INT( ( hub_y(inot) - nacelle_radius(inot) + 0.5_wp * dy ) / dy )
     1168          index_nacr(inot) = INT( ( hub_y(inot) + nacelle_radius(inot) + 0.5_wp * dy ) / dy )
    11651169!
    11661170!--       Determine the bottom and the top edge of the nacelle (corresponding
     
    11691173!--       surface. All points between z=0 and z=dz/s would already be contained
    11701174!--       in grid box 1.
    1171           index_nacb(inot) = INT( ( rcz(inot) - rnac(inot) ) / dz(1) ) + 1
    1172           index_nact(inot) = INT( ( rcz(inot) + rnac(inot) ) / dz(1) ) + 1
     1175          index_nacb(inot) = INT( ( hub_z(inot) - nacelle_radius(inot) ) / dz(1) ) + 1
     1176          index_nact(inot) = INT( ( hub_z(inot) + nacelle_radius(inot) ) / dz(1) ) + 1
    11731177
    11741178!
    11751179!--       Determine the indices of the grid boxes containing the left and
    11761180!--       the right boundaries of the tower:
    1177           tower_n = ( rcy(inot) + 0.5_wp * dtow(inot) - 0.5_wp * dy ) / dy
    1178           tower_s = ( rcy(inot) - 0.5_wp * dtow(inot) - 0.5_wp * dy ) / dy
     1181          tower_n = ( hub_y(inot) + 0.5_wp * tower_diameter(inot) - 0.5_wp * dy ) / dy
     1182          tower_s = ( hub_y(inot) - 0.5_wp * tower_diameter(inot) - 0.5_wp * dy ) / dy
    11791183
    11801184!
     
    11951199!--                      leftmost and rightmost grid box:
    11961200                            IF ( j == tower_s )  THEN
    1197                                tow_cd_surf(k,j,i) = ( rcz(inot) -              &
     1201                               tow_cd_surf(k,j,i) = ( hub_z(inot) -              &
    11981202                                    ( k_hub(inot) * dz(1) - 0.5_wp * dz(1) ) )*& ! extension in z-direction
    11991203                                  ( ( tower_s + 1.0_wp + 0.5_wp ) * dy    -    &
    1200                                     ( rcy(inot) - 0.5_wp * dtow(inot) ) ) *    & ! extension in y-direction
    1201                                   turb_cd_tower(inot)
     1204                                    ( hub_y(inot) - 0.5_wp * tower_diameter(inot) ) ) *    & ! extension in y-direction
     1205                                  tower_cd(inot)
    12021206                            ELSEIF ( j == tower_n )  THEN
    1203                                tow_cd_surf(k,j,i) = ( rcz(inot)            -   &
     1207                               tow_cd_surf(k,j,i) = ( hub_z(inot)            -   &
    12041208                                    ( k_hub(inot) * dz(1) - 0.5_wp * dz(1) ) )*& ! extension in z-direction
    1205                                   ( ( rcy(inot) + 0.5_wp * dtow(inot) )   -    &
     1209                                  ( ( hub_y(inot) + 0.5_wp * tower_diameter(inot) )   -    &
    12061210                                    ( tower_n + 0.5_wp ) * dy )           *    & ! extension in y-direction
    1207                                   turb_cd_tower(inot)
     1211                                  tower_cd(inot)
    12081212!
    12091213!--                         grid boxes inbetween
    12101214!--                         (where tow_cd_surf = grid box area):
    12111215                            ELSE
    1212                                tow_cd_surf(k,j,i) = ( rcz(inot) -              &
     1216                               tow_cd_surf(k,j,i) = ( hub_z(inot) -              &
    12131217                                    ( k_hub(inot) * dz(1) - 0.5_wp * dz(1) ) )*&
    1214                                     dy * turb_cd_tower(inot)
     1218                                    dy * tower_cd(inot)
    12151219                            ENDIF
    12161220!
    12171221!--                      tower lies completely within one grid box:
    12181222                         ELSE
    1219                             tow_cd_surf(k,j,i) = ( rcz(inot) - ( k_hub(inot) * &
     1223                            tow_cd_surf(k,j,i) = ( hub_z(inot) - ( k_hub(inot) * &
    12201224                                       dz(1) - 0.5_wp * dz(1) ) ) *            &
    1221                                        dtow(inot) * turb_cd_tower(inot)
     1225                                       tower_diameter(inot) * tower_cd(inot)
    12221226                         ENDIF
    12231227!
     
    12321236                               tow_cd_surf(k,j,i) = dz(1) * (                  &
    12331237                                      ( tower_s + 1 + 0.5_wp ) * dy         -  &
    1234                                       ( rcy(inot) - 0.5_wp * dtow(inot) )      &
    1235                                                         ) * turb_cd_tower(inot)
     1238                                      ( hub_y(inot) - 0.5_wp * tower_diameter(inot) )      &
     1239                                                        ) * tower_cd(inot)
    12361240                            ELSEIF ( j == tower_n )  THEN
    12371241                               tow_cd_surf(k,j,i) = dz(1) * (                  &
    1238                                       ( rcy(inot) + 0.5_wp * dtow(inot) )   -  &
     1242                                      ( hub_y(inot) + 0.5_wp * tower_diameter(inot) )   -  &
    12391243                                      ( tower_n + 0.5_wp ) * dy                &
    1240                                                          ) * turb_cd_tower(inot)
     1244                                                         ) * tower_cd(inot)
    12411245!
    12421246!--                         grid boxes inbetween
     
    12441248                            ELSE
    12451249                               tow_cd_surf(k,j,i) = dz(1) * dy *               &
    1246                                                     turb_cd_tower(inot)
     1250                                                    tower_cd(inot)
    12471251                            ENDIF
    12481252!
    12491253!--                         tower lies completely within one grid box:
    12501254                         ELSE
    1251                             tow_cd_surf(k,j,i) = dz(1) * dtow(inot) *          &
    1252                                                 turb_cd_tower(inot)
     1255                            tow_cd_surf(k,j,i) = dz(1) * tower_diameter(inot) *          &
     1256                                                tower_cd(inot)
    12531257                         ENDIF ! end if larger than grid box
    12541258
     
    12791283!          DO  i_ip = 1, upper_end
    12801284!             yvalue   = dy_int * ( i_ip - 0.5_wp ) + 0.5_wp * dy           !<--- segmentation fault
    1281 !             sqrt_arg = rnac(inot)**2 - ( yvalue - rcy(inot) )**2          !<--- segmentation fault
     1285!             sqrt_arg = nacelle_radius(inot)**2 - ( yvalue - hub_y(inot) )**2          !<--- segmentation fault
    12821286!             IF ( sqrt_arg >= 0.0_wp )  THEN
    12831287!!
    12841288!!--             bottom intersection point
    1285 !                circle_points(1,i_ip) = rcz(inot) - SQRT( sqrt_arg )
     1289!                circle_points(1,i_ip) = hub_z(inot) - SQRT( sqrt_arg )
    12861290!!
    12871291!!--             top intersection point
    1288 !                circle_points(2,i_ip) = rcz(inot) + SQRT( sqrt_arg )       !<--- segmentation fault
     1292!                circle_points(2,i_ip) = hub_z(inot) + SQRT( sqrt_arg )       !<--- segmentation fault
    12891293!             ELSE
    12901294!                circle_points(:,i_ip) = -111111                            !<--- segmentation fault
     
    13381342!                         IF ( ( nxlg <= i ) .AND. ( nxrg >= i ) ) THEN
    13391343!                            nac_cd_surf(k,j,i) = nac_cd_surf(k,j,i) +        &  !<--- segmentation fault
    1340 !                                                  dy_int * dz_int * turb_cd_nacelle(inot)
     1344!                                                  dy_int * dz_int * nacelle_cd(inot)
    13411345!                         ENDIF   
    13421346!                      ENDDO
     
    13821386!
    13831387!--    Define dimensions in output file
    1384        ALLOCATE( ndim(1:nturbines) )
    1385        DO  n = 1, nturbines
     1388       ALLOCATE( ndim(1:n_turbines) )
     1389       DO  n = 1, n_turbines
    13861390          ndim(n) = n
    13871391       ENDDO
     
    13891393                                   dimension_name = 'turbine',                 &
    13901394                                   output_type = 'int32',                      &
    1391                                    bounds = (/1_iwp, nturbines/),              &
     1395                                   bounds = (/1_iwp, n_turbines/),             &
    13921396                                   values_int32 = ndim )
    13931397       DEALLOCATE( ndim )
     
    16491653       REAL(wp), DIMENSION(:,:), ALLOCATABLE  :: turb_cl_table      !<
    16501654                                         
    1651        ALLOCATE ( read_cl_cd(1:2*nairfoils+1) )
     1655       ALLOCATE ( read_cl_cd(1:2*n_airfoils+1) )
    16521656
    16531657!
     
    17181722       ENDDO rloop2
    17191723
    1720        ALLOCATE( alpha_attack_tab(1:dlen), turb_cl_table(1:dlen,1:nairfoils), &
    1721                  turb_cd_table(1:dlen,1:nairfoils) )
     1724       ALLOCATE( alpha_attack_tab(1:dlen), turb_cl_table(1:dlen,1:n_airfoils), &
     1725                 turb_cd_table(1:dlen,1:n_airfoils) )
    17221726
    17231727       DO jj = 1,dlen+1
     
    17281732          READ ( 90, * ) read_cl_cd
    17291733          alpha_attack_tab(jj) = read_cl_cd(1)
    1730           DO ii= 1, nairfoils
     1734          DO ii= 1, n_airfoils
    17311735             turb_cl_table(jj,ii) = read_cl_cd(ii*2)
    17321736             turb_cd_table(jj,ii) = read_cl_cd(ii*2+1)
     
    17401744
    17411745!
    1742 !--    For each possible radial position (resolution: 0.1 m --> 631 values if rr(1)=63m)
     1746!--    For each possible radial position (resolution: 0.1 m --> 631 values if rotor_radius(1)=63m)
    17431747!--    and each possible angle of attack (resolution: 0.1 degrees --> 3601 values!)
    17441748!--    determine the lift and drag coefficient by interpolating between the
     
    17511755       ALLOCATE( turb_cd_sel2(1:dlenbl) )
    17521756
    1753        radres     = INT( rr(1) * 10.0_wp ) + 1_iwp
     1757       radres     = INT( rotor_radius(1) * 10.0_wp ) + 1_iwp
    17541758       dlenbl_int = INT( 360.0_wp / accu_cl_cd_tab ) + 1_iwp
    17551759
     
    18661870!--    Calculation of the rotation matrix for the application of the tilt to
    18671871!--    the rotors
    1868        rot_eigen_rad(1) = SIN( phi_yaw(inot) )    ! x-component of the radial eigenvector
    1869        rot_eigen_rad(2) = COS( phi_yaw(inot) )    ! y-component of the radial eigenvector
     1872       rot_eigen_rad(1) = SIN( yaw_angle(inot) )  ! x-component of the radial eigenvector
     1873       rot_eigen_rad(2) = COS( yaw_angle(inot) )  ! y-component of the radial eigenvector
    18701874       rot_eigen_rad(3) = 0.0_wp                  ! z-component of the radial eigenvector
    18711875
     
    18741878       rot_eigen_azi(3) = 1.0_wp                  ! z-component of the azimuth eigenvector
    18751879
    1876        rot_eigen_nor(1) =  COS( phi_yaw(inot) )  ! x-component of the normal eigenvector
    1877        rot_eigen_nor(2) = -SIN( phi_yaw(inot) )  ! y-component of the normal eigenvector
     1880       rot_eigen_nor(1) =  COS( yaw_angle(inot) ) ! x-component of the normal eigenvector
     1881       rot_eigen_nor(2) = -SIN( yaw_angle(inot) ) ! y-component of the normal eigenvector
    18781882       rot_eigen_nor(3) = 0.0_wp                  ! z-component of the normal eigenvector
    18791883   
     
    18831887
    18841888       rot_coord_trans(inot,1,1) = rot_eigen_rad(1)**2                   *     &
    1885                                    ( 1.0_wp - COS( tilt ) ) + COS( tilt )
     1889                                   ( 1.0_wp - COS( tilt_angle ) ) + COS( tilt_angle )
    18861890       rot_coord_trans(inot,1,2) = rot_eigen_rad(1) * rot_eigen_rad(2)   *     &
    1887                                    ( 1.0_wp - COS( tilt ) )              -     &
    1888                                    rot_eigen_rad(3) * SIN( tilt )
     1891                                   ( 1.0_wp - COS( tilt_angle ) )              -     &
     1892                                   rot_eigen_rad(3) * SIN( tilt_angle )
    18891893       rot_coord_trans(inot,1,3) = rot_eigen_rad(1) * rot_eigen_rad(3)   *     &
    1890                                    ( 1.0_wp - COS( tilt ) )              +     &
    1891                                    rot_eigen_rad(2) * SIN( tilt )
     1894                                   ( 1.0_wp - COS( tilt_angle ) )              +     &
     1895                                   rot_eigen_rad(2) * SIN( tilt_angle )
    18921896       rot_coord_trans(inot,2,1) = rot_eigen_rad(2) * rot_eigen_rad(1)   *     &
    1893                                    ( 1.0_wp - COS( tilt ) )              +     &
    1894                                    rot_eigen_rad(3) * SIN( tilt )
     1897                                   ( 1.0_wp - COS( tilt_angle ) )              +     &
     1898                                   rot_eigen_rad(3) * SIN( tilt_angle )
    18951899       rot_coord_trans(inot,2,2) = rot_eigen_rad(2)**2                   *     &
    1896                                    ( 1.0_wp - COS( tilt ) ) + COS( tilt )
     1900                                   ( 1.0_wp - COS( tilt_angle ) ) + COS( tilt_angle )
    18971901       rot_coord_trans(inot,2,3) = rot_eigen_rad(2) * rot_eigen_rad(3)   *     &
    1898                                    ( 1.0_wp - COS( tilt ) )              -     &
    1899                                    rot_eigen_rad(1) * SIN( tilt )
     1902                                   ( 1.0_wp - COS( tilt_angle ) )              -     &
     1903                                   rot_eigen_rad(1) * SIN( tilt_angle )
    19001904       rot_coord_trans(inot,3,1) = rot_eigen_rad(3) * rot_eigen_rad(1)   *     &
    1901                                    ( 1.0_wp - COS( tilt ) )              -     &
    1902                                    rot_eigen_rad(2) * SIN( tilt )
     1905                                   ( 1.0_wp - COS( tilt_angle ) )              -     &
     1906                                   rot_eigen_rad(2) * SIN( tilt_angle )
    19031907       rot_coord_trans(inot,3,2) = rot_eigen_rad(3) * rot_eigen_rad(2)   *     &
    1904                                    ( 1.0_wp - COS( tilt ) )              +     &
    1905                                    rot_eigen_rad(1) * SIN( tilt )
     1908                                   ( 1.0_wp - COS( tilt_angle ) )              +     &
     1909                                   rot_eigen_rad(1) * SIN( tilt_angle )
    19061910       rot_coord_trans(inot,3,3) = rot_eigen_rad(3)**2                   *     &
    1907                                    ( 1.0_wp - COS( tilt ) ) + COS( tilt )
     1911                                   ( 1.0_wp - COS( tilt_angle ) ) + COS( tilt_angle )
    19081912
    19091913!
     
    19731977!
    19741978!--       Loop over number of turbines:
    1975           DO inot = 1, nturbines
    1976 
    1977              cos_yaw = COS(phi_yaw(inot))
    1978              sin_yaw = SIN(phi_yaw(inot))
     1979          DO inot = 1, n_turbines
     1980
     1981             cos_yaw = COS(yaw_angle(inot))
     1982             sin_yaw = SIN(yaw_angle(inot))
    19791983!
    19801984!--          Loop over rings of each turbine:
     
    20162020!
    20172021!--                Coordinates of the single segments (center points):
    2018                    rbx(ring,rseg) = rcx(inot) + cur_r * rote(1)
    2019                    rby(ring,rseg) = rcy(inot) + cur_r * rote(2)
    2020                    rbz(ring,rseg) = rcz(inot) + cur_r * rote(3)
     2022                   rbx(ring,rseg) = hub_x(inot) + cur_r * rote(1)
     2023                   rby(ring,rseg) = hub_y(inot) + cur_r * rote(2)
     2024                   rbz(ring,rseg) = hub_z(inot) + cur_r * rote(3)
    20212025
    20222026!--                !-----------------------------------------------------------!
     
    21782182!--       Exchange between PEs (information required on each PE):
    21792183#if defined( __parallel )
    2180           CALL MPI_ALLREDUCE( u_int_1_l, u_int, nturbines * MAXVAL(nrings) *   &
     2184          CALL MPI_ALLREDUCE( u_int_1_l, u_int, n_turbines * MAXVAL(nrings) *   &
    21812185                              MAXVAL(nsegs), MPI_REAL, MPI_SUM, comm2d, ierr )
    2182           CALL MPI_ALLREDUCE( v_int_1_l, v_int, nturbines * MAXVAL(nrings) *   &
     2186          CALL MPI_ALLREDUCE( v_int_1_l, v_int, n_turbines * MAXVAL(nrings) *   &
    21832187                              MAXVAL(nsegs), MPI_REAL, MPI_SUM, comm2d, ierr )
    2184           CALL MPI_ALLREDUCE( w_int_1_l, w_int, nturbines * MAXVAL(nrings) *   &
     2188          CALL MPI_ALLREDUCE( w_int_1_l, w_int, n_turbines * MAXVAL(nrings) *   &
    21852189                              MAXVAL(nsegs), MPI_REAL, MPI_SUM, comm2d, ierr )
    21862190#else
     
    21942198!--       Loop over number of turbines:
    21952199
    2196           DO inot = 1, nturbines
     2200          DO inot = 1, n_turbines
    21972201pit_loop: DO
    21982202
     
    22002204                torque_total(inot) = 0.0_wp
    22012205                thrust_rotor(inot) = 0.0_wp
    2202                 pitch_add(inot)    = pitch_add(inot) + 0.25_wp
    2203 !                 IF ( myid == 0 ) PRINT*, 'Pitch', inot, pitch_add(inot)
     2206                pitch_angle(inot)    = pitch_angle(inot) + 0.25_wp
     2207!                 IF ( myid == 0 ) PRINT*, 'Pitch', inot, pitch_angle(inot)
    22042208             ELSE
    2205                 cos_yaw = COS(phi_yaw(inot))
    2206                 sin_yaw = SIN(phi_yaw(inot))
     2209                cos_yaw = COS(yaw_angle(inot))
     2210                sin_yaw = SIN(yaw_angle(inot))
    22072211                IF ( pitch_control )  THEN
    2208                    pitch_add(inot) = MAX(pitch_add_old(inot) - pitch_rate *    &
     2212                   pitch_angle(inot) = MAX(pitch_angle_old(inot) - pitch_rate *    &
    22092213                                         dt_3d , 0.0_wp )
    22102214                ENDIF
     
    22612265!
    22622266!--                Coordinates of the single segments (center points):
    2263                    rbx(ring,rseg) = rcx(inot) + cur_r * rote(1)
    2264 
    2265                    rby(ring,rseg) = rcy(inot) + cur_r * rote(2)
    2266 
    2267                    rbz(ring,rseg) = rcz(inot) + cur_r * rote(3)
     2267                   rbx(ring,rseg) = hub_x(inot) + cur_r * rote(1)
     2268
     2269                   rby(ring,rseg) = hub_y(inot) + cur_r * rote(2)
     2270
     2271                   rbz(ring,rseg) = hub_z(inot) + cur_r * rote(3)
    22682272
    22692273!
     
    22962300
    22972301                   phi_rel(rseg) = ATAN2( u_rot ,                               &
    2298                                          ( omega_rot(inot) * cur_r -           &
     2302                                         ( rotor_speed(inot) * cur_r -          &
    22992303                                           vtheta(rseg) ) )
    23002304
     
    23372341!
    23382342!--                Correct with collective pitch angle:
    2339                    alpha_attack(rseg) = alpha_attack(rseg) - pitch_add(inot)
     2343                   alpha_attack(rseg) = alpha_attack(rseg) - pitch_angle(inot)
    23402344
    23412345!
     
    23432347!--                to the rotor:
    23442348                   vrel(rseg) = SQRT( u_rot**2 +                               &
    2345                                       ( omega_rot(inot) * cur_r -              &
     2349                                      ( rotor_speed(inot) * cur_r -            &
    23462350                                        vtheta(rseg) )**2 )
    23472351
     
    23932397                                        ( (2.0_wp*pi) / 360.0_wp )
    23942398
    2395                    IF ( tl_cor )  THEN
     2399                   IF ( tip_loss_correction )  THEN
    23962400                   
    23972401!--                  Tip loss correction following Schito
     
    24012405!--                 
    24022406                     tl_factor = ( 2.0 / pi ) *                                &
    2403                           ACOS( EXP( -1.0 * ( 3.0 * ( rr(inot) - cur_r ) /     &
     2407                          ACOS( EXP( -1.0 * ( 3.0 * ( rotor_radius(inot) - cur_r ) /     &
    24042408                          ( 2.0 * cur_r * abs( sin( phi_rel(rseg) ) ) ) ) ) )
    24052409                         
     
    24762480!--             the force balance of the accelerating torque
    24772481!--             and the torque of the rotating rotor and generator
    2478                 om_rate = ( torque_total(inot) * air_dens * gear_eff -        &
    2479                             gear_ratio * torque_gen_old(inot) ) /              &
    2480                           ( inertia_rot +                                      &
    2481                             gear_ratio * gear_ratio * inertia_gen ) * dt_3d
     2482                om_rate = ( torque_total(inot) * air_density * gear_efficiency - &
     2483                            gear_ratio * torque_gen_old(inot) ) /                &
     2484                          ( rotor_inertia +                                        &
     2485                            gear_ratio * gear_ratio * generator_inertia ) * dt_3d
    24822486
    24832487!
    24842488!--             The generator speed is given by the product of gear gear_ratio
    24852489!--             and rotor speed
    2486                 omega_gen(inot) = gear_ratio * ( omega_rot(inot) + om_rate )     
     2490                generator_speed(inot) = gear_ratio * ( rotor_speed(inot) + om_rate )     
    24872491             
    24882492             ENDIF
     
    24952499!--             maximum pitch rate, then the pitch loop is repeated with a pitch
    24962500!--             gain
    2497                 IF ( (  omega_gen(inot)  > rated_genspeed   )  .AND.           &
    2498                      ( pitch_add(inot) < 25.0_wp ) .AND.                       &
    2499                      ( pitch_add(inot) < pitch_add_old(inot) +                 &
     2501                IF ( (  generator_speed(inot)  > generator_speed_rated   )  .AND.    &
     2502                     ( pitch_angle(inot) < 25.0_wp ) .AND.                       &
     2503                     ( pitch_angle(inot) < pitch_angle_old(inot) +                 &
    25002504                       pitch_rate * dt_3d  ) ) THEN
    25012505                   pitch_sw = .TRUE.
     
    25072511!
    25082512!--             The current pitch is saved for the next time step
    2509                 pitch_add_old(inot) = pitch_add(inot)
     2513                pitch_angle_old(inot) = pitch_angle(inot)
    25102514                pitch_sw = .FALSE.
    25112515             ENDIF
     
    25542558!--
    25552559!--          Calculation of the boundaries:
    2556              i_smear(inot) = CEILING( ( rr(inot) * ABS( roty(inot,1) ) +       &
     2560             i_smear(inot) = CEILING( ( rotor_radius(inot) * ABS( roty(inot,1) ) +       &
    25572561                                        eps_min ) / dx )
    2558              j_smear(inot) = CEILING( ( rr(inot) * ABS( roty(inot,2) ) +       &
     2562             j_smear(inot) = CEILING( ( rotor_radius(inot) * ABS( roty(inot,2) ) +       &
    25592563                                        eps_min ) / dy )
    25602564
     
    26542658             IF ( start_up )  THEN
    26552659                WDLON = MAX( 1 , NINT( 30.0_wp / dt_3d ) )  ! 30s running mean array
    2656                 ALLOCATE( wd30(1:nturbines,1:WDLON) )
     2660                ALLOCATE( wd30(1:n_turbines,1:WDLON) )
    26572661                wd30 = 999.0_wp                  ! Set to dummy value
    26582662                ALLOCATE( wd30_l(1:WDLON) )
    26592663               
    26602664                WDSHO = MAX( 1 , NINT( 2.0_wp / dt_3d ) )   ! 2s running mean array
    2661                 ALLOCATE( wd2(1:nturbines,1:WDSHO) )
     2665                ALLOCATE( wd2(1:n_turbines,1:WDSHO) )
    26622666                wd2 = 999.0_wp                   ! Set to dummy value
    26632667                ALLOCATE( wd2_l(1:WDSHO) )
     
    26692673!--
    26702674!--          Loop over number of turbines:
    2671              DO inot = 1, nturbines
     2675             DO inot = 1, n_turbines
    26722676!
    26732677!--             Find processor at i_hub, j_hub             
     
    26872691                      CALL wtm_yawcontrol( inot )
    26882692
    2689                       phi_yaw_l(inot) = phi_yaw(inot)
     2693                      yaw_angle_l(inot) = yaw_angle(inot)
    26902694                     
    26912695                   ENDIF
     
    26972701!--          Transfer of information to the other cpus
    26982702#if defined( __parallel )         
    2699              CALL MPI_ALLREDUCE( u_inflow_l, u_inflow, nturbines, MPI_REAL,    &
     2703             CALL MPI_ALLREDUCE( u_inflow_l, u_inflow, n_turbines, MPI_REAL,   &
    27002704                                 MPI_SUM, comm2d, ierr )
    2701              CALL MPI_ALLREDUCE( wdir_l, wdir, nturbines, MPI_REAL, MPI_SUM,   &
     2705             CALL MPI_ALLREDUCE( wdir_l, wdir, n_turbines, MPI_REAL, MPI_SUM,  &
    27022706                                 comm2d, ierr )
    2703              CALL MPI_ALLREDUCE( phi_yaw_l, phi_yaw, nturbines, MPI_REAL,      &
     2707             CALL MPI_ALLREDUCE( yaw_angle_l, yaw_angle, n_turbines, MPI_REAL, &
    27042708                                 MPI_SUM, comm2d, ierr )
    27052709#else
    27062710             u_inflow = u_inflow_l
    27072711             wdir     = wdir_l
    2708              phi_yaw  = phi_yaw_l
     2712             yaw_angle  = yaw_angle_l
    27092713             
    27102714             
    27112715#endif
    2712              DO inot = 1, nturbines
     2716             DO inot = 1, n_turbines
    27132717!             
    27142718!--             Update rotor orientation               
     
    27222726!
    27232727!--          Transfer of information to the other cpus
    2724 !              CALL MPI_ALLREDUCE( omega_gen, omega_gen_old, nturbines,        &
     2728!              CALL MPI_ALLREDUCE( generator_speed, generator_speed_old, n_turbines,        &
    27252729!                                  MPI_REAL,MPI_SUM, comm2d, ierr )
    27262730#if defined( __parallel )   
    2727              CALL MPI_ALLREDUCE( torque_gen, torque_gen_old, nturbines,        &
     2731             CALL MPI_ALLREDUCE( torque_gen, torque_gen_old, n_turbines,                           &
    27282732                                 MPI_REAL, MPI_SUM, comm2d, ierr )
    2729              CALL MPI_ALLREDUCE( omega_rot_l, omega_rot, nturbines,            &
     2733             CALL MPI_ALLREDUCE( rotor_speed_l, rotor_speed, n_turbines,                           &
    27302734                                 MPI_REAL, MPI_SUM, comm2d, ierr )
    2731              CALL MPI_ALLREDUCE( omega_gen_f, omega_gen_f_old, nturbines,      &
     2735             CALL MPI_ALLREDUCE( generator_speed_f, generator_speed_f_old, n_turbines,             &
    27322736                                 MPI_REAL, MPI_SUM, comm2d, ierr )
    27332737#else
    27342738             torque_gen_old  = torque_gen
    2735              omega_rot       = omega_rot_l
    2736              omega_gen_f_old = omega_gen_f
     2739             rotor_speed       = rotor_speed_l
     2740             generator_speed_f_old = generator_speed_f
    27372741#endif
    27382742           
     
    27422746         
    27432747         
    2744           DO inot = 1, nturbines
     2748          DO inot = 1, n_turbines
    27452749
    27462750
     
    27482752             IF ( myid == 0 ) THEN
    27492753                IF ( openfile_turb_mod(400+inot)%opened )  THEN
    2750                    WRITE ( 400+inot, 106 ) time_since_reference_point, omega_rot(inot),    &
    2751                              omega_gen(inot), torque_gen_old(inot),            &
    2752                              torque_total(inot), pitch_add(inot),              &
    2753                              torque_gen_old(inot)*omega_gen(inot)*gen_eff,     &
    2754                              torque_total(inot)*omega_rot(inot)*air_dens,      &
    2755                              thrust_rotor(inot),                               &
    2756                              wdir(inot)*180.0_wp/pi,                           &
    2757                              (phi_yaw(inot))*180.0_wp/pi                   
     2754                   WRITE ( 400+inot, 106 ) time_since_reference_point, rotor_speed(inot),          &
     2755                             generator_speed(inot), torque_gen_old(inot),                          &
     2756                             torque_total(inot), pitch_angle(inot),                                &
     2757                             torque_gen_old(inot)*generator_speed(inot)*generator_efficiency,      &
     2758                             torque_total(inot)*rotor_speed(inot)*air_density,                     &
     2759                             thrust_rotor(inot),                                                   &
     2760                             wdir(inot)*180.0_wp/pi,                                               &
     2761                             (yaw_angle(inot))*180.0_wp/pi                   
    27582762                             
    27592763                ELSE
     
    27642768                                           turbine_id ), FORM='FORMATTED' )
    27652769                   WRITE ( 400+inot, 105 ) inot
    2766                    WRITE ( 400+inot, 106 ) time_since_reference_point, omega_rot(inot),    &
    2767                              omega_gen(inot), torque_gen_old(inot),            &
    2768                              torque_total(inot), pitch_add(inot),              &
    2769                              torque_gen_old(inot)*omega_gen(inot)*gen_eff,     &
    2770                              torque_total(inot)*omega_rot(inot)*air_dens,      &
    2771                              thrust_rotor(inot),                               &
    2772                              wdir(inot)*180.0_wp/pi,                           &                   
    2773                              (phi_yaw(inot))*180.0_wp/pi
     2770                   WRITE ( 400+inot, 106 ) time_since_reference_point, rotor_speed(inot),          &
     2771                             generator_speed(inot), torque_gen_old(inot),                          &
     2772                             torque_total(inot), pitch_angle(inot),                                &
     2773                             torque_gen_old(inot)*generator_speed(inot)*generator_efficiency,      &
     2774                             torque_total(inot)*rotor_speed(inot)*air_density,                     &
     2775                             thrust_rotor(inot),                                                   &
     2776                             wdir(inot)*180.0_wp/pi,                                               &
     2777                             (yaw_angle(inot))*180.0_wp/pi
    27742778                ENDIF
    27752779             ENDIF
     
    28432847          IF ( .NOT. ANY( wd30_l == 999.) ) THEN
    28442848
    2845              missal = SUM( wd30_l ) / SIZE( wd30_l ) - phi_yaw(inot)
    2846 !
    2847 !--          Check if turbine is missaligned by more than max_miss
    2848              IF ( ABS( missal ) > max_miss )  THEN
     2849             missal = SUM( wd30_l ) / SIZE( wd30_l ) - yaw_angle(inot)
     2850!
     2851!--          Check if turbine is missaligned by more than yaw_misalignment_max
     2852             IF ( ABS( missal ) > yaw_misalignment_max )  THEN
    28492853!
    28502854!--             Check in which direction to yaw         
     
    28522856!
    28532857!--             Start yawing of turbine
    2854                 phi_yaw(inot) = phi_yaw(inot) + yawdir(inot) * yaw_speed * dt_3d
     2858                yaw_angle(inot) = yaw_angle(inot) + yawdir(inot) * yaw_speed * dt_3d
    28552859                doyaw(inot) = .TRUE.
    28562860                wd30_l = 999.  ! fill with dummies again
     
    28632867!--    If turbine is already yawing:
    28642868!--    Initialize 2 s running mean and yaw until the missalignment is smaller
    2865 !--    than min_miss
     2869!--    than yaw_misalignment_min
    28662870
    28672871       ELSE
     
    28762880!
    28772881!--          Calculate missalignment of turbine       
    2878              missal = SUM( wd2_l - phi_yaw(inot) ) / SIZE( wd2_l )
     2882             missal = SUM( wd2_l - yaw_angle(inot) ) / SIZE( wd2_l )
    28792883!
    28802884!--          Check if missalignment is still larger than 0.5 degree and if the
    28812885!--          yaw direction is still right
    2882              IF ( ( ABS( missal ) > min_miss )  .AND.                          &
     2886             IF ( ( ABS( missal ) > yaw_misalignment_min )  .AND.              &
    28832887                  ( yawdir(inot) == SIGN( 1.0_wp, missal ) ) )  THEN
    28842888!
    28852889!--             Continue yawing       
    2886                 phi_yaw(inot) = phi_yaw(inot) + yawdir(inot) * yaw_speed * dt_3d
     2890                yaw_angle(inot) = yaw_angle(inot) + yawdir(inot) * yaw_speed * dt_3d
    28872891             ELSE
    28882892!
     
    28942898!
    28952899!--          Continue yawing
    2896              phi_yaw(inot) = phi_yaw(inot) + yawdir(inot) * yaw_speed * dt_3d
     2900             yaw_angle(inot) = yaw_angle(inot) + yawdir(inot) * yaw_speed * dt_3d
    28972901          ENDIF
    28982902     
     
    29192923!
    29202924!--    Calculate slope constant for region 15
    2921        slope15   = ( slope2 * min_reg2 * min_reg2 ) / ( min_reg2 - min_reg15 )
     2925       slope15         = ( region_2_slope * region_2_min * region_2_min ) /                        &
     2926                         ( region_2_min - region_15_min )
    29222927!
    29232928!--    Calculate upper limit of slipage region
    2924        vs_sysp   = rated_genspeed / 1.1_wp
     2929       vs_sysp         = generator_speed_rated / 1.1_wp
    29252930!
    29262931!--    Calculate slope of slipage region
    2927        slope25   = ( rated_power / rated_genspeed ) /                          &
    2928                    ( rated_genspeed - vs_sysp )
     2932       region_25_slope = ( generator_power_rated / generator_speed_rated ) /                       &
     2933                       ( generator_speed_rated - vs_sysp )
    29292934!
    29302935!--    Calculate lower limit of slipage region
    2931        min_reg25 = ( slope25 - SQRT( slope25 * ( slope25 - 4.0_wp *            &
    2932                                                  slope2 * vs_sysp ) ) ) /      &
    2933                    ( 2.0_wp * slope2 )
     2936       region_25_min   = ( region_25_slope - SQRT( region_25_slope *                               &
     2937                         ( region_25_slope - 4.0_wp * region_2_slope * vs_sysp ) ) ) /             &
     2938                         ( 2.0_wp * region_2_slope )
    29342939!
    29352940!--    Frequency for the simple low pass filter
    2936        Fcorner   = 0.25_wp
     2941       Fcorner       = 0.25_wp
    29372942!
    29382943!--    At the first timestep the torque is set to its maximum to prevent
    29392944!--    an overspeeding of the rotor
    29402945       IF ( TRIM( initializing_actions ) /= 'read_restart_data' ) THEN
    2941           torque_gen_old(:) = max_torque_gen
     2946          torque_gen_old(:) = generator_torque_max
    29422947       ENDIF 
    29432948     
     
    29682973!--    for the control of the generator torque       
    29692974       lp_coeff = EXP( -2.0_wp * 3.14_wp * dt_3d * Fcorner )
    2970        omega_gen_f(inot) = ( 1.0_wp - lp_coeff ) * omega_gen(inot) + lp_coeff *&
    2971                            omega_gen_f_old(inot)
    2972 
    2973        IF ( omega_gen_f(inot) <= min_reg15 )  THEN
     2975       generator_speed_f(inot) = ( 1.0_wp - lp_coeff ) * generator_speed(inot) + lp_coeff *&
     2976                           generator_speed_f_old(inot)
     2977
     2978       IF ( generator_speed_f(inot) <= region_15_min )  THEN
    29742979!                       
    29752980!--       Region 1: Generator torque is set to zero to accelerate the rotor:
    29762981          torque_gen(inot) = 0
    29772982       
    2978        ELSEIF ( omega_gen_f(inot) <= min_reg2 )  THEN
     2983       ELSEIF ( generator_speed_f(inot) <= region_2_min )  THEN
    29792984!                       
    29802985!--       Region 1.5: Generator torque is increasing linearly with rotor speed:
    2981           torque_gen(inot) = slope15 * ( omega_gen_f(inot) - min_reg15 )
     2986          torque_gen(inot) = slope15 * ( generator_speed_f(inot) - region_15_min )
    29822987                         
    2983        ELSEIF ( omega_gen_f(inot) <= min_reg25 )  THEN
     2988       ELSEIF ( generator_speed_f(inot) <= region_25_min )  THEN
    29842989!
    29852990!--       Region 2: Generator torque is increased by the square of the generator
    29862991!--                 speed to keep the TSR optimal:
    2987           torque_gen(inot) = slope2 * omega_gen_f(inot) * omega_gen_f(inot)
     2992          torque_gen(inot) = region_2_slope * generator_speed_f(inot) * generator_speed_f(inot)
    29882993       
    2989        ELSEIF ( omega_gen_f(inot) < rated_genspeed )  THEN
     2994       ELSEIF ( generator_speed_f(inot) < generator_speed_rated )  THEN
    29902995!                       
    29912996!--       Region 2.5: Slipage region between 2 and 3:
    2992           torque_gen(inot) = slope25 * ( omega_gen_f(inot) - vs_sysp )
     2997          torque_gen(inot) = region_25_slope * ( generator_speed_f(inot) - vs_sysp )
    29932998       
    29942999       ELSE
     
    29963001!--       Region 3: Generator torque is antiproportional to the rotor speed to
    29973002!--                 keep the power constant:
    2998           torque_gen(inot) = rated_power / omega_gen_f(inot)
     3003          torque_gen(inot) = generator_power_rated / generator_speed_f(inot)
    29993004       
    30003005       ENDIF
     
    30023007!--    Calculate torque rate and confine with a max
    30033008       trq_rate = ( torque_gen(inot) - torque_gen_old(inot) ) / dt_3d
    3004        trq_rate = MIN( MAX( trq_rate, -1.0_wp * max_trq_rate ), max_trq_rate )
     3009       trq_rate = MIN( MAX( trq_rate, -1.0_wp * generator_torque_rate_max ), &
     3010                  generator_torque_rate_max )
    30053011!                       
    30063012!--    Calculate new gen torque and confine with max torque                         
    30073013       torque_gen(inot) = torque_gen_old(inot) + trq_rate * dt_3d
    3008        torque_gen(inot) = MIN( torque_gen(inot), max_torque_gen )                                             
     3014       torque_gen(inot) = MIN( torque_gen(inot), generator_torque_max )                                             
    30093015!
    30103016!--    Overwrite values for next timestep                       
    3011        omega_rot_l(inot) = omega_gen(inot) / gear_ratio
     3017       rotor_speed_l(inot) = generator_speed(inot) / gear_ratio
    30123018
    30133019   
     
    31943200!--       At the first call of this routine write the spatial coordinates.
    31953201          IF ( .NOT. initial_write_coordinates )  THEN
    3196              ALLOCATE ( output_values_1d_target(1:nturbines) )
    3197              output_values_1d_target = rcx(1:nturbines)
     3202             ALLOCATE ( output_values_1d_target(1:n_turbines) )
     3203             output_values_1d_target = hub_x(1:n_turbines)
    31983204             output_values_1d_pointer => output_values_1d_target     
    31993205             return_value = dom_write_var( nc_filename,                              &
     
    32013207                                        values_realwp_1d = output_values_1d_pointer, &
    32023208                                        bounds_start = (/1/),                        &
    3203                                         bounds_end   = (/nturbines/) )
    3204 
    3205              output_values_1d_target = rcy(1:nturbines)
     3209                                        bounds_end   = (/n_turbines/) )
     3210
     3211             output_values_1d_target = hub_y(1:n_turbines)
    32063212             output_values_1d_pointer => output_values_1d_target     
    32073213             return_value = dom_write_var( nc_filename,                              &
     
    32093215                                        values_realwp_1d = output_values_1d_pointer, &
    32103216                                        bounds_start = (/1/),                        &
    3211                                         bounds_end   = (/nturbines/) )
    3212 
    3213              output_values_1d_target = rcz(1:nturbines)
     3217                                        bounds_end   = (/n_turbines/) )
     3218
     3219             output_values_1d_target = hub_z(1:n_turbines)
    32143220             output_values_1d_pointer => output_values_1d_target     
    32153221             return_value = dom_write_var( nc_filename,                              &
     
    32173223                                        values_realwp_1d = output_values_1d_pointer, &
    32183224                                        bounds_start = (/1/),                        &
    3219                                         bounds_end   = (/nturbines/) )                                       
     3225                                        bounds_end   = (/n_turbines/) )                                       
    32203226                                       
    32213227             initial_write_coordinates = .TRUE.
     
    32253231          t_ind = t_ind + 1
    32263232         
    3227           ALLOCATE ( output_values_1d_target(1:nturbines) )
    3228           output_values_1d_target = omega_rot(:)
     3233          ALLOCATE ( output_values_1d_target(1:n_turbines) )
     3234          output_values_1d_target = rotor_speed(:)
    32293235          output_values_1d_pointer => output_values_1d_target
    32303236         
     
    32333239                                        values_realwp_1d = output_values_1d_pointer, &
    32343240                                        bounds_start = (/1, t_ind/),                 &
    3235                                         bounds_end   = (/nturbines, t_ind /) )
    3236 
    3237           output_values_1d_target = omega_gen(:)
     3241                                        bounds_end   = (/n_turbines, t_ind /) )
     3242
     3243          output_values_1d_target = generator_speed(:)
    32383244          output_values_1d_pointer => output_values_1d_target   
    32393245          return_value = dom_write_var( nc_filename,                                 &
     
    32413247                                        values_realwp_1d = output_values_1d_pointer, &
    32423248                                        bounds_start = (/1, t_ind/),                 &
    3243                                         bounds_end   = (/nturbines, t_ind /) )
     3249                                        bounds_end   = (/n_turbines, t_ind /) )
    32443250
    32453251          output_values_1d_target = torque_gen_old(:)
     
    32503256                                        values_realwp_1d = output_values_1d_pointer, &
    32513257                                        bounds_start = (/1, t_ind/),                 &
    3252                                         bounds_end   = (/nturbines, t_ind /) )
     3258                                        bounds_end   = (/n_turbines, t_ind /) )
    32533259
    32543260          output_values_1d_target = torque_total(:)
     
    32593265                                        values_realwp_1d = output_values_1d_pointer, &
    32603266                                        bounds_start = (/1, t_ind/),                 &
    3261                                         bounds_end   = (/nturbines, t_ind /) )
    3262 
    3263           output_values_1d_target = pitch_add(:)
     3267                                        bounds_end   = (/n_turbines, t_ind /) )
     3268
     3269          output_values_1d_target = pitch_angle(:)
    32643270          output_values_1d_pointer => output_values_1d_target   
    32653271
     
    32683274                                        values_realwp_1d = output_values_1d_pointer, &
    32693275                                        bounds_start = (/1, t_ind/),                 &
    3270                                         bounds_end   = (/nturbines, t_ind /) )
    3271 
    3272           output_values_1d_target = torque_gen_old(:)*omega_gen(:)*gen_eff
     3276                                        bounds_end   = (/n_turbines, t_ind /) )
     3277
     3278          output_values_1d_target = torque_gen_old(:)*generator_speed(:)*generator_efficiency
    32733279          output_values_1d_pointer => output_values_1d_target   
    32743280   
     
    32773283                                        values_realwp_1d = output_values_1d_pointer, &
    32783284                                        bounds_start = (/1, t_ind/),                 &
    3279                                         bounds_end   = (/nturbines, t_ind /) )
    3280 
    3281           DO inot = 1, nturbines
    3282              output_values_1d_target(inot) = torque_total(inot)*omega_rot(inot)*air_dens
     3285                                        bounds_end   = (/n_turbines, t_ind /) )
     3286
     3287          DO inot = 1, n_turbines
     3288             output_values_1d_target(inot) = torque_total(inot)*rotor_speed(inot)*air_density
    32833289          ENDDO
    32843290          output_values_1d_pointer => output_values_1d_target   
     
    32883294                                        values_realwp_1d = output_values_1d_pointer, &
    32893295                                        bounds_start = (/1, t_ind/),                 &
    3290                                         bounds_end   = (/nturbines, t_ind /) )
     3296                                        bounds_end   = (/n_turbines, t_ind /) )
    32913297
    32923298          output_values_1d_target = thrust_rotor(:)
     
    32973303                                        values_realwp_1d = output_values_1d_pointer, &
    32983304                                        bounds_start = (/1, t_ind/),                 &
    3299                                         bounds_end   = (/nturbines, t_ind /) )
     3305                                        bounds_end   = (/n_turbines, t_ind /) )
    33003306
    33013307          output_values_1d_target = wdir(:)*180.0_wp/pi
     
    33063312                                        values_realwp_1d = output_values_1d_pointer, &
    33073313                                        bounds_start = (/1, t_ind/),                 &
    3308                                         bounds_end   = (/nturbines, t_ind /) )
    3309 
    3310           output_values_1d_target = (phi_yaw(:))*180.0_wp/pi
     3314                                        bounds_end   = (/n_turbines, t_ind /) )
     3315
     3316          output_values_1d_target = (yaw_angle(:))*180.0_wp/pi
    33113317          output_values_1d_pointer => output_values_1d_target   
    33123318
     
    33153321                                        values_realwp_1d = output_values_1d_pointer, &
    33163322                                        bounds_start = (/1, t_ind/),                 &
    3317                                         bounds_end   = (/nturbines, t_ind /) )
     3323                                        bounds_end   = (/n_turbines, t_ind /) )
    33183324
    33193325          output_values_0d_target = time_since_reference_point
     
    33233329                                        'time',                                      &
    33243330                                        values_realwp_0d = output_values_0d_pointer, &
    3325                                            bounds_start = (/t_ind/),                    &
     3331                                           bounds_start = (/t_ind/),                 &
    33263332                                     bounds_end   = (/t_ind/) )         
    33273333         
  • palm/trunk/TESTS/cases/wind_turbine_model/INPUT/wind_turbine_model_p3d

    r4069 r4447  
    3838         time_turbine_on  = 1.0,
    3939
    40          nturbines = 4,
    41          rcx =   300.0, 600.0, 300.0, 600.0,
    42          rcy =   300.0, 300.0, 600.0, 600.0,
    43          rcz =   480.0, 480.0, 480.0, 480.0,
    44          rr  =    63.0, 63.0, 63.0, 63.0,
    45          rnac =    1.5, 1.5, 1.5, 1.5,
    46          dtow =    4.0, 4.0, 4.0, 4.0,
     40         n_turbines = 4,
     41         hub_x =   300.0, 600.0, 300.0, 600.0,
     42         hub_y =   300.0, 300.0, 600.0, 600.0,
     43         hub_z =   480.0, 480.0, 480.0, 480.0,
     44         rotor_radius  =    63.0, 63.0, 63.0, 63.0,
     45         nacelle_radius =    1.5, 1.5, 1.5, 1.5,
     46         tower_diameter =    4.0, 4.0, 4.0, 4.0,
    4747
    48          omega_rot = 0.9, 0.9, 0.9, 0.9,
    49          phi_yaw = -20.0, 10.0, 0.0, 30.0,
    50          tilt = 0.0,
    51          rated_power = 5296610.0,
     48         rotor_speed = 0.9, 0.9, 0.9, 0.9,
     49         yaw_angle = -20.0, 10.0, 0.0, 30.0,
     50         tilt_angle = 0.0,
     51         generator_power_rated = 5296610.0,
    5252         speed_control = .T.,
    5353         pitch_control = .T.,
    54          pitch_add = 0.0,
     54         pitch_angle = 0.0,
    5555         yaw_control = .T.,
    5656         yaw_speed = 0.01,
    5757   
    58          turb_cd_tower   = 1.2, 1.2, 1.2, 1.2,
     58         tower_cd   = 1.2, 1.2, 1.2, 1.2,
    5959       
    60          segment_length = 1.0,
    61          segment_width  = 0.5,
     60         segment_length_tangential = 1.0,
     61         segment_width_radial  = 0.5,
    6262       
    63          nairfoils = 8, /
     63         n_airfoils = 8, /
Note: See TracChangeset for help on using the changeset viewer.