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

Last change on this file since 1353 was 1353, checked in by heinze, 10 years ago

REAL constants provided with KIND-attribute

  • Property svn:keywords set to Id
File size: 6.0 KB
Line 
1 SUBROUTINE init_rankine
2
3!--------------------------------------------------------------------------------!
4! This file is part of PALM.
5!
6! PALM is free software: you can redistribute it and/or modify it under the terms
7! of the GNU General Public License as published by the Free Software Foundation,
8! either version 3 of the License, or (at your option) any later 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-2014 Leibniz Universitaet Hannover
18!--------------------------------------------------------------------------------!
19!
20! Current revisions:
21! -----------------
22! REAL constants provided with KIND-attribute
23!
24! Former revisions:
25! -----------------
26! $Id: init_rankine.f90 1353 2014-04-08 15:21:23Z heinze $
27!
28! 1322 2014-03-20 16:38:49Z raasch
29! REAL constants defined as wp_kind
30!
31! 1320 2014-03-20 08:40:49Z raasch
32! ONLY-attribute added to USE-statements,
33! kind-parameters added to all INTEGER and REAL declaration statements,
34! kinds are defined in new module kinds,
35! revision history before 2012 removed,
36! comment fields (!:) to be used for variable explanations added to
37! all variable declaration statements
38!
39! 1036 2012-10-22 13:43:42Z raasch
40! code put under GPL (PALM 3.9)
41!
42! Revision 1.1  1997/08/11 06:18:43  raasch
43! Initial revision
44!
45!
46! Description:
47! ------------
48! Initialize a (nondivergent) Rankine eddy with a vertical axis in order to test
49! the advection terms and the pressure solver.
50!------------------------------------------------------------------------------!
51
52    USE arrays_3d,                                                             &
53        ONLY:  pt, pt_init, u, u_init, v, v_init
54
55    USE control_parameters,                                                    &
56        ONLY:  initializing_actions, n_sor, nsor, nsor_ini   
57
58    USE constants,                                                             &
59        ONLY:  pi
60
61    USE grid_variables,                                                        &
62        ONLY:  dx, dy 
63
64    USE indices,                                                               &
65        ONLY:  nbgp, nx, nxl, nxlg, nxr, nxrg, nyn, nyng, nys, nysg, nzb, nzt     
66               
67    USE kinds
68
69    IMPLICIT NONE
70
71    INTEGER(iwp) ::  i   !:
72    INTEGER(iwp) ::  ic  !:
73    INTEGER(iwp) ::  j   !:
74    INTEGER(iwp) ::  jc  !:
75    INTEGER(iwp) ::  k   !:
76    INTEGER(iwp) ::  kc1 !:
77    INTEGER(iwp) ::  kc2 !:
78   
79    REAL(wp)     ::  alpha  !:
80    REAL(wp)     ::  betrag !:
81    REAL(wp)     ::  radius !:
82    REAL(wp)     ::  rc     !:
83    REAL(wp)     ::  uw     !:
84    REAL(wp)     ::  vw     !:
85    REAL(wp)     ::  x      !:
86    REAL(wp)     ::  y      !:
87
88!
89!-- Default: eddy radius rc, eddy strength z,
90!--          position of eddy centre: ic, jc, kc1, kc2
91    rc  =  4.0_wp * dx
92    ic  =  ( nx+1 ) / 2
93    jc  =  ic
94    kc1 = nzb
95    kc2 = nzt+1
96
97!
98!-- Reset initial profiles to constant profiles
99    IF ( INDEX(initializing_actions, 'set_constant_profiles') /= 0 )  THEN
100       DO  i = nxlg, nxrg
101          DO  j = nysg, nyng
102             pt(:,j,i) = pt_init
103             u(:,j,i)  = u_init
104             v(:,j,i)  = v_init
105          ENDDO
106       ENDDO
107    ENDIF
108
109!
110!-- Compute the u-component.
111    DO  i = nxl, nxr
112       DO  j = nys, nyn
113          x = ( i - ic - 0.5_wp ) * dx
114          y = ( j - jc          ) * dy
115          radius = SQRT( x**2 + y**2 )
116          IF ( radius <= 2.0_wp * rc )  THEN
117             betrag = radius / ( 2.0_wp * rc ) * 0.08_wp
118          ELSEIF ( radius > 2.0_wp * rc  .AND.  radius < 8.0_wp * rc )  THEN
119             betrag = 0.08_wp * EXP( -( radius - 2.0_wp * rc ) / 2.0_wp )
120          ELSE
121             betrag = 0.0_wp
122          ENDIF
123
124          IF ( x == 0.0_wp )  THEN
125             IF ( y > 0.0_wp )  THEN
126                alpha = pi / 2.0_wp
127             ELSEIF ( y < 0.0_wp )  THEN
128                alpha = 3.0_wp * pi / 2.0_wp
129             ENDIF
130          ELSE
131             IF ( x < 0.0_wp )  THEN
132                alpha = ATAN( y / x ) + pi
133             ELSE
134                IF ( y < 0.0_wp )  THEN
135                   alpha = ATAN( y / x ) + 2.0_wp * pi
136                ELSE
137                   alpha = ATAN( y / x )
138                ENDIF
139             ENDIF
140          ENDIF
141
142          uw = -SIN( alpha ) * betrag
143
144          DO  k = kc1, kc2
145             u(k,j,i) = u(k,j,i) + uw
146          ENDDO
147       ENDDO
148    ENDDO
149
150!
151!-- Compute the v-component.
152    DO  i = nxl, nxr
153       DO  j = nys, nyn
154          x = ( i - ic          ) * dx
155          y = ( j - jc - 0.5_wp ) * dy
156          radius = SQRT( x**2 + y**2 )
157          IF ( radius <= 2.0_wp * rc )  THEN
158             betrag = radius / ( 2.0_wp * rc ) * 0.08_wp
159          ELSEIF ( radius > 2.0_wp * rc  .AND.  radius < 8.0_wp * rc )  THEN
160             betrag = 0.08_wp * EXP( -( radius - 2.0_wp * rc ) / 2.0_wp )
161          ELSE
162             betrag = 0.0_wp
163          ENDIF
164
165          IF ( x == 0.0_wp )  THEN
166             IF ( y > 0.0_wp )  THEN
167                alpha = pi / 2.0_wp
168             ELSEIF ( y < 0.0_wp )  THEN
169                alpha = 3.0_wp * pi / 2.0_wp
170             ENDIF
171          ELSE
172             IF ( x < 0.0_wp )  THEN
173                alpha = ATAN( y / x ) + pi
174             ELSE
175                IF ( y < 0.0_wp )  THEN
176                   alpha = ATAN( y / x ) + 2.0_wp * pi
177                ELSE
178                   alpha = ATAN( y / x )
179                ENDIF
180             ENDIF
181          ENDIF
182
183          vw = COS( alpha ) * betrag
184
185          DO  k = kc1, kc2
186             v(k,j,i) = v(k,j,i) + vw
187          ENDDO
188       ENDDO
189    ENDDO
190
191!
192!-- Exchange of boundary values for the velocities.
193    CALL exchange_horiz( u, nbgp)
194    CALL exchange_horiz( v, nbgp )
195!
196!-- Make velocity field nondivergent.
197    n_sor = nsor_ini
198    CALL pres
199    n_sor = nsor
200
201 END SUBROUTINE init_rankine
Note: See TracBrowser for help on using the repository browser.