source: palm/trunk/SOURCE/init_rankine.f90 @ 4481

Last change on this file since 4481 was 4457, checked in by raasch, 4 years ago

ghost point exchange modularized, bugfix for wrong 2d-exchange

  • Property svn:keywords set to Id
File size: 5.8 KB
Line 
1!> @file init_rankine.f90
2!------------------------------------------------------------------------------!
3! This file is part of the PALM model system.
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 1997-2020 Leibniz Universitaet Hannover
18!------------------------------------------------------------------------------!
19!
20! Current revisions:
21! -----------------
22!
23!
24! Former revisions:
25! -----------------
26! $Id: init_rankine.f90 4457 2020-03-11 14:20:43Z maronga $
27! use statement for exchange horiz added
28!
29! 4360 2020-01-07 11:25:50Z suehring
30! Corrected "Former revisions" section
31!
32! 3655 2019-01-07 16:51:22Z knoop
33! Modularization of all bulk cloud physics code components
34!
35! Revision 1.1  1997/08/11 06:18:43  raasch
36! Initial revision
37!
38!
39! Description:
40! ------------
41!> Initialize a (nondivergent) Rankine eddy with a vertical axis in order to test
42!> the advection terms and the pressure solver.
43!------------------------------------------------------------------------------!
44 SUBROUTINE init_rankine
45 
46
47    USE arrays_3d,                                                             &
48        ONLY:  pt, pt_init, u, u_init, v, v_init
49
50    USE control_parameters,                                                    &
51        ONLY:  initializing_actions, n_sor, nsor, nsor_ini   
52
53    USE basic_constants_and_equations_mod,                                     &
54        ONLY:  pi
55
56    USE exchange_horiz_mod,                                                    &
57        ONLY:  exchange_horiz
58
59    USE grid_variables,                                                        &
60        ONLY:  dx, dy 
61
62    USE indices,                                                               &
63        ONLY:  nbgp, nx, nxl, nxlg, nxr, nxrg, nyn, nyng, nys, nysg, nzb, nzt     
64               
65    USE kinds
66
67    IMPLICIT NONE
68
69    INTEGER(iwp) ::  i   !<
70    INTEGER(iwp) ::  ic  !<
71    INTEGER(iwp) ::  j   !<
72    INTEGER(iwp) ::  jc  !<
73    INTEGER(iwp) ::  k   !<
74    INTEGER(iwp) ::  kc1 !<
75    INTEGER(iwp) ::  kc2 !<
76   
77    REAL(wp)     ::  alpha  !<
78    REAL(wp)     ::  betrag !<
79    REAL(wp)     ::  radius !<
80    REAL(wp)     ::  rc     !<
81    REAL(wp)     ::  uw     !<
82    REAL(wp)     ::  vw     !<
83    REAL(wp)     ::  x      !<
84    REAL(wp)     ::  y      !<
85
86!
87!-- Default: eddy radius rc, eddy strength z,
88!--          position of eddy centre: ic, jc, kc1, kc2
89    rc  =  4.0_wp * dx
90    ic  =  ( nx+1 ) / 2
91    jc  =  ic
92    kc1 = nzb
93    kc2 = nzt+1
94
95!
96!-- Reset initial profiles to constant profiles
97    IF ( INDEX(initializing_actions, 'set_constant_profiles') /= 0 )  THEN
98       DO  i = nxlg, nxrg
99          DO  j = nysg, nyng
100             pt(:,j,i) = pt_init
101             u(:,j,i)  = u_init
102             v(:,j,i)  = v_init
103          ENDDO
104       ENDDO
105    ENDIF
106
107!
108!-- Compute the u-component.
109    DO  i = nxl, nxr
110       DO  j = nys, nyn
111          x = ( i - ic - 0.5_wp ) * dx
112          y = ( j - jc          ) * dy
113          radius = SQRT( x**2 + y**2 )
114          IF ( radius <= 2.0_wp * rc )  THEN
115             betrag = radius / ( 2.0_wp * rc ) * 0.08_wp
116          ELSEIF ( radius > 2.0_wp * rc  .AND.  radius < 8.0_wp * rc )  THEN
117             betrag = 0.08_wp * EXP( -( radius - 2.0_wp * rc ) / 2.0_wp )
118          ELSE
119             betrag = 0.0_wp
120          ENDIF
121
122          IF ( x == 0.0_wp )  THEN
123             IF ( y > 0.0_wp )  THEN
124                alpha = pi / 2.0_wp
125             ELSEIF ( y < 0.0_wp )  THEN
126                alpha = 3.0_wp * pi / 2.0_wp
127             ENDIF
128          ELSE
129             IF ( x < 0.0_wp )  THEN
130                alpha = ATAN( y / x ) + pi
131             ELSE
132                IF ( y < 0.0_wp )  THEN
133                   alpha = ATAN( y / x ) + 2.0_wp * pi
134                ELSE
135                   alpha = ATAN( y / x )
136                ENDIF
137             ENDIF
138          ENDIF
139
140          uw = -SIN( alpha ) * betrag
141
142          DO  k = kc1, kc2
143             u(k,j,i) = u(k,j,i) + uw
144          ENDDO
145       ENDDO
146    ENDDO
147
148!
149!-- Compute the v-component.
150    DO  i = nxl, nxr
151       DO  j = nys, nyn
152          x = ( i - ic          ) * dx
153          y = ( j - jc - 0.5_wp ) * dy
154          radius = SQRT( x**2 + y**2 )
155          IF ( radius <= 2.0_wp * rc )  THEN
156             betrag = radius / ( 2.0_wp * rc ) * 0.08_wp
157          ELSEIF ( radius > 2.0_wp * rc  .AND.  radius < 8.0_wp * rc )  THEN
158             betrag = 0.08_wp * EXP( -( radius - 2.0_wp * rc ) / 2.0_wp )
159          ELSE
160             betrag = 0.0_wp
161          ENDIF
162
163          IF ( x == 0.0_wp )  THEN
164             IF ( y > 0.0_wp )  THEN
165                alpha = pi / 2.0_wp
166             ELSEIF ( y < 0.0_wp )  THEN
167                alpha = 3.0_wp * pi / 2.0_wp
168             ENDIF
169          ELSE
170             IF ( x < 0.0_wp )  THEN
171                alpha = ATAN( y / x ) + pi
172             ELSE
173                IF ( y < 0.0_wp )  THEN
174                   alpha = ATAN( y / x ) + 2.0_wp * pi
175                ELSE
176                   alpha = ATAN( y / x )
177                ENDIF
178             ENDIF
179          ENDIF
180
181          vw = COS( alpha ) * betrag
182
183          DO  k = kc1, kc2
184             v(k,j,i) = v(k,j,i) + vw
185          ENDDO
186       ENDDO
187    ENDDO
188
189!
190!-- Exchange of boundary values for the velocities.
191    CALL exchange_horiz( u, nbgp)
192    CALL exchange_horiz( v, nbgp )
193!
194!-- Make velocity field nondivergent.
195    n_sor = nsor_ini
196    CALL pres
197    n_sor = nsor
198
199 END SUBROUTINE init_rankine
Note: See TracBrowser for help on using the repository browser.