Class for constructing the linear/nonlinear problem for the solver. More...
#include <epot_problem.hpp>
Classes | |
class | Node2DoF |
Class nodes to degrees of freedom mapping. | |
Public Member Functions | |
EpotProblem () | |
Default constructor. | |
EpotProblem (std::istream &s) | |
Constructor for loading problem from a file. | |
~EpotProblem () | |
Destructor for problem. | |
void | set_neumann_order (int32_t order) |
Set Neumann boundary order. | |
void | enable_smooth_solids (bool enable) |
Enable smooth solid edges. | |
void | set_forced_potential_volume (double force_pot, bool(*force_pot_func)(double, double, double)) |
Define forced potential volume. | |
void | set_initial_plasma (double Up, bool(*plasma_func)(double, double, double)) |
Define initial plasma to the problem. | |
void | set_pexp_plasma (double rhoe, double Te, double Up) |
Enable plasma model for positive ion extraction problem. | |
void | set_nsimp_initial_plasma (bool(*plasma_func)(double, double, double)) |
Define initial plasma boundary location to negative ion extraction problem. | |
void | set_nsimp_plasma (double rhop, double Ep, std::vector< double > rhoi, std::vector< double > Ei) |
Enable plasma model for negative ion extraction problem. | |
void | construct (const Geometry &g) |
Construct matrix form of the problem. | |
void | set_solver (Solver &s) |
Set solver to be used for the problem. | |
void | solve (ScalarField &epot, const ScalarField &scharge) const |
Solve the problem. | |
void | get_vecmat (const Matrix **A, const Vector **B) const |
Return const pointers to the matrix A and vector B of the linear problem. | |
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. | |
bool | linear (void) const |
Return true if problem is linear. | |
int | get_dof (void) const |
Get degrees of freedom. | |
void | debug_print (std::ostream &os) const |
Print debugging information to os. | |
void | save (std::ostream &s) const |
Saves problem data to stream. |
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
is
in 1D, which is discretized into
using finite differences. In 2D coordinates the discretized form is
and in 3D it is
In cylindrical coordinates the Poisson equation is
where because of cylindrical symmetry of the simulations. Therefore the discretized form becomes
where because the radius
. At the symmetry axis there is an exception because both
and
approach zero. By using Bernoulli-L'Hopital rule we can evaluate
which turns the Poisson equation to
on axis. Discretation of the equation gives us
Here so that the final form is
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. . The Neumann boundary condition can be defined as first order discretation
or second order discretation
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 with a thermal energy distribution with temperature
. The screening charge is therefore
where electron charge density at plasma potential is the same as the total positive beam space charge density for enabling plasma neutrality.
Default constructor.
EpotProblem::EpotProblem | ( | std::istream & | s | ) |
Constructor for loading problem from a file.
Destructor for problem.
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] |
void EpotProblem::get_vecmat | ( | const Matrix ** | A, |
const Vector ** | B | ||
) | const [virtual] |
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.