Classes | Public Member Functions | List of all members
EpotProblem Class Reference

Class for constructing the linear/nonlinear problem for the solver. More...

#include <epot_problem.hpp>

Inheritance diagram for EpotProblem:
Problem

Public Member Functions

 EpotProblem ()
 Default constructor. More...
 
 EpotProblem (std::istream &s)
 Constructor for loading problem from a file. More...
 
 ~EpotProblem ()
 Destructor for problem. More...
 
void set_neumann_order (int32_t order)
 Set Neumann boundary order. More...
 
void enable_smooth_solids (bool enable)
 Enable smooth solid edges. More...
 
void set_forced_potential_volume (double force_pot, bool(*force_pot_func)(double, double, double))
 Define forced potential volume. More...
 
void set_initial_plasma (double Up, bool(*plasma_func)(double, double, double))
 Define initial plasma to the problem. More...
 
void set_pexp_plasma (double rhoe, double Te, double Up)
 Enable plasma model for positive ion extraction problem. More...
 
void set_nsimp_initial_plasma (bool(*plasma_func)(double, double, double))
 Define initial plasma boundary location to negative ion extraction problem. More...
 
void set_nsimp_plasma (double rhop, double Ep, std::vector< double > rhoi, std::vector< double > Ei)
 Enable plasma model for negative ion extraction problem. More...
 
void construct (const Geometry &g)
 Construct matrix form of the problem. More...
 
void set_solver (Solver &s)
 Set solver to be used for the problem. More...
 
void solve (ScalarField &epot, const ScalarField &scharge) const
 Solve the problem. More...
 
void get_vecmat (const Matrix **A, const Vector **B) const
 Return const pointers to the matrix A and vector B of the linear problem. More...
 
void get_resjac (const Matrix **J, const Vector **R, const Vector &X) const
 Return const pointers to jacobian matrix and residual vector of the problem to J and R at X. More...
 
bool linear (void) const
 Return true if problem is linear. More...
 
int get_dof (void) const
 Get degrees of freedom. More...
 
void debug_print (std::ostream &os) const
 Print debugging information to os. More...
 
void save (std::ostream &s) const
 Saves problem data to stream. More...
 
- Public Member Functions inherited from Problem
virtual ~Problem ()
 Virtual destructor. More...
 

Detailed Description

Class for constructing the linear/nonlinear problem for the solver.

EpotProblem class constructs the Poisson (equation) problem in finite difference form from Geometry (mesh) and various parameters and it presents the problem to the Solver via matrix/vector representation. In case of linear problem (no plasma model), the Poisson equation

\[ \nabla^2 \phi = -\frac{\rho}{\epsilon_0} \]

is

\[ \frac{\partial^2 \phi}{\partial x^2} = -\frac{\rho}{\epsilon_0} \]

in 1D, which is discretized into

\[ \phi_{i-1} + \phi_{i+1} - 2\phi_{i} = -h^2 \frac{\rho_{i}}{\epsilon_0} \]

using finite differences. In 2D coordinates the discretized form is

\[ \phi_{i-1,j} + \phi_{i+1,j} + \phi_{i,j-1} + \phi_{i,j+1} - 4\phi_{i,j} = -h^2 \frac{\rho_{i,j}}{\epsilon_0} \]

and in 3D it is

\[ \phi_{i-1,j,k} + \phi_{i+1,j,k} + \phi_{i,j-1,k} + \phi_{i,j+1,k} + \phi_{i,j,k-1} + \phi_{i,j,k+1} - 6\phi_{i,j} = -h^2 \frac{\rho_{i,j,k}}{\epsilon_0}. \]

In cylindrical coordinates the Poisson equation is

\[ \frac{\partial^2 \phi}{\partial r^2} + \frac{1}{r} \frac{\partial \phi}{\partial r} + \frac{1}{r^2} \frac{\partial^2 \phi}{\partial \theta^2} + \frac{\partial^2 \phi}{\partial z^2} = -\frac{\rho}{\epsilon_0}, \]

where $ \frac{\partial^2 \phi}{\partial \theta^2} = 0 $ because of cylindrical symmetry of the simulations. Therefore the discretized form becomes

\[ \phi_{i-1,j} + \phi_{i+1,j} + \left( 1 - \frac{h}{2r_j} \right) \phi_{i,j-1} + \left( 1 + \frac{h}{2r_j} \right) \phi_{i,j+1} - 4\phi_{i,j} = -h^2 \frac{\rho_{i,j}}{\epsilon_0}, \]

where $ \frac{h}{2r_j} = \frac{h}{2jh} = \frac{1}{2j} $ because the radius $ r_j = hj $. At the symmetry axis there is an exception because both $ r $ and $ \frac{\partial \phi}{\partial r} $ approach zero. By using Bernoulli-L'Hopital rule we can evaluate

\[ \lim_{r \rightarrow 0} \frac{1}{r} \frac{\partial \phi}{\partial r} = \lim_{r \rightarrow 0} \frac{\partial^2 \phi}{\partial r^2}, \]

which turns the Poisson equation to

\[ 2 \frac{\partial^2 \phi}{\partial r^2} + \frac{\partial^2 \phi}{\partial z^2} = -\frac{\rho}{\epsilon_0} \]

on axis. Discretation of the equation gives us

\[ \phi_{i-1,j} + \phi_{i+1,j} + 2\phi_{i,j+1} + 2\phi_{i,j-1} - 6\phi_{i,j} = -h^2 \frac{\rho_{i,j}}{\epsilon_0}. \]

Here $ \phi_{i,j-1} = \phi_{i,j+1} $ so that the final form is

\[ \phi_{i-1,j} + \phi_{i+1,j} + 4\phi_{i,j+1} - 6\phi_{i,j} = -h^2 \frac{\rho_{i,j}}{\epsilon_0}. \]

In addition to the Poisson equation the problem matrix and vector also contain finite difference representations of the boundary conditions. The Dirichlet boundary condition is defined by constant potential at boundary, i.e. $ \phi_{i,j} = \phi_{\mathrm{const}} $. The Neumann boundary condition can be defined as first order discretation

\[ \frac{\phi_{i+1}-\phi_{i}}{h} = N_{\mathrm{const}} \]

or second order discretation

\[ \frac{-\phi_{i+2}+4\phi_{i+1}-3\phi_{i}}{2h} = N_{\mathrm{const}} \]

selected by the user.

The plasma problems are described by using nonlinear models for screening charges in the plasma. For positive ion extraction for example, the screening charge is an electron population at the plasma potential $ \phi_p $ with a thermal energy distribution with temperature $ T_e $. The screening charge is therefore

\[ \rho_e = \rho_{e0} \exp \left( \frac{\phi-\phi_p}{kT_e/e} \right), \]

where electron charge density at plasma potential $ (\rho_{e0}) $ is the same as the total positive beam space charge density for enabling plasma neutrality.

Constructor & Destructor Documentation

EpotProblem::EpotProblem ( )

Default constructor.

EpotProblem::EpotProblem ( std::istream &  s)

Constructor for loading problem from a file.

EpotProblem::~EpotProblem ( )

Destructor for problem.

Member Function Documentation

void EpotProblem::construct ( const Geometry g)

Construct matrix form of the problem.

Requires that mesh is build for geometry g.

void EpotProblem::debug_print ( std::ostream &  os) const

Print debugging information to os.

void EpotProblem::enable_smooth_solids ( bool  enable)

Enable smooth solid edges.

Smooth edges are enabled by default.

int EpotProblem::get_dof ( void  ) const
inline

Get degrees of freedom.

void EpotProblem::get_resjac ( const Matrix **  J,
const Vector **  R,
const Vector X 
) const
virtual

Return const pointers to jacobian matrix and residual vector of the problem to J and R at X.

This function should only be called by Solver, while method Problem::solve() is running and only in case of nonlinear problem.

Implements Problem.

void EpotProblem::get_vecmat ( const Matrix **  A,
const Vector **  B 
) const
virtual

Return const pointers to the matrix A and vector B of the linear problem.

This function should only be called by Solver, while method Problem::solve() is running and only in case of linear problem.

Implements Problem.

bool EpotProblem::linear ( void  ) const
virtual

Return true if problem is linear.

Implements Problem.

void EpotProblem::save ( std::ostream &  s) const

Saves problem data to stream.

void EpotProblem::set_forced_potential_volume ( double  force_pot,
bool(*)(double, double, double)  force_pot_func 
)

Define forced potential volume.

Vacuum volume inside the volume defined by function force_pot_func will be forced to potential force_pot. This function is designed to be used with negative ion plasma extraction to stabilize plasma close non-physical boundaries.

void EpotProblem::set_initial_plasma ( double  Up,
bool(*)(double, double, double)  plasma_func 
)

Define initial plasma to the problem.

Initial plasma volume is defined in the area given by plasma_func.

void EpotProblem::set_neumann_order ( int32_t  order)

Set Neumann boundary order.

Valid values are 1 and 2 (default).

void EpotProblem::set_nsimp_initial_plasma ( bool(*)(double, double, double)  plasma_func)

Define initial plasma boundary location to negative ion extraction problem.

Initial plasma volume is defined in the area given by plasma_func.

void EpotProblem::set_nsimp_plasma ( double  rhop,
double  Ep,
std::vector< double >  rhoi,
std::vector< double >  Ei 
)

Enable plasma model for negative ion extraction problem.

The positive (analytic) space charges for the negative ion plasma extraction are set using this function. The positive ions consist of fast (directed) protons and any number of thermal positive ions trapped at the plasma boundary in the zero potential.

The parameters set are rhop, the space charge density of protons and Ep, the energy of protons at zero potential. Vectors rhoi and Ei are used to set the space charge densities and thermal energies of the trapped ions.

void EpotProblem::set_pexp_plasma ( double  rhoe,
double  Te,
double  Up 
)

Enable plasma model for positive ion extraction problem.

Enable plasma model with background electron charge density of rhoe and electron temperature Te. The plasma potential is set to Up.

void EpotProblem::set_solver ( Solver s)

Set solver to be used for the problem.

void EpotProblem::solve ( ScalarField epot,
const ScalarField scharge 
) const

Solve the problem.

The epot field is used as an initial guess for the solver. The space charge density field scharge is added to the problem vector before solving. The solution is returned in epot.


The documentation for this class was generated from the following file: