ETS  \$Id: Doxyfile 2162 2020-02-26 14:16:09Z g2dpc $
 All Classes Files Functions Variables Pages
psi_error.f90
Go to the documentation of this file.
1 subroutine psi_error
2 !-----------------------------------------------------------------------
3 ! subroutine to evaluate the error in psi and grad(psi) on the nodes
4 ! input is a restored psi vector (not called by Helena)
5 !-----------------------------------------------------------------------
6 
7  use itm_types
8  use mod_mesh
9  use mod_helena_io, only : out_he
11  use mod_output
12 
13  implicit none
14 
15  real(r8), dimension(10, 10) :: abspsi, abspsx, abspsy, abpsxy
16  real(r8) :: errmps, errmpx, errmpy, errpxy, errps, errpsx, errpsy
17  real(r8) :: s, r
18  real(r8) :: x, xr, xs, xrs, xrr, xss
19  real(r8) :: y, yr, ys, yrs, yrr, yss
20  real(r8) :: eqpsi, psir, psis, psrs, psrr, psss
21  real(r8) :: solpsi, spsix, spsiy, spsixy
22  real(r8) :: ejac
23  real(r8) :: psix, psiy
24  real(r8) :: rmax, smax
25  real(r8) :: rx, ry, sx, sy
26  real(r8) :: er, es
27  real(r8) :: rxy, sxy, psixy
28  integer(itm_i4) :: i, j, k, l
29  integer(itm_i4) :: node, n1, n2, n3, n4
30  integer(itm_i4) :: imax, jmax
31 
32  do k = 1, 10
33  do l = 1, 10
34  abspsi(k, l) = 0._r8
35  abspsx(k, l) = 0._r8
36  abspsy(k, l) = 0._r8
37  abpsxy(k, l) = 0._r8
38  end do
39  end do
40  errmps = 0._r8
41  errmpx = 0._r8
42  errmpy = 0._r8
43  errpxy = 0._r8
44  errps = 0._r8
45  errpsx = 0._r8
46  errpsy = 0._r8
47  do l = 1, 10
48  s = -1._r8 + 2._r8 * (l - 1) / 10._r8
49  do i = 1, nr - 1
50  do j = 1, np - 1
51  do k = 1, 10
52  r = -1._r8 + 2._r8 * (k - 1) / 10._r8
53  node = (i - 1) * np + j
54  n1 = node
55  n2 = node + 1
56  n3 = node + 1 + np
57  n4 = node + np
58  call interpolation(2, xx(1, n1), xx(1, n2), xx(1, n3), xx(1, n4), &
59  r, s, x, xr, xs, xrs, xrr, xss)
60  call interpolation(2, yy(1, n1), yy(1, n2), yy(1, n3), yy(1, n4), &
61  r, s, y, yr, ys, yrs, yrr, yss)
62  call interpolation(2, psi(4 * (n1 - 1) + 1), psi(4 * (n2 - 1) &
63  + 1), psi(4 * (n3 - 1) + 1), psi(4 * (n4 - 1) + 1), r, s, &
64  eqpsi, psir, psis, psrs, psrr, psss)
65  call soloviev(x, y, solpsi, spsix, spsiy, spsixy)
66  abspsi(k, l) = abspsi(k, l) + abs(solpsi - eqpsi)
67  ejac = xr * ys - xs * yr
68  psix = (ys * psir - yr * psis) / ejac
69  psiy = (-xs * psir + xr * psis) / ejac
70  abspsx(k, l) = abspsx(k, l) + abs(psix - spsix)
71  abspsy(k, l) = abspsy(k, l) + abs(psiy - spsiy)
72  if (abs(solpsi - eqpsi) > errmps) then
73  errmps = abs(solpsi - eqpsi)
74  end if
75  if (abs(psix - spsix) > errmpx) then
76  errmpx = abs(psix - spsix)
77  end if
78  if (abs(psiy - spsiy) > errmpy) then
79  errmpy = abs(psiy - spsiy)
80  rmax = r
81  smax = s
82  imax = i
83  jmax = j
84  end if
85  ry = -xs / ejac
86  rx = ys / ejac
87  sy = xr / ejac
88  sx = -yr / ejac
89  er = xrr * ys + xr * yrs - xrs * yr - xs * yrr
90  es = xrs * ys + xr * yss - xss * yr - xs * yrs
91  rxy = -(er * ry + es * sy) * ys / ejac**2 + (yrs * ry &
92  + yss * sy) / ejac
93  sxy = (er * ry + es * sy) * yr / ejac**2 - (yrr * ry &
94  + yrs * sy) / ejac
95  psixy = psrr * rx * ry + psrs * (rx * sy + sx * ry) &
96  + psir * rxy + psss * sx * sy + psis * sxy
97  if (abs(psixy - spsixy) > errpxy) then
98  errpxy = abs(psixy - spsixy)
99  end if
100  abpsxy(k, l) = abpsxy(k, l) + abs(psixy - spsixy)
101  end do
102  end do
103  end do
104  do k = 1, 10
105  r = -1._r8 + 2._r8 * (k - 1) / 10._r8
106  abspsi(k, l) = abspsi(k, l) / ((nr - 1) * (np - 1))
107  abspsx(k, l) = abspsx(k, l) / ((nr - 1) * (np - 1))
108  abspsy(k, l) = abspsy(k, l) / ((nr - 1) * (np - 1))
109  errps = errps + abspsi(k, l)
110  errpsx = errpsx + abspsx(k, l)
111  errpsy = errpsy + abspsy(k, l)
112  end do
113  end do
114  if (standard_output) then
115  write(out_he, *) 'max err in psi :', errmps
116  write(out_he, *) 'max err in psix:', errmpx
117  write(out_he, *) 'max err in psiy:', errmpy
118  write(out_he, *) ' at i,j : ', i, j
119  write(out_he, *) ' r,s : ', rmax, smax
120  write(out_he, *) 'max err in psixy :', errpxy
121  write(out_he, *) 'average error in psi : ', errps / 100.
122  write(out_he, *) 'average error in psix : ', errpsx / 100.
123  write(out_he, *) 'average error in psiy : ', errpsy / 100.
124  end if
125 
126  return
127 end subroutine psi_error
subroutine soloviev(x, y, solpsi, psix, psiy, psixy)
Definition: soloviev.f90:1
subroutine interpolation(type_interp, xn1, xn2, xn3, xn4, r, s, x, xr, xs, xrs, xrr, xss, yn1, yn2, yn3, yn4, pn1, pn2, pn3, pn4, yr, ys, ps)
subroutine psi_error
Definition: psi_error.f90:1