A module which writes out the electrostatic drive of zonal flows.
The code is based on a Python3 post-processing tool from Stephen Biggs-Fox
which can be found at [gitlab.com/stephen-biggs-fox/zonal-transfer-functions]
The code calculates the Reynolds stress drive through a bispectra-like
transfer function by directly performing three-wave-coupling calculations.
The couplings take place between a "target mode", a "source modes", and
a "mediator mode", the latter being determined by a selection rule.
The total electrostatic zonal flow drive is resolved over the poloidal angle
in the output "kinetic_energy_transfer_theta". Additional insight into the
poloidal distributions of contributions from different source and target scales
are provided by "kinetic_energy_transfer_theta_kxsource",
"kinetic_energy_transfer_theta_kxtarget", and "kinetic_energy_transfer_theta_kysource".
Variables
Type |
Visibility | Attributes |
|
Name |
| Initial | |
real,
|
private, |
dimension(:), allocatable
|
:: |
kxnew_array |
|
|
|
real,
|
private, |
dimension(:), allocatable
|
:: |
kynew_array |
|
|
|
logical,
|
private, |
dimension(:,:,:), allocatable
|
:: |
valid_mediator_lookup |
|
|
|
real,
|
private, |
dimension(:,:,:), allocatable
|
:: |
z_factor |
|
|
|
integer,
|
private |
|
:: |
ikx0 |
|
|
|
integer,
|
private |
|
:: |
iky0 |
|
|
|
integer,
|
private |
|
:: |
nkynew |
|
|
|
real,
|
private, |
dimension(:), allocatable
|
:: |
T_result_theta |
|
|
|
real,
|
private, |
dimension(:,:), allocatable
|
:: |
T_result_theta_kxsource |
|
|
|
real,
|
private, |
dimension(:,:), allocatable
|
:: |
T_result_theta_kxtarget |
|
|
|
real,
|
private, |
dimension(:,:), allocatable
|
:: |
T_result_theta_kysource |
|
|
|
logical,
|
private, |
parameter
|
:: |
distribute_work |
= |
.true. |
If true then distribute theta grid points over processors. This requires
some additional global communication so at scale (and with small ntheta)
it might be more efficient to do all the calculation on proc0 and avoid
the associated communcations.
|
Interfaces
-
similar to numpy.fft.fftshift in Python
shift data such that the element for kx=0 or ky=0 is in the center of the array
Arguments
Type |
Intent | Optional | Attributes |
|
Name |
|
real,
|
intent(inout), |
|
dimension(:)
|
:: |
array |
|
-
similar to numpy.fft.fftshift in Python
shift data such that the element for kx=0 and ky=0 is in the center of the matrix
Arguments
Type |
Intent | Optional | Attributes |
|
Name |
|
complex,
|
intent(inout), |
|
dimension(:,:)
|
:: |
array |
|
Functions
Arguments
Type |
Intent | Optional | Attributes |
|
Name |
|
integer,
|
intent(in) |
|
|
:: |
iproc |
|
integer,
|
intent(in) |
|
|
:: |
ntgrid |
|
Return Value
logical
Arguments
Type |
Intent | Optional | Attributes |
|
Name |
|
integer,
|
intent(in) |
|
|
:: |
iproc |
|
integer,
|
intent(in) |
|
|
:: |
theta_index |
|
integer,
|
intent(in) |
|
|
:: |
nproc |
|
integer,
|
intent(in) |
|
|
:: |
ntgrid |
|
Return Value
logical
private elemental function get_ikm(ikt, iks, ik0) result(ikm)
return the mediator index for either kx or ky
Arguments
Type |
Intent | Optional | Attributes |
|
Name |
|
integer,
|
intent(in) |
|
|
:: |
ikt |
|
integer,
|
intent(in) |
|
|
:: |
iks |
|
integer,
|
intent(in) |
|
|
:: |
ik0 |
|
Return Value
integer
private elemental function valid_mediator(ikxt, ikxs, ikx0, ikyt, ikys, iky0, nkx, nky)
return bolean whether a source-mode and target-mode combination yields a valid mediator
Arguments
Type |
Intent | Optional | Attributes |
|
Name |
|
integer,
|
intent(in) |
|
|
:: |
ikxt |
|
integer,
|
intent(in) |
|
|
:: |
ikxs |
|
integer,
|
intent(in) |
|
|
:: |
ikx0 |
|
integer,
|
intent(in) |
|
|
:: |
ikyt |
|
integer,
|
intent(in) |
|
|
:: |
ikys |
|
integer,
|
intent(in) |
|
|
:: |
iky0 |
|
integer,
|
intent(in) |
|
|
:: |
nkx |
|
integer,
|
intent(in) |
|
|
:: |
nky |
|
Return Value
logical
Subroutines
Arguments
Type |
Intent | Optional | Attributes |
|
Name |
|
integer,
|
intent(in) |
|
|
:: |
file_id |
|
extend ky to negative values and return in "shifted" format.
due to reality condition only ky >= 0 is used in GS2.
Arguments
Type |
Intent | Optional | Attributes |
|
Name |
|
real,
|
intent(out), |
|
dimension(:)
|
:: |
kynew |
|
private subroutine get_z_factor(kx_array, ky_array, result_array)
where the second term, ,
is unique for kinetic energy transfer and does not appear for
internal energy transfer or entropy transfer
Arguments
Type |
Intent | Optional | Attributes |
|
Name |
|
real,
|
intent(in), |
|
dimension(:)
|
:: |
kx_array |
|
real,
|
intent(in), |
|
dimension(:)
|
:: |
ky_array |
|
real,
|
intent(out), |
|
dimension(:,:,:)
|
:: |
result_array |
|
private subroutine get_full(field_arr, result_array)
extend a 2D data array to negative ky-values
with the original "unshifted" order
Arguments
Type |
Intent | Optional | Attributes |
|
Name |
|
complex,
|
intent(in), |
|
dimension(:,:)
|
:: |
field_arr |
|
complex,
|
intent(out), |
|
dimension(:,:)
|
:: |
result_array |
|
similar to numpy.fft.fftshift in Python
shift data such that the element for kx=0 or ky=0 is in the center of the array
Arguments
Type |
Intent | Optional | Attributes |
|
Name |
|
real,
|
intent(inout), |
|
dimension(:)
|
:: |
array |
|
similar to numpy.fft.fftshift in Python
shift data such that the element for kx=0 and ky=0 is in the center of the matrix
Arguments
Type |
Intent | Optional | Attributes |
|
Name |
|
complex,
|
intent(inout), |
|
dimension(:,:)
|
:: |
array |
|
create a boolean lookup for the valid mediator attribute of a
pair of target wavevector and source wavevector
Arguments
Type |
Intent | Optional | Attributes |
|
Name |
|
logical,
|
intent(out), |
|
dimension(:,:,:)
|
:: |
valid_mediator_lookup |
|
calculate the mediator mode for all possible pairs of source and target wavevectors
Arguments
Type |
Intent | Optional | Attributes |
|
Name |
|
complex,
|
intent(in), |
|
dimension(:, :)
|
:: |
phi_source |
|
complex,
|
intent(out), |
|
dimension(:, :, :)
|
:: |
result_array |
|
compute the three-wave couplings
Arguments
Type |
Intent | Optional | Attributes |
|
Name |
|
real,
|
intent(in) |
|
|
:: |
B_factor |
|
real,
|
intent(in), |
|
dimension(:, :, :)
|
:: |
z_factor |
|
complex,
|
intent(in), |
|
dimension(:)
|
:: |
phi_target |
|
complex,
|
intent(in), |
|
dimension(:, :, :)
|
:: |
phi_mediator |
|
complex,
|
intent(in), |
|
dimension(:, :)
|
:: |
phi_source |
|
real,
|
intent(out), |
|
dimension(:,:,:)
|
:: |
result_array |
|
Arguments
Type |
Intent | Optional | Attributes |
|
Name |
|
integer,
|
intent(in) |
|
|
:: |
file_id |
|
integer,
|
intent(in) |
|
|
:: |
nout |
|
Arguments
Type |
Intent | Optional | Attributes |
|
Name |
|
integer,
|
intent(in) |
|
|
:: |
theta_index |
|
real,
|
intent(out), |
|
dimension(:, :, :)
|
:: |
T_result_3D |
|