ETS  \$Id: Doxyfile 2162 2020-02-26 14:16:09Z g2dpc $
 All Classes Files Functions Variables Pages
mod_ne_te_profile.f90
Go to the documentation of this file.
2 
3  use itm_types
4  use mod_dete
5  use mod_helena_io, only : out_he
6 
7  implicit none
8 
9  contains
10 
11 !---------------------------------------------------------------------------
12  subroutine ne_te_profile(dt, psi, f, df, const, df_in)
13 !---------------------------------------------------------------------------
14 ! calculates the values of T_e and n_i and the derivative in psi
15 !---------------------------------------------------------------------------
16 
17  implicit none
18 
19  type(ne_te), intent(in) :: dt
20  real(r8), intent(in) :: psi
21  real(r8), intent(out) :: f, df
22  real(r8), intent(out), optional :: const
23  real(r8), intent(in), optional :: df_in
24 
25  real(r8) :: ex, ext, denom, ztmp
26 
27  if (.not. present(df_in)) then
28 
29  ex = exp(psi / dt%delta)
30  ext = exp(dt%psi_m / dt%delta)
31  denom = 2.0_r8 * dt%delta * (ex + ext)
32  ztmp = (dt%psi_m - psi) / (2.0_r8 * dt%delta)
33 
34  f = (0.5_r8 * (dt%h - dt%h_0) * (((1.0_r8 + dt%slope * ztmp) &
35  * exp(ztmp) - exp(-ztmp)) / (exp(ztmp) + exp(-ztmp)) + 1.0_r8) &
36  + dt%h_0) * dt%fac
37 
38  df = (dt%h - dt%h_0) * ext * (dt%delta * ((4.0_r8 &
39  + dt%slope) * ex + dt%slope * ext) - dt%slope *ex &
40  * (psi - dt%psi_m)) / (denom * denom)
41 
42  if (.not. present(const)) return
43 
44  if (dt%shape == 1) then
45  const = f + dt%fac * df * (dt%alpha(1) + (1._r8 - dt%alpha(1)) &
46  / (dt%alpha(2) + 1.0_r8)) * psi
47  else
48  const = f + dt%fac * df * ((2.0_r8 / 3.0_r8 * dt%alpha(1) &
49  + 0.5_r8 * dt%alpha(2)) / (dt%alpha(1) + dt%alpha(2)) &
50  + 0.5_r8 * dt%alpha(3))
51  end if
52 
53  else
54 
55  if (dt%shape == 1) then
56 ! df = -dt%fac * df_in * (dt%alpha(1) + (1.0_r8 - dt%alpha(1)) &
57 ! * (psi &
58  df = df_in * (dt%alpha(1) + (1.0_r8 - dt%alpha(1)) * (psi &
59  / dt%psi_0) **dt%alpha(2))
60  f = -dt%fac * df_in * (dt%alpha(1) * psi + (1.0_r8 - dt%alpha(1)) &
61  / (dt%alpha(2) + 1.0_r8) / dt%psi_0**dt%alpha(2) &
62  * psi**(dt%alpha(2) + 1.0_r8)) + const
63  else
64 ! df = -dt%fac * df_in / dt%psi_0 * ((dt%alpha(1) * (psi &
65 ! / dt%psi_0)**0.5_r8 &
66  df = df_in / dt%psi_0 * ((dt%alpha(1) * (psi / dt%psi_0)**0.5_r8 &
67  + dt%alpha(2) * (psi / dt%psi_0)) / (dt%alpha(1) + dt%alpha(2)) &
68  + dt%alpha(3) * (1.0_r8 - psi / dt%psi_0))
69  f = -dt%fac * df_in * ((2.0_r8 / 3.0_r8 * dt%alpha(1) * (psi &
70  / dt%psi_0) **1.5_r8 + 0.5_r8 * dt%alpha(2) * (psi &
71  / dt%psi_0)**2) / (dt%alpha(1) + dt%alpha(2)) + dt%alpha(3) * (psi &
72  / dt%psi_0 - 0.5_r8 * (psi / dt%psi_0)**2)) + const
73  end if
74 
75  end if
76  return
77  end subroutine ne_te_profile
78 
79 end module mod_ne_te_profile
subroutine ne_te_profile(dt, psi, f, df, const, df_in)