PB3D
[2.45]
Ideal linear high-n MHD stability in 3-D
|
Go to the documentation of this file.
5 #include <PB3D_macros.h>
36 character(*),
parameter :: rout_name =
'init_rich'
44 character(len=4) :: grid_eq_name
45 character(len=4) :: grid_x_name
46 character(len=max_str_ln) :: err_msg
57 if (
rank.eq.0 .and. max_it_rich.gt.1)
then
60 call writo(
'Richardson extrapolation loop initialization')
63 call writo(
'Richardson extrapolation loop continuation at &
88 call writo(
'reconstructing Richardson extrapolation variables')
91 call writo(
'Prepare general variables')
104 grid_eq_name =
'eq_B'
125 call writo(
'Prepare variables for Richardson level '//&
151 call writo(
'Recreate Richardson variables')
165 err_msg =
'Saved variables started with &
186 call grid_x_b%dealloc()
194 call grid_eq_b%dealloc()
195 call grid_sol%dealloc()
202 call writo(
'Richardson extrapolation variables reconstructed')
205 if (max_it_rich.gt.1)
then
206 call writo(
'Maximum number of iterations: '//&
207 &trim(
i2str(max_it_rich)))
208 call writo(
'Tolerance requested: '//trim(
r2strt(tol_rich)))
227 if (max_it_rich.gt.1)
then
229 call writo(
'Finishing Richardson extrapolation loop')
237 &
' steps, no convergence reached:')
242 call writo(
'Maximum relative error '//&
245 call writo(
'Tolerance requested: '//trim(
r2strt(tol_rich)))
246 call writo(
'Resulting best guesses for Eigenvalues:')
249 call writo(
'For Eigenvalue '//trim(
i2str(id))//
':')
256 call writo(
'with, theoretically, an error of the order O(Δ^'//&
259 &
') without Richardson extrapolation')
260 call writo(
'Notice that this is ONLY valid if the problem in the &
261 &different Richardson stages is similar:')
263 call writo(
'- It has to be part of the point spectrum')
264 call writo(
'- The Eigenvectors should look similar')
270 if (
rank.eq.0)
call draw_sol_val_rich()
283 subroutine draw_sol_val_rich()
287 character(len=max_str_ln) :: plot_title
288 character(len=max_str_ln) :: plot_name
291 call writo(
'Plotting Eigenvalues as function of nr. of parallel &
296 plot_title =
'Eigenvalues as function of nr. of parallel points'
297 plot_name =
'Eigenvalues_richardson'
307 call writo(
'Done plotting Eigenvalues')
308 end subroutine draw_sol_val_rich
334 character(*),
parameter :: rout_name =
'start_rich_lvl'
338 logical :: only_half_grid
339 integer :: n_par_x_loc
340 integer :: var_size_without_par(2)
352 only_half_grid = .false.
355 only_half_grid = .true.
363 call writo(
'Jumping straight to solution, no need to divide into &
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
390 &n_div_max=1,range_name=
'poloidal points in the &
391 &axisymmetric HELENA cross-section')
433 subroutine set_guess()
435 real(
dp),
parameter :: tol = 5._dp
444 end subroutine set_guess
462 complex(dp),
intent(in) :: sol_val(:)
492 real(dp),
allocatable :: corr(:)
494 real(dp) :: tol_SLEPC_adapt_factor = 0.01_dp
510 call writo(
'Richardson level '//trim(
i2str(ir))//
' -> '//&
511 &trim(
i2str(ir+1))//
': maximum relative error '//&
523 call writo(
'tolerance '//trim(
r2strt(tol_rich))//
' not yet &
542 character(*),
parameter :: rout_name =
'find_max_rich_lvl'
545 integer,
intent(inout) :: lvl_rich_req
546 integer,
intent(inout) :: max_lvl_rich_file
550 character(len=max_str_ln) :: group_name
551 logical :: group_exists
557 group_exists = .true.
559 if (lvl_rich_req.gt.0 .and. lvl_rich_req.lt.huge(1)) ir = lvl_rich_req
560 do while (group_exists)
561 group_name =
'sol_R_'//trim(
i2str(ir))
566 max_lvl_rich_file = ir-2
Gather parallel variable in serial version on group master.
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.
subroutine, public stop_rich_lvl()
Stop a Richardson level.
Operations considering perturbation quantities.
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.
integer, parameter, public dp
double precision
integer function, public calc_eq_jobs_lims(n_par_X, n_div)
Calculate eq_jobs_lims.
Variables that have to do with equilibrium quantities and the grid used in the calculations:
logical, public rich_conv
if Richarson extrapolation has converged
Numerical utilities related to MPI.
Numerical variables used by most other modules.
integer function, public init_rich()
Initialize Richardson extrapolation system.
integer, parameter, public max_str_ln
maximum length of strings
integer function, public start_rich_lvl()
Start a Richardson level.
Variables concerning Richardson extrapolation.
elemental character(len=max_str_ln) function, public i2str(k)
Convert an integer to string.
integer, public n_sol_requested
how many solutions requested
subroutine check_conv()
Decides whether convergence has been reached for the Richardson extrapolation.
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...
integer function, public init_modes(grid_eq, eq)
Initializes some variables concerning the mode numbers.
Utilities pertaining to HDF5 and XDMF.
integer, public norm_disc_prec_sol
precision for normal discretization for solution
integer, public n_r_eq
nr. of normal points in equilibrium grid
Print 2-D output on a file.
subroutine, public term_rich()
Terminate the Richardson extrapolation system.
elemental character(len=max_str_ln) function, public r2strt(k)
Convert a real (double) to string.
integer function, public reconstruct_pb3d_in(data_name)
Reconstructs the input variables from PB3D HDF5 output.
real(dp), dimension(:), allocatable, public alpha
field line label alpha
integer function, public probe_hdf5_group(HDF5_name, group_name, group_exists)
Probe HDF5 file for group existence.
integer, public n_r_sol
nr. of normal points in solution grid
real(dp), dimension(:,:), allocatable, public x_axis_rich
x axis for plot of Eigenvalues with Richardson level
logical function, public do_rich()
Tests whether this Richardson level should be done.
integer, public rich_restart_lvl
starting Richardson level (0: none [default])
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.
integer, public eq_style
either 1 (VMEC) or 2 (HELENA)
integer, public max_it_rich
number of levels for Richardson extrapolation
subroutine, public calc_rich_ex(sol_val)
Calculates the coefficients of the Eigenvalues in the Richardson extrapolation.
integer function, public setup_modes(mds, grid_eq, grid, plot_name)
Sets up some variables concerning the mode numbers.
real(dp), dimension(:), allocatable, public tol_slepc
tolerance for SLEPC for different Richardson levels
integer, public n_par_x
nr. of parallel points in field-aligned grid
Variables pertaining to the perturbation quantities.
integer function, public find_max_rich_lvl(lvl_rich_req, max_lvl_rich_file)
Probe to find out which Richardson levels are available.
logical, public use_guess
whether a guess is formed from previous level of Richardson
Calculate grid of equidistant points, where optionally the last point can be excluded.
type(modes_type), public mds_sol
modes variables for solution grid
logical, public no_guess
disable guessing Eigenfunction from previous level of Richardson
elemental character(len=max_str_ln) function, public r2str(k)
Convert a real (double) to string.
subroutine, public writo(input_str, persistent, error, warning, alert)
Write output to file identified by output_i.
Numerical utilities related to giving output.
Variables that have to do with HELENA quantities.
real(dp), dimension(:), allocatable, public max_rel_err
maximum relative error for all Richardson levels
Operations on PB3D output.
real(dp), parameter, public pi
Numerical utilities related to the grids and different coordinate systems.
real(dp), public max_alpha
max. of field-line label [ ] in field-aligned grid
integer function, public reconstruct_pb3d_eq_1(grid_eq, eq, data_name, lim_pos)
Reconstructs the equilibrium variables from PB3D HDF5 output.
character(len=max_str_ln), public pb3d_name
name of PB3D output file
logical, public jump_to_sol
jump to solution
Variables pertaining to the different grids used.
integer function, public reconstruct_pb3d_grid(grid, data_name, rich_lvl, tot_rich, lim_pos, grid_limits)
Reconstructs grid variables from PB3D HDF5 output.
subroutine, public lvl_ud(inc)
Increases/decreases lvl of output.
integer, public min_n_par_x
min. of n_par_X (e.g. first value in Richardson loop)
integer, public rich_lvl
current level of Richardson extrapolation
Variables pertaining to the solution quantities.
real(dp), public min_alpha
min. of field-line label [ ] in field-aligned grid
integer, public n_alpha
nr. of field-lines
Operations concerning giving output, on the screen as well as in output files.
integer, public rank
MPI rank.
complex(dp), dimension(:,:,:), allocatable, public sol_val_rich
Richardson array of eigenvalues.
elemental character(len=max_str_ln) function, public c2str(k)
Convert a complex (double) to string.
integer, dimension(:,:), allocatable, public loc_max_rel_err
location of maximum of relative error
integer, public nchi
nr. of poloidal points
Operations on the equilibrium variables.
Operations concerning Richardson extrapolation.
real(dp), public tol_rich
tolerance for Richardson extrapolation