DL_MG
Data Types | Functions/Subroutines | Variables
dl_mg Module Reference

Contains public subroutines: initialisation/clean, solver interface, version and error reporting. More...

Data Types

interface  dl_mg_solver
 

Functions/Subroutines

subroutine, public dl_mg_init (nx_global, ny_global, nz_global, dx_, dy_, dz_, bc_, gstart, gend, commin_, report_unit_, report_file_, min_omp_thread_block, errors_return, ierror)
 Collects the parameters needed for DL_MG internal initialisation. More...
 
subroutine dl_mg_solver_poisson (eps, eps_mid, alpha, rho, pot, fd_order, tol_res_rel, tol_res_abs, tol_pot_rel, tol_pot_abs, tol_cg_res_rel, tol_cg_res_abs, tol_vcycle_res_rel, tol_vcycle_res_abs, tol_level_1_res_rel, tol_level_1_res_abs, mg_max_conv_rate, max_iters_defco, max_iters_cg, max_iters_vcycle, max_iters_level_1, v_iterations, omega_sor, use_cg, use_pot_in, use_damping, res, ierror)
 Poisson Equation driver. More...
 
subroutine dl_mg_solver_pbe (eps, eps_mid, alpha, rho, lambda, temp, nion, c, q, pot, fd_order, tol_res_rel, tol_res_abs, tol_pot_rel, tol_pot_abs, tol_newton_res_rel, tol_newton_res_abs, tol_cg_res_rel, tol_cg_res_abs, tol_vcycle_res_rel, tol_vcycle_res_abs, tol_level_1_res_rel, tol_level_1_res_abs, tol_mu_rel, tol_mu_abs, mg_max_conv_rate, max_iters_defco, max_iters_cg, max_iters_vcycle, max_iters_level_1, max_iters_newton, v_iterations, use_cg, omega_sor, linearised, der_pot, steric_weight, expcap, res, use_fas, use_pot_in, use_damping, neutralisation_method, neutralisation_ion_ratios, betamu_electrostatic, steric_weight_average, used_ion_concentrations, used_neutralisation_ratios, ierror)
 solves PBE with steric potential More...
 
subroutine, public dl_mg_solver_status (nwt_iteration, nwt_solution_norm, nwt_residual_norm, nwt_target_residual_norm, nwt_ierror, defco_iteration, defco_solution_norm, defco_residual_norm, defco_error_norm, defco_target_residual_norm, defco_ierror)
 return the last updated in the newton status could be useful to asses the quality of a partital solution when the the solver returns with an error More...
 
subroutine, public dl_mg_error_string (err_code, msg, len_str)
 returns the error string associated with an error code More...
 
subroutine, public dl_mg_version (version_string)
 returns the version string More...
 
subroutine, public dl_mg_free ()
 Free solver data structures. More...
 

Variables

real(kind=kind(0.d0)), dimension(1, 1, 1, 1), parameter, public dl_mg_eps_mid_ignore =reshape([-1d0], [1,1,1,1])
 
logical, save initialised = .false.
 
logical, save initialised_nonlin = .false.
 

Detailed Description

Contains public subroutines: initialisation/clean, solver interface, version and error reporting.

Function/Subroutine Documentation

◆ dl_mg_error_string()

subroutine, public dl_mg::dl_mg_error_string ( integer, intent(in)  err_code,
character(len=*), intent(out)  msg,
integer, intent(out), optional  len_str 
)

returns the error string associated with an error code

Parameters
[in]err_codesee params_inc
[out]msgstring describing the error code, its length must be at lest DL_MG_MAX_ERROR_STRING
[out]len_strreturns the length of the actual message

◆ dl_mg_free()

subroutine, public dl_mg::dl_mg_free

Free solver data structures.

This is needed if the application solves more than one PBE or PE problem.

Note: the arrays used to compute the solution are deallocated at the end of dl_mg_poisson_solver or dl_mg_pbe_solver. This subroutine frees some internal data structures and resets the internal initialisation flags. After this call a new problem can be initialised.

◆ dl_mg_init()

subroutine, public dl_mg::dl_mg_init ( integer, intent(in)  nx_global,
integer, intent(in)  ny_global,
integer, intent(in)  nz_global,
real(wp), intent(in)  dx_,
real(wp), intent(in)  dy_,
real(wp), intent(in)  dz_,
integer, dimension(3), intent(in)  bc_,
integer, dimension(3), intent(in)  gstart,
integer, dimension(3), intent(in)  gend,
intent(in)  commin_,
integer, intent(in)  report_unit_,
character(len=*), intent(in)  report_file_,
integer, dimension(3), intent(in), optional  min_omp_thread_block,
logical, intent(in), optional  errors_return,
integer, intent(out), optional  ierror 
)

Collects the parameters needed for DL_MG internal initialisation.

Parameters
[in]nx_globalglobal grid size along x, see Grid Size Constrains for the recommended size
[in]ny_globalglobal grid size along y, see above
[in]nz_globalglobal grid size along z, see above
[in]dx_size of grids unit step along x
[in]dy_size of grids unit step along y
[in]dz_size of grids unit step along z
[in]bc_boundary conditions along x, y, z. Accepted values: DL_MG_BC_DIRICHLET, DL_MG_PERIODIC.
[in]gstartcoordinates of the start point in the global index space for the subdomain held by this rank
[in]gendcoordinates of the end point in the global index space for the subdomain held by this rank
[in]report_unit_IO unit to be used by DL_MG for reporting
[in]report_file_name of DL_MG log file
[in]min_omp_thread_blockminimum block size to be allocated to a OMP threads in loops that iterate the 6 pts stencil at the coarse level of multigrid is better to let som thread lazy rather than having them fighting over the cache lines It does not make sense to use a value less than 3 because the Laplace stencil uses 3 grid layers. if set <= 0 the default value are used see set_loop_blocks
[in]errors_returnif present and true don't abort on error, just return the error code
[out]ierrorerror flag

◆ dl_mg_solver_pbe()

subroutine dl_mg::dl_mg_solver_pbe ( real(wp), dimension(:,:,:), intent(in)  eps,
real(wp), dimension(:, :, :, :), intent(in), target  eps_mid,
real(wp), intent(in)  alpha,
real(wp), dimension(:, :, :), intent(in)  rho,
real(wp), intent(in)  lambda,
real(wp), intent(in)  temp,
integer, intent(in)  nion,
real(wp), dimension(nion), intent(in)  c,
real(wp), dimension(nion), intent(in)  q,
real(wp), dimension(:, :, :), intent(inout)  pot,
integer, intent(in)  fd_order,
real(wp), intent(in), optional  tol_res_rel,
real(wp), intent(in), optional  tol_res_abs,
real(wp), intent(in), optional  tol_pot_rel,
real(wp), intent(in), optional  tol_pot_abs,
real(wp), intent(in), optional  tol_newton_res_rel,
real(wp), intent(in), optional  tol_newton_res_abs,
real(wp), intent(in), optional  tol_cg_res_rel,
real(wp), intent(in), optional  tol_cg_res_abs,
real(wp), intent(in), optional  tol_vcycle_res_rel,
real(wp), intent(in), optional  tol_vcycle_res_abs,
real(wp), intent(in), optional  tol_level_1_res_rel,
real(wp), intent(in), optional  tol_level_1_res_abs,
real(wp), intent(in), optional  tol_mu_rel,
real(wp), intent(in), optional  tol_mu_abs,
real(wp), intent(in), optional  mg_max_conv_rate,
integer, intent(in), optional  max_iters_defco,
integer, intent(in), optional  max_iters_cg,
integer, intent(in), optional  max_iters_vcycle,
integer, intent(in), optional  max_iters_level_1,
integer, intent(in), optional  max_iters_newton,
integer, dimension(2), intent(in), optional  v_iterations,
logical, intent(in), optional  use_cg,
real(wp), intent(in), optional  omega_sor,
logical, intent(in), optional  linearised,
real(wp), dimension(:,:,:), intent(in), optional  der_pot,
real(wp), dimension(:,:,:), intent(in), optional  steric_weight,
real(wp), intent(in), optional  expcap,
real(wp), dimension(:, :, :), intent(out), optional  res,
logical, intent(in), optional  use_fas,
logical, intent(in), optional  use_pot_in,
logical, intent(in), optional  use_damping,
integer, intent(in), optional  neutralisation_method,
real(wp), dimension(nion), intent(in), optional  neutralisation_ion_ratios,
real(wp), dimension(nion), intent(out), optional  betamu_electrostatic,
real(wp), intent(out), optional  steric_weight_average,
real(wp), dimension(nion), intent(out), optional  used_ion_concentrations,
real(wp), dimension(nion), intent(out), optional  used_neutralisation_ratios,
integer, intent(out), optional  ierror 
)

solves PBE with steric potential

Parameters
[in]epsrelative permitivity on the grid points, ignored if the finite difference order is 2
[in]eps_midrelative permitivity, at the points located halfway between the grid points in each direction E.g.: eps_mid(i,j,k,1) is associated with the middle point of grid segment between (i,j,k) and (i+1,j,k).
[in]alphamultiplicative constant for \(\rho\) defined by the units used
[in]rhocharge density
[in]temptemperature in Kelvin
[in]nionNumber of ionic species
[in]cConcentrations of ionic species in \( r_{Bohr}^{-3}\), where \( r_{Bohr}\) is the Bohr radius. Note: the concentration must be defined in relation to the accesible ion volume, not the grid domain volume. These quantities differ when steric weight is used, see this note.
[in]qElectric charge in electron charge units of each ionic specie present in solution.
[in,out]potsolution to be sought, see embeded
[in]fd_orderderivatives approximation order in finite diferences
[in]tol_res_relrelative tolerance parameter for the residual of the top iteration (defect correction if fd_order > 2, else applies to Newton or linearised PBE). See Convergence Criteria
[in]tol_res_absabsolute tolerace ...
[in]tol_pot_relrelative tolerance parameter for the potential of the top iteration (used only in defect correction)
[in]tol_pot_absabsolute tolerace for the potential
[in]tol_newton_res_relrelative tol for newton iteration
[in]tol_newton_res_absabsolute ...
[in]tol_cg_res_relrelative tol for CG
[in]tol_cg_res_absabsolute ...
[in]tol_vcycle_res_relrelative tol for V cycle iterations
[in]tol_vcycle_res_absabsolute ...
[in]tol_level_1_res_reltolerance for multgrig coarse loop, used only if number of levels > 1
[in]tol_level_1_res_absabsolute tolerance ...
[in]tol_mu_relrelative tolerance for excess electrostatic potential
[in]tol_mu_absabsolute tolerance for excess electrostatic potential
[in]mg_max_conv_ratelargest allowed convergence rate, i.e. the inverse ratio of two consecutive residuals in the multigrid solver
[in]max_iters_defcomaximum number of iterations for the higher order correction
[in]max_iters_newtonmaximum number of iteration for Newton
[in]max_iters_cgmaximum number of CG iterations
[in]max_iters_vcyclemaximum number of V cycles (recommended value not more that 50) at the coarsest level
[in]max_iters_level_1max number of iteration
[in]v_iterationsnumber of relaxation iteration on the V-cycle branches
[in]omega_sorSOR relaxation parameter
[in]lineariseduse linereased version
[in]der_potpotential function at which the derivative of the Boltzmann term is computed (if not present defaults to 0)
[in]steric_weightsteric weight in the Boltzmann term, i.e. \( e^{(-\beta V_{steric}(r))} \)
[in]expcapcap of the exponential argument in the Boltzmann term
[out]resresidual at the of computation
[in]use_fasuse Full Approximation Scheme to solve non-linear PBE, the default is Newton method
[in]use_pot_instart iterating from this potential, if not present starts from 0
[in]use_dampingif present and true use error damping in defect correction loop
[in]neutralisation_methodselect the neutralisation method for PBE with PBC
[in]neutralisation_ion_ratiosratios of ion mixing when neutralisation_method is set to dl_mg_neutralise_with_ions_fixed non-negative reals, no need to be normalised to 1.
[out]betamu_electrostaticarray containing \( \mu_i /(k_B T) \) computed in the Newton solver or in the defect correction section see Periodic boundary conditions (PBC) for PBE
[out]used_ion_concentrationsarray containing the bulk ion concentration used in PBE solution. It might differ from the input concentration when neutralisation_method is set to dl_mg_neutralise_with_ions_fixed or to dl_mg_neutralise_with_ions_auto.
[out]used_neutralisation_ratiosarray containing the neutralisation ratios used to shift the bulk concentrations. Relevant only if neutralisation_method is set to dl_mg_neutralise_with_ions_fixed or to dl_mg_neutralise_with_ions_auto
[out]steric_weight_average\( (1/V) \int_V e^{(-\beta V_{steric}(r))} dv\) useful if the calling app wants to compute the ions distribution functions

◆ dl_mg_solver_poisson()

subroutine dl_mg::dl_mg_solver_poisson ( real(wp), dimension(:, :, :), intent(in)  eps,
real(wp), dimension(:, :, :, :), intent(in)  eps_mid,
real(wp), intent(in)  alpha,
real(wp), dimension(:, :, :), intent(in)  rho,
real(wp), dimension(:, :, :), intent(inout)  pot,
integer, intent(in)  fd_order,
real(wp), intent(in), optional  tol_res_rel,
real(wp), intent(in), optional  tol_res_abs,
real(wp), intent(in), optional  tol_pot_rel,
real(wp), intent(in), optional  tol_pot_abs,
real(wp), intent(in), optional  tol_cg_res_rel,
real(wp), intent(in), optional  tol_cg_res_abs,
real(wp), intent(in), optional  tol_vcycle_res_rel,
real(wp), intent(in), optional  tol_vcycle_res_abs,
real(wp), intent(in), optional  tol_level_1_res_rel,
real(wp), intent(in), optional  tol_level_1_res_abs,
real(wp), intent(in), optional  mg_max_conv_rate,
integer, intent(in), optional  max_iters_defco,
integer, intent(in), optional  max_iters_cg,
integer, intent(in), optional  max_iters_vcycle,
integer, intent(in), optional  max_iters_level_1,
integer, dimension(2), intent(in), optional  v_iterations,
real(wp), intent(in), optional  omega_sor,
logical, intent(in), optional  use_cg,
logical, intent(in), optional  use_pot_in,
logical, intent(in), optional  use_damping,
real(wp), dimension(:, :, :), intent(out), optional  res,
integer, intent(out), optional  ierror 
)

Poisson Equation driver.

Parameters
[in]epsrelative permitivity on the grid points, ignored if the finite difference order is 2
[in]eps_midrelative permitivity, at the points located halfway between the grid points in each direction. the fourth index stores the direction: 1 -> x, 2 ->y, 3 -> z E.g.: eps_mid(i,j,k,1) is associated with the middle point of grid segment between (i,j,k) and (i+1,j,k).
[in]alphamultiplicative constant for \(\rho\) defined by the units used
[in]rhor.h.s. term (charge density)
[in,out]potthe potential to be computed, see embeded
[in]fd_orderfinite difference order used in defect correction
[out]resthe residual
[in]use_pot_instart iterating from this potential, if not present starts from 0 inside the domain
[in]tol_res_relrelative tolerance parameter for the residual of the top iteration (defect correction if fd_order > 2, else multigrid). See Convergence Criteria
[in]tol_res_absabsolute tolerace ...
[in]tol_pot_relrelative tolerance parameter for the potential of the top iteration (used only in defect correction)
[in]tol_pot_absabsolute tolerace for the potential
[in]tol_cg_res_relrelative tol for conjugate gradient iterations
[in]tol_cg_res_absabsolute ...
[in]tol_vcycle_res_relrelative tol for V cycle iterations
[in]tol_vcycle_res_absabsolute ...
[in]tol_level_1_res_reltolerance for multgrig coarse loop, used only if number of levels > 1
[in]tol_level_1_res_absabsolute tolerance ...
[in]mg_max_conv_ratelargest allowed convergence rate, i.e. the inverse ratio of two consecutive residuals in the multigrid solver
[in]max_iters_defcomaximum number of iterations for the higher order correction
[in]max_iters_cgmaximum number of CG iterations
[in]max_iters_vcyclemaximum number of V cycles (recommended value not more that 50) at the coarsest level
[in]max_iters_level_1max number of iteration
[in]v_iterationsnumber of relaxation iteration on the V-cycle branches
[in]omega_sorSOR relaxation parameter
[in]use_dampingif true use error damping in defect correction loop
[out]ierrorerror flag

◆ dl_mg_solver_status()

subroutine, public dl_mg::dl_mg_solver_status ( integer, intent(out), optional  nwt_iteration,
real(wp), intent(out), optional  nwt_solution_norm,
real(wp), intent(out), optional  nwt_residual_norm,
real(wp), intent(out), optional  nwt_target_residual_norm,
integer, intent(out), optional  nwt_ierror,
integer, intent(out), optional  defco_iteration,
real(wp), intent(out), optional  defco_solution_norm,
real(wp), intent(out), optional  defco_residual_norm,
real(wp), intent(out), optional  defco_error_norm,
real(wp), intent(out), optional  defco_target_residual_norm,
integer, intent(out), optional  defco_ierror 
)

return the last updated in the newton status could be useful to asses the quality of a partital solution when the the solver returns with an error

◆ dl_mg_version()

subroutine, public dl_mg::dl_mg_version ( character(len=*), intent(out)  version_string)

returns the version string

Parameters
[out]version_stringlength must be at least DL_MG_VERSION_STRING_LENGTH, see params_inc

Variable Documentation

◆ dl_mg_eps_mid_ignore

real(kind=kind(0.d0)), dimension(1,1,1,1), parameter, public dl_mg::dl_mg_eps_mid_ignore =reshape([-1d0], [1,1,1,1])

◆ initialised

logical, save dl_mg::initialised = .false.
private

◆ initialised_nonlin

logical, save dl_mg::initialised_nonlin = .false.
private