Radial derivatives and integration

radial_derivatives.f90

Description

Radial derivatives functions

Quick access

Variables:

get_bound_vals, get_dcheb, get_dcheb_complex, get_dcheb_real_1d, get_ddcheb, get_dddcheb, get_dr, get_dr_complex, get_dr_real_1d, work_1d_real

Routines:

bulk_to_ghost(), exch_ghosts(), finalize_der_arrays(), get_ddddr_ghost(), get_dddr(), get_ddr(), get_ddr_ghost(), get_ddr_rloc(), get_dr_rloc(), initialize_der_arrays()

Needed modules

  • constants (zero(), one(), three()): module containing constants and parameters used in the code.

  • precision_mod: This module controls the precision used in MagIC

  • mem_alloc: This little module is used to estimate the global memory allocation used in MagIC

  • cosine_transform_odd: This module contains the built-in type I discrete Cosine Transforms. This implementation is based on Numerical Recipes and FFTPACK. This only works for n_r_max-1 = 2**a 3**b 5**c, with a,b,c integers….

  • radial_scheme (type_rscheme()): This is an abstract type that defines the radial scheme used in MagIC

  • logic (l_finite_diff()): Module containing the logicals that control the run

  • parallel_mod: This module contains the blocking information

  • useful (abortrun()): This module contains several useful routines.

Variables

  • radial_der/get_bound_vals [private]
  • radial_der/get_dcheb [public]
  • radial_der/get_dcheb_complex [private]
  • radial_der/get_dcheb_real_1d [private]
  • radial_der/get_ddcheb [private]
  • radial_der/get_dddcheb [private]
  • radial_der/get_dr [public]
  • radial_der/get_dr_complex [private]
  • radial_der/get_dr_real_1d [private]
  • radial_der/work (*,*) [complex,private/allocatable]
  • radial_der/work_1d_real (*) [real,private/allocatable]

Subroutines and functions

subroutine  radial_der/initialize_der_arrays(n_r_max, llm, ulm)

Allocate work arrays to compute derivatives

Parameters:
  • n_r_max [integer ,in]

  • llm [integer ,in]

  • ulm [integer ,in]

Called from:

magic

subroutine  radial_der/finalize_der_arrays()

Deallocate work arrays

Called from:

magic

subroutine  radial_der/get_ddr(f, df, ddf, n_f_max, n_f_start, n_f_stop, n_r_max, r_scheme[, l_dct_in])

Returns first radial derivative df and second radial derivative ddf of the input function f. Array f(n_f_max,*) may contain several functions numbered by the first index. The subroutine calculates the derivatives of the functions f(n_f_start,*) to f(n_f_stop) by transforming to a Chebychev representation using n_r_max radial grid points.

Parameters:
  • f (n_f_max,n_r_max) [complex ,in]

  • df (n_f_max,n_r_max) [complex ,out] :: first derivative of f

  • ddf (n_f_max,n_r_max) [complex ,out] :: second derivative of f

  • n_f_max [integer ,in,] :: first dim of f

  • n_f_start [integer ,in] :: first function to be treated

  • n_f_stop [integer ,in] :: last function to be treated

  • n_r_max [integer ,in,] :: number of radial grid points

  • r_scheme [real ]

Options:

l_dct_in [logical ,in,]

Called from:

get_mag_rhs_imp(), get_phase_rhs_imp(), get_entropy_rhs_imp(), get_pol_rhs_imp(), assemble_pol(), assemble_single(), get_single_rhs_imp(), get_comp_rhs_imp(), get_tor_rhs_imp()

subroutine  radial_der/get_dddr(f, df, ddf, dddf, n_f_max, n_f_start, n_f_stop, n_r_max, r_scheme[, l_dct_in])

Returns first radial derivative df, the second radial deriv. ddf, and the third radial derivative dddf of the input function f. Array f(n_f_max,*) may contain several functions numbered by the first index. The subroutine calculates the derivaties of the functions f(n_f_start,*) to f(n_f_stop) by transforming to a Chebychev representation using n_r_max radial grid points.

Parameters:
  • f (n_f_max,n_r_max) [complex ,in]

  • df (n_f_max,n_r_max) [complex ,out] :: first derivative of f

  • ddf (n_f_max,n_r_max) [complex ,out] :: second derivative of f

  • dddf (n_f_max,n_r_max) [complex ,out] :: third derivative of f

  • n_f_max [integer ,in,] :: first dim of f

  • n_f_start [integer ,in] :: first function to be treated

  • n_f_stop [integer ,in] :: last function to be treated

  • n_r_max [integer ,in,] :: number of radial grid points

  • r_scheme [real ]

Options:

l_dct_in [logical ,in,]

Called from:

get_pol_rhs_imp(), get_single_rhs_imp()

subroutine  radial_der/get_dr_rloc(f_rloc, df_rloc, lm_max, nrstart, nrstop, n_r_max, r_scheme)

Purpose of this subroutine is to take the first radial derivative of an input complex array distributed over radius. This can only be used with finite differences.

Parameters:
  • f_rloc (lm_max,1 - nrstart + nrstop) [complex ,in]

  • df_rloc (lm_max,1 - nrstart + nrstop) [complex ,out]

  • lm_max [integer ,in,]

  • nrstart [integer ,in,required]

  • nrstop [integer ,in,required]

  • n_r_max [integer ,in]

  • r_scheme [real ]

Called from:

dtvrms(), dtbrms(), finish_exp_mag_rdist(), finish_exp_entropy_rdist(), finish_exp_pol_rdist(), get_pol_rhs_imp_ghost(), finish_exp_smat_rdist(), finish_exp_comp_rdist()

Call to:

abortrun(), get_openmp_blocks(), exch_ghosts()

subroutine  radial_der/get_ddr_rloc(f_rloc, df_rloc, ddf_rloc, lm_max, nrstart, nrstop, n_r_max, r_scheme)

Purpose of this subroutine is to take the first and second radial derivatives of an input complex array distributed over radius. This can only be used with finite differences.

Parameters:
Call to:

abortrun(), get_openmp_blocks(), exch_ghosts()

subroutine  radial_der/get_ddr_ghost(f_rloc, df_rloc, ddf_rloc, lm_max, start_lm, stop_lm, nrstart, nrstop, r_scheme)

Purpose of this subroutine is to take the first and second radial derivatives of an input complex array distributed over radius that has the ghost zones properly filled.

Parameters:
  • f_rloc (lm_max,3 - nrstart + nrstop) [complex ,in]

  • df_rloc (lm_max,1 - nrstart + nrstop) [complex ,out]

  • ddf_rloc (lm_max,1 - nrstart + nrstop) [complex ,out]

  • lm_max [integer ,in,]

  • start_lm [integer ,in]

  • stop_lm [integer ,in]

  • nrstart [integer ,in,required]

  • nrstop [integer ,in,required]

  • r_scheme [real ]

Called from:

get_mag_rhs_imp_ghost(), get_phase_rhs_imp_ghost(), get_entropy_rhs_imp_ghost(), get_comp_rhs_imp_ghost(), get_tor_rhs_imp_ghost()

Call to:

abortrun()

subroutine  radial_der/get_ddddr_ghost(f_rloc, df_rloc, ddf_rloc, dddf_rloc, ddddf_rloc, lm_max, start_lm, stop_lm, nrstart, nrstop, r_scheme)

Purpose of this subroutine is to take the first and second radial derivatives of an input complex array distributed over radius that has the ghost zones properly filled.

Parameters:
Called from:

get_pol_rhs_imp_ghost()

Call to:

abortrun()

subroutine  radial_der/exch_ghosts(f, lm_max, nrstart, nrstop, nghosts)
Parameters:
  • f (lm_max,1 + 2 * nghosts - nrstart + nrstop) [complex ,inout]

  • lm_max [integer ,in,]

  • nrstart [integer ,in,required]

  • nrstop [integer ,in,required]

  • nghosts [integer ,in,required]

Called from:

get_dr_rloc(), get_ddr_rloc(), getstartfields(), assemble_mag_rloc(), assemble_phase_rloc(), assemble_entropy_rloc(), assemble_pol_rloc(), assemble_comp_rloc(), assemble_tor_rloc()

subroutine  radial_der/bulk_to_ghost(x, x_g, ng, nrstart, nrstop, lm_max, start_lm, stop_lm)

This subroutine is used to copy an array that is defined from nRstart to nRstop to an array that is defined from nRstart-1 to nRstop+1

Parameters:
  • x (lm_max,1 - nrstart + nrstop) [complex ,in]

  • x_g (lm_max,1 + 2 * ng - nrstart + nrstop) [complex ,out]

  • ng [integer ,in] :: Number of ghost zones

  • nrstart [integer ,in,required]

  • nrstop [integer ,in,required]

  • lm_max [integer ,in,]

  • start_lm [integer ,in]

  • stop_lm [integer ,in]

Called from:

getstartfields(), assemble_mag_rloc(), assemble_phase_rloc(), assemble_entropy_rloc(), assemble_pol_rloc(), assemble_comp_rloc(), assemble_tor_rloc()

radial_derivatives_even.f90

Quick access

Variables:

get_dcheb_even, get_ddcheb_even

Routines:

get_ddr_even(), get_ddrns_even(), get_drns_even()

Needed modules

  • constants (zero()): module containing constants and parameters used in the code.

  • precision_mod: This module controls the precision used in MagIC

  • cosine_transform_odd: This module contains the built-in type I discrete Cosine Transforms. This implementation is based on Numerical Recipes and FFTPACK. This only works for n_r_max-1 = 2**a 3**b 5**c, with a,b,c integers….

  • cosine_transform_even

Variables

  • radial_der_even/get_dcheb_even [private]
  • radial_der_even/get_ddcheb_even [private]

Subroutines and functions

subroutine  radial_der_even/get_ddr_even(f, df, ddf, n_f_max, n_f_start, n_f_stop, n_r_max, n_cheb_max, dr_fac, work1, work2, chebt_odd, chebt_even)

Returns first rarial derivative df and second radial derivative ddf of the input function f. Array f(n_f_max,*) may contain several functions numbered by the first index. The subroutine calculates the derivaties of the functions f(n_f_start,*) to f(n_f_stop) by transforming to a Chebychev representation using n_r_max radial grid points. The cheb transforms have to be initialized by calling init_costf1 and init_costf2.

Parameters:
  • f (n_f_max,n_r_max) [complex ,in]

  • df (n_f_max,n_r_max) [complex ,out] :: first derivative of f

  • ddf (n_f_max,n_r_max) [complex ,out] :: second derivative of f

  • n_f_max [integer ,in,] :: first dim of f

  • n_f_start [integer ,in] :: first function to be treated

  • n_f_stop [integer ,in] :: last function to be treated

  • n_r_max [integer ,in,] :: number of radial grid points

  • n_cheb_max [integer ,in] :: number of cheb modes

  • dr_fac [real ,in] :: mapping factor

  • work1 (n_f_max,n_r_max) [complex ,out] :: work array needed for costf

  • work2 (n_f_max,n_r_max) [complex ,out] :: work array needed for costf

  • chebt_odd [costf_odd_t ,in]

  • chebt_even [costf_even_t ,in]

Called from:

get_mag_ic_rhs_imp()

subroutine  radial_der_even/get_drns_even(f, df, n_f_max, n_f_start, n_f_stop, n_r_max, n_cheb_max, dr_fac, work1, chebt_odd, chebt_even)

Returns first rarial derivative df and second radial derivative ddf of the input function f. Array f(n_f_max,*) may contain several functions numbered by the first index. The subroutine calculates the derivaties of the functions f(n_f_start,*) to f(n_f_stop) by transforming to a Chebychev representation using n_r_max radial grid points. The cheb transforms have to be initialized by calling init_costf1 and init_costf2.

Parameters:
  • f (n_f_max,n_r_max) [complex ,inout]

  • df (n_f_max,n_r_max) [complex ,out] :: first derivative of f

  • n_f_max [integer ,in,] :: first dim of f

  • n_f_start [integer ,in] :: first function to be treated

  • n_f_stop [integer ,in] :: last function to be treated

  • n_r_max [integer ,in,] :: number of radial grid points

  • n_cheb_max [integer ,in] :: number of cheb modes

  • dr_fac [real ,in] :: mapping factor

  • work1 (n_f_max,n_r_max) [complex ,out] :: work array needed for costf

  • chebt_odd [costf_odd_t ,in]

  • chebt_even [costf_even_t ,in]

Called from:

fields_average(), write_dtb_frame()

subroutine  radial_der_even/get_ddrns_even(f, df, ddf, n_f_max, n_f_start, n_f_stop, n_r_max, n_cheb_max, dr_fac, work1, chebt_odd, chebt_even)

Returns first rarial derivative df and second radial derivative ddf of the input function f. Array f(n_f_max,*) may contain several functions numbered by the first index. The subroutine calculates the derivaties of the functions f(n_f_start,*) to f(n_f_stop) by transforming to a Chebychev representation using n_r_max radial grid points. The cheb transforms have to be initialized by calling init_costf1 and init_costf2.

Parameters:
  • f (n_f_max,n_r_max) [complex ,inout]

  • df (n_f_max,n_r_max) [complex ,out] :: first derivative of f

  • ddf (n_f_max,n_r_max) [complex ,out] :: second derivative of f

  • n_f_max [integer ,in,] :: first dim of f

  • n_f_start [integer ,in] :: first function to be treated

  • n_f_stop [integer ,in] :: last function to be treated

  • n_r_max [integer ,in,] :: number of radial grid points

  • n_cheb_max [integer ,in] :: number of cheb modes

  • dr_fac [real ,in] :: mapping factor

  • work1 (n_f_max,n_r_max) [complex ,out] :: work array needed for costf

  • chebt_odd [costf_odd_t ,in]

  • chebt_even [costf_even_t ,in]

Called from:

fields_average()

integration.f90

Description

Radial integration functions

Quick access

Routines:

cylmean_itc(), cylmean_otc(), rint_r(), rintic(), simps()

Needed modules

  • precision_mod: This module controls the precision used in MagIC

  • constants (half(), one(), two(), pi()): module containing constants and parameters used in the code.

  • radial_scheme (type_rscheme()): This is an abstract type that defines the radial scheme used in MagIC

  • cosine_transform_odd: This module contains the built-in type I discrete Cosine Transforms. This implementation is based on Numerical Recipes and FFTPACK. This only works for n_r_max-1 = 2**a 3**b 5**c, with a,b,c integers….

Variables

Subroutines and functions

function  integration/rintic(f, nrmax, drfac, chebt)

This function performs the radial integral over a function f that is given on the appropriate nRmax radial Chebychev grid points.

Parameters:
  • f (nrmax) [real ,inout] :: This is zero order contribution

  • nrmax [integer ,in,] :: Only even chebs for IC

  • drfac [real ,in]

  • chebt [costf_odd_t ,in]

Return:

rintic [real ]

Called from:

get_e_mag(), get_power()

function  integration/rint_r(f, r, r_scheme)

Same as function rInt but for a radial dependent mapping function dr_fac2.

Parameters:
  • f (*) [real ,in] :: Input function

  • r (*) [real ,in] :: Radius

  • r_scheme [real ] :: Radial scheme (FD or Cheb)

Return:

rint [real ]

Called from:

dtbrms(), get_poltorrms(), getdlm(), get_e_kin(), get_u_square(), get_e_mag(), outhemi(), outhelicity(), outheat(), outphase(), get_onset(), outperppar(), get_angular_moment(), get_angular_moment_rloc(), output(), get_power(), precalc(), get_amplitude(), updatewp()

Call to:

simps()

function  integration/simps(f, r)

Simpson’s method to integrate a function

Parameters:
  • f (*) [real ,in] :: Input function

  • r (*) [real ,in] :: Radius

Return:

rint [real ]

Called from:

rint_r(), initialize_geos(), outgeos(), initialize_outto_mod(), outto()

subroutine  integration/cylmean_otc(a, v, n_s_max, n_s_otc, r, s, theta[, zdensin])

This routine computes a z-averaging using Simpsons’s rule outside T.C.

Parameters:
  • a (*,*) [real ,in]

  • v (n_s_max) [real ,out]

  • n_s_max [integer ,in,]

  • n_s_otc [integer ,in]

  • r (*) [real ,in] :: Spherical radius

  • s (n_s_max) [real ,in] :: Cylindrical radius

  • theta (*) [real ,in] :: Colatitude

Options:

zdensin [real ,in,]

Called from:

outgeos(), outomega()

subroutine  integration/cylmean_itc(a, vn, vs, n_s_max, n_s_otc, r, s, theta[, zdensin])

This routine computes a z-averaging using Simpsons’s rule inside T.C.

Parameters:
  • a (*,*) [real ,in]

  • vn (n_s_max) [real ,out]

  • vs (n_s_max) [real ,out]

  • n_s_max [integer ,in,]

  • n_s_otc [integer ,in]

  • r (*) [real ,in] :: Spherical radius

  • s (n_s_max) [real ,in] :: Cylindrical radius

  • theta (*) [real ,in] :: Colatitude

Options:

zdensin [real ,in,]

Called from:

outomega()