SICOPOLIS V3.2
 All Classes Files Functions Variables Macros
metric.F90
Go to the documentation of this file.
1 !+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
2 !
3 ! Subroutine : m e t r i c
4 !
5 !> @file
6 !!
7 !! Definition of the components g11 and g22 of the metric tensor of the
8 !! applied coordinates.
9 !!
10 !! @section Copyright
11 !!
12 !! Copyright 2009-2016 Ralf Greve
13 !!
14 !! @section License
15 !!
16 !! This file is part of SICOPOLIS.
17 !!
18 !! SICOPOLIS is free software: you can redistribute it and/or modify
19 !! it under the terms of the GNU General Public License as published by
20 !! the Free Software Foundation, either version 3 of the License, or
21 !! (at your option) any later version.
22 !!
23 !! SICOPOLIS is distributed in the hope that it will be useful,
24 !! but WITHOUT ANY WARRANTY; without even the implied warranty of
25 !! MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
26 !! GNU General Public License for more details.
27 !!
28 !! You should have received a copy of the GNU General Public License
29 !! along with SICOPOLIS. If not, see <http://www.gnu.org/licenses/>.
30 !<
31 !+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
32 
33 !-------------------------------------------------------------------------------
34 !> Definition of the components g11 and g22 of the metric tensor of the
35 !! applied coordinates.
36 !<------------------------------------------------------------------------------
37 subroutine metric()
38 
39 use sico_types
41 use sico_vars
42 
43 implicit none
44 integer(i4b) :: i, j
45 real(dp) :: k
46 real(dp) :: g11_g(0:jmax,0:imax), g22_g(0:jmax,0:imax), &
47  g11_sgx(0:jmax,0:imax), g11_sgy(0:jmax,0:imax), &
48  g22_sgx(0:jmax,0:imax), g22_sgy(0:jmax,0:imax)
49 real(dp) :: xhelp, yhelp
50 
51 #if GRID==0
52 
53 !-------- Components g11, g22 on the grid points (_g) and between
54 ! the grid points (_sg) --------
55 
56 do i=0, imax
57 do j=0, jmax
58  g11_g(j,i) = 1
59  g22_g(j,i) = 1
60  g11_sgx(j,i) = 1
61  g11_sgy(j,i) = 1
62  g22_sgx(j,i) = 1
63  g22_sgy(j,i) = 1
64 end do
65 end do
66 
67 #elif GRID==1
68 
69 !-------- Components g11, g22 on the grid points (_g) --------
70 
71 if (phi0 > eps) then ! for northern hemisphere
72  k = (cos(0.25_dp*pi-0.5_dp*phi0))**2
73 else if (phi0 < (-eps)) then ! for southern hemisphere
74  k = (cos(0.25_dp*pi+0.5_dp*phi0))**2
75 else
76  stop ' metric: PHI0 must be different from zero!'
77 end if
78 
79 do i=0, imax
80 do j=0, jmax
81  g11_g(j,i) = 1.0_dp/ &
82  ( k**2*(1.0_dp+(xi(i)**2+eta(j)**2)/(2.0_dp*r*k)**2)**2 )
83  g22_g(j,i) = g11_g(j,i)
84 end do
85 end do
86 
87 !-------- Components g11, g22 between the grid points (_sg) --------
88 
89 do i=0, imax-1
90 do j=0, jmax
91  xhelp = 0.5_dp*(xi(i)+xi(i+1))
92  g11_sgx(j,i) = 1.0_dp/ &
93  ( k**2*(1.0_dp+(xhelp**2+eta(j)**2)/(2.0_dp*r*k)**2)**2 )
94  g22_sgx(j,i) = g11_sgx(j,i)
95 end do
96 end do
97 
98 do i=0, imax
99 do j=0, jmax-1
100  yhelp = 0.5_dp*(eta(j)+eta(j+1))
101  g22_sgy(j,i) = 1.0_dp/ &
102  ( k**2*(1.0_dp+(xi(i)**2+yhelp**2)/(2.0_dp*r*k)**2)**2 )
103  g11_sgy(j,i) = g22_sgy(j,i)
104 end do
105 end do
106 
107 #elif GRID==2
108 
109 !-------- Components g11, g22 on the grid points (_g) --------
110 
111 do i=0, imax
112 do j=0, jmax
113  g11_g(j,i) = r**2*(cos(eta(j)))**2
114  g22_g(j,i) = r**2
115 end do
116 end do
117 
118 !-------- Components g11, g22 between the grid points (_sg) --------
119 
120 do i=0, imax-1
121 do j=0, jmax
122  g11_sgx(j,i) = r**2*(cos(eta(j)))**2
123  g22_sgx(j,i) = r**2
124 end do
125 end do
126 
127 do i=0, imax
128 do j=0, jmax-1
129  yhelp = 0.5_dp*(eta(j)+eta(j+1))
130  g22_sgy(j,i) = r**2
131  g11_sgy(j,i) = r**2*(cos(yhelp))**2
132 end do
133 end do
134 
135 #endif
136 
137 !-------- Square roots (sq_) and inverse square roots (insq_) of
138 ! g11 and g22 --------
139 
140 do i=0, imax
141 do j=0, jmax
142  sq_g11_g(j,i) = sqrt(g11_g(j,i))
143  sq_g22_g(j,i) = sqrt(g22_g(j,i))
144  insq_g11_g(j,i) = 1.0_dp/sq_g11_g(j,i)
145  insq_g22_g(j,i) = 1.0_dp/sq_g22_g(j,i)
146 end do
147 end do
148 
149 do i=0, imax-1
150 do j=0, jmax
151  sq_g11_sgx(j,i) = sqrt(g11_sgx(j,i))
152  sq_g22_sgx(j,i) = sqrt(g22_sgx(j,i))
153  insq_g11_sgx(j,i) = 1.0_dp/sq_g11_sgx(j,i)
154 end do
155 end do
156 
157 do i=0, imax
158 do j=0, jmax-1
159  sq_g22_sgy(j,i) = sqrt(g22_sgy(j,i))
160  sq_g11_sgy(j,i) = sqrt(g11_sgy(j,i))
161  insq_g22_sgy(j,i) = 1.0_dp/sq_g22_sgy(j,i)
162 end do
163 end do
164 
165 end subroutine metric
166 !
Declarations of kind types for SICOPOLIS.
Definition: sico_types.F90:35
Declarations of global variables for SICOPOLIS (for the ANT domain).
Definition: sico_vars.F90:35
subroutine metric()
Definition of the components g11 and g22 of the metric tensor of the applied coordinates.
Definition: metric.F90:37
Declarations of global variables for SICOPOLIS.