PB3D [2.47]
Ideal linear high-n MHD stability in 3-D
Loading...
Searching...
No Matches
driver_eq.f90
Go to the documentation of this file.
1!------------------------------------------------------------------------------!
2!> Driver of the equilibrium part of PB3D.
3!------------------------------------------------------------------------------!
5#include <PB3D_macros.h>
7 use output_ops
8 use messages
9 use num_vars, only: dp, pi, max_str_ln
10 use grid_vars, only: grid_type
11 use eq_vars, only: eq_1_type, eq_2_type
12 use vac_vars, only: vac_type
13
14 implicit none
15 private
16 public run_driver_eq
17
18 ! global variables
19#if ldebug
20 logical :: plot_info = .false. !< plot information for comparison with HELENA \ldebug
21#endif
22
23contains
24 !> Main driver of PB3D equilibrium part.
25 !!
26 !! - sets up ([out] means for output):
27 !! * \c grid_eq [out] (for HELENA, only first Richardson level)
28 !! * \c grid_eq_B [out] (for VMEC, equal to grid_eq_out)
29 !! * \c eq_1 [out] (only first Richardson level)
30 !! * \c eq_2 [out] (for HELENA, only first Richardson level)
31 !! where output means
32 !! * on the equilibrium grid if \c X_grid style is 1,3 (no change).
33 !! * on a redistributed grid if \c X_grid_style is 2
34 !!
35 !! - writes to HDF5:
36 !! * \c grid_eq (for HELENA, only first Richardson level)
37 !! * \c grid_eq_B (for VMEC, equal to grid_eq)
38 !! * \c eq_1 (only first Richardson level)
39 !! * \c eq_2 (only for HELENA)
40 !!
41 !! - deallocates:
42 !! * \c grid_eq [out] before setting up
43 !! * \c grid_B_eq [out] before setting up
44 !! * \c eq_2 [out] before setting up
45 !!
46 !! \return ierr
47 integer function run_driver_eq(grid_eq_out,grid_eq_B_out,eq_1_out,&
48 &eq_2_out,vac) result(ierr)
49
62 use num_utilities, only: derivs
63 use mpi_utilities, only: wait_mpi
64 use rich_vars, only: rich_lvl
66 use vac_ops, only: store_vac
67 !!use num_utilities, only: calc_aux_utilities
68
69 character(*), parameter :: rout_name = 'run_driver_eq'
70
71 ! input / output
72 type(grid_type), intent(inout), target :: grid_eq_out !< output equilibrium grid
73 type(grid_type), intent(inout), pointer :: grid_eq_b_out !< output field-aligned equilibrium grid
74 type(eq_1_type), intent(inout) :: eq_1_out !< flux equilibrium variables in output grid
75 type(eq_2_type), intent(inout) :: eq_2_out !< metric equilibrium variables in output grid
76 type(vac_type), intent(inout) :: vac !< vacuum variables
77
78 ! local variables
79 type(eq_1_type) :: eq_1 ! flux equilibrium variables
80 type(eq_2_type) :: eq_2 ! metric equilibrium variables
81 type(grid_type) :: grid_eq ! equilibrium grid
82 type(grid_type) :: grid_eq_b ! field-aligned equilibrium grid
83 integer :: eq_limits(2) ! min. and max. index of eq. grid of this process
84 integer :: rich_lvl_name ! either the Richardson level or zero, to append to names
85 logical :: do_eq_1_ops ! whether specific calculations for eq_1 are necessary
86 logical :: do_eq_2_ops ! whether specific calculations for eq_2 are necessary
87 logical :: only_half_grid ! calculate only half grid
88 logical :: dealloc_vars ! whether to deallocate variables to save memory
89 character(len=8) :: flux_name ! toroidal or poloidal
90 character(len=max_str_ln) :: grid_eq_b_name ! name of grid_eq_B
91
92 ! initialize ierr
93 ierr = 0
94
95 ! decide whether to append Richardson level to name
96 select case (eq_style)
97 case (1) ! VMEC
98 rich_lvl_name = rich_lvl ! append richardson level
99 case (2) ! HELENA
100 rich_lvl_name = 0 ! do not append name
101 end select
102
103 ! Divide equilibrium grid under group processes, calculating the limits
104 ! and the normal coordinate.
105 ierr = calc_norm_range('PB3D_eq',eq_limits=eq_limits)
106 chckerr('')
107
108 ! jump to solution if requested
109 if (rich_lvl.eq.rich_restart_lvl .and. jump_to_sol) then
110 call writo('Prepare to jump to solution')
111 call lvl_ud(1)
112
113 ! grid_eq_out
114 select case (x_grid_style)
115 case (1,3) ! equilibrium or optimized
116 ! perturbation quantities are calculated on equilibrium
117 ! normal grid or optimized variant
118 ierr = reconstruct_pb3d_grid(grid_eq_out,'eq',&
119 &rich_lvl=rich_lvl_name,grid_limits=eq_limits)
120 chckerr('')
121 case (2) ! solution
122 ! start from equilibrium grid in equilibrium limits and then
123 ! redistribute it
124 ierr = reconstruct_pb3d_grid(grid_eq,'eq',&
125 &rich_lvl=rich_lvl_name,grid_limits=eq_limits)
126 chckerr('')
127 ierr = redistribute_output_grid(grid_eq,grid_eq_out)
128 chckerr('')
129 call grid_eq%dealloc()
130 end select
131
132 ! eq_1_out
133 ierr = reconstruct_pb3d_eq_1(grid_eq_out,eq_1_out,'eq_1')
134 chckerr('')
135
136 ! eq_2_out
137 if (eq_style.eq.2) then
138 ierr = reconstruct_pb3d_eq_2(grid_eq_out,eq_2_out,'eq_2')
139 chckerr('')
140 end if
141
142 call lvl_ud(-1)
143 call writo('Skipping rest to jump to solution')
144 return
145 end if
146
147 ! set up whether to deallocate variables
148 dealloc_vars = .true.
149#if ldebug
150 if (plot_info) dealloc_vars = .false.
151 if (ltest) dealloc_vars = .false.
152#endif
153 if (plot_b .or. plot_j .or. plot_kappa) dealloc_vars = .false. ! need transformation matrices
154
155 ! user output
156 call writo('The equilibrium variables are processed')
157 call lvl_ud(1)
158
159 select case (alpha_style)
160 case (1) ! single field line, multiple turns
161 call writo('With a single field-line')
162 call lvl_ud(1)
163 call writo('with label alpha = '//&
164 &trim(r2strt(alpha(1))))
165 call writo('with parallel range '//trim(r2strt(min_par_x))//&
166 &'..'//trim(r2strt(max_par_x)))
167 call lvl_ud(-1)
168 case (2) ! multiple field lines, single turns
169 call writo('With '//trim(i2str(n_alpha))//' field-lines')
170 end select
171 if (use_pol_flux_f) then
172 flux_name = 'poloidal'
173 else
174 flux_name = 'toroidal'
175 end if
176 call writo('using the '//trim(flux_name)//' flux as the normal &
177 &variable')
178
179 call lvl_ud(-1)
180
181 ! set up whether half or full parallel grid has to be calculated
182 if (rich_lvl.eq.1) then
183 only_half_grid = .false.
184 else
185 only_half_grid = .true.
186 end if
187
188 ! decide whether to do certain equilibrium calculations
189 if (rich_lvl.eq.rich_restart_lvl .and. eq_job_nr.eq.1) then
190 do_eq_1_ops = .true.
191 else
192 do_eq_1_ops = .false.
193 end if
194 select case (eq_style)
195 case (1) ! VMEC
196 do_eq_2_ops = .true.
197 case (2) ! HELENA
198 if (rich_lvl.eq.rich_restart_lvl .and. eq_job_nr.eq.1) then
199 do_eq_2_ops = .true.
200 else
201 do_eq_2_ops = .false.
202 end if
203 end select
204
205 ! setup equilibrium grid
206 call writo('Determine the equilibrium grid')
207 call lvl_ud(1)
208 ierr = setup_grid_eq(grid_eq,eq_limits)
209 call lvl_ud(-1)
210 chckerr('')
211
212 ! Calculate the flux equilibrium quantities.
213 ! Note: There are some E quantities that are needed in to set up the
214 ! equilibrium grid and that are not present in eq_1_out.
215 ierr = calc_eq(grid_eq,eq_1)
216 chckerr('')
217
218 ! Write to HDF5 only for first calculation
219 if (rich_lvl.eq.1 .and. eq_job_nr.eq.1) then
220 ! write flux equilibrium variables to output
221 ierr = print_output_eq(grid_eq,eq_1,'eq_1')
222 chckerr('')
223
224 ! plot flux quantities if requested
225 if (plot_flux_q) then
226 ierr = flux_q_plot(grid_eq,eq_1)
227 chckerr('')
228 else
229 call writo('Flux quantities plot not requested')
230 end if
231 end if
232
233 ! grid_eq and grid_eq_B
234 ! VMEC: The equilibrium grid is field-aligned but its angular variables
235 ! need to be set up still.
236 ! HELENA: The equilibrium grid is not field-aligned but taken from
237 ! the equilibrium output. The field-aligned grid has to be set up
238 ! separately.
239 select case (eq_style)
240 case (1) ! VMEC
241 ! calculate angular grid points for equilibrium grid
242 call writo('Calculate angular equilibrium grid')
243 ierr = calc_ang_grid_eq_b(grid_eq,eq_1,only_half_grid=&
244 &only_half_grid)
245 chckerr('')
246 case (2) ! HELENA
247 ! set up field-aligned equilibrium grid
248 call writo('Determine the field-aligned equilibrium grid')
249 ierr = setup_grid_eq_b(grid_eq,grid_eq_b,eq_1,&
250 &only_half_grid=only_half_grid)
251 chckerr('')
252
253 ! write field-aligned equilibrium grid variables to output
254 ierr = print_output_grid(grid_eq_b,'field-aligned equilibrium',&
255 &'eq_B',rich_lvl=rich_lvl,par_div=.true.)
256 chckerr('')
257 end select
258
259 ! only do when needed
260 if (do_eq_2_ops) then
261 ! write equilibrium grid variables to output
262 ierr = print_output_grid(grid_eq,'equilibrium','eq',&
263 &rich_lvl=rich_lvl_name,par_div=size(eq_jobs_lims,2).gt.1)
264 chckerr('')
265
266 ! Calculate the metric equilibrium quantities
267 ierr = calc_eq(grid_eq,eq_1,eq_2,dealloc_vars=dealloc_vars)
268 chckerr('')
269
270#if ldebug
271 if (plot_info) then
272 ! plot info for comparison between VMEC and HELENA
273 call plot_info_for_vmec_hel_comparision()
274 end if
275#endif
276
277 if (rich_lvl.eq.1 .and. eq_style.eq.2) then ! only if first Richardson level
278 ! write metric equilibrium variables to output
279 ierr = print_output_eq(grid_eq,eq_2,'eq_2',par_div=.false.)
280 chckerr('')
281 end if
282
283 ! store vacuum variables
284 ierr = store_vac(grid_eq,eq_1,eq_2,vac)
285 chckerr('')
286 end if
287
288 ! set output variables
289 select case (x_grid_style)
290 case (1,3) ! equilibrium or enriched
291 call writo('Copy the equilibrium grids and variables to &
292 &output grid')
293 case (2) ! solution
294 call writo('Redistribute the equilibrium grids and variables &
295 &to output grid')
296 end select
297 call lvl_ud(1)
298
299 ! grid_eq_out
300 if (do_eq_2_ops) then
301 if (associated(grid_eq_out%r_F)) call grid_eq_out%dealloc() ! deallocate if necessary
302 select case (x_grid_style)
303 case (1,3) ! equilibrium or enriched
304 ierr = grid_eq%copy(grid_eq_out)
305 chckerr('')
306 case (2) ! solution
307 ierr = redistribute_output_grid(grid_eq,grid_eq_out)
308 chckerr('')
309 end select
310 end if
311
312 ! eq_1_out
313 if (do_eq_1_ops) then
314 if (allocated(eq_1_out%pres_FD)) call eq_1_out%dealloc() ! deallocate if necessary
315 select case (x_grid_style)
316 case (1,3) ! equilibrium or optimized
317 call eq_1%copy(grid_eq,eq_1_out)
318 case (2) ! solution
319 ierr = redistribute_output_eq(grid_eq,grid_eq_out,eq_1,&
320 &eq_1_out)
321 chckerr('')
322 end select
323 end if
324
325 ! eq_2_out
326 if (do_eq_2_ops) then
327 if (allocated(eq_2_out%jac_FD)) call eq_2_out%dealloc() ! deallocate if necessary
328 select case (x_grid_style)
329 case (1,3) ! equilibrium or optimized
330 call eq_2%copy(grid_eq,eq_2_out)
331 case (2) ! solution
332 ierr = redistribute_output_eq(grid_eq,grid_eq_out,eq_2,&
333 &eq_2_out)
334 chckerr('')
335 end select
336 end if
337
338 ! grid_eq_B_out
339 select case (eq_style)
340 case (1) ! VMEC
341 grid_eq_b_out => grid_eq_out
342 case (2) ! HELENA
343 if (associated(grid_eq_b_out)) then
344 call grid_eq_b_out%dealloc()
345 deallocate(grid_eq_b_out)
346 nullify(grid_eq_b_out)
347 end if
348 allocate(grid_eq_b_out)
349 select case (x_grid_style)
350 case (1,3) ! equilibrium or optimized
351 ierr = grid_eq_b%copy(grid_eq_b_out)
352 chckerr('')
353 case (2) ! solution
354 ierr = redistribute_output_grid(grid_eq_b,grid_eq_b_out)
355 chckerr('')
356 end select
357 end select
358
359 ! clean up
360 call grid_eq%dealloc()
361 call eq_1%dealloc() ! eq_1 is always calculated because there are some quantities that are not present in eq_1_out
362 if (do_eq_2_ops) then
363 call eq_2%dealloc()
364 end if
365 if (eq_style.eq.2) then
366 call grid_eq_b%dealloc()
367 end if
368
369 call lvl_ud(-1)
370
371 ! plot magnetic field if requested
372 ! (done in parts, for every parallel job)
373 if (plot_b) then
374 select case (eq_style)
375 case (1) ! VMEC
376 ierr = b_plot(grid_eq_out,eq_1_out,eq_2_out,&
378 chckerr('')
379 case (2) ! HELENA
380 if (rich_lvl.eq.1) then
381 ierr = b_plot(grid_eq_out,eq_1_out,eq_2_out)
382 chckerr('')
383 end if
384 end select
385 else
386 if (eq_job_nr.eq.1) call writo('Magnetic field plot not requested')
387 end if
388
389 ! plot current if requested
390 ! (done in parts, for every parallel job)
391 if (plot_j) then
392 select case (eq_style)
393 case (1) ! VMEC
394 ierr = j_plot(grid_eq_out,eq_1_out,eq_2_out,&
396 chckerr('')
397 case (2) ! HELENA
398 if (rich_lvl.eq.1) then
399 ierr = j_plot(grid_eq_out,eq_1_out,eq_2_out)
400 chckerr('')
401 end if
402 end select
403 else
404 if (eq_job_nr.eq.1) call writo('Current plot not requested')
405 end if
406
407 ! plot curvature if requested
408 ! (done in parts, for every parallel job)
409 if (plot_kappa) then
410 select case (eq_style)
411 case (1) ! VMEC
412 ierr = kappa_plot(grid_eq_out,eq_1_out,eq_2_out,&
414 chckerr('')
415 case (2) ! HELENA
416 if (rich_lvl.eq.1) then
417 ierr = kappa_plot(grid_eq_out,eq_1_out,eq_2_out)
418 chckerr('')
419 end if
420 end select
421 else
422 if (eq_job_nr.eq.1) call writo('Curvature plot not requested')
423 end if
424
425 ! plot full field-aligned grid if requested
426 ! Note: As this needs a total grid, it cannot be easiliy created like
427 ! plot_B, where the output is updated for every equilibrium job.
428 if (plot_magn_grid) then
429 if (eq_job_nr.eq.size(eq_jobs_lims,2)) then
430 ! set up the name of grid_eq_B
431 select case (eq_style)
432 case (1) ! VMEC
433 grid_eq_b_name = 'eq' ! already field-aligned
434 case (2) ! HELENA
435 grid_eq_b_name = 'eq_B' ! not already field-aligned
436 end select
437
438 ! reconstruct the full field-aligned grid
439 ierr = reconstruct_pb3d_grid(grid_eq_b,trim(grid_eq_b_name),&
440 &rich_lvl=rich_lvl,tot_rich=.true.,grid_limits=eq_limits)
441 chckerr('')
442
443 ! wait for all processes (sometimes necessary to finish lock)
444 ierr = wait_mpi()
445 chckerr('')
446
447 ! plot it
448 ierr = magn_grid_plot(grid_eq_b)
449 chckerr('')
450
451 ! deallocate
452 call grid_eq_b%dealloc()
453 end if
454 else
455 if (eq_job_nr.eq.1) call writo('Magnetic grid plot not requested')
456 end if
457#if ldebug
458 contains
459 ! Plots information for comparison between HELENA and VMEC.
460 !> \private
461 subroutine plot_info_for_vmec_hel_comparision()
462 use helena_vars, only: r_h, z_h
464
465 ! local variables
466 real(dp), allocatable :: x_plot(:,:,:), y_plot(:,:,:), z_plot(:,:,:)
467 integer :: id
468 integer :: d(3)
469 logical :: not_ready
470
471 call writo('Plotting information for comparison between VMEC and &
472 &HELENA',alert=.true.)
473 not_ready = .true.
474 do while (not_ready)
475 call writo('derivative in dim 1?')
476 d(1) = get_int(lim_lo=0)
477 call writo('derivative in dim 2?')
478 d(2) = get_int(lim_lo=0)
479 call writo('derivative in dim 3?')
480 d(3) = get_int(lim_lo=0)
481
482 ! x, y, z
483 allocate(x_plot(grid_eq%n(1),grid_eq%n(2),grid_eq%loc_n_r))
484 allocate(y_plot(grid_eq%n(1),grid_eq%n(2),grid_eq%loc_n_r))
485 allocate(z_plot(grid_eq%n(1),grid_eq%n(2),grid_eq%loc_n_r))
486 x_plot = grid_eq%theta_F
487 y_plot = 0._dp
488 do id = 1,grid_eq%loc_n_r
489 z_plot(:,:,id) = grid_eq%loc_r_F(id)/maxval(grid_eq%r_F)
490 end do
491 call plot_hdf5('x_plot','x_plot',x_plot)
492 call plot_hdf5('y_plot','y_plot',y_plot)
493 call plot_hdf5('z_plot','z_plot',z_plot)
494
495 ! flux quantities
496 call print_ex_2d('pres_FD','pres_FD',eq_1%pres_FD(:,d(2)),&
497 &x=grid_eq%loc_r_F,draw=.false.)
498 call draw_ex(['pres_FD'],'pres_FD',1,1,.false.)
499 call print_ex_2d('q_saf_FD','q_saf_FD',eq_1%q_saf_FD(:,d(2)),&
500 &x=grid_eq%loc_r_F,draw=.false.)
501 call draw_ex(['q_saf_FD'],'q_saf_FD',1,1,.false.)
502 call print_ex_2d('flux_p_FD','flux_p_FD',&
503 &eq_1%flux_p_FD(:,d(2)),x=grid_eq%loc_r_F,draw=.false.)
504 call draw_ex(['flux_p_FD'],'flux_p_FD',1,1,.false.)
505 call print_ex_2d('flux_t_FD','flux_t_FD',&
506 &eq_1%flux_t_FD(:,d(2)),x=grid_eq%loc_r_F,draw=.false.)
507 call draw_ex(['flux_t_FD'],'flux_t_FD',1,1,.false.)
508
509 ! R and Z
510 select case (eq_style)
511 case(1)
512 call plot_hdf5('R_V','R_V',&
513 &eq_2%R_E(:,:,:,d(1),d(2),d(3)),x=x_plot,y=y_plot,&
514 &z=z_plot)
515 call plot_hdf5('Z_V','Z_V',&
516 &eq_2%Z_E(:,:,:,d(1),d(2),d(3)),x=x_plot,y=y_plot,&
517 &z=z_plot)
518 call plot_hdf5('L_V','L_V',&
519 &eq_2%L_E(:,:,:,d(1),d(2),d(3)),x=x_plot,y=y_plot,&
520 &z=z_plot)
521 case(2)
522 if (sum(d).eq.0) then
523 call plot_hdf5('R_H','R_H',&
524 &reshape(r_h(:,grid_eq%i_min:grid_eq%i_max),&
525 &[grid_eq%n(1:2),grid_eq%loc_n_r]),&
526 &x=x_plot,y=y_plot,z=z_plot)
527 call plot_hdf5('Z_H','Z_H',&
528 &reshape(z_h(:,grid_eq%i_min:grid_eq%i_max),&
529 &[grid_eq%n(1:2),grid_eq%loc_n_r]),&
530 &x=x_plot,y=y_plot,z=z_plot)
531 else
532 call writo('R and Z can only be plot for d = 0')
533 end if
534 end select
535
536 ! metric fators
537 call plot_hdf5('jac_FD','jac_FD',&
538 &eq_2%jac_FD(:,:,:,d(1),d(2),d(3)),&
539 &x=x_plot,y=y_plot,z=z_plot)
540 do id = 1,6
541 call plot_hdf5('g_FD_'//trim(i2str(id)),&
542 &'g_FD_'//trim(i2str(id)),&
543 &eq_2%g_FD(:,:,:,id,d(1),d(2),d(3)),&
544 &x=x_plot,y=y_plot,z=z_plot)
545 call plot_hdf5('h_FD_'//trim(i2str(id)),&
546 &'h_FD_'//trim(i2str(id)),&
547 &eq_2%h_FD(:,:,:,id,d(1),d(2),d(3)),&
548 &x=x_plot,y=y_plot,z=z_plot)
549 end do
550
551 ! clean up
552 deallocate(x_plot,y_plot,z_plot)
553
554 call writo('Want to redo the plotting?')
555 not_ready = get_log(.true.)
556 end do
557
558 ! reset not_ready
559 not_ready = .true.
560
561 call writo('Done, paused',alert=.true.)
562 call pause_prog()
563 end subroutine plot_info_for_vmec_hel_comparision
564#endif
565 end function run_driver_eq
566end module driver_eq
Calculate the equilibrium quantities on a grid determined by straight field lines.
Definition eq_ops.f90:48
Print equilibrium quantities to an output file:
Definition eq_ops.f90:90
Redistribute the equilibrium variables, but only the Flux variables are saved.
Definition eq_ops.f90:103
Prints variables vars with names var_names in an HDF5 file with name c file_name and accompanying XDM...
Print 2-D output on a file.
Driver of the equilibrium part of PB3D.
Definition driver_eq.f90:4
integer function, public run_driver_eq(grid_eq_out, grid_eq_b_out, eq_1_out, eq_2_out, vac)
Main driver of PB3D equilibrium part.
Definition driver_eq.f90:49
Operations on the equilibrium variables.
Definition eq_ops.f90:4
integer function, public kappa_plot(grid_eq, eq_1, eq_2, rich_lvl, xyz)
Plots the curvature.
Definition eq_ops.f90:5971
integer function, public j_plot(grid_eq, eq_1, eq_2, rich_lvl, plot_fluxes, xyz)
Plots the current.
Definition eq_ops.f90:5803
integer function, public b_plot(grid_eq, eq_1, eq_2, rich_lvl, plot_fluxes, xyz)
Plots the magnetic fields.
Definition eq_ops.f90:5700
integer function, public flux_q_plot(grid_eq, eq)
Plots the flux quantities in the solution grid.
Definition eq_ops.f90:3810
Variables that have to do with equilibrium quantities and the grid used in the calculations:
Definition eq_vars.f90:27
Operations that have to do with the grids and different coordinate systems.
Definition grid_ops.f90:4
integer function, public calc_ang_grid_eq_b(grid_eq, eq, only_half_grid)
Calculate equilibrium grid that follows magnetic field lines.
Definition grid_ops.f90:798
integer function, public print_output_grid(grid, grid_name, data_name, rich_lvl, par_div, remove_previous_arrs)
Print grid variables to an output file.
integer function, public calc_norm_range(style, in_limits, eq_limits, x_limits, sol_limits, r_f_eq, r_f_x, r_f_sol, jq)
Calculates normal range for the input grid, the equilibrium grid and/or the solution grid.
Definition grid_ops.f90:46
integer function, public redistribute_output_grid(grid, grid_out, no_outer_trim)
Redistribute a grid to match the normal distribution of solution grid.
Definition grid_ops.f90:995
integer function, public setup_grid_eq_b(grid_eq, grid_eq_b, eq, only_half_grid)
Sets up the field-aligned equilibrium grid.
Definition grid_ops.f90:601
integer function, public magn_grid_plot(grid)
Plots the grid in real 3-D space.
integer function, public setup_grid_eq(grid_eq, eq_limits)
Sets up the equilibrium grid.
Definition grid_ops.f90:529
Variables pertaining to the different grids used.
Definition grid_vars.f90:4
real(dp), dimension(:), allocatable, public alpha
field line label alpha
Definition grid_vars.f90:28
real(dp), public min_par_x
min. of parallel coordinate [ ] in field-aligned grid
Definition grid_vars.f90:24
integer, public n_alpha
nr. of field-lines
Definition grid_vars.f90:23
real(dp), public max_par_x
max. of parallel coordinate [ ] in field-aligned grid
Definition grid_vars.f90:25
Operations on HDF5 and XDMF variables.
Definition HDF5_ops.f90:27
integer function, public create_output_hdf5(hdf5_name)
Creates an HDF5 output file.
Variables that have to do with HELENA quantities.
real(dp), dimension(:,:), allocatable, public r_h
major radius (xout)
real(dp), dimension(:,:), allocatable, public z_h
height (yout)
Numerical utilities related to input.
integer function, public get_int(lim_lo, lim_hi, ind)
Queries for user input for an integer value, where allowable range can be provided as well.
subroutine, public pause_prog(ind)
Pauses the running of the program.
logical function, public get_log(yes, ind)
Queries for a logical value yes or no, where the default answer is also to be provided.
Numerical utilities related to giving output.
Definition messages.f90:4
subroutine, public lvl_ud(inc)
Increases/decreases lvl of output.
Definition messages.f90:254
subroutine, public writo(input_str, persistent, error, warning, alert)
Write output to file identified by output_i.
Definition messages.f90:275
Numerical utilities related to MPI.
integer function, public wait_mpi()
Wait for all processes, wrapper to MPI barrier.
Numerical utilities.
integer, dimension(:,:,:), allocatable, public d
1-D array indices of derivatives
integer function, dimension(:,:), allocatable, public derivs(order, dims)
Returns derivatives of certain order.
Numerical variables used by most other modules.
Definition num_vars.f90:4
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
logical, public plot_b
whether to plot the magnetic field in real coordinates
Definition num_vars.f90:104
logical, public plot_kappa
whether to plot curvature
Definition num_vars.f90:107
real(dp), parameter, public pi
Definition num_vars.f90:83
logical, public plot_flux_q
whether to plot flux quantities in real coordinates
Definition num_vars.f90:106
integer, parameter, public max_str_ln
maximum length of strings
Definition num_vars.f90:50
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
integer, public eq_style
either 1 (VMEC) or 2 (HELENA)
Definition num_vars.f90:89
integer, public alpha_style
style for alpha (1: one field line, many turns, 2: many field lines, one turn)
Definition num_vars.f90:100
logical, public plot_j
whether to plot the current in real coordinates
Definition num_vars.f90:105
integer, public rich_restart_lvl
starting Richardson level (0: none [default])
Definition num_vars.f90:173
logical, public jump_to_sol
jump to solution
Definition num_vars.f90:141
logical, public plot_magn_grid
whether to plot the grid in real coordinates
Definition num_vars.f90:103
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
Operations concerning giving output, on the screen as well as in output files.
Definition output_ops.f90:5
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.
Operations on PB3D output.
Definition PB3D_ops.f90:8
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
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
integer function, public reconstruct_pb3d_eq_2(grid_eq, eq, data_name, rich_lvl, tot_rich, lim_pos)
Reconstructs the equilibrium variables from PB3D HDF5 output.
Definition PB3D_ops.f90:695
Variables concerning Richardson extrapolation.
Definition rich_vars.f90:4
integer, public rich_lvl
current level of Richardson extrapolation
Definition rich_vars.f90:19
Operations on strings.
elemental character(len=max_str_ln) function, public i2str(k)
Convert an integer to string.
elemental character(len=max_str_ln) function, public r2strt(k)
Convert a real (double) to string.
Operations and variables pertaining to the vacuum response.
Definition vac_ops.f90:23
integer function, public store_vac(grid, eq_1, eq_2, vac)
Stores calculation of the vacuum response by storing the necessary variables.
Definition vac_ops.f90:113
Variables pertaining to the vacuum quantities.
Definition vac_vars.f90:4
flux equilibrium type
Definition eq_vars.f90:63
metric equilibrium type
Definition eq_vars.f90:114
Type for grids.
Definition grid_vars.f90:59
vacuum type
Definition vac_vars.f90:46