DL_MG
|
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. |
Contains public subroutines: initialisation/clean, solver interface, version and error reporting.
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
[in] | err_code | see params_inc |
[out] | msg | string describing the error code, its length must be at lest DL_MG_MAX_ERROR_STRING |
[out] | len_str | returns the length of the actual message |
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.
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.
[in] | nx_global | global grid size along x, see Grid Size Constrains for the recommended size |
[in] | ny_global | global grid size along y, see above |
[in] | nz_global | global 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] | gstart | coordinates of the start point in the global index space for the subdomain held by this rank |
[in] | gend | coordinates 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_block | minimum 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_return | if present and true don't abort on error, just return the error code |
[out] | ierror | error flag |
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
[in] | eps | relative permitivity on the grid points, ignored if the finite difference order is 2 |
[in] | eps_mid | relative 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] | alpha | multiplicative constant for \(\rho\) defined by the units used |
[in] | rho | charge density |
[in] | temp | temperature in Kelvin |
[in] | nion | Number of ionic species |
[in] | c | Concentrations 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] | q | Electric charge in electron charge units of each ionic specie present in solution. |
[in,out] | pot | solution to be sought, see embeded |
[in] | fd_order | derivatives approximation order in finite diferences |
[in] | tol_res_rel | relative 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_abs | absolute tolerace ... |
[in] | tol_pot_rel | relative tolerance parameter for the potential of the top iteration (used only in defect correction) |
[in] | tol_pot_abs | absolute tolerace for the potential |
[in] | tol_newton_res_rel | relative tol for newton iteration |
[in] | tol_newton_res_abs | absolute ... |
[in] | tol_cg_res_rel | relative tol for CG |
[in] | tol_cg_res_abs | absolute ... |
[in] | tol_vcycle_res_rel | relative tol for V cycle iterations |
[in] | tol_vcycle_res_abs | absolute ... |
[in] | tol_level_1_res_rel | tolerance for multgrig coarse loop, used only if number of levels > 1 |
[in] | tol_level_1_res_abs | absolute tolerance ... |
[in] | tol_mu_rel | relative tolerance for excess electrostatic potential |
[in] | tol_mu_abs | absolute tolerance for excess electrostatic potential |
[in] | mg_max_conv_rate | largest allowed convergence rate, i.e. the inverse ratio of two consecutive residuals in the multigrid solver |
[in] | max_iters_defco | maximum number of iterations for the higher order correction |
[in] | max_iters_newton | maximum number of iteration for Newton |
[in] | max_iters_cg | maximum number of CG iterations |
[in] | max_iters_vcycle | maximum number of V cycles (recommended value not more that 50) at the coarsest level |
[in] | max_iters_level_1 | max number of iteration |
[in] | v_iterations | number of relaxation iteration on the V-cycle branches |
[in] | omega_sor | SOR relaxation parameter |
[in] | linearised | use linereased version |
[in] | der_pot | potential function at which the derivative of the Boltzmann term is computed (if not present defaults to 0) |
[in] | steric_weight | steric weight in the Boltzmann term, i.e. \( e^{(-\beta V_{steric}(r))} \) |
[in] | expcap | cap of the exponential argument in the Boltzmann term |
[out] | res | residual at the of computation |
[in] | use_fas | use Full Approximation Scheme to solve non-linear PBE, the default is Newton method |
[in] | use_pot_in | start iterating from this potential, if not present starts from 0 |
[in] | use_damping | if present and true use error damping in defect correction loop |
[in] | neutralisation_method | select the neutralisation method for PBE with PBC |
[in] | neutralisation_ion_ratios | ratios 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_electrostatic | array 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_concentrations | array 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_ratios | array 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 |
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.
[in] | eps | relative permitivity on the grid points, ignored if the finite difference order is 2 |
[in] | eps_mid | relative 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] | alpha | multiplicative constant for \(\rho\) defined by the units used |
[in] | rho | r.h.s. term (charge density) |
[in,out] | pot | the potential to be computed, see embeded |
[in] | fd_order | finite difference order used in defect correction |
[out] | res | the residual |
[in] | use_pot_in | start iterating from this potential, if not present starts from 0 inside the domain |
[in] | tol_res_rel | relative tolerance parameter for the residual of the top iteration (defect correction if fd_order > 2, else multigrid). See Convergence Criteria |
[in] | tol_res_abs | absolute tolerace ... |
[in] | tol_pot_rel | relative tolerance parameter for the potential of the top iteration (used only in defect correction) |
[in] | tol_pot_abs | absolute tolerace for the potential |
[in] | tol_cg_res_rel | relative tol for conjugate gradient iterations |
[in] | tol_cg_res_abs | absolute ... |
[in] | tol_vcycle_res_rel | relative tol for V cycle iterations |
[in] | tol_vcycle_res_abs | absolute ... |
[in] | tol_level_1_res_rel | tolerance for multgrig coarse loop, used only if number of levels > 1 |
[in] | tol_level_1_res_abs | absolute tolerance ... |
[in] | mg_max_conv_rate | largest allowed convergence rate, i.e. the inverse ratio of two consecutive residuals in the multigrid solver |
[in] | max_iters_defco | maximum number of iterations for the higher order correction |
[in] | max_iters_cg | maximum number of CG iterations |
[in] | max_iters_vcycle | maximum number of V cycles (recommended value not more that 50) at the coarsest level |
[in] | max_iters_level_1 | max number of iteration |
[in] | v_iterations | number of relaxation iteration on the V-cycle branches |
[in] | omega_sor | SOR relaxation parameter |
[in] | use_damping | if true use error damping in defect correction loop |
[out] | ierror | error flag |
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
subroutine, public dl_mg::dl_mg_version | ( | character(len=*), intent(out) | version_string | ) |
returns the version string
[out] | version_string | length must be at least DL_MG_VERSION_STRING_LENGTH, see params_inc |
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]) |
|
private |
|
private |