gs2_diagnostics Module

A module for calculating and writing the main GS2 outputs.



Contents


Variables

Type Visibility Attributes Name Initial
real, public :: omegatol
real, public :: omegatinst
logical, public :: print_line
logical, public :: print_flux_line
logical, public :: print_summary
logical, public :: write_line
logical, public :: write_flux_line
logical, public :: write_omega
logical, public :: write_omavg
logical, public :: write_ascii
logical, public :: write_gs
logical, public :: write_ql_metric
logical, public :: write_g
logical, public :: write_gyx
logical, public :: write_eigenfunc
logical, public :: write_fields
logical, public :: write_final_fields
logical, public :: write_final_antot
logical, public :: write_final_moments
logical, public :: write_avg_moments
logical, public :: write_parity
logical, public :: write_moments
logical, public :: ob_midplane
logical, public :: write_final_db
logical, public :: write_full_moments_notgc
logical, public :: write_cross_phase = .false.
logical, public :: write_final_epar
logical, public :: write_kpar
logical, public :: write_heating
logical, public :: write_lorentzian
logical, public :: write_fluxes
logical, public :: write_fluxes_by_mode
logical, public :: write_verr
logical, public :: write_cerr
logical, public :: write_max_verr
logical, public :: exit_when_converged
logical, public :: use_nonlin_convergence
logical, public :: dump_check1
logical, public :: dump_check2
logical, public :: dump_fields_periodically
logical, public :: make_movie
logical, public :: save_for_restart
logical, public :: save_distfn
logical, public :: save_glo_info_and_grids
logical, public :: save_velocities
logical, public :: write_symmetry
logical, public :: write_correlation_extend
logical, public :: write_correlation
logical, public :: write_pflux_sym
logical, public :: write_nl_flux_dist
logical, public :: write_pflux_tormom
logical, private :: file_safety_check
integer, public :: nwrite
integer, public :: igomega
integer, public :: nmovie
integer, public :: navg
integer, public :: nsave
integer, public :: nwrite_mult
integer, public :: nc_sync_freq
logical, public :: write_phi_over_time
logical, public :: write_apar_over_time
logical, public :: write_bpar_over_time
logical, private :: append_old
logical, private :: write_jext = .true.
integer, private :: trin_istep = 0

Variables for convergence condition testing

integer, private :: conv_isteps_converged = 0
real, private, allocatable, dimension(:) :: conv_heat
real, private :: heat_sum_av = 0
real, private :: heat_av = 0
real, private :: heat_av_test = 0
logical, private :: write_any
logical, private :: write_any_fluxes
logical, private :: dump_any
logical, private :: initialized = .false.
complex, private, allocatable, dimension (:,:,:) :: domega
complex, private, dimension (:, :), allocatable :: omega

Complex frequency, and time-averaged complex frequency

complex, private, dimension (:, :), allocatable :: omegaavg

Complex frequency, and time-averaged complex frequency

integer, private :: out_unit
integer, private :: heat_unit
integer, private :: heat_unit2
integer, private :: lpc_unit
integer, private :: jext_unit
integer, private :: phase_unit
integer, private :: dump_check1_unit
integer, private :: dump_check2_unit
integer, private :: res_unit
integer, private :: res_unit2
integer, private :: parity_unit
integer, private :: conv_nstep_av
integer, private :: conv_min_step
integer, private :: conv_max_step
integer, private :: conv_nsteps_converged
complex, private, dimension (:,:,:), allocatable :: omegahist

Frequency time history, size (navg, ntheta0, naky)

type(heating_diagnostics), private :: h

Heating diagnostics summed over space at the current timestep

type(heating_diagnostics), private, dimension(:), save, allocatable :: h_hist

Heating diagnostics summed over space over the last navg timesteps

type(heating_diagnostics), private, dimension(:,:), save, allocatable :: hk

Heating diagnostics as a function of at the current timestep

type(heating_diagnostics), private, dimension(:,:,:), save, allocatable :: hk_hist

Heating diagnostics as a function of over the last navg timesteps

real, private, dimension(:,:,:), allocatable :: j_ext_hist
real, private, dimension (:,:,:), allocatable :: pflux_tormom
real, public :: start_time = 0.0
real, public, dimension (:), allocatable :: pflux_avg
real, public, dimension (:), allocatable :: qflux_avg
real, public, dimension (:), allocatable :: heat_avg
real, public, dimension (:), allocatable :: vflux_avg
real, private :: conv_test_multiplier
integer, private :: ntg_extend
integer, private :: nth0_extend
integer, private :: nout = 1
integer, private :: nout_movie = 1
integer, private :: nout_big = 1
complex, private :: wtmp_old = 0.
logical, private :: exist

Does the gs2_diagnostics_knobs namelist exist in the input file?

type(gs2_diagnostics_config_type), private :: gs2_diagnostics_config

Interfaces

private interface get_vol_average

  • private subroutine get_vol_average_one(a, b, axb, axb_by_mode)

    FIXME : Add documentation

    Arguments

    Type IntentOptional Attributes Name
    complex, intent(in), dimension (:,:) :: a
    complex, intent(in), dimension (:,:) :: b
    real, intent(out) :: axb
    real, intent(out), dimension (:,:) :: axb_by_mode
  • private subroutine get_vol_average_all(a, b, axb, axb_by_mode)

    FIXME : Add documentation

    Arguments

    Type IntentOptional Attributes Name
    complex, intent(in), dimension (-ntgrid:,:,:) :: a
    complex, intent(in), dimension (-ntgrid:,:,:) :: b
    real, intent(out) :: axb
    real, intent(out), dimension (:,:) :: axb_by_mode

private interface get_vol_int

  • private subroutine get_vol_int_one(a, b, axb, axb_by_mode)

    FIXME : Add documentation

    Arguments

    Type IntentOptional Attributes Name
    complex, intent(in), dimension (:,:) :: a
    complex, intent(in), dimension (:,:) :: b
    complex, intent(out) :: axb
    complex, intent(out), dimension (:,:) :: axb_by_mode
  • private subroutine get_vol_int_all(a, b, axb, axb_by_mode)

    FIXME : Add documentation

    Arguments

    Type IntentOptional Attributes Name
    complex, intent(in), dimension (-ntgrid:,:,:) :: a
    complex, intent(in), dimension (-ntgrid:,:,:) :: b
    complex, intent(out) :: axb
    complex, intent(out), dimension (:,:) :: axb_by_mode

private interface get_fldline_avg

Calculate the field-line average

  • private subroutine get_fldline_avg_r(fld_in, fld_out)

    Calculate the field-line average (real values)

    Arguments

    Type IntentOptional Attributes Name
    real, intent(in), dimension (-ntgrid:) :: fld_in
    real, intent(out) :: fld_out
  • private subroutine get_fldline_avg_c(fld_in, fld_out)

    Calculate the field-line average (complex values)

    Arguments

    Type IntentOptional Attributes Name
    complex, intent(in), dimension (-ntgrid:) :: fld_in
    complex, intent(out) :: fld_out

Derived Types

Components

Type Visibility Attributes Name Initial
logical, public :: exist = .false.

Does the related namelist exist in the target input file?

integer, public :: index = 0

Used to hold the specific index of numbered namelists

logical, public :: skip_read = .false.

Do we want to skip the read step in init?

logical, public :: skip_broadcast = .false.

Do we want to skip the broadcast step in init?

logical, public :: append_old = .false.

Append output data to a previous output file <run name>.out.nc if it already exists. Grid sizes must be unchanged.

integer, public :: conv_max_step = 80000

Used for Trinity nonlinear convergence check (use_nonlin_convergence). The maximum number of time steps, after which consider the run converged regardless.

integer, public :: conv_min_step = 4000

Used for the Trinity nonlinear convergence check (use_nonlin_convergence). The minimum number of time steps before convergence condition can trigger an exit.

integer, public :: conv_nstep_av = 4000

Used for the Trinity nonlinear convergence check (use_nonlin_convergence). The number of timesteps the convergence condition averages over

integer, public :: conv_nsteps_converged = 10000

Used for the Trinity nonlinear convergence check (use_nonlin_convergence). The number of steps where convergence is true before convergence is accepted

real, public :: conv_test_multiplier = 4e-1

Used for the Trinity nonlinear convergence check (use_nonlin_convergence). Multiplier for the cumulative average of the heat flux

logical, public :: dump_check1 = .false.

Write out the field-line average of to dump.check1. This option is usually used for Rosenbluth-Hinton calculations.

Read more…
logical, public :: dump_check2 = .false.

Write out at igomega to <run name>.dc2.

Read more…
logical, public :: dump_fields_periodically = .false.

Write out to dump.fields.t=(time) every 10 * nwrite timesteps.

Read more…
logical, public :: enable_parallel = .false.

Enable parallel IO in the .out.nc file. Currently disabled by default and doesn't activate feature when set to true as we hard code that parallel IO isn't supported for the .out.nc file.

Read more…
logical, public :: exit_when_converged = .true.

Exit when the run has reached convergence

logical, public :: file_safety_check = .true.

Verify that the restart file(s) can be written before starting the run

integer, public :: igomega = 0

Index in to measure various diagnostics at. By default, this is the outboard midplane , but it may be useful to set this to a non-zero value for tearing parity modes.

logical, public :: make_movie = .false.

Write out in real space over time, suitable for creating animations. Timestep period is controlled with nmovie

Read more…
integer, public :: navg = 10

Number of timesteps to average over for time-averaged diagnostics

Read more…
integer, public :: ncheck = 10

correction by varying collisionality. But doesn't happen on timesteps when diagnostics are written.

Read more…
integer, public :: nc_sync_freq = 10

Sets the number of output steps between syncing the netcdf file. Higher values may reduce disk overheads but increase the risk of data loss on unclean exit.

integer, public :: nmovie = -1

Timestep period to write real space fields

Read more…
integer, public :: nsave = -1

Timestep period for writing restart data if save_for_restart is .true.. Negative values disable the periodic checkpoints.

integer, public :: nwrite = 10

Timestep period for writing outputs

Read more…
integer, public :: nwrite_mult = 10

Timestep period multiplier for certain "large" diagnostics, which are written every nwrite_mult * nwrite timesteps.

Read more…
logical, public :: ob_midplane = .false.

If .true., write moments at the outboard midplane only, as opposed to along the entire flux surface

Read more…
real, public :: omegatinst = 1.0e6

Threshold complex frequency () for detecting a numerical instability. If averaged over navg timesteps is greater than omegatinst, abort the run.

Read more…
real, public :: omegatol = 1e-3

Frequency () convergence tolerance. Consider the simulation converged and finish the run if has changed by less than omegatol over the last navg timesteps.

Read more…
logical, public :: print_flux_line = .false.

Print the instantaneous fluxes to screen/stdout every nwrite timesteps

logical, public :: print_line = .false.

Print estimated frequencies and growth rates to screen/stdout every nwrite timesteps

Read more…
logical, public :: save_distfn = .false.

Write the distribution function to <rootname>.nc.dfn.<processor> files. Only written at end of simulation

logical, public :: save_for_restart = .false.

Write restart files at the end of the simulation. If nsave is positive, then also enable checkpoints by writing restart files every nsave timesteps.

logical, public :: save_glo_info_and_grids = .false.

Save some layout and distribution information in restart files

logical, public :: save_many = .false.

If .true., write one restart file per processor, otherwise write a single restart file.

Read more…
logical, public :: save_velocities = .false.

Save parallel and perpendicular velocities in final restart and/or distribution function files

logical, public :: serial_netcdf4 = .false.

Read more…
logical, public :: use_nonlin_convergence = .false.

For nonlinear runs, stop the run when the averaged differential of the summed averaged heat flux drops below a threshold for a period of time, controlled by conv_test_multiplier, conv_nsteps_converged, gs2_diagnostics_knobs, conv_max_step, and conv_min_step.

logical, public :: write_any = .true.

If .false., skip writing any diagnostics

Read more…
logical, public :: write_apar_over_time = .false.

Write the entire field every nwrite timesteps

Read more…
logical, public :: write_ascii = .true.

Write diagnostics to text files. Generally this creates a different text file for each diagnostic. Note that this independent of whether or not netCDF files are used.

Read more…
logical, public :: write_avg_moments = .false.

Write flux surface averaged low-order moments of every nwrite timesteps

Read more…
logical, public :: write_bpar_over_time = .false.

Write the entire field every nwrite timesteps

Read more…
logical, public :: write_cerr = .false.

Write the collision error every nwrite timesteps to text file with suffix .cres

Read more…
logical, public :: write_collisional = .false.

Write collisional heating (collisional and hyper viscous rate of loss of free energy for each mode) every nwrite timesteps

Read more…
logical, public :: write_correlation = .true.

Write two point parallel correlation function calculated from the electric potential as a function of and parallel separation every nwrite timesteps

Read more…
logical, public :: write_correlation_extend = .false.

Write two point parallel correlation function calculated from the electric potential as a function of and parallel separation, time averaged and calculated along the extended domain every nwrite timesteps once istep > nstep/4.

Read more…
logical, public :: write_cross_phase = .false.

Write the cross phase between electron density and perpendicular electron temperature every nwrite timesteps. Calculated at both the outboard midplane, averaged across and ; and averaged across all space

Read more…
logical, public :: write_density_over_time = .false.

Write the whole non-adiabatic part of the density moment every nwrite timesteps

Read more…
logical, public :: write_eigenfunc = .false.

Write normalised to the value of at the outboard midplane every nwrite timesteps.

Read more…
logical, public :: write_fields = .true.

Enable writing every nwrite timesteps

Read more…
logical, public :: write_final_antot = .false.

Write the right-hand sides of the field equations at the final timestep. If write_ascii is enabled, the file suffix is .antot

Read more…
logical, public :: write_final_db = .false.

Write at the final timestep. If write_ascii is enabled, the file suffix is .db

Read more…
logical, public :: write_final_epar = .false.

Write at the final timestep. If write_ascii is enabled, the file suffix is .epar

Read more…
logical, public :: write_final_fields = .false.

Write at the final timestep. If write_ascii is enabled, the file suffix is .fields

Read more…
logical, public :: write_final_moments = .false.

Write various moments (densities, parallel and perpendicular velocities and temperatures, and heat and momentum fluxes) at the final timestep. If write_ascii is enabled, the file suffix is .fields and contains the moments, their magnitudes, and field-line averages. The netCDF output has only the values.

Read more…
logical, public :: write_flux_line = .false.

Write instantaneous fluxes to output file every nwrite timesteps

Read more…
logical, public :: write_fluxes = .false.

Write fluxes (heat, momentum and particle; total and per-species) every nwrite timesteps.

Read more…
logical, public :: write_fluxes_by_mode = .false.

Write fluxes (heat, momentum and particle; total and per-species) as a function of Fourier mode every nwrite timesteps.

Read more…
logical, public :: write_full_moments_notgc = .false.

Write moments (density, parallel flow, and parallel and perpendicular temperatures) in non-guiding centre coordinates every nwrite timesteps

logical, public :: write_g = .false.

Write at ik=it=is=1, ig=0 to text file <runname>.dist

Read more…
logical, public :: write_gs = .false.

Read more…
logical, public :: write_gyx = .false.

Write as a function of real space every nmovie timesteps to text file ".yxdist"

Read more…
logical, public :: write_heating = .false.

Write out various heating, free energy and energy injection diagnostics. Text file extension is .heat

logical, public :: write_jext = .false.

Write time averaged external current in the antenna, , as a function of . File suffix is .jext

Read more…
logical, public :: write_kpar = .false.

Write the parallel spectrum of at final timestep. File suffix is .kpar

Read more…
logical, public :: write_line = .true.

Print estimated frequencies and growth rates to text file every nwrite timesteps

logical, public :: write_lorentzian = .false.

Write antenna_w every nwrite timesteps

Read more…
logical, public :: write_max_verr = .false.

Write the estimated maximum error from velocity space integrals for various quantities

Read more…
logical, public :: write_moments = .true.

Write various moments (total and non-adiabatic part of perturbed species density, perturbed parallel flow, perturbed parallel and perpendicular temperatures, parallel heat flux, particule flux and heat flux) every nwrite timesteps

Read more…
logical, public :: write_nl_flux_dist = .false.

Write the poloidal distributions of the fluxes of particles, parallel momentum, perpendicular momentum, and energy every nwrite timesteps.

Read more…
logical, public :: write_ntot_over_time = .false.

Write the whole total density moment every nwrite timesteps

Read more…
logical, public :: write_omavg = .true.

Write time-averaged growth rate and frequency to the output text file every nwrite timesteps. Time average is rolling window over the previous navg timesteps

Read more…
logical, public :: write_omega = .true.

Write instantaneous growth rate and frequency every nwrite timesteps

Read more…
logical, public :: write_parity = .false.

Write parities in distribution and particle fluxes to text file with the suffix .parity

Read more…
logical, public :: write_pflux_sym = .false.

Write particle flux density as a function of and velocity space every nwrite timesteps. Used for looking at the effect of asymmetry. See Parra et al POP 18 062501 2011 and ask Jung-Pyo Lee

Read more…
logical, public :: write_pflux_tormom = .false.

Write toroidal angular momentum flux carried by particle flux every nwrite timesteps. Only calculated if gs2 is built with LOWFLOW on.

Read more…
logical, public :: write_phi_over_time = .false.

Write the entire field every nwrite timesteps

Read more…
logical, public :: write_ql_metric = .true.

Write a simple quasi-linear metric to netcdf.

logical, public :: write_symmetry = .false.

Write the particle and momentum flux as a function of and velocity space. See write_pflux_sym and write_pflux_tormom

Read more…
logical, public :: write_tperp_over_time = .false.

Write the whole perturbed perpendicular temperature moment every nwrite timesteps

Read more…
logical, public :: write_upar_over_time = .false.

Write the whole perturbed parallel velocity moment every nwrite timesteps

Read more…
logical, public :: write_verr = .false.

Write estimates of error resulting from velocity space integrals in the calculation of various quantities every nwrite timesteps.

Read more…
logical, public :: write_zonal_transfer = .false.

Write the transfer of free energy, , as a function of , averaged over , every nwrite timesteps

Read more…

Type-Bound Procedures

procedure , public , :: is_initialised => is_initialised_generic Function
procedure , public , :: init => init_generic Subroutine
procedure , public , :: setup => setup_generic Subroutine
procedure , public , :: write_namelist_header Subroutine
procedure , public , :: get_name => get_name_generic Function
procedure , public , :: get_requires_index => get_requires_index_generic Function
procedure , public , nopass :: write_namelist_footer Subroutine
generic, public , :: write_key_val => write_key_val_string, write_key_val_real, write_key_val_complex, write_key_val_integer, write_key_val_logical, write_key_val_real_array, write_key_val_complex_array, write_key_val_integer_array
procedure , public :: read => read_diagnostics_base_config Subroutine
procedure , public :: write => write_diagnostics_base_config Subroutine
procedure , public :: reset => reset_diagnostics_base_config Subroutine
procedure , public :: broadcast => broadcast_diagnostics_base_config Subroutine
procedure , public , nopass :: get_default_name => get_default_name_diagnostics_base_config Function
procedure , public , nopass :: get_default_requires_index => get_default_requires_index_diagnostics_base_config Function

Functions

public function diffusivity()

A linear estimate of the diffusivity, used for Trinity testing

Arguments

None

Return Value real

private function get_field_weighted_average_kperp2(field) result(average)

Calculates <|field|2 kperp2>_theta / <|field|2>_theta. Useful for simple quasilinear metric

Arguments

Type IntentOptional Attributes Name
complex, intent(in), dimension(-ntgrid:ntgrid, ntheta0, naky) :: field

Return Value real, dimension(ntheta0, naky)

public function calculate_simple_quasilinear_flux_metric_by_k(growth_rates) result(ql_metric)

Calculates a simple gamma/kperp2 QL flux metric

Arguments

Type IntentOptional Attributes Name
real, intent(in), dimension(ntheta0, naky) :: growth_rates

Return Value real, dimension(ntheta0, naky)

public pure function calculate_instantaneous_omega(ig, tolerance) result(omega_inst)

Calculates the instantaneous omega from chinew = chi * exp(-i * omega * dt) with chi = phi + apar + bpar. This gives omega = log(chinew/chi) * i / dt.

Arguments

Type IntentOptional Attributes Name
integer, intent(in), optional :: ig
real, intent(in), optional :: tolerance

Return Value complex, dimension(ntheta0, naky)

public function get_gs2_diagnostics_config()

Get the module level config instance

Arguments

None

Return Value type(gs2_diagnostics_config_type)


Subroutines

public subroutine wnml_gs2_diagnostics(unit)

Write the diagnostics namelist to file

Arguments

Type IntentOptional Attributes Name
integer, intent(in) :: unit

Unit of an open file to write to

public subroutine check_gs2_diagnostics(report_unit)

Perform some basic checking of the diagnostic input parameters, and write the results to file

Arguments

Type IntentOptional Attributes Name
integer, intent(in) :: report_unit

Unit of an open file to write to

public subroutine init_gs2_diagnostics(list, nstep, gs2_diagnostics_config_in, header)

Initialise this module and all its dependencies, including defining NetCDF vars, call real_init, which calls read_parameters; broadcast all the different write flags.

Arguments

Type IntentOptional Attributes Name
logical, intent(in) :: list

If true, this is a "list-mode run" and so turn off print_flux_line and print_line if set

integer, intent(in) :: nstep

Maximum number of steps to take

type(gs2_diagnostics_config_type), intent(in), optional :: gs2_diagnostics_config_in

Input parameters for this module

type(standard_header_type), intent(in), optional :: header

Header for files with build and run information

public subroutine check_restart_file_writeable(check_writable, need_restart, extra_files)

Check if we can write the restart files

Read more…

Arguments

Type IntentOptional Attributes Name
logical, intent(in) :: check_writable

Has the user requested this check

logical, intent(in) :: need_restart

Has the user requested restart files

logical, intent(inout) :: extra_files

Has the user requested distribution function to be written

private subroutine real_init(is_list_run, gs2_diagnostics_config_in, header)

Read the input parameters; open the various text output files according to the relevant input flags; allocate and zero the module-level flux arrays, gs2_diagnostics_knobs and gs2_diagnostics_knobs

Arguments

Type IntentOptional Attributes Name
logical, intent(in) :: is_list_run

If true, this is a "list-mode run" and so turn off print_flux_line and print_line if set

type(gs2_diagnostics_config_type), intent(in), optional :: gs2_diagnostics_config_in

Input parameters for this module

type(standard_header_type), intent(in), optional :: header

Header for files with build and run information

public subroutine apply_old_defaults(gs2_diagnostics_config_in)

Set values according to the old diagnostics defaults.

Read more…

Arguments

Type IntentOptional Attributes Name
type(gs2_diagnostics_config_type), intent(inout) :: gs2_diagnostics_config_in

public subroutine read_parameters(is_list_run, gs2_diagnostics_config_in)

Read the input parameters for the diagnostics module

Arguments

Type IntentOptional Attributes Name
logical, intent(in) :: is_list_run

If true, this is a "list-mode run" and so turn off print_flux_line and print_line if set

type(gs2_diagnostics_config_type), intent(in), optional :: gs2_diagnostics_config_in

Configuration for this module, can be used to set new default values or avoid reading the input file

public subroutine finish_gs2_diagnostics()

Finalise the diagnostics module, writing final timestep diagnostics and closing any open files

Arguments

None

public subroutine save_restart_dist_fn(save_for_restart, save_distfn, save_glo_info_and_grids, save_velocities, user_time, fileopt_base)

Save some extra information in final restart files

Arguments

Type IntentOptional Attributes Name
logical, intent(in) :: save_for_restart

See save_for_restart

logical, intent(in) :: save_distfn

See save_distfn

logical, intent(in) :: save_glo_info_and_grids

See save_glo_info_and_grids

logical, intent(in) :: save_velocities

See save_velocities

real, intent(in) :: user_time

Current simulation time

character(len=*), intent(in), optional :: fileopt_base

Optional string to add to file name

private subroutine deallocate_arrays()

Deallocate the gs2_diagnostics module-level arrays

Arguments

None

private subroutine close_files()

Close various text output files

Arguments

None

public subroutine loop_diagnostics(istep, exit, debopt, force)

Calculate and write the various diagnostic quantities.

Read more…

Arguments

Type IntentOptional Attributes Name
integer, intent(in) :: istep

Current timestep

logical, intent(out) :: exit

If true, simulation should stop (for example, because it has converged)

logical, intent(in), optional :: debopt

If true, turn on some debug prints

logical, intent(in), optional :: force

private subroutine do_get_omega(istep, debug, exit)

Calculate gs2_diagnostics_knobs for linear simulations or if run_parameters_knobs is on; otherwise set gs2_diagnostics_knobs and gs2_diagnostics_knobs to zero

Arguments

Type IntentOptional Attributes Name
integer, intent(in) :: istep

The current timestep

logical, intent(in) :: debug

Turn on some debug messages

logical, intent(inout) :: exit

Returns true if the simulation has converged (see omegatol) or if a numerical instability has occurred (see gs2_diagnostics_knobs).

private subroutine do_write_ncloop(time, istep, phi2, apar2, bpar2, phitot)

Compute volume averages of the fields and write the fields, field averages, heating and frequency to the netCDF files

Arguments

Type IntentOptional Attributes Name
real, intent(in) :: time

Simulation time

integer, intent(in) :: istep

Current timestep

real, intent(out) :: phi2

Fields squared

real, intent(out) :: apar2

Fields squared

real, intent(out) :: bpar2

Fields squared

real, intent(out), dimension (:, :) :: phitot

FIXME: add documentation. Needs phinorm documenting

private subroutine bcast_scan_parameter(scan_hflux, scan_momflux, scan_phi2)

Broadcast one of the input parameters according to target_parameter_switch

Arguments

Type IntentOptional Attributes Name
real, intent(inout), dimension(:) :: scan_hflux
real, intent(inout), dimension(:) :: scan_momflux
real, intent(inout), dimension(:) :: scan_phi2

private subroutine do_write_eigenfunc(file_id, write_text, phi0)

Write normalised to the value of at the outboard midplane

Read more…

Arguments

Type IntentOptional Attributes Name
integer, intent(in) :: file_id

NetCDF ID of the file to write to

logical, intent(in) :: write_text

If true, write text file

complex, intent(inout), dimension (:,:) :: phi0

The normalising factor for the fields that is actually used. See write_eigenfunc for more details

public subroutine do_write_geom()

Write some geometry information to text file <runname>.g

Arguments

None

private subroutine do_write_movie(time)

Transform to real space, then write to netCDF

Arguments

Type IntentOptional Attributes Name
real, intent(in) :: time

Current simulation time

private subroutine do_print_line(phitot)

Print estimated frequencies and growth rates to screen/stdout

Arguments

Type IntentOptional Attributes Name
real, intent(in), dimension (:, :) :: phitot

Total magnitude of all the fields

private subroutine do_write_jext(time, istep)

Calculate and write the time-averaged antenna current to jext_unit

Arguments

Type IntentOptional Attributes Name
real, intent(in) :: time

Current simulation time

integer, intent(in) :: istep

Current timestep

private subroutine do_write_moments()

Write various moments to netCDF

Arguments

None

private subroutine do_write_crossphase(time)

Calculate the cross-phase (see get_cross_phase) and write to the phase_unit file

Arguments

Type IntentOptional Attributes Name
real, intent(in) :: time

Current simulation time

private subroutine do_write_line(time, it, ik, phitot)

Write estimated frequency and growth rates to out_unit for an individual point

Arguments

Type IntentOptional Attributes Name
real, intent(in) :: time

Simulation time

integer, intent(in) :: it

- and -indices

integer, intent(in) :: ik

- and -indices

real, intent(in) :: phitot

Simulation time

private subroutine do_write_omega(it, ik)

Write instantaneous growth rate and frequency to out_unit for an individual point

Arguments

Type IntentOptional Attributes Name
integer, intent(in) :: it

- and -indices

integer, intent(in) :: ik

- and -indices

private subroutine do_write_omavg(it, ik)

Write time-averaged growth rate and frequency to out_unit for an individual point

Arguments

Type IntentOptional Attributes Name
integer, intent(in) :: it
integer, intent(in) :: ik

private subroutine do_write_verr()

Write some error estimates.

Read more…

Arguments

None

public subroutine do_write_heating(t, file_unit, file_unit2, h)

Write the (total) heating diagnostics to heat_unit and heat_unit2 (per-species)

Arguments

Type IntentOptional Attributes Name
real, intent(in) :: t
integer, intent(in) :: file_unit
integer, intent(in) :: file_unit2
type(heating_diagnostics), intent(in) :: h

Heating diagnostics

public subroutine do_write_symmetry(file_id, nout)

Calculate the momentum flux as a function of and write to netCDF

Arguments

Type IntentOptional Attributes Name
integer, intent(in) :: file_id

NetCDF ID of the file to write to

integer, intent(in) :: nout

Current timestep

public subroutine do_write_nl_flux_dist(file_id, nout)

Calculate the poloidal distributions of the fluxes of particles, parallel momentum, perpendicular momentum, and energy (see section 3.1 and appendix A of Ball et al. PPCF 58 (2016) 045023 as well as section 5 of "GS2 analytic geometry specification")

Arguments

Type IntentOptional Attributes Name
integer, intent(in) :: file_id

NetCDF ID of the file to write to

integer, intent(in) :: nout

Current timestep

public subroutine do_write_pflux_sym(file_id, nout)

Calculate the particle flux contribution to toroidal momentum flux and write to netCDF

Arguments

Type IntentOptional Attributes Name
integer, intent(in) :: file_id

NetCDF ID of the file to write to

integer, intent(in) :: nout

Current timestep

public subroutine do_write_correlation(file_id, nout)

Calculate the correlation function over the physical domain and write to netCDF

Arguments

Type IntentOptional Attributes Name
integer, intent(in) :: file_id

NetCDF ID of the file to write to

integer, intent(in) :: nout

Current timestep

public subroutine do_write_correlation_extend(file_id, time, time_old)

Calculate the correlation function over the extended domain and write to netCDF

Read more…

Arguments

Type IntentOptional Attributes Name
integer, intent(in) :: file_id

NetCDF ID of the file to write to

real, intent(in) :: time

Current and previous simulation times

real, intent(in) :: time_old

Current and previous simulation times

public subroutine do_write_parity(t, file_unit, write_text)

Calculate average parity of distribution function under , and write to parity_unit

Arguments

Type IntentOptional Attributes Name
real, intent(in) :: t
integer, intent(in) :: file_unit

Open formatted file to write text to

logical, intent(in) :: write_text

If false, don't calculate or write parity

private subroutine do_write_avg_moments()

Calculate flux surfgace averaged low-order moments of and write to netCDF

Arguments

None

private subroutine do_write_full_moments_notgc()

Calculate moments (density, parallel flow, and parallel and perpendicular temperatures) in non-guiding centre coordinates and write to netCDF

Arguments

None

private subroutine do_write_dump_1(t)

Calculate the field-line average of and write to dump_check1_unit

Arguments

Type IntentOptional Attributes Name
real, intent(in) :: t

private subroutine do_write_dump_2(t)

Calculate at igomega and write to dump_check2_unit

Arguments

Type IntentOptional Attributes Name
real, intent(in) :: t

public subroutine do_dump_fields_periodically(t)

Write out to text file

Arguments

Type IntentOptional Attributes Name
real, intent(in) :: t

private subroutine flush_files()

Flush text files (only out_unit, res_unit, lpc_unit, and parity_unit)

Arguments

None

private subroutine check_nonlin_convergence(istep, heat_flux, exit)

Trinity convergence condition - simple and experimental look for the averaged differential of the summed averaged heat flux to drop below a threshold

Arguments

Type IntentOptional Attributes Name
integer, intent(in) :: istep
real, intent(in) :: heat_flux
logical, intent(inout) :: exit

private subroutine heating(istep, h, hk)

Calculate some heating diagnostics, and update their time history

Arguments

Type IntentOptional Attributes Name
integer, intent(in) :: istep
type(heating_diagnostics), intent(inout) :: h

Heating diagnostics summed over space at the current timestep

type(heating_diagnostics), intent(inout), dimension(:,:) :: hk

Heating diagnostics as a function of at the current timestep

private subroutine calc_jext(istep, j_ext)

Calculate the time-averaged antenna current

Arguments

Type IntentOptional Attributes Name
integer, intent(in) :: istep

Current simulation timestep

real, intent(inout), dimension(:,:) :: j_ext

public subroutine get_omegaavg(istep, exit, omegaavg, debopt)

Calculate the time-averaged complex frequency, check convergence criterion, and numerical instability criterion.

Read more…

Arguments

Type IntentOptional Attributes Name
integer, intent(in) :: istep

The current timestep

logical, intent(inout) :: exit

Should the simulation exit? FIXME: This could be intent(out) only

complex, intent(out), dimension (:,:) :: omegaavg

The time-averaged complex frequency

logical, intent(in), optional :: debopt

If true, write some debug messages

private subroutine phinorm(phitot)

Summed magnitude of all the fields

Arguments

Type IntentOptional Attributes Name
real, intent(out), dimension (:,:) :: phitot

private subroutine get_vol_average_all(a, b, axb, axb_by_mode)

FIXME : Add documentation

Read more…

Arguments

Type IntentOptional Attributes Name
complex, intent(in), dimension (-ntgrid:,:,:) :: a
complex, intent(in), dimension (-ntgrid:,:,:) :: b
real, intent(out) :: axb
real, intent(out), dimension (:,:) :: axb_by_mode

private subroutine get_vol_average_one(a, b, axb, axb_by_mode)

FIXME : Add documentation

Arguments

Type IntentOptional Attributes Name
complex, intent(in), dimension (:,:) :: a
complex, intent(in), dimension (:,:) :: b
real, intent(out) :: axb
real, intent(out), dimension (:,:) :: axb_by_mode

public subroutine get_volume_average(f, favg)

FIXME : Add documentation

Arguments

Type IntentOptional Attributes Name
real, intent(in), dimension (:,:) :: f
real, intent(out) :: favg

private subroutine get_surf_average(f, favg)

FIXME : Add documentation

Arguments

Type IntentOptional Attributes Name
real, intent(in), dimension (:,:) :: f
real, intent(out), dimension (:) :: favg

public subroutine reset_init()

FIXME : Add documentation

Arguments

None

public subroutine ensemble_average(nensembles, time_int)

FIXME : Add documentation

Arguments

Type IntentOptional Attributes Name
integer, intent(in) :: nensembles
real, intent(out) :: time_int

private subroutine get_fldline_avg_r(fld_in, fld_out)

Calculate the field-line average (real values)

Arguments

Type IntentOptional Attributes Name
real, intent(in), dimension (-ntgrid:) :: fld_in
real, intent(out) :: fld_out

private subroutine get_fldline_avg_c(fld_in, fld_out)

Calculate the field-line average (complex values)

Arguments

Type IntentOptional Attributes Name
complex, intent(in), dimension (-ntgrid:) :: fld_in
complex, intent(out) :: fld_out

private subroutine get_cross_phase(phase_tot, phase_theta)

This is a highly simplified synthetic diagnostic which calculates the cross phase between the electron density and the perpendicular electron temperature for comparisons with DIII-D.
Returns the value of the cross-phase at the outboard midplane and integrated over all v and x. We can generalize this routine to other fields at some point, but for now this is just a skeleton for a more realistic synthetic diagnostic.

Arguments

Type IntentOptional Attributes Name
real, intent(out) :: phase_tot
real, intent(out) :: phase_theta

private subroutine get_vol_int_all(a, b, axb, axb_by_mode)

FIXME : Add documentation

Arguments

Type IntentOptional Attributes Name
complex, intent(in), dimension (-ntgrid:,:,:) :: a
complex, intent(in), dimension (-ntgrid:,:,:) :: b
complex, intent(out) :: axb
complex, intent(out), dimension (:,:) :: axb_by_mode

private subroutine get_vol_int_one(a, b, axb, axb_by_mode)

FIXME : Add documentation

Arguments

Type IntentOptional Attributes Name
complex, intent(in), dimension (:,:) :: a
complex, intent(in), dimension (:,:) :: b
complex, intent(out) :: axb
complex, intent(out), dimension (:,:) :: axb_by_mode

private subroutine get_volume_int(f, favg)

FIXME : Add documentation

Arguments

Type IntentOptional Attributes Name
complex, intent(in), dimension (:,:) :: f
complex, intent(out) :: favg

private subroutine correlation_extend(cfnc, phi2extend)

Calculate the correlation function over the extended domain

Arguments

Type IntentOptional Attributes Name
complex, intent(out), dimension (:,:,:) :: cfnc
real, intent(out), dimension (:,:,:) :: phi2extend

private subroutine correlation(cfnc_2pi)

Calculate the correlation function on the physical domain

Arguments

Type IntentOptional Attributes Name
complex, intent(out), dimension (-ntgrid:,:) :: cfnc_2pi

private subroutine reorder_kx(unord, ord)

FIXME : Add documentation

Arguments

Type IntentOptional Attributes Name
complex, intent(in), dimension (:) :: unord
complex, intent(out), dimension (:) :: ord

public subroutine set_gs2_diagnostics_config(gs2_diagnostics_config_in)

Set the module level config type Will abort if the module has already been initialised to avoid inconsistencies.

Arguments

Type IntentOptional Attributes Name
type(gs2_diagnostics_config_type), intent(in), optional :: gs2_diagnostics_config_in