PB3D  [2.45]
Ideal linear high-n MHD stability in 3-D
rich_ops.f90
Go to the documentation of this file.
1 !------------------------------------------------------------------------------!
3 !------------------------------------------------------------------------------!
4 module rich_ops
5 #include <PB3D_macros.h>
6 #include <wrappers.h>
7  use str_utilities
8  use output_ops
9  use messages
11  use grid_vars, only: grid_type
12  use eq_vars, only: eq_1_type
13  use sol_vars, only: sol_type
14  use rich_vars
15 
16  implicit none
17  private
20 
21 contains
27  integer function init_rich() result(ierr)
31  use x_ops, only: init_modes, setup_modes
32  use x_vars, only: mds_sol
34  use grid_utilities, only: calc_eqd_grid
35 
36  character(*), parameter :: rout_name = 'init_rich'
37 
38  ! local variables
39  type(grid_type) :: grid_eq_b
40  type(grid_type) :: grid_x_b
41  type(grid_type) :: grid_sol
42  type(eq_1_type) :: eq
43  type(sol_type) :: sol
44  character(len=4) :: grid_eq_name
45  character(len=4) :: grid_x_name
46  character(len=max_str_ln) :: err_msg
47 
48  ! set variables
49  rich_lvl = 1
50  rich_conv = .false.
51  use_guess = .false.
52 
53  ! initialize ierr
54  ierr = 0
55 
56  ! user output (only master has variables set up)
57  if (rank.eq.0 .and. max_it_rich.gt.1) then ! only when more than one level
58  if (rich_restart_lvl.eq.1) then
59  ! user output
60  call writo('Richardson extrapolation loop initialization')
61  else
62  ! user output
63  call writo('Richardson extrapolation loop continuation at &
64  &level '//trim(i2str(rich_restart_lvl)))
65  end if
66  end if
67  call lvl_ud(1)
68 
69  ! some preliminary things
70  ierr = reconstruct_pb3d_in('in') ! reconstruct miscellaneous PB3D output variables
71  chckerr('')
72 
73  ! allocate variables
74  allocate(sol_val_rich(max_it_rich,max_it_rich,n_sol_requested))
75  sol_val_rich = 0.0_dp
76  allocate(x_axis_rich(max_it_rich,n_sol_requested))
77  allocate(max_rel_err(max_it_rich-1))
78  allocate(loc_max_rel_err(max_it_rich-1,1))
79 
80  ! set up alpha
81  allocate(alpha(n_alpha))
82  ierr = calc_eqd_grid(alpha,min_alpha*pi,max_alpha*pi,excl_last=.true.)
83  chckerr('')
84 
85  ! Richardson restart
86  if (rich_restart_lvl.gt.1) then
87  ! user output
88  call writo('reconstructing Richardson extrapolation variables')
89  call lvl_ud(1)
90 
91  call writo('Prepare general variables')
92  call lvl_ud(1)
93 
94  ! use guess
95  use_guess = .true.
96 
97  ! set up grid names
98  select case (eq_style)
99  case (1) ! VMEC
100  grid_x_name = 'X' ! grids are already field-aligned
101  grid_eq_name = 'eq' ! grids are already field-aligned
102  case (2) ! HELENA
103  grid_x_name = 'X_B' ! field-aligned grid is separate
104  grid_eq_name = 'eq_B' ! field-aligned grid is separate
105  end select
106 
107  ! reconstruct field-aligned equilibrium grid (for level 1)
108  ierr = reconstruct_pb3d_grid(grid_eq_b,trim(grid_eq_name),&
109  &rich_lvl=1)
110  chckerr('')
111 
112  ! reconstruct solution grid
113  ierr = reconstruct_pb3d_grid(grid_sol,'sol')
114  chckerr('')
115 
116  ! reconstruct flux equilibrium variables
117  ierr = reconstruct_pb3d_eq_1(grid_eq_b,eq,'eq_1')
118  chckerr('')
119 
120  call lvl_ud(-1)
121 
122  ! loop over all previous Richardson levels using rich_lvl as
123  ! counter
124  do rich_lvl = 1,rich_restart_lvl-1
125  call writo('Prepare variables for Richardson level '//&
126  &trim(i2str(rich_lvl)))
127  call lvl_ud(1)
128 
129  ! reconstruct field-aligned perturbation grid
130  ierr = reconstruct_pb3d_grid(grid_x_b,trim(grid_x_name),&
132  chckerr('')
133 
134  if (rich_lvl.eq.1) then
135  ! initialize global n and m variables
136  ierr = init_modes(grid_eq_b,eq)
137  chckerr('')
138 
139  ! set up n and m variables for sol grid
140  ierr = setup_modes(mds_sol,grid_eq_b,grid_sol)
141  chckerr('')
142  end if
143 
144  ! reconstruct solution
145  ierr = reconstruct_pb3d_sol(mds_sol,grid_sol,sol,'sol',&
147  chckerr('')
148 
149  call lvl_ud(-1)
150 
151  call writo('Recreate Richardson variables')
152  call lvl_ud(1)
153 
154  ! set x_axis_rich
155  if (rich_lvl.eq.1) then
156  ! set up n_par_X for first rich_lvl
157  n_par_x = grid_x_b%n(1)
158 
159  ! check it
160  if (n_par_x.eq.min_n_par_x) then
161  ! set x_axis_rich
162  x_axis_rich(1,:) = min_n_par_x
163  else
164  ierr = 1
165  err_msg = 'Saved variables started with &
166  &min_n_par_X = '//trim(i2str(n_par_x))//&
167  &' whereas here '//trim(i2str(min_n_par_x))//&
168  &' is specified'
169  chckerr(err_msg)
170  end if
171  else
172  ! update n_par_X
173  n_par_x = n_par_x*2-1
174 
175  ! set x_axis_rich
177  end if
178 
179  ! calculate Richardson extrapolation
180  call calc_rich_ex(sol%val)
181 
182  ! update error variables
183  call check_conv()
184 
185  ! clean up
186  call grid_x_b%dealloc()
187  call sol%dealloc()
188 
189  call lvl_ud(-1)
190  end do
191 
192  ! clean up
193  call mds_sol%dealloc()
194  call grid_eq_b%dealloc()
195  call grid_sol%dealloc()
196  call eq%dealloc()
197 
198  ! set rich_lvl
200 
201  call lvl_ud(-1)
202  call writo('Richardson extrapolation variables reconstructed')
203  end if
204 
205  if (max_it_rich.gt.1) then ! only when more than one level
206  call writo('Maximum number of iterations: '//&
207  &trim(i2str(max_it_rich)))
208  call writo('Tolerance requested: '//trim(r2strt(tol_rich)))
209 
210  call writo('')
211  end if
212 
213  call lvl_ud(-1)
214  end function init_rich
215 
219  subroutine term_rich()
221  use input_utilities, only: dealloc_in
222 
223  ! local variables
224  integer :: id ! counter
225 
226  ! user output
227  if (max_it_rich.gt.1) then
228  ! user output
229  call writo('Finishing Richardson extrapolation loop')
230  call lvl_ud(1)
231 
232  if (rich_conv) then
233  call writo('Convergence reached in '//trim(i2str(rich_lvl-1))//&
234  &' steps:')
235  else
236  call writo('After '//trim(i2str(rich_lvl-1))//&
237  &' steps, no convergence reached:')
238  end if
239 
240  call lvl_ud(1)
241 
242  call writo('Maximum relative error '//&
243  &trim(r2str(max_rel_err(rich_lvl-2)))//&
244  &' for Eigenvalue '//trim(i2str(loc_max_rel_err(rich_lvl-2,1))))
245  call writo('Tolerance requested: '//trim(r2strt(tol_rich)))
246  call writo('Resulting best guesses for Eigenvalues:')
247  call lvl_ud(1)
248  do id = 1,size(sol_val_rich,3)
249  call writo('For Eigenvalue '//trim(i2str(id))//':')
250  call lvl_ud(1)
251  call writo(trim(c2str(sol_val_rich(rich_lvl-1,rich_lvl-1,id))),&
252  &alert=.true.)
253  call lvl_ud(-1)
254  end do
255  call lvl_ud(-1)
256  call writo('with, theoretically, an error of the order O(Δ^'//&
257  &trim(i2str(2*norm_disc_prec_sol*rich_lvl))//'),')
258  call writo('compared to O(Δ^'//trim(i2str(2*norm_disc_prec_sol))//&
259  &') without Richardson extrapolation')
260  call writo('Notice that this is ONLY valid if the problem in the &
261  &different Richardson stages is similar:')
262  call lvl_ud(1)
263  call writo('- It has to be part of the point spectrum')
264  call writo('- The Eigenvectors should look similar')
265  call lvl_ud(-1)
266 
267  call lvl_ud(-1)
268 
269  ! draw X values
270  if (rank.eq.0) call draw_sol_val_rich()
271 
272  call writo('')
273 
274  call lvl_ud(-1)
275  end if
276 
277  ! clean up
278  call dealloc_in()
279  contains
280  ! Draws the Eigenvalues for the different levels of Richardson
281  ! extrapolation as a function of the number of parallel points.
283  subroutine draw_sol_val_rich()
284  use num_vars, only: n_sol_requested
285 
286  ! local variables
287  character(len=max_str_ln) :: plot_title ! title for plots
288  character(len=max_str_ln) :: plot_name ! name of plot
289 
290  ! user output
291  call writo('Plotting Eigenvalues as function of nr. of parallel &
292  &points')
293  call lvl_ud(1)
294 
295  ! print, using rich_lvl-1 as it has been aumented
296  plot_title = 'Eigenvalues as function of nr. of parallel points'
297  plot_name = 'Eigenvalues_richardson'
298  call print_ex_2d([plot_title],plot_name,&
299  &rp(sol_val_rich(1:rich_lvl-1,1,:)),&
300  &x=x_axis_rich(1:rich_lvl-1,:),draw=.false.)
301 
302  ! output in file
303  call draw_ex([plot_title],plot_name,n_sol_requested,1,.false.)
304 
305  ! user output
306  call lvl_ud(-1)
307  call writo('Done plotting Eigenvalues')
308  end subroutine draw_sol_val_rich
309  end subroutine term_rich
310 
312  logical function do_rich()
313  if (rich_lvl.gt.max_it_rich .or. rich_conv) then
314  do_rich = .false.
315  else
316  do_rich = .true.
317  end if
318  end function do_rich
319 
326  integer function start_rich_lvl() result(ierr)
328  use grid_vars, only: n_r_eq, n_r_sol, n_alpha
330  use helena_vars, only: nchi
332  use mpi_utilities, only: get_ser_var
333 
334  character(*), parameter :: rout_name = 'start_rich_lvl'
335 
336  ! local variables
337  integer :: n_div
338  logical :: only_half_grid
339  integer :: n_par_x_loc
340  integer :: var_size_without_par(2)
341 
342  ! initialize ierr
343  ierr = 0
344 
345  ! set use_guess to .false. if user sets no_guess
346  if (no_guess) use_guess = .false.
347 
348  ! Calculate total number of parallel points for the solution in
349  ! Richardson loops
350  if (rich_lvl.eq.1) then
352  only_half_grid = .false.
353  else
354  n_par_x = 2 * n_par_x - 1
355  only_half_grid = .true.
356  end if
357 
358  ! use calc_n_par_X_rich, taking into account possible half grid
359  ierr = calc_n_par_x_rich(n_par_x_loc,only_half_grid)
360  chckerr('')
361 
362  if (rich_lvl.eq.rich_restart_lvl .and. jump_to_sol) then
363  call writo('Jumping straight to solution, no need to divide into &
364  &equilibrium jobs')
365 
366  return
367  end if
368 
369  ! Get local n_par_X to divide the equilibrium jobs. Note that the
370  ! average size of eq_2 variables for all processes together is n_r_eq,
371  ! times the number of field lines, the size due to the dimensions
372  ! corresponding to the derivatives, and the number of variables (see
373  ! subroutine 'calc_memory_eq' and 'calc_memory_X'), while it is n_r_sol
374  ! for the X_1 variables.
375  var_size_without_par(1) = n_r_eq
376  var_size_without_par(2) = n_r_sol
377  var_size_without_par = var_size_without_par * n_alpha
378  select case (eq_style)
379  case (1) ! VMEC
380  ! divide equilibrium jobs
381  ierr = divide_eq_jobs(n_par_x_loc,var_size_without_par,&
382  &n_div)
383  chckerr('')
384  case (2) ! HELENA
385  ! divide equilibrium jobs
386  ! Note: calculations for first Richardson level have to be done
387  ! with a single job, as this is the calculation where the
388  ! variables are calculated that are interpolated in all levels.
389  ierr = divide_eq_jobs(nchi,var_size_without_par,n_div,&
390  &n_div_max=1,range_name='poloidal points in the &
391  &axisymmetric HELENA cross-section') ! everything is tabulated on nchi poloidal points
392  chckerr('')
393  end select
394 
395  ! calculate equilibrium job limits
396  ierr = calc_eq_jobs_lims(n_par_x_loc,n_div)
397  chckerr('')
398  end function start_rich_lvl
399 
404  subroutine stop_rich_lvl()
405  ! update the x axis of the Eigenvalue plot
406  x_axis_rich(rich_lvl,:) = 1._dp*n_par_x
407 
408  ! Richardson extrapolation
409  if (max_it_rich.gt.1) then ! only do this if more than 1 Richardson level
410  ! user output
411  if (rich_lvl.gt.1) call writo('Richardson level '//&
412  &trim(i2str(rich_lvl))//' summary')
413  call lvl_ud(1)
414 
415  ! decide whether converged or not
416  call check_conv()
417 
418  ! setup possible guess for next Richardson level
419  call set_guess()
420 
421  if (rich_lvl.gt.1) call writo('')
422  call lvl_ud(-1)
423  else ! if not, Richardson is done
424  rich_conv = .true.
425  end if
426 
427  ! increase level
428  rich_lvl = rich_lvl + 1
429  contains
430  ! Decides whether a guess should be used in a possible next Richardson
431  ! level.
433  subroutine set_guess()
434  ! local variables
435  real(dp), parameter :: tol = 5._dp ! tolerance for increase of error
436 
437  ! decide on guess
438  if (rich_lvl.ge.3) then ! start from level 3
439  use_guess = max_rel_err(rich_lvl-1).lt.&
440  &tol*max_rel_err(rich_lvl-2) ! set guess for next level to true if max_rel_err is decreasing
441  else
442  use_guess = .true. ! for first Richardson level, set guess for next level to true
443  end if
444  end subroutine set_guess
445  end subroutine stop_rich_lvl
446 
458  subroutine calc_rich_ex(sol_val)
460 
461  ! input / output
462  complex(dp), intent(in) :: sol_val(:)
463 
464  ! local variables
465  integer :: ir ! counter
466 
467  ! do calculations if rich_lvl > 1
468  sol_val_rich(rich_lvl,1,1:size(sol_val)) = sol_val ! size(sol_val) can be less than n_sol_requested
469  do ir = 2,rich_lvl
470  sol_val_rich(rich_lvl,ir,1:size(sol_val)) = &
471  &sol_val_rich(rich_lvl,ir-1,1:size(sol_val)) + &
472  &1._dp/(2**(2*(ir-1)*norm_disc_prec_sol)-1._dp) * &
473  &(sol_val_rich(rich_lvl,ir-1,1:size(sol_val)) - &
474  &sol_val_rich(rich_lvl-1,ir-1,1:size(sol_val)))
475  end do
476  end subroutine calc_rich_ex
477 
488  subroutine check_conv()
489  use num_vars, only: tol_slepc
490 
491  ! local variables
492  real(dp), allocatable :: corr(:) ! correction for order (rich_lvl-1) of error
493  integer :: ir ! counter
494  real(dp) :: tol_SLEPC_adapt_factor = 0.01_dp ! factor to relate tol_SLEPC to maximum relative error
495 
496  if (rich_lvl.gt.1) then ! only do this if in Richardson level higher than 1
497  ! set relative correction
498  allocate(corr(size(sol_val_rich,3)))
499  corr = abs(2*(sol_val_rich(rich_lvl,rich_lvl-1,:)-&
500  &sol_val_rich(rich_lvl-1,rich_lvl-1,:))/&
502  &sol_val_rich(rich_lvl-1,rich_lvl-1,:)))
503 
504  ! get maximum and location of maximum for relative correction
505  max_rel_err(rich_lvl-1) = maxval(corr)
506  loc_max_rel_err(rich_lvl-1,:) = maxloc(corr)
507 
508  ! user output
509  do ir = 1,rich_lvl-1
510  call writo('Richardson level '//trim(i2str(ir))//' -> '//&
511  &trim(i2str(ir+1))//': maximum relative error '//&
512  &trim(r2strt(max_rel_err(ir)))//' for Eigenvalue '//&
513  &trim(i2str(loc_max_rel_err(ir,1))))
514  end do
515 
516  ! check whether tolerance has been reached
517  if (max_rel_err(rich_lvl-1).lt.tol_rich) then
518  rich_conv = .true.
519  call writo('tolerance '//trim(r2strt(tol_rich))//&
520  &' reached after '//trim(i2str(rich_lvl))//&
521  &' iterations')
522  else
523  call writo('tolerance '//trim(r2strt(tol_rich))//' not yet &
524  &reached')
525  end if
526 
527  ! check whether to decrease next tol_SLEPC
528  if (rich_lvl.lt.max_it_rich) tol_slepc(rich_lvl+1) = min(&
529  &tol_slepc(rich_lvl+1),&
530  &tol_slepc_adapt_factor*max_rel_err(rich_lvl-1))
531  end if
532  end subroutine check_conv
533 
537  integer function find_max_rich_lvl(lvl_rich_req,max_lvl_rich_file) &
538  &result(ierr)
539  use num_vars, only: pb3d_name
541 
542  character(*), parameter :: rout_name = 'find_max_rich_lvl'
543 
544  ! input / output
545  integer, intent(inout) :: lvl_rich_req
546  integer, intent(inout) :: max_lvl_rich_file
547 
548  ! local variables
549  integer :: ir ! counter
550  character(len=max_str_ln) :: group_name ! name of group to probe for
551  logical :: group_exists ! whether probed group exists
552 
553  ! initialize ierr
554  ierr = 0
555 
556  ! try openining solution for different Richardson extrapolation levels
557  group_exists = .true. ! group_exists becomes stopping criterion
558  ir = 1 ! initialize counter
559  if (lvl_rich_req.gt.0 .and. lvl_rich_req.lt.huge(1)) ir = lvl_rich_req ! move to requested
560  do while (group_exists)
561  group_name = 'sol_R_'//trim(i2str(ir))
562  ierr = probe_hdf5_group(pb3d_name,group_name,group_exists)
563  chckerr('')
564  ir = ir + 1 ! increment counter
565  end do
566  max_lvl_rich_file = ir-2 ! -2 because there will be one additional iteration
567  end function find_max_rich_lvl
568 end module rich_ops
mpi_utilities::get_ser_var
Gather parallel variable in serial version on group master.
Definition: MPI_utilities.f90:55
pb3d_ops::reconstruct_pb3d_sol
integer function, public reconstruct_pb3d_sol(mds, grid_sol, sol, data_name, rich_lvl, lim_sec_sol, lim_pos)
Reconstructs the solution variables from PB3D HDF5 output.
Definition: PB3D_ops.f90:1359
rich_ops::stop_rich_lvl
subroutine, public stop_rich_lvl()
Stop a Richardson level.
Definition: rich_ops.f90:405
x_ops
Operations considering perturbation quantities.
Definition: X_ops.f90:4
eq_ops::divide_eq_jobs
integer function, public divide_eq_jobs(n_par_X, arr_size, n_div, n_div_max, n_par_X_base, range_name)
Divides the equilibrium jobs.
Definition: eq_ops.f90:6566
num_vars::dp
integer, parameter, public dp
double precision
Definition: num_vars.f90:46
eq_ops::calc_eq_jobs_lims
integer function, public calc_eq_jobs_lims(n_par_X, n_div)
Calculate eq_jobs_lims.
Definition: eq_ops.f90:6701
eq_vars
Variables that have to do with equilibrium quantities and the grid used in the calculations:
Definition: eq_vars.f90:27
rich_vars::rich_conv
logical, public rich_conv
if Richarson extrapolation has converged
Definition: rich_vars.f90:25
mpi_utilities
Numerical utilities related to MPI.
Definition: MPI_utilities.f90:20
num_vars
Numerical variables used by most other modules.
Definition: num_vars.f90:4
rich_ops::init_rich
integer function, public init_rich()
Initialize Richardson extrapolation system.
Definition: rich_ops.f90:28
num_vars::max_str_ln
integer, parameter, public max_str_ln
maximum length of strings
Definition: num_vars.f90:50
rich_ops::start_rich_lvl
integer function, public start_rich_lvl()
Start a Richardson level.
Definition: rich_ops.f90:327
rich_vars
Variables concerning Richardson extrapolation.
Definition: rich_vars.f90:4
str_utilities::i2str
elemental character(len=max_str_ln) function, public i2str(k)
Convert an integer to string.
Definition: str_utilities.f90:18
num_vars::n_sol_requested
integer, public n_sol_requested
how many solutions requested
Definition: num_vars.f90:170
rich_ops::check_conv
subroutine check_conv()
Decides whether convergence has been reached for the Richardson extrapolation.
Definition: rich_ops.f90:489
grid_utilities::calc_n_par_x_rich
integer function, public calc_n_par_x_rich(n_par_X_rich, only_half_grid)
Calculates the local number of parallel grid points for this Richardson level, taking into account th...
Definition: grid_utilities.f90:2862
x_ops::init_modes
integer function, public init_modes(grid_eq, eq)
Initializes some variables concerning the mode numbers.
Definition: X_ops.f90:919
hdf5_utilities
Utilities pertaining to HDF5 and XDMF.
Definition: HDF5_utilities.f90:6
num_vars::norm_disc_prec_sol
integer, public norm_disc_prec_sol
precision for normal discretization for solution
Definition: num_vars.f90:122
grid_vars::n_r_eq
integer, public n_r_eq
nr. of normal points in equilibrium grid
Definition: grid_vars.f90:20
output_ops::print_ex_2d
Print 2-D output on a file.
Definition: output_ops.f90:47
str_utilities
Operations on strings.
Definition: str_utilities.f90:4
grid_vars::grid_type
Type for grids.
Definition: grid_vars.f90:59
rich_ops::term_rich
subroutine, public term_rich()
Terminate the Richardson extrapolation system.
Definition: rich_ops.f90:220
str_utilities::r2strt
elemental character(len=max_str_ln) function, public r2strt(k)
Convert a real (double) to string.
Definition: str_utilities.f90:54
pb3d_ops::reconstruct_pb3d_in
integer function, public reconstruct_pb3d_in(data_name)
Reconstructs the input variables from PB3D HDF5 output.
Definition: PB3D_ops.f90:41
eq_vars::eq_1_type
flux equilibrium type
Definition: eq_vars.f90:63
grid_vars::alpha
real(dp), dimension(:), allocatable, public alpha
field line label alpha
Definition: grid_vars.f90:28
hdf5_utilities::probe_hdf5_group
integer function, public probe_hdf5_group(HDF5_name, group_name, group_exists)
Probe HDF5 file for group existence.
Definition: HDF5_utilities.f90:251
sol_vars::sol_type
solution type
Definition: sol_vars.f90:30
grid_vars::n_r_sol
integer, public n_r_sol
nr. of normal points in solution grid
Definition: grid_vars.f90:22
rich_vars::x_axis_rich
real(dp), dimension(:,:), allocatable, public x_axis_rich
x axis for plot of Eigenvalues with Richardson level
Definition: rich_vars.f90:27
rich_ops::do_rich
logical function, public do_rich()
Tests whether this Richardson level should be done.
Definition: rich_ops.f90:313
num_vars::rich_restart_lvl
integer, public rich_restart_lvl
starting Richardson level (0: none [default])
Definition: num_vars.f90:173
output_ops::draw_ex
subroutine, public draw_ex(var_names, draw_name, nplt, draw_dim, plot_on_screen, ex_plot_style, data_name, draw_ops, extra_ops, is_animated, ranges, delay, persistent)
Use external program to draw a plot.
Definition: output_ops.f90:1079
num_vars::eq_style
integer, public eq_style
either 1 (VMEC) or 2 (HELENA)
Definition: num_vars.f90:89
num_vars::max_it_rich
integer, public max_it_rich
number of levels for Richardson extrapolation
Definition: num_vars.f90:127
rich_ops::calc_rich_ex
subroutine, public calc_rich_ex(sol_val)
Calculates the coefficients of the Eigenvalues in the Richardson extrapolation.
Definition: rich_ops.f90:459
x_ops::setup_modes
integer function, public setup_modes(mds, grid_eq, grid, plot_name)
Sets up some variables concerning the mode numbers.
Definition: X_ops.f90:1060
num_vars::tol_slepc
real(dp), dimension(:), allocatable, public tol_slepc
tolerance for SLEPC for different Richardson levels
Definition: num_vars.f90:118
rich_vars::n_par_x
integer, public n_par_x
nr. of parallel points in field-aligned grid
Definition: rich_vars.f90:20
x_vars
Variables pertaining to the perturbation quantities.
Definition: X_vars.f90:4
rich_ops::find_max_rich_lvl
integer function, public find_max_rich_lvl(lvl_rich_req, max_lvl_rich_file)
Probe to find out which Richardson levels are available.
Definition: rich_ops.f90:539
rich_vars::use_guess
logical, public use_guess
whether a guess is formed from previous level of Richardson
Definition: rich_vars.f90:23
grid_utilities::calc_eqd_grid
Calculate grid of equidistant points, where optionally the last point can be excluded.
Definition: grid_utilities.f90:75
x_vars::mds_sol
type(modes_type), public mds_sol
modes variables for solution grid
Definition: X_vars.f90:125
rich_vars::no_guess
logical, public no_guess
disable guessing Eigenfunction from previous level of Richardson
Definition: rich_vars.f90:24
str_utilities::r2str
elemental character(len=max_str_ln) function, public r2str(k)
Convert a real (double) to string.
Definition: str_utilities.f90:42
messages::writo
subroutine, public writo(input_str, persistent, error, warning, alert)
Write output to file identified by output_i.
Definition: messages.f90:275
messages
Numerical utilities related to giving output.
Definition: messages.f90:4
helena_vars
Variables that have to do with HELENA quantities.
Definition: HELENA_vars.f90:4
rich_vars::max_rel_err
real(dp), dimension(:), allocatable, public max_rel_err
maximum relative error for all Richardson levels
Definition: rich_vars.f90:28
pb3d_ops
Operations on PB3D output.
Definition: PB3D_ops.f90:8
num_vars::pi
real(dp), parameter, public pi
Definition: num_vars.f90:83
grid_utilities
Numerical utilities related to the grids and different coordinate systems.
Definition: grid_utilities.f90:4
grid_vars::max_alpha
real(dp), public max_alpha
max. of field-line label [ ] in field-aligned grid
Definition: grid_vars.f90:27
pb3d_ops::reconstruct_pb3d_eq_1
integer function, public reconstruct_pb3d_eq_1(grid_eq, eq, data_name, lim_pos)
Reconstructs the equilibrium variables from PB3D HDF5 output.
Definition: PB3D_ops.f90:597
num_vars::pb3d_name
character(len=max_str_ln), public pb3d_name
name of PB3D output file
Definition: num_vars.f90:139
num_vars::jump_to_sol
logical, public jump_to_sol
jump to solution
Definition: num_vars.f90:141
grid_vars
Variables pertaining to the different grids used.
Definition: grid_vars.f90:4
pb3d_ops::reconstruct_pb3d_grid
integer function, public reconstruct_pb3d_grid(grid, data_name, rich_lvl, tot_rich, lim_pos, grid_limits)
Reconstructs grid variables from PB3D HDF5 output.
Definition: PB3D_ops.f90:442
messages::lvl_ud
subroutine, public lvl_ud(inc)
Increases/decreases lvl of output.
Definition: messages.f90:254
rich_vars::min_n_par_x
integer, public min_n_par_x
min. of n_par_X (e.g. first value in Richardson loop)
Definition: rich_vars.f90:22
rich_vars::rich_lvl
integer, public rich_lvl
current level of Richardson extrapolation
Definition: rich_vars.f90:19
sol_vars
Variables pertaining to the solution quantities.
Definition: sol_vars.f90:4
grid_vars::min_alpha
real(dp), public min_alpha
min. of field-line label [ ] in field-aligned grid
Definition: grid_vars.f90:26
grid_vars::n_alpha
integer, public n_alpha
nr. of field-lines
Definition: grid_vars.f90:23
output_ops
Operations concerning giving output, on the screen as well as in output files.
Definition: output_ops.f90:5
num_vars::rank
integer, public rank
MPI rank.
Definition: num_vars.f90:68
rich_vars::sol_val_rich
complex(dp), dimension(:,:,:), allocatable, public sol_val_rich
Richardson array of eigenvalues.
Definition: rich_vars.f90:26
input_utilities::dealloc_in
subroutine, public dealloc_in()
Cleans up input from equilibrium codes.
Definition: input_utilities.f90:268
str_utilities::c2str
elemental character(len=max_str_ln) function, public c2str(k)
Convert a complex (double) to string.
Definition: str_utilities.f90:66
input_utilities
Numerical utilities related to input.
Definition: input_utilities.f90:4
rich_vars::loc_max_rel_err
integer, dimension(:,:), allocatable, public loc_max_rel_err
location of maximum of relative error
Definition: rich_vars.f90:29
helena_vars::nchi
integer, public nchi
nr. of poloidal points
Definition: HELENA_vars.f90:35
eq_ops
Operations on the equilibrium variables.
Definition: eq_ops.f90:4
rich_ops
Operations concerning Richardson extrapolation.
Definition: rich_ops.f90:4
num_vars::tol_rich
real(dp), public tol_rich
tolerance for Richardson extrapolation
Definition: num_vars.f90:128