ETS  \$Id: Doxyfile 2162 2020-02-26 14:16:09Z g2dpc $
 All Classes Files Functions Variables Pages
arclength.f90
Go to the documentation of this file.
1 subroutine arclength(fr, mfm, theta, dtc, wr, ws)
2 !-----------------------------------------------------------------------
3 ! subroutine to calculate the arclength of the plasma boundary
4 ! routine returns the theta values at equidistant arclength
5 ! parameters :
6 ! fr : fourier series of boundary (input)
7 ! mfm : number of harmonics in fr (input)
8 ! theta : resulting values of theta
9 ! dtc : the derivative of theta to equidistant angle
10 !-----------------------------------------------------------------------
11  use itm_types
12  use mod_parameter
13  use mod_mesh
14 
15  implicit none
16 
17  integer(itm_i4), intent(in) :: mfm
18  real(r8), dimension(mfm + 2), intent(in) :: fr
19  real(r8), dimension(4), intent(in) :: wr, ws
20 
21  real(r8), dimension(np), intent(out) :: theta, dtc
22 
23  integer(itm_i4), parameter :: npts = 512
24 
25  real(r8), dimension(npts) :: xl, dxl
26  real(r8) :: ti1, ti2
27  real(r8) :: dl, dr, tk, rr
28  real(r8) :: chil, dct
29  integer(itm_i4) :: i, j, k, m
30 
31  xl(1) = 0._r8
32 !---------------------------------- calculate lenght(theta)
33  do j = 1, npts - 1
34  ti1 = (j - 1) / dble(npts - 1) * (ias + 1) * pi
35  ti2 = j / dble(npts - 1) * (ias + 1) * pi
36 !---------------------------------- 4 point gaussian integration
37  dl = 0._r8
38  do k = 1, 4
39  tk = ti1 + (ti2 - ti1) * (wr(k) + 1._r8) / 2._r8
40  rr = fr(1) / 2._r8
41  dr = 0._r8
42  do m = 2, mfm / 2
43  rr = rr + fr(2 * m - 1) * cos((m - 1) * tk) + fr(2 * m) &
44  * sin((m - 1) * tk)
45  dr = dr - (m - 1) * fr(2 * m - 1) * sin((m - 1) * tk) &
46  + (m - 1) * fr(2 * m) * cos((m - 1) * tk)
47  end do
48  dl = dl + sqrt(rr * rr + dr * dr) * ws(k)
49  end do
50  xl(j + 1) = xl(j) + dl * (ias + 1) / (2._r8 * pi * (npts - 1))
51  rr = fr(1) / 2._r8
52  dr = 0._r8
53  do m = 2, mfm / 2
54  rr = rr + fr(2 * m - 1) * cos((m - 1) * ti2) + fr(2 * m) &
55  * sin((m - 1._r8) * ti2)
56  dr = dr - (m - 1) * fr(2 * m - 1) * sin((m - 1) * ti2) &
57  + (m - 1) * fr(2 * m) * cos((m - 1) * ti2)
58  end do
59  dxl(j + 1) = sqrt(rr * rr + dr * dr)
60  end do
61  ti2 = 0._r8
62  rr = fr(1) / 2._r8
63  dr = 0._r8
64 
65  do m = 2, mfm / 2
66  rr = rr + fr(2 * m - 1) * cos((m - 1) * ti2) + fr(2 * m) &
67  * sin((m - 1) * ti2)
68  dr = dr - (m - 1) * fr(2 * m- 1 ) * sin((m - 1) * ti2) &
69  + (m - 1) * fr(2 * m) * cos((m - 1) * ti2)
70  end do
71  dxl(1) = sqrt(rr * rr + dr * dr)
72 
73  theta(1) = 0._r8
74  theta(np) = (ias + 1) * pi
75  dtc(1) = 1._r8 / (dxl(1) * (ias + 1) * pi / xl(npts))
76  dtc(np) = 1._r8 / (dxl(npts) * (ias + 1) * pi / xl(npts))
77  i = 1
78  do j = 2, np - 1
79  chil = (j - 1) / dble(np - 1) * xl(npts)
80  do while ((chil > xl(i)) .and. (i < npts))
81  i = i + 1
82  end do
83 !--------------------------- interval located, use linear interpolation
84  theta(j) = (dble(i - 1) + (chil - xl(i)) / (xl(i + 1) &
85  - xl(i))) / dble(npts - 1) * (ias + 1) * pi
86  dct = ((chil - xl(i)) / (xl(i + 1) - xl(i)) * (dxl(i + 1) &
87  - dxl(i)) + dxl(i)) * (ias + 1) * pi / xl(npts)
88  dtc(j) = 1._r8 / dct
89  end do
90 
91  return
92 end subroutine arclength
subroutine arclength(fr, mfm, theta, dtc, wr, ws)
Definition: arclength.f90:1