SICOPOLIS V3.1
 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-2013 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 
42 implicit none
43 integer(i4b) :: i, j
44 real(dp) :: k
45 real(dp) :: g11_g(0:jmax,0:imax), g22_g(0:jmax,0:imax), &
46  g11_sgx(0:jmax,0:imax), g11_sgy(0:jmax,0:imax), &
47  g22_sgx(0:jmax,0:imax), g22_sgy(0:jmax,0:imax)
48 real(dp) :: xhelp, yhelp
49 
50 #if GRID==0
51 
52 !-------- Components g11, g22 on the grid points (_g) and between
53 ! the grid points (_sg) --------
54 
55 do i=0, imax
56 do j=0, jmax
57  g11_g(j,i) = 1
58  g22_g(j,i) = 1
59  g11_sgx(j,i) = 1
60  g11_sgy(j,i) = 1
61  g22_sgx(j,i) = 1
62  g22_sgy(j,i) = 1
63 end do
64 end do
65 
66 #elif GRID==1
67 
68 !-------- Components g11, g22 on the grid points (_g) --------
69 
70 if (phi0 > eps) then ! for northern hemisphere
71  k = (cos(0.25_dp*pi-0.5_dp*phi0))**2
72 else if (phi0 < (-eps)) then ! for southern hemisphere
73  k = (cos(0.25_dp*pi+0.5_dp*phi0))**2
74 else
75  stop ' metric: PHI0 must be different from zero!'
76 end if
77 
78 do i=0, imax
79 do j=0, jmax
80  g11_g(j,i) = 1.0_dp/ &
81  ( k**2*(1.0_dp+(xi(i)**2+eta(j)**2)/(2.0_dp*r*k)**2)**2 )
82  g22_g(j,i) = g11_g(j,i)
83 end do
84 end do
85 
86 !-------- Components g11, g22 between the grid points (_sg) --------
87 
88 do i=0, imax-1
89 do j=0, jmax
90  xhelp = 0.5_dp*(xi(i)+xi(i+1))
91  g11_sgx(j,i) = 1.0_dp/ &
92  ( k**2*(1.0_dp+(xhelp**2+eta(j)**2)/(2.0_dp*r*k)**2)**2 )
93  g22_sgx(j,i) = g11_sgx(j,i)
94 end do
95 end do
96 
97 do i=0, imax
98 do j=0, jmax-1
99  yhelp = 0.5_dp*(eta(j)+eta(j+1))
100  g22_sgy(j,i) = 1.0_dp/ &
101  ( k**2*(1.0_dp+(xi(i)**2+yhelp**2)/(2.0_dp*r*k)**2)**2 )
102  g11_sgy(j,i) = g22_sgy(j,i)
103 end do
104 end do
105 
106 #elif GRID==2
107 
108 !-------- Components g11, g22 on the grid points (_g) --------
109 
110 do i=0, imax
111 do j=0, jmax
112  g11_g(j,i) = r**2*(cos(eta(j)))**2
113  g22_g(j,i) = r**2
114 end do
115 end do
116 
117 !-------- Components g11, g22 between the grid points (_sg) --------
118 
119 do i=0, imax-1
120 do j=0, jmax
121  g11_sgx(j,i) = r**2*(cos(eta(j)))**2
122  g22_sgx(j,i) = r**2
123 end do
124 end do
125 
126 do i=0, imax
127 do j=0, jmax-1
128  yhelp = 0.5_dp*(eta(j)+eta(j+1))
129  g22_sgy(j,i) = r**2
130  g11_sgy(j,i) = r**2*(cos(yhelp))**2
131 end do
132 end do
133 
134 #endif
135 
136 !-------- Square roots (sq_) and inverse square roots (insq_) of
137 ! g11 and g22 --------
138 
139 do i=0, imax
140 do j=0, jmax
141  sq_g11_g(j,i) = sqrt(g11_g(j,i))
142  sq_g22_g(j,i) = sqrt(g22_g(j,i))
143  insq_g11_g(j,i) = 1.0_dp/sq_g11_g(j,i)
144  insq_g22_g(j,i) = 1.0_dp/sq_g22_g(j,i)
145 end do
146 end do
147 
148 do i=0, imax-1
149 do j=0, jmax
150  sq_g11_sgx(j,i) = sqrt(g11_sgx(j,i))
151  sq_g22_sgx(j,i) = sqrt(g22_sgx(j,i))
152  insq_g11_sgx(j,i) = 1.0_dp/sq_g11_sgx(j,i)
153 end do
154 end do
155 
156 do i=0, imax
157 do j=0, jmax-1
158  sq_g22_sgy(j,i) = sqrt(g22_sgy(j,i))
159  sq_g11_sgy(j,i) = sqrt(g11_sgy(j,i))
160  insq_g22_sgy(j,i) = 1.0_dp/sq_g22_sgy(j,i)
161 end do
162 end do
163 
164 end subroutine metric
165 !