Report Typos and Errors    
Semi-Lagrangian Library
Modular library for kinetic and gyrokinetic simulations of plasmas in fusion energy devices.
sll_m_poisson_1d_polar.F90
Go to the documentation of this file.
1 #ifndef DOXYGEN_SHOULD_SKIP_THIS
2 !**************************************************************
3 ! Copyright INRIA
4 ! Authors :
5 ! CALVI project team
6 !
7 ! This code SeLaLib (for Semi-Lagrangian-Library)
8 ! is a parallel library for simulating the plasma turbulence
9 ! in a tokamak.
10 !
11 ! This software is governed by the CeCILL-B license
12 ! under French law and abiding by the rules of distribution
13 ! of free software. You can use, modify and redistribute
14 ! the software under the terms of the CeCILL-B license as
15 ! circulated by CEA, CNRS and INRIA at the following URL
16 ! "http://www.cecill.info".
17 !**************************************************************
18 
21 module sll_m_poisson_1d_polar
22 !+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
23 #include "sll_memory.h"
24 #include "sll_working_precision.h"
25 #include "sll_errors.h"
26 
27  use sll_m_poisson_1d_base, only: &
29 
30  implicit none
31 
32  public :: &
33  sll_f_new_poisson_1d_polar, &
34  sll_t_poisson_1d_polar
35 
36  private
37 !+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
38 
39  type, extends(sll_c_poisson_1d_base) :: sll_t_poisson_1d_polar
40  sll_real64 :: length
41  sll_int32 :: nc_eta1
42  !type(sll_plan_poisson_polar), pointer :: poiss
43 
44  contains
45  procedure, pass(poisson) :: init => &
46  initialize_poisson_1d_polar
47  procedure, pass(poisson) :: compute_phi_from_rho => &
48  compute_phi_from_rho_1d_polar
49  procedure, pass(poisson) :: compute_E_from_rho => &
50  compute_e_from_rho_1d_polar
51 ! procedure, pass(poisson) :: compute_E_from_phi => &
52 ! compute_E_from_phi_2d_polar
53 
54  end type sll_t_poisson_1d_polar
55 
56 contains
57  function sll_f_new_poisson_1d_polar( &
58  eta1_min, &
59  eta1_max, &
60  nc_eta1, &
61  bc) &
62  result(poisson)
63 
64  type(sll_t_poisson_1d_polar), pointer :: poisson
65  sll_real64, intent(in) :: eta1_min
66  sll_real64, intent(in) :: eta1_max
67  sll_int32, intent(in) :: nc_eta1
68  sll_int32, intent(in), optional :: bc
69  sll_int32 :: ierr
70 
71  sll_allocate(poisson, ierr)
72  call initialize_poisson_1d_polar( &
73  poisson, &
74  eta1_min, &
75  eta1_max, &
76  nc_eta1, &
77  bc)
78 
79  end function sll_f_new_poisson_1d_polar
80 
81  subroutine initialize_poisson_1d_polar( &
82  poisson, &
83  eta1_min, &
84  eta1_max, &
85  nc_eta1, &
86  bc)
87  class(sll_t_poisson_1d_polar) :: poisson
88  sll_real64, intent(in) :: eta1_min
89  sll_real64, intent(in) :: eta1_max
90  sll_int32, intent(in) :: nc_eta1
91  sll_int32, intent(in), optional :: bc
92  !sll_int32 :: ierr
93 
94  if (present(bc)) then
95  print *, '#Warning bc=', bc, 'present but not used'
96  end if
97  poisson%length = eta1_max - eta1_min
98  poisson%nc_eta1 = nc_eta1
99 
100  end subroutine initialize_poisson_1d_polar
101 
102  ! solves -\Delta phi = rho in 1d
103  subroutine compute_phi_from_rho_1d_polar(poisson, phi, rho)
104  class(sll_t_poisson_1d_polar) :: poisson
105  sll_real64, dimension(:), intent(in) :: rho
106  sll_real64, dimension(:), intent(out) :: phi
107 
108  sll_error('compute_phi_from_rho_1d_polar', '#not implemented yet')
109 
110  end subroutine compute_phi_from_rho_1d_polar
111 
112  ! solves E = -\nabla Phi with -\Delta phi = rho in 1d
113  subroutine compute_e_from_rho_1d_polar(poisson, E, rho)
114  class(sll_t_poisson_1d_polar) :: poisson
115  sll_real64, dimension(:), intent(in) :: rho
116  sll_real64, dimension(:), intent(out) :: e
117  sll_int32 :: n
118  sll_real64 :: l
119 
120  n = poisson%nc_eta1
121  l = poisson%length
122 
123  e(1:n + 1) = rho(1:n + 1)
124 
125  call poisson1dpolar(e, l, n)
126 
127  end subroutine compute_e_from_rho_1d_polar
128 
129  subroutine poisson1dpolar(E, L, N)
130  integer, intent(in)::N
131  !sll_real64,dimension(0:N),intent(inout)::E
132  sll_real64, dimension(:), intent(inout) :: e
133  sll_real64, intent(in) :: l
134  integer :: i
135  sll_real64 :: eold
136  sll_real64 :: enew
137  sll_real64 :: dx
138  sll_real64 :: tmp
139 
140  !dx = L/real(N,f64)
141  dx = l/(2._f64*real(n, f64))
142 
143  eold = e(1 + n/2)*dx
144  tmp = 0._f64
145  e(1 + n/2) = 0._f64
146  do i = 1, n/2
147  enew = e(1 + n/2 + i)*dx
148  tmp = (tmp - eold)*(1._f64 - 1._f64/real(i, f64)) - enew
149  eold = enew
150  e(1 + n/2 + i) = tmp
151  e(1 + n/2 - i) = -tmp
152  end do
153 
154  end subroutine poisson1dpolar
155 
156 end module sll_m_poisson_1d_polar
157 #endif /* DOXYGEN_SHOULD_SKIP_THIS */
Module interface to solve Poisson equation in 1D.
    Report Typos and Errors