PB3D  [2.45]
Ideal linear high-n MHD stability in 3-D
Frequently Asked Questions

Table of Contents

runtime errors

Table 1. frequently encountered errors
error solution
"need at least N points in grid" grid_utilities.setup_deriv_data() needs a minimum number of points in a grid to setup data with which the derivatives can be calculated later in grid_utilities.apply_disc(). If the grid does not have enough points, and the order of the derivative is too high, the procedure gives this error message. The solution is to either increase the number of points, or to lower the order. It might be that the number of points in the grid is lower than you expect because the grid is divided. In this case, you need more memory (see max_tot_mem in Input variables).
"Aument number of modes or choose finer grid" The range of secondary mode numbers at every flux surface is either user-specified, for X_style 1, or chosen automatically around the most resonant values for X_style 2 (see Input variables). This implies that, on the other hand, every secondary mode should have a normal range in which it is present, possibly multiple ranges for reversed-shear configurations. The code automatically checks whether this is indeed the case. It could, for example, be that a certain mode number is not present anywhere, when the normal grid in which it is tabulated is too coarse. A solution is therefore to choose a finer grid. Alternatively, for X_style 1, the range can be adapted, and for X_style 2 the number of modes n_mod_X. Note that the particular grid that this discussion is about, can be found out by the trace of the error message. If it results from the solution driver, it concerns the solution grid, and if it concerns the perturbation driver, it concerns the perturbation grid. The solution grid is specified by its range through min_r_sol and max_r_sol and the number of points n_r_sol, and the perturbation grid by the X_grid_style. See Input variables.
"Zero pivot in LU factorization" There exist cases in which the eigenvalue solver fails when n_mod_X = 1, for unkown reasons. Increase n_mod_X or play with other parameters, such as the norm_disc_prec_sol.
jump_to_sol does not work Jumping over the equilibrium and perturbation drivers straight to the solution only works if solution parameters such as the boundary conditions are changed, not if the number of points in the solution, n_r_sol, is changed, as in this case the equilibrium and solution drivers need to be recalculated properly.
The solution suffers from numerical oscillations This is a work in progress. Change the limits of the solution grid min_r_sol (and possibly max_r_sol). Better even is to use asymmetric finite differences norm_disc_style_sol = 2

common problems

Table 2. common problems
problem solution
code compilation stuck Especially on intel systems, it has been found that sometimes the compiler seems to be stuck, especially for eq_ops. A solution is to use less optimization for the problematic files through -O2.
unphysical eigenvector For coarse equilbrium grids and/or strongly varying safety factors, and when using the fast version (i.e. with n_mod_X), it is possible that the resonating mode number range varies too quickly, leading to inaccurate interpolation of tensorial perturbation quantities in the solution grid. Try using X_grid_style 3, where enrichment of the equilibrium grid is used to set up the perturbation grid. If this does not help, additionally lower max_njq_change from its default value.
low accuracy for energy reconstruction Energy reconstruction tries to see whether by calculating the total volume integral of the perturbed potential energy and dividing it by the total volume integral of the kinetic energy of the perturbation, the eigenvalue can be recovered. This gives a lot of insight in the processes that drive the instabilities, by looking at the individual terms of these integrals, and is a good check on the internal consistency of the PB3D code. Note that for axisymmetric equilibria, the volume integral reduces to a surface integral in a poloidal cross-section. It is actually very hard to perform a good energy reconstruction because the techniques used differ from the ones in the PB3D code, where the normal derivatives of the eigenvector are performed using finite differences, while in the energy reconstruction direct volume integrals are used. To get the best possible results, therefore, it is important to achieve full Richardson convergence in the number of parallel points (by increasing max_it_rich and/or min_n_par_X), as well as convergence in the number of secondary mode harmonics (by increasing n_mod_X). Doing this, for axisymmetric cases, the code should retun quite accurate results, from version 2.26 upwards. These can furthermore be improved by choosing a finer post-processing grid (see n_theta_plot and n_zeta_plot). It is, however, possible that a small fraction, possibly of the order of a percent remains in the relative difference. This is probably due to the fact that in PB3D for X_style 2 (fast), the stencil is cut when the normal index falls out of its mode range (see insert_block_mat()).
Changing input does not work for Richardson extrapolation You cannot change the inputs as Richardson extrapolation depends on having these constant (with the exception of the number of poins in the parallel integrals, but this is done internally in PB3D). The important exception to this fact, however, is that you can change some of the solution grid parameters, such as n_r_sol (see Input variables).
The code has not been tested satisfactorily for decreasing normal coordinate. When the normal coordinate is decreasing (but still monotonous), the code should be able to handle this. However, a quick test gave some problems, which have to be debuged. An easy workaround is to just run the equilibrium solver again with inverted fields and currents.
The code has to be adapted for reversed-shear regions still. When there are reversed-shear regions, the routines that calculate the resonant flux surfaces, such as calc_res_surf() need to be extended. If this is not done, there will be problems, mostly for X_style 2 (fast), and especially for X_grid_style 3 (enriched).