XGCa
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Data Types | Functions/Subroutines
poisson.F90 File Reference
#include "petsc_version_defs.h"
#include <petsc/finclude/petsc.h>
Include dependency graph for poisson.F90:

Data Types

module  f90moduleinterfaces
 Explicit interfaces to somve PETSc function used by the FSA solver. More...
 
interface  f90moduleinterfaces::pcsetapplicationcontext
 
interface  f90moduleinterfaces::pcgetapplicationcontext
 
interface  f90moduleinterfaces::matcreateshell
 
interface  f90moduleinterfaces::matshellsetcontext
 
interface  f90moduleinterfaces::matshellgetcontext
 

Functions/Subroutines

subroutine init_poisson (grid, psn, iflag_dummy)
 
subroutine pcshermanmorrisonapply (pc, xin, yout, ierr)
 Applies a Sherman-Morrison preconditioner. More...
 
subroutine create_2field_solver (grid, bd, solver, solver_data)
 Sets up a 2x2 block solver for the Poisson equation. The first row is the Poisson equation, the second row is a constraint equation for the flux-surface averaged potential. More...
 
subroutine make_12mat (grid, Bmat, BIdentMat, FSAMass_Te, solver, bd, scale, xgc_petsc)
 
subroutine make_21mat (grid, Cmat, Cio, Bmat, CConstBCVec, bd, xgc_petsc, petsc_xgc_bd)
 
subroutine solve_axisymmetric_poisson (iflag)
 High level Poisson solver routine for n=0, offers choice of outer iterative solver, two-step solver, and FSA solver. More...
 
subroutine solve_turb_poisson (iflag, ipc)
 High level Poisson solver routine for |n|>0 Currently, only one implementation is available. More...
 
subroutine set_rhs_poisson (grid, psn, solver, iflag, is_turb, is_two_step)
 Routine to set and process the rhs arrays for both axisymmetric and turbulent poisson solvers. Also sets boundary data for XGCA. More...
 
subroutine save_rhs_poisson (grid, psn, solver, iflag, ipc, do_solve_poisson)
 Save the charge density for time averaging of the Poisson equation. More...
 
subroutine spectral_solver_decompose (grid, field_inout, field_ntor)
 Decompose field into spectral components treated by the spectral solver and the rest treated by the regular solver. More...
 
integer function get_ntor_num_from_ntor_real (ntor_real, nphi, wedge_n)
 Calculates the numerical toroidal mode number for a given real toroidal mode number. More...
 
subroutine spectral_solver_reassemble (grid, field_inout, field_ntor)
 Reassemble the full field from the spectral components treated by the spectral solver, and the rest treated by the regular solver. More...
 
subroutine set_petsc_rhs_vec_axisymmetric_poisson (grid, psn, solver)
 Places rhs and (optionally) boundary condition data into a PETSc vector. More...
 
subroutine set_initial_guess_axisymmetric_poisson (grid, psn)
 Sets initial guess for the iterative axisymmetric poisson solver using the simple00 solver. The initial guess is stored in psnpot0m. More...
 
subroutine solve_axisymmetric_poisson_iter (grid, psn)
 Poisson solver that uses an iterative method to solve for the axisymmetric electrostatic potential: The Poisson equation for the axisymmetric mode is

\[ -\nabla_\perp \cdot \xi \nabla_\perp \overline{\phi}_{k+1} + \frac{e n_0/T_{e,0}} \overline{\phi}_{k+1} = e \left( \langle \overline{\delta n_i} \rangle_g - \overline{\delta n_{e,NA}} \right) + \frac{e n_0/T_{e,0}} \langle \phi_{k} \rangle_{fs} \]

where \(k\) is the iteration index, \(xi\) is the electric susceptibility, \(e\) is the elementary charge, \(n_0\) and \(T_0\) are the background density and temperature, \(\langle \overline{\delta n_i} \rangle_g\) is the gyroaveraged ion (gyrocenter) charge density, \(\overline{\delta n_{e,NA}}\) is the non-adiabatic electron charge density, and \(\langle\dots\rangle_{fs}\) is the the flux-surface average. \(\overline{\dots}\) is the toroidal average. More...

 
subroutine axisym_mat_mult (A, X, Y, ierr)
 Subroutine used to apply the shell matrix representing the left hand side of the axisymmetric Poisson equation. More...
 
subroutine axisym_pc_apply (pc, X, Y, ierr)
 Subroutine used to apply the shell preconditioner used in the iterative solution of the axisymmetric Poisson equation. More...
 
subroutine solve_axisymmetric_poisson_two_step_fsa (grid, psn)
 Simple two-step 2D solver driver for the axisymmetric potential and one-step solver ("FSA-solver") with constraint equation for the flux-surface averaged potential. For the two-step solver, the RHS is the flux-surface averaged charge density, the LHS consists only of the polarization operator. The result of the 2D solve is flux-surface averaged; i.e., the result is \(\langle\phi\rangle\) The Poisson equation for the flux-surface averaged mode is

\[ -\nabla_\perp \cdot \xi \nabla_\perp \overline{\phi} = e \left\langle \left( \langle \overline{\delta n_i} \rangle_g - \overline{\delta n_{e,NA}} \right) \right\rangle_{fs} \]

where \(xi\) is the electric susceptibility, \(e\) is the elementary charge, \(n_0\) is the background density, \(\langle \overline{\delta n_i} \rangle_g\) is the gyroaveraged ion (gyrocenter) charge density, \(\overline{\delta n_{e,NA}}\) is the non-adiabatic electron charge density, and \(\langle\dots\rangle_{fs}\) is the the flux-surface average. \(\overline{\dots}\) is the toroidal average. More...

 
subroutine post_process_axisymmetric_poisson (grid, psn)
 Routine to post process the solution from the axisymmetric poisson solver. More...
 
subroutine solve_turb_poisson_default (grid, psn)
 Routine to solve the non-axisymmetric Poisson equation:

\[ -\nabla_\perp \cdot \xi \nabla_\perp \delta\phi + \frac{e n_0/T_{e,0}} \delta\phi = e \left( \langle \delta n_i \rangle_g - \overline{\delta n_{e,NA}} \right) \]

. More...

 
subroutine post_process_turb_poisson (grid, psn)
 Routine to post process the solution from the non-axisymmetric Poisson equation. More...
 

Function/Subroutine Documentation

subroutine axisym_mat_mult (   A,
  X,
  Y,
  ierr 
)

Subroutine used to apply the shell matrix representing the left hand side of the axisymmetric Poisson equation.

Parameters
[in]AShell matrix which multiplies X, Petsc Mat
[in]XVector to be multiplied, Petsc Vec
[out]YVector to store product A*X, Petsc Vec
[out]ierrPETSc Error code

Here is the call graph for this function:

Here is the caller graph for this function:

subroutine axisym_pc_apply (   pc,
  X,
  Y,
  ierr 
)

Subroutine used to apply the shell preconditioner used in the iterative solution of the axisymmetric Poisson equation.

Parameters
[in]pcShell preconditioner which is applied to residual X, Petsc PC
[in]XResidual vector, Petsc Vec
[out]YPreconditioned residual vector, Petsc Vec
[out]ierrPETSc Error code

Here is the call graph for this function:

Here is the caller graph for this function:

subroutine create_2field_solver ( type(grid_type)  grid,
type(boundary2_type)  bd,
type(xgc_solver)  solver,
type(solver_init_data), intent(in)  solver_data 
)

Sets up a 2x2 block solver for the Poisson equation. The first row is the Poisson equation, the second row is a constraint equation for the flux-surface averaged potential.

Parameters
[in]gridXGC grid object, type(grid_type)
[in]bdObject containing the indices of the solver boundary vertices in the XGC mesh.
[in,out]solverXGC solver object into which to put the new solver, type(xgc_solver)
[in]solver_dataData needed for settug up the ssolver, type(solver_init_data)

Here is the call graph for this function:

Here is the caller graph for this function:

integer function get_ntor_num_from_ntor_real ( integer, intent(in)  ntor_real,
integer, intent(in)  nphi,
integer, intent(in)  wedge_n 
)

Calculates the numerical toroidal mode number for a given real toroidal mode number.

Parameters
[in]ntor_realReal toroidal mode number, integer
[in]nphiNumber of toroidal planes per wedge, integer
[in]wedge_nNumber of wedges per toroidal circuit, integer

Here is the call graph for this function:

Here is the caller graph for this function:

subroutine init_poisson ( type(grid_type)  grid,
type(psn_type)  psn,
integer  iflag_dummy 
)

Here is the call graph for this function:

Here is the caller graph for this function:

subroutine make_12mat ( type(grid_type)  grid,
intent(inout)  Bmat,
  BIdentMat,
intent(in)  FSAMass_Te,
type(xgc_solver)  solver,
type(boundary2_type), intent(in)  bd,
real (8), intent(in)  scale,
dimension(grid%nnode), intent(in)  xgc_petsc 
)

Here is the call graph for this function:

Here is the caller graph for this function:

subroutine make_21mat ( type(grid_type)  grid,
  Cmat,
  Cio,
intent(in)  Bmat,
  CConstBCVec,
type(boundary2_type), intent(in)  bd,
dimension(grid%nnode), intent(in)  xgc_petsc,
dimension(grid%nnode), intent(in)  petsc_xgc_bd 
)

Here is the call graph for this function:

Here is the caller graph for this function:

subroutine pcshermanmorrisonapply (   pc,
  xin,
  yout,
  ierr 
)

Applies a Sherman-Morrison preconditioner.

Parameters
[in,out]pcPETCs PC object (manages preconditioners)
xin???, Vec
yout???, Vec
[out]ierrPETc error code

Here is the caller graph for this function:

subroutine post_process_axisymmetric_poisson ( type(grid_type)  grid,
type(psn_type)  psn 
)

Routine to post process the solution from the axisymmetric poisson solver.

Parameters
[in]gridXGC grid data object
[in,out]psnXGC field data object

Here is the call graph for this function:

Here is the caller graph for this function:

subroutine post_process_turb_poisson ( type(grid_type), intent(in)  grid,
type(psn_type), intent(inout)  psn 
)

Routine to post process the solution from the non-axisymmetric Poisson equation.

Parameters
[in]gridXGC grid data object
[in,out]psnXGC field data object

Here is the call graph for this function:

Here is the caller graph for this function:

subroutine save_rhs_poisson ( type(grid_type), intent(in)  grid,
type(psn_type), intent(inout)  psn,
type(xgc_solver), intent(inout)  solver,
integer, intent(in)  iflag,
integer, intent(in)  ipc,
logical, intent(out)  do_solve_poisson 
)

Save the charge density for time averaging of the Poisson equation.

Parameters
[in]gridXGC grid data structure, type(grid_type)
[in,out]psnXGC field data structure, type(psn_type)
[in,out]solverXGC solver object, type(xgc_solver)
[in]iflagAdiabatic solve indicator, integer
[in]ipcRK2 stage index, integer
[out]do_solve_poissonWhether to solve Ampere's law after saving RHS, logical

Here is the caller graph for this function:

subroutine set_initial_guess_axisymmetric_poisson ( type(grid_type), intent(in)  grid,
type(psn_type), intent(inout)  psn 
)

Sets initial guess for the iterative axisymmetric poisson solver using the simple00 solver. The initial guess is stored in psnpot0m.

Parameters
[in]gridSolver grid data, type(grid_type)
[in,out]psnField data; the pot0m is stored there, type(psn_type)

Here is the call graph for this function:

Here is the caller graph for this function:

subroutine set_petsc_rhs_vec_axisymmetric_poisson ( type(grid_type)  grid,
type(psn_type)  psn,
type(xgc_solver)  solver 
)

Places rhs and (optionally) boundary condition data into a PETSc vector.

Parameters
[in]gridSolver grid data, type(grid_type)
[in,out]psnField data; the rhs XGC data is stored there, type(psn_type)
[in,out]solverXGC solver object; the rhs PETSc vector is stored there, type(xgc_solver)

Here is the call graph for this function:

Here is the caller graph for this function:

subroutine set_rhs_poisson ( type(grid_type)  grid,
type(psn_type)  psn,
type(xgc_solver)  solver,
integer, intent(in)  iflag,
logical, intent(in)  is_turb,
logical, intent(in)  is_two_step 
)

Routine to set and process the rhs arrays for both axisymmetric and turbulent poisson solvers. Also sets boundary data for XGCA.

Parameters
[in]gridXGC grid data object
[in,out]psnXGC field data object
[in,out]solverXGC solver object, type(xgc_solver)
[in]iflagFlag to indicate whether adiabatic elec or full eq. is solved, integer
[in]is_turbIf .true. set RHS for turbulence solve, otherwise for axisymmetric solve
[in]is_two_stepWhether this is for setting the RHS for the (n=0,|m|>0) step of the two-step solver

Here is the call graph for this function:

Here is the caller graph for this function:

subroutine solve_axisymmetric_poisson ( integer  iflag)

High level Poisson solver routine for n=0, offers choice of outer iterative solver, two-step solver, and FSA solver.

Parameters
[in]iflagFlag to indicate whether adiabatic elec or full eq. is solved, integer

Here is the call graph for this function:

Here is the caller graph for this function:

subroutine solve_axisymmetric_poisson_iter ( type(grid_type), intent(in)  grid,
type(psn_type), intent(inout)  psn 
)

Poisson solver that uses an iterative method to solve for the axisymmetric electrostatic potential: The Poisson equation for the axisymmetric mode is

\[ -\nabla_\perp \cdot \xi \nabla_\perp \overline{\phi}_{k+1} + \frac{e n_0/T_{e,0}} \overline{\phi}_{k+1} = e \left( \langle \overline{\delta n_i} \rangle_g - \overline{\delta n_{e,NA}} \right) + \frac{e n_0/T_{e,0}} \langle \phi_{k} \rangle_{fs} \]

where \(k\) is the iteration index, \(xi\) is the electric susceptibility, \(e\) is the elementary charge, \(n_0\) and \(T_0\) are the background density and temperature, \(\langle \overline{\delta n_i} \rangle_g\) is the gyroaveraged ion (gyrocenter) charge density, \(\overline{\delta n_{e,NA}}\) is the non-adiabatic electron charge density, and \(\langle\dots\rangle_{fs}\) is the the flux-surface average. \(\overline{\dots}\) is the toroidal average.

The RHS and LHS of the axisymmetric equation can be Fourier-filtered (poloidal modes). The LHS of the non-axisymmetric equation can be Fourier-filtered in the toroidal and poloidal direction. The solver in both cases is a linear finite-element solver on an unstructured triangular grid.

Parameters
[in]gridSolver grid data, type(grid_type)
[in,out]psnField data; the potential is stored there, type(psn_type)

Here is the call graph for this function:

Here is the caller graph for this function:

subroutine solve_axisymmetric_poisson_two_step_fsa ( type(grid_type), intent(in)  grid,
type(psn_type), intent(inout)  psn 
)

Simple two-step 2D solver driver for the axisymmetric potential and one-step solver ("FSA-solver") with constraint equation for the flux-surface averaged potential. For the two-step solver, the RHS is the flux-surface averaged charge density, the LHS consists only of the polarization operator. The result of the 2D solve is flux-surface averaged; i.e., the result is \(\langle\phi\rangle\) The Poisson equation for the flux-surface averaged mode is

\[ -\nabla_\perp \cdot \xi \nabla_\perp \overline{\phi} = e \left\langle \left( \langle \overline{\delta n_i} \rangle_g - \overline{\delta n_{e,NA}} \right) \right\rangle_{fs} \]

where \(xi\) is the electric susceptibility, \(e\) is the elementary charge, \(n_0\) is the background density, \(\langle \overline{\delta n_i} \rangle_g\) is the gyroaveraged ion (gyrocenter) charge density, \(\overline{\delta n_{e,NA}}\) is the non-adiabatic electron charge density, and \(\langle\dots\rangle_{fs}\) is the the flux-surface average. \(\overline{\dots}\) is the toroidal average.

NOTE: The two-step solver does not support non-zero Dirichlet boundary conditions!

The FSA solver solves the same equation as the outer-iterative solver (solve_axisymmetric_poisson_iter), but with a twist. The flux-surface averaged potential is treated as an independent field \(\lambda\) in the Poisson equation. In order to make the equation consistent, a second (constraint) equation is added that enforces \(\lambda=\langle\phi\rangle_{fs}\). So the FSA solver solves a 2x2 block system.

Parameters
[in]gridSolver grid data, type(grid_type)
[in,out]psnField data; the potential is stored there, type(psn_type)

Here is the call graph for this function:

Here is the caller graph for this function:

subroutine solve_turb_poisson ( integer  iflag,
integer  ipc 
)

High level Poisson solver routine for |n|>0 Currently, only one implementation is available.

Parameters
[in]gridXGC grid data object
[in,out]psnXGC field data object
[in]iflagFlag to indicate whether adiabatic elec or full eq. is solved, integer
[in]ipcRK2 stage index, integer

Here is the call graph for this function:

Here is the caller graph for this function:

subroutine solve_turb_poisson_default ( type(grid_type), intent(in)  grid,
type(psn_type), intent(inout)  psn 
)

Routine to solve the non-axisymmetric Poisson equation:

\[ -\nabla_\perp \cdot \xi \nabla_\perp \delta\phi + \frac{e n_0/T_{e,0}} \delta\phi = e \left( \langle \delta n_i \rangle_g - \overline{\delta n_{e,NA}} \right) \]

.

Parameters
[in]gridXGC grid data object
[in,out]psnXGC field data object

Here is the call graph for this function:

Here is the caller graph for this function:

subroutine spectral_solver_decompose ( type(grid_type), intent(in)  grid,
real(kind=8), dimension(grid%nnode), intent(inout)  field_inout,
real(kind=8), dimension(grid%nnode,2), intent(out)  field_ntor 
)

Decompose field into spectral components treated by the spectral solver and the rest treated by the regular solver.

Parameters
[in]gridXGC grid object, type(grid_type)
[in,out]field_inoutInput data, real(8)
[out]field_ntorOutput

Here is the call graph for this function:

Here is the caller graph for this function:

subroutine spectral_solver_reassemble ( type(grid_type), intent(in)  grid,
real(kind=8), dimension(grid%nnode), intent(inout)  field_inout,
real(kind=8), dimension(grid%nnode,2), intent(inout)  field_ntor 
)

Reassemble the full field from the spectral components treated by the spectral solver, and the rest treated by the regular solver.

Parameters
[in]gridXGC grid object, type(grid_type)
[in,out]field_inoutInput data, real(8)
[in,out]field_ntorOutput

Here is the call graph for this function:

Here is the caller graph for this function: