PB3D [2.47]
Ideal linear high-n MHD stability in 3-D
Loading...
Searching...
No Matches
num_vars.f90
Go to the documentation of this file.
1!------------------------------------------------------------------------------!
2!> Numerical variables used by most other modules.
3!------------------------------------------------------------------------------!
4module num_vars
5 use iso_fortran_env
6
7 implicit none
8 private
37 &rz_0, &
42
43 ! technical variables
44 !integer, parameter :: dp = kind(1.d0) !< double precision
45 !integer, parameter :: qp = selected_real_kind (32) !< quadruple precision
46 integer, parameter :: dp = real64 !< double precision
47 !integer, parameter :: qp = REAL128 !< quadruple precision
48 integer, parameter :: dpi = int64 !< double precision
49 real(dp), parameter :: weight_dp = 0.008 !< size of double precision in kB
50 integer, parameter :: max_str_ln = 120 !< maximum length of strings
51 integer, parameter :: max_name_ln = 30 !< maximum length of filenames
52 integer, parameter :: max_deriv = 2 !< highest derivatives for metric factors in Flux coords.
53 integer :: prog_style !< program style (1: PB3D, 2: PB3D_POST)
54 character(len=4) :: prog_name !< name of program, used for info
55 character(len=3), parameter :: output_name = 'out' !< name of output file
56 character(len=14), parameter :: shell_commands_name = 'shell_commands' !< name of shell commands file
57 character(len=9), parameter :: mem_usage_name = 'mem_usage' !< name of memory usage file
58 integer :: mem_usage_count !< counter for memory usage output
59 real(dp), parameter :: prog_version = 2.47_dp !< version number
60 real(dp), parameter :: min_pb3d_version = 2.43_dp !< minimum PB3D version for POST
61#if ldebug
62 logical :: debug_version = .true. !< debug version used
63#else
64 logical :: debug_version = .false. !< not debug version
65#endif
66
67 ! MPI variables
68 integer :: rank !< MPI rank
69 integer :: n_procs !< nr. of MPI processes
70 integer :: sol_n_procs !< nr. of MPI processes for solution with SLEPC
71 integer(kind=8) :: time_start !< start time of simulation
72
73 ! job variables
74 real(dp) :: max_tot_mem !< maximum total memory for all processes [MB]
75 real(dp) :: max_x_mem !< maximum memory for perturbation calculations for all processes [MB]
76 integer, allocatable :: x_jobs_lims(:,:) !< data about X jobs: [\f$\min_k\f$, \f$\max_k\f$, \f$\min_m\f$, \f$\max_m\f$] for all jobs
77 integer, allocatable :: eq_jobs_lims(:,:) !< data about eq jobs: [\f$\min_\theta\f$, \f$\max_\theta\f$] for all jobs
78 integer :: x_job_nr !< nr. of X job
79 integer :: eq_job_nr !< nr. of eq job
80 real(dp), parameter :: mem_scale_fac = 6.0 !< empirical scale factor of memory to calculate eq compared to just storing it
81
82 ! physical and mathematical variables
83 real(dp), parameter :: pi=4_dp*datan(1.0_dp) !< \f$\pi\f$
84 real(dp), parameter :: mu_0_original = 4e-7_dp*pi !< permeability of free space
85 complex(dp), parameter :: iu = (0,1) !< complex unit
86
87 ! concerning runtime
88 integer :: ev_style !< determines the method used for solving an EV problem
89 integer :: eq_style !< either 1 (VMEC) or 2 (HELENA)
90 integer :: rho_style !< style for equilibrium density profile
91 integer :: u_style !< style for calculation of U (1: ord.2, 2: ord.1, 1: ord.0)
92 integer :: norm_style !< style for normalization
93 integer :: k_style !< style for kinetic energy
94 integer :: bc_style(2) !< style for BC left and right
95 integer :: x_style !< style for secondary mode numbers (1: prescribed, 2: fast)
96 integer :: matrix_slepc_style !< style for matrix storage (1: sparse, 2: shell)
97 integer :: solver_slepc_style !< style for solver (1: Krylov-Schur, 2: GD)
98 integer :: post_style !< style for POST (1: extended grid, 2: B-aligned grid)
99 integer :: x_grid_style !< style for normal component of X grid (1: eq, 2: sol, 3: enriched)
100 integer :: alpha_style !< style for alpha (1: one field line, many turns, 2: many field lines, one turn)
101 integer :: max_it_slepc !< maximum nr. of iterations for SLEPC
102 logical :: plot_resonance !< whether to plot the q-profile or iota-profile with resonances
103 logical :: plot_magn_grid !< whether to plot the grid in real coordinates
104 logical :: plot_b !< whether to plot the magnetic field in real coordinates
105 logical :: plot_j !< whether to plot the current in real coordinates
106 logical :: plot_flux_q !< whether to plot flux quantities in real coordinates
107 logical :: plot_kappa !< whether to plot curvature
108 logical :: plot_sol_xi !< whether to plot plasma perturbation of solution in POST
109 logical :: plot_sol_q !< whether to plot magnetic perturbation of solution in POST
110 logical :: plot_vac_pot !< whether to plot vacuum potential in POST
111 logical :: plot_e_rec !< whether to plot energy reconstruction in POST
112 logical :: ltest !< whether or not to call the testing routines
113 logical :: use_pol_flux_e !< whether poloidal flux is used in E coords.
114 logical :: use_pol_flux_f !< whether poloidal flux is used in F coords.
115 logical :: use_normalization !< whether to use normalization or not
116 real(dp) :: ev_bc !< value of artificial Eigenvalue for boundary condition
117 real(dp) :: ev_guess !< first guess for eigenvalue
118 real(dp), allocatable :: tol_slepc(:) !< tolerance for SLEPC for different Richardson levels
119 real(dp) :: max_njq_change !< maximum change of prim. mode number times saf. fac. / rot. transf. when using X_style 2 (fast)
120 integer :: norm_disc_prec_eq !< precision for normal discretization for equilibrium
121 integer :: norm_disc_prec_x !< precision for normal discretization for perturbation
122 integer :: norm_disc_prec_sol !< precision for normal discretization for solution
123 integer :: norm_disc_style_sol !< style for normal discretization for solution (1: central fin. diff., 2: left fin. diff.)
124 integer :: magn_int_style !< style for magnetic integrals (1: trapezoidal, 2: Simpson 3/8)
125
126 ! concerning Richardson extrapolation
127 integer :: max_it_rich !< number of levels for Richardson extrapolation
128 real(dp) :: tol_rich !< tolerance for Richardson extrapolation
129
130 ! concerning finding the magnetic field lines
131 integer :: max_it_zero !< maximum number of iterations to find zeros
132 integer :: max_nr_backtracks_hh !< maximum number of backtracks for Householder, relax. factors
133 real(dp) :: tol_zero !< tolerance for zeros
134 real(dp) :: tol_norm !< tolerance for normal range (normalized to 0..1)
135
136 ! concerning input / output
137 integer, parameter :: ex_max_size = 10000 !< maximum size of matrices for external plot
138 character(len=max_str_ln) :: eq_name !< name of equilibrium file from VMEC or HELENA
139 character(len=max_str_ln) :: pb3d_name !< name of PB3D output file
140 logical :: no_plots = .false. !< no plots made
141 logical :: jump_to_sol = .false. !< jump to solution
142 logical :: export_hel = .false. !< export HELENA
143 logical :: plot_vmec_modes = .false. !< plot VMEC modes
144 logical :: invert_top_bottom_h = .false. !< invert top and bottom for HELENA equilibria
145 logical :: no_output = .false. !< no output shown
146 logical :: post_output_full = .false. !< POST has output on full grids
147 logical :: post_output_sol = .false. !< POST has outputs of solution
148 logical :: do_execute_command_line = .false. !< call "execute_command_line" inside program
149 logical :: print_mem_usage = .false. !< print memory usage is printed
150 logical :: swap_angles = .false. !< swap angles theta and zeta in plots (only for POST)
151 logical :: compare_tor_pos = .false. !< compare quantities at toroidal positions (only for POST)
152 logical :: retain_all_sol !< retain also faulty solutions
153 character(len=5) :: plot_dir = 'Plots' !< directory where to save plots
154 character(len=7) :: script_dir = 'Scripts' !< directory where to save scripts for plots
155 character(len=4) :: data_dir = 'Data' !< directory where to save data for plots
156 integer :: n_theta_plot !< nr. of poloidal points in plot
157 integer :: n_zeta_plot !< nr. of toroidal points in plot
158 integer :: n_vac_plot(2) !< nr. of points in R and Z in vacuum
159 real(dp) :: min_theta_plot !< min. of \c theta_plot
160 real(dp) :: max_theta_plot !< max. of \c theta_plot
161 real(dp) :: min_zeta_plot !< min. of \c zeta_plot
162 real(dp) :: max_zeta_plot !< max. of \c zeta_plot
163 real(dp) :: min_r_plot !< min. of \c r_plot
164 real(dp) :: max_r_plot !< max. of \c r_plot
165 real(dp) :: min_rvac_plot !< min. of \c R in which to plot vacuum
166 real(dp) :: max_rvac_plot !< max. of \c R in which to plot vacuum
167 real(dp) :: min_zvac_plot !< min. of \c Z in which to plot vacuum
168 real(dp) :: max_zvac_plot !< max. of \c Z in which to plot vacuum
169 integer :: plot_grid_style !< style for POST plot grid (0: 3-D plots, 1: slab plots, 2: slab plots with folding, 3: straight cylinder))
170 integer :: n_sol_requested !< how many solutions requested
171 integer :: n_sol_plotted(4) !< how many solutions to be plot (first unstable, last unstable, first stable, last stable)
172 integer :: plot_size(2) !< size of plot in inches
173 integer :: rich_restart_lvl !< starting Richardson level (0: none [default])
174 character(len=max_str_ln) :: input_name !< will hold the full name of the input file
175 integer :: ex_plot_style !< external plot style (1: GNUPlot, 2: Bokeh for 2D, Mayavi for 3D)
176 real(dp) :: pert_mult_factor_post !< factor with which to multiply perturbation strength for POST
177
178 ! Concerning comparing toroidal positions
179 real(dp) :: rz_0(2) !< origin of geometrical poloidal coordinate
180
181 ! Concerning file numbers
182 integer, parameter :: input_i = 50 !< file number of input file
183 integer, parameter :: eq_i = 51 !< file number of equilibrium file from VMEC or HELENA
184 integer, parameter :: pb3d_i = 52 !< file number of PB3D output file
185 integer, parameter :: output_i = 53 !< file number of output file
186 integer, parameter :: shell_commands_i = 54 !< file number of shell commands file
187 integer, parameter :: mem_usage_i = 55 !< file number of memory usage file
188 integer, parameter :: output_ev_i = 56 !< file number of output of EV
189 integer, parameter :: decomp_i = 57 !< file number of output of EV decomposition
190 integer, parameter :: hel_export_i = 59 !< file number of output of HELENA equilibrium export file
191 integer, parameter :: hel_pert_i = 58 !< file number of HELENA equilibrium perturbation file
192 integer, parameter :: prop_b_tor_i = 60 !< file number of \f$B_\phi\f$ proportionality factor file
193end module num_vars
Numerical variables used by most other modules.
Definition num_vars.f90:4
integer, parameter, public ex_max_size
maximum size of matrices for external plot
Definition num_vars.f90:137
integer, public sol_n_procs
nr. of MPI processes for solution with SLEPC
Definition num_vars.f90:70
integer, parameter, public dp
double precision
Definition num_vars.f90:46
logical, public ltest
whether or not to call the testing routines
Definition num_vars.f90:112
integer, public post_style
style for POST (1: extended grid, 2: B-aligned grid)
Definition num_vars.f90:98
logical, public plot_b
whether to plot the magnetic field in real coordinates
Definition num_vars.f90:104
integer, public n_theta_plot
nr. of poloidal points in plot
Definition num_vars.f90:156
integer, public plot_grid_style
style for POST plot grid (0: 3-D plots, 1: slab plots, 2: slab plots with folding,...
Definition num_vars.f90:169
character(len=3), parameter, public output_name
name of output file
Definition num_vars.f90:55
integer, public norm_disc_prec_sol
precision for normal discretization for solution
Definition num_vars.f90:122
logical, public plot_kappa
whether to plot curvature
Definition num_vars.f90:107
character(len=max_str_ln), public input_name
will hold the full name of the input file
Definition num_vars.f90:174
integer, parameter, public max_name_ln
maximum length of filenames
Definition num_vars.f90:51
real(dp), public max_r_plot
max. of r_plot
Definition num_vars.f90:164
real(dp), public min_theta_plot
min. of theta_plot
Definition num_vars.f90:159
real(dp), parameter, public pi
Definition num_vars.f90:83
logical, public print_mem_usage
print memory usage is printed
Definition num_vars.f90:149
character(len=7), public script_dir
directory where to save scripts for plots
Definition num_vars.f90:154
real(dp), public max_zeta_plot
max. of zeta_plot
Definition num_vars.f90:162
integer, parameter, public shell_commands_i
file number of shell commands file
Definition num_vars.f90:186
logical, public compare_tor_pos
compare quantities at toroidal positions (only for POST)
Definition num_vars.f90:151
real(dp), public max_njq_change
maximum change of prim. mode number times saf. fac. / rot. transf. when using X_style 2 (fast)
Definition num_vars.f90:119
real(dp), public tol_norm
tolerance for normal range (normalized to 0..1)
Definition num_vars.f90:134
logical, public no_output
no output shown
Definition num_vars.f90:145
real(dp), parameter, public mem_scale_fac
empirical scale factor of memory to calculate eq compared to just storing it
Definition num_vars.f90:80
integer, public n_procs
nr. of MPI processes
Definition num_vars.f90:69
logical, public plot_flux_q
whether to plot flux quantities in real coordinates
Definition num_vars.f90:106
complex(dp), parameter, public iu
complex unit
Definition num_vars.f90:85
integer, dimension(2), public plot_size
size of plot in inches
Definition num_vars.f90:172
character(len=max_str_ln), public eq_name
name of equilibrium file from VMEC or HELENA
Definition num_vars.f90:138
integer, public n_sol_requested
how many solutions requested
Definition num_vars.f90:170
integer, parameter, public max_str_ln
maximum length of strings
Definition num_vars.f90:50
integer, dimension(:,:), allocatable, public x_jobs_lims
data about X jobs: [ , , , ] for all jobs
Definition num_vars.f90:76
logical, public plot_sol_q
whether to plot magnetic perturbation of solution in POST
Definition num_vars.f90:109
real(dp), public ev_guess
first guess for eigenvalue
Definition num_vars.f90:117
real(dp), public ev_bc
value of artificial Eigenvalue for boundary condition
Definition num_vars.f90:116
logical, public post_output_sol
POST has outputs of solution.
Definition num_vars.f90:147
integer, public prog_style
program style (1: PB3D, 2: PB3D_POST)
Definition num_vars.f90:53
real(dp), parameter, public mu_0_original
permeability of free space
Definition num_vars.f90:84
integer, dimension(2), public n_vac_plot
nr. of points in R and Z in vacuum
Definition num_vars.f90:158
logical, public use_normalization
whether to use normalization or not
Definition num_vars.f90:115
integer, public norm_disc_style_sol
style for normal discretization for solution (1: central fin. diff., 2: left fin. diff....
Definition num_vars.f90:123
integer, public u_style
style for calculation of U (1: ord.2, 2: ord.1, 1: ord.0)
Definition num_vars.f90:91
real(dp), public max_zvac_plot
max. of Z in which to plot vacuum
Definition num_vars.f90:168
logical, public debug_version
debug version used
Definition num_vars.f90:62
integer, parameter, public mem_usage_i
file number of memory usage file
Definition num_vars.f90:187
character(len=5), public plot_dir
directory where to save plots
Definition num_vars.f90:153
logical, public plot_vac_pot
whether to plot vacuum potential in POST
Definition num_vars.f90:110
integer, public n_zeta_plot
nr. of toroidal points in plot
Definition num_vars.f90:157
real(dp), public max_rvac_plot
max. of R in which to plot vacuum
Definition num_vars.f90:166
integer(kind=8), public time_start
start time of simulation
Definition num_vars.f90:71
logical, public plot_resonance
whether to plot the q-profile or iota-profile with resonances
Definition num_vars.f90:102
real(dp), parameter, public min_pb3d_version
minimum PB3D version for POST
Definition num_vars.f90:60
integer, dimension(:,:), allocatable, public eq_jobs_lims
data about eq jobs: [ , ] for all jobs
Definition num_vars.f90:77
integer, public x_grid_style
style for normal component of X grid (1: eq, 2: sol, 3: enriched)
Definition num_vars.f90:99
character(len=4), public prog_name
name of program, used for info
Definition num_vars.f90:54
real(dp), public min_zeta_plot
min. of zeta_plot
Definition num_vars.f90:161
integer, public rho_style
style for equilibrium density profile
Definition num_vars.f90:90
integer, parameter, public max_deriv
highest derivatives for metric factors in Flux coords.
Definition num_vars.f90:52
real(dp), parameter, public prog_version
version number
Definition num_vars.f90:59
integer, parameter, public eq_i
file number of equilibrium file from VMEC or HELENA
Definition num_vars.f90:183
logical, public post_output_full
POST has output on full grids.
Definition num_vars.f90:146
integer, public eq_style
either 1 (VMEC) or 2 (HELENA)
Definition num_vars.f90:89
integer, parameter, public dpi
double precision
Definition num_vars.f90:48
integer, public mem_usage_count
counter for memory usage output
Definition num_vars.f90:58
integer, parameter, public hel_pert_i
file number of HELENA equilibrium perturbation file
Definition num_vars.f90:191
integer, public max_it_slepc
maximum nr. of iterations for SLEPC
Definition num_vars.f90:101
integer, parameter, public decomp_i
file number of output of EV decomposition
Definition num_vars.f90:189
character(len=9), parameter, public mem_usage_name
name of memory usage file
Definition num_vars.f90:57
logical, public plot_vmec_modes
plot VMEC modes
Definition num_vars.f90:143
character(len=max_str_ln), public pb3d_name
name of PB3D output file
Definition num_vars.f90:139
integer, public norm_disc_prec_eq
precision for normal discretization for equilibrium
Definition num_vars.f90:120
integer, parameter, public output_ev_i
file number of output of EV
Definition num_vars.f90:188
integer, dimension(4), public n_sol_plotted
how many solutions to be plot (first unstable, last unstable, first stable, last stable)
Definition num_vars.f90:171
logical, public invert_top_bottom_h
invert top and bottom for HELENA equilibria
Definition num_vars.f90:144
integer, public x_job_nr
nr. of X job
Definition num_vars.f90:78
real(dp), public min_rvac_plot
min. of R in which to plot vacuum
Definition num_vars.f90:165
real(dp), public tol_rich
tolerance for Richardson extrapolation
Definition num_vars.f90:128
logical, public export_hel
export HELENA
Definition num_vars.f90:142
integer, public alpha_style
style for alpha (1: one field line, many turns, 2: many field lines, one turn)
Definition num_vars.f90:100
real(dp), public pert_mult_factor_post
factor with which to multiply perturbation strength for POST
Definition num_vars.f90:176
logical, public plot_j
whether to plot the current in real coordinates
Definition num_vars.f90:105
integer, parameter, public pb3d_i
file number of PB3D output file
Definition num_vars.f90:184
integer, public max_nr_backtracks_hh
maximum number of backtracks for Householder, relax. factors
Definition num_vars.f90:132
integer, dimension(2), public bc_style
style for BC left and right
Definition num_vars.f90:94
integer, public ex_plot_style
external plot style (1: GNUPlot, 2: Bokeh for 2D, Mayavi for 3D)
Definition num_vars.f90:175
real(dp), dimension(2), public rz_0
origin of geometrical poloidal coordinate
Definition num_vars.f90:179
integer, public ev_style
determines the method used for solving an EV problem
Definition num_vars.f90:88
real(dp), public min_r_plot
min. of r_plot
Definition num_vars.f90:163
integer, public rank
MPI rank.
Definition num_vars.f90:68
real(dp), public min_zvac_plot
min. of Z in which to plot vacuum
Definition num_vars.f90:167
integer, parameter, public input_i
file number of input file
Definition num_vars.f90:182
integer, public rich_restart_lvl
starting Richardson level (0: none [default])
Definition num_vars.f90:173
integer, public k_style
style for kinetic energy
Definition num_vars.f90:93
integer, parameter, public hel_export_i
file number of output of HELENA equilibrium export file
Definition num_vars.f90:190
logical, public plot_sol_xi
whether to plot plasma perturbation of solution in POST
Definition num_vars.f90:108
integer, public norm_disc_prec_x
precision for normal discretization for perturbation
Definition num_vars.f90:121
real(dp), dimension(:), allocatable, public tol_slepc
tolerance for SLEPC for different Richardson levels
Definition num_vars.f90:118
logical, public jump_to_sol
jump to solution
Definition num_vars.f90:141
integer, public norm_style
style for normalization
Definition num_vars.f90:92
integer, public max_it_zero
maximum number of iterations to find zeros
Definition num_vars.f90:131
integer, parameter, public prop_b_tor_i
file number of proportionality factor file
Definition num_vars.f90:192
logical, public do_execute_command_line
call "execute_command_line" inside program
Definition num_vars.f90:148
real(dp), parameter, public weight_dp
size of double precision in kB
Definition num_vars.f90:49
logical, public plot_magn_grid
whether to plot the grid in real coordinates
Definition num_vars.f90:103
integer, public x_style
style for secondary mode numbers (1: prescribed, 2: fast)
Definition num_vars.f90:95
logical, public swap_angles
swap angles theta and zeta in plots (only for POST)
Definition num_vars.f90:150
logical, public retain_all_sol
retain also faulty solutions
Definition num_vars.f90:152
integer, public matrix_slepc_style
style for matrix storage (1: sparse, 2: shell)
Definition num_vars.f90:96
real(dp), public max_theta_plot
max. of theta_plot
Definition num_vars.f90:160
logical, public use_pol_flux_e
whether poloidal flux is used in E coords.
Definition num_vars.f90:113
integer, public eq_job_nr
nr. of eq job
Definition num_vars.f90:79
logical, public use_pol_flux_f
whether poloidal flux is used in F coords.
Definition num_vars.f90:114
real(dp), public tol_zero
tolerance for zeros
Definition num_vars.f90:133
real(dp), public max_tot_mem
maximum total memory for all processes [MB]
Definition num_vars.f90:74
logical, public plot_e_rec
whether to plot energy reconstruction in POST
Definition num_vars.f90:111
integer, parameter, public output_i
file number of output file
Definition num_vars.f90:185
integer, public magn_int_style
style for magnetic integrals (1: trapezoidal, 2: Simpson 3/8)
Definition num_vars.f90:124
character(len=14), parameter, public shell_commands_name
name of shell commands file
Definition num_vars.f90:56
character(len=4), public data_dir
directory where to save data for plots
Definition num_vars.f90:155
real(dp), public max_x_mem
maximum memory for perturbation calculations for all processes [MB]
Definition num_vars.f90:75
integer, public max_it_rich
number of levels for Richardson extrapolation
Definition num_vars.f90:127
logical, public no_plots
no plots made
Definition num_vars.f90:140
integer, public solver_slepc_style
style for solver (1: Krylov-Schur, 2: GD)
Definition num_vars.f90:97