ETS  \$Id: Doxyfile 2162 2020-02-26 14:16:09Z g2dpc $
 All Classes Files Functions Variables Pages
suydam_read_helena.f90
Go to the documentation of this file.
1 subroutine suydam_read_helena(equilibrium)
2 !-----------------------------------------------------------------------
3 ! - reads helena mapping file
4 ! - scales quantities with q on axis
5 !-----------------------------------------------------------------------
6 
7  use itm_types
8  use mod_map
9  use mod_mesh, only : nr
10  use mod_parameter
11  use mod_profiles
12  use mod_spline
13  use mod_suydam
14  use mod_helena_io, only : out_he
15  use mod_output
16  use helena_spline
17 
18  use euitm_schemas
19 
20  implicit none
21 
22  type(type_equilibrium), intent(in) :: equilibrium
23 
24  integer(itm_i4) :: i, j
25  real(r8) :: c1(nr - 1), dummy(3)
26  real(r8) :: scaleq, rbphi02, wurzel
27  real(r8) :: dq0, dq1
28  real(r8) :: dp_axis, dp_boundary
29  real(r8) :: drbphi_axis, drbphi_boundary
30  real(r8) :: raxis
31 
32  npsi = nr
33 
34 !-- raxis = Rmag/Rvac
35  raxis = equilibrium%global_param%mag_axis%position%r &
36  / equilibrium%eqgeometry%geom_axis%r
37  g11_hel(1, :) = 0._r8
38  g33_hel(1, :) = 1._r8 / raxis**2
39 
40  call allocate_spline_coefficients(q_spline, npsi - 1)
41 
42  do j = 1, nchi
43  c1(:) = g12_hel(2:npsi - 1, j)
44  call spline(npsi - 1, cs(2), c1, 0._r8, 0._r8, 2, q_spline)
45  g12_hel(1, j) = spwert(npsi - 1, 0._r8, q_spline, cs(2), dummy, 0)
46  end do
47 
48  call deallocate_spline_coefficients(q_spline)
49 
50 !------------------------------------------------------------------
51 ! scale quantities with value of q on axis (total current)
52 !------------------------------------------------------------------
53  scaleq = qs(1) / qaxis
54 
55  cpsurf = cpsurf * scaleq
56  p0 = p0 * scaleq**2
57  g12_hel = -g12_hel * scaleq
58  g11_hel = g11_hel * scaleq**2
59 
60  rbphi02 = rbphi(1)**2
61 
62 !-- derivatives at plasma boundaries (all zero except for dp_boundary)
63  dp_axis = 0._r8
64  drbphi_axis = 0._r8
65  drbphi_boundary = 0._r8
66  dp_boundary = equilibrium%profiles_1d%pprime(nr) &
67  * 2._r8 * equilibrium%profiles_1d%psi(nr) * mu0 &
68  / equilibrium%global_param%mag_axis%bphi**2
69 
70 !-- scaling
71  dp_axis = dp_axis * scaleq**2
72  dp_boundary = dp_boundary * scaleq**2
73  drbphi_axis = drbphi_axis * scaleq**2
74  drbphi_boundary = drbphi_boundary * scaleq / sqrt(1._r8 + rbphi02 &
75  / rbphi(npsi)**2 * (1._r8 / scaleq**2 - 1._r8))
76 
77  do i = 1, npsi
78  wurzel = sqrt(1._r8 + rbphi02 / rbphi(i)**2 * (1._r8 / scaleq**2 &
79  - 1._r8))
80  qs(i) = wurzel * qs(i)
81  rbphi(i) = wurzel * scaleq * rbphi(i)
82  end do
83 
84  if (standard_output) then
85  write(out_he, *) npsi, nchi
86  write(out_he, 51) scaleq
87  write(out_he, 52) cpsurf
88  write(out_he, 53) (qs(i), i = 1, nr)
89  write(out_he, 54) (p0(i), i = 1, npsi)
90  write(out_he, 55) (rbphi(i), i = 1, npsi)
91  end if
92 
93 ! splines
94 
95  dq1 = (qs(npsi) - qs(npsi - 1)) / (cs(npsi) - cs(npsi - 1))
96  dq0 = (qs(2) - qs(1)) / (cs(2) - cs(1))
97 
98  call allocate_spline_coefficients(q_spline, npsi)
99  call allocate_spline_coefficients(p_spline, npsi)
100  call allocate_spline_coefficients(rbphi_spline, npsi)
101 
102  call spline(npsi, cs, qs, dq0, dq1, 1, q_spline)
103  call spline(npsi, cs, p0, dp_axis, dp_boundary, 1, p_spline)
104  call spline(npsi, cs, rbphi, drbphi_axis, drbphi_boundary, 1, rbphi_spline)
105 
106  dqs = q_spline%sp2
107 
108  return
109 
110  51 format(/' after scale: scaleq=', es12.4)
111  52 format(/' cpsurf = ', es12.4)
112  53 format(/' qs'/(1x, 5es16.8))
113  54 format(/' p0'/(1x, 5es16.8))
114  55 format(/' rbphi'/(1x, 5es16.8))
115 
116 end subroutine suydam_read_helena
subroutine allocate_spline_coefficients(spline, n)
subroutine spline(N, X, Y, ALFA, BETA, TYP, A, B, C, D)
Definition: solution6.f90:655
REAL *8 function spwert(N, XWERT, A, B, C, D, X, ABLTG)
Definition: solution6.f90:155
subroutine deallocate_spline_coefficients(spline)
subroutine suydam_read_helena(equilibrium)