Navigation

Main Page
Download
Support
Installation
Tutorial
Examples
Reference Manual
   Version 1.0.6dev
      Class Index
      File List
   Version 1.0.6
   Version 1.0.5new_solver
   Version 1.0.5dev
   Version 1.0.5b
   Version 1.0.4dev
   Version 1.0.4
Publications


Hosted by Get Ion Beam Simulator at SourceForge.net. Fast, secure and Free Open Source software downloads
epot_solver.hpp
Go to the documentation of this file.
1 
5 /* Copyright (c) 2005-2013,2017,2021 Taneli Kalvas. All rights reserved.
6  *
7  * You can redistribute this software and/or modify it under the terms
8  * of the GNU General Public License as published by the Free Software
9  * Foundation; either version 2 of the License, or (at your option)
10  * any later version.
11  *
12  * This library is distributed in the hope that it will be useful, but
13  * WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15  * General Public License for more details.
16  *
17  * You should have received a copy of the GNU General Public License
18  * along with this library (file "COPYING" included in the package);
19  * if not, write to the Free Software Foundation, Inc., 51 Franklin
20  * Street, Fifth Floor, Boston, MA 02110-1301 USA
21  *
22  * If you have questions about your rights to use or distribute this
23  * software, please contact Berkeley Lab's Technology Transfer
24  * Department at TTD@lbl.gov. Other questions, comments and bug
25  * reports should be sent directly to the author via email at
26  * taneli.kalvas@jyu.fi.
27  *
28  * NOTICE. This software was developed under partial funding from the
29  * U.S. Department of Energy. As such, the U.S. Government has been
30  * granted for itself and others acting on its behalf a paid-up,
31  * nonexclusive, irrevocable, worldwide license in the Software to
32  * reproduce, prepare derivative works, and perform publicly and
33  * display publicly. Beginning five (5) years after the date
34  * permission to assert copyright is obtained from the U.S. Department
35  * of Energy, and subject to any subsequent five (5) year renewals,
36  * the U.S. Government is granted for itself and others acting on its
37  * behalf a paid-up, nonexclusive, irrevocable, worldwide license in
38  * the Software to reproduce, prepare derivative works, distribute
39  * copies to the public, perform publicly and display publicly, and to
40  * permit others to do so.
41  */
42 
43 #ifndef EPOT_SOLVER_HPP
44 #define EPOT_SOLVER_HPP 1
45 
46 
47 #include <iostream>
48 #include <stdint.h>
49 #include "solver.hpp"
50 #include "callback.hpp"
51 #include "meshscalarfield.hpp"
52 #include "geometry.hpp"
53 
54 
58 
59  coordinate_axis_e _axis;
60  double _val;
61 
62 public:
63 
69  InitialPlasma( coordinate_axis_e axis, double val )
70  : _axis(axis), _val(val) {}
71 
75 
78  virtual bool operator()( const Vec3D &x ) const {
79  switch( _axis ) {
80  case AXIS_X:
81  if( x[0] < _val )
82  return( true );
83  else
84  return( false );
85  break;
86  case AXIS_Y:
87  case AXIS_R:
88  if( x[1] < _val )
89  return( true );
90  else
91  return( false );
92  break;
93  case AXIS_Z:
94  if( x[2] < _val )
95  return( true );
96  else
97  return( false );
98  break;
99  }
100 
101  // Never here
102  return( false );
103  }
104 };
105 
106 
122  PLASMA_NONE = 0,
123  PLASMA_PEXP_INITIAL,
124  PLASMA_NSIMP_INITIAL,
125  PLASMA_PEXP,
126  PLASMA_NSIMP,
127  PLASMA_SHIELD
128 };
129 
130 
131 #define EPOT_SOLVER_BXMIN 1
132 #define EPOT_SOLVER_BXMAX 2
133 #define EPOT_SOLVER_BYMIN 4
134 #define EPOT_SOLVER_BYMAX 8
135 #define EPOT_SOLVER_BZMIN 16
136 #define EPOT_SOLVER_BZMAX 32
137 
138 
139 #define PLASMA_INITIAL PLASMA_PEXP_INITIAL
140 
210 class EpotSolver {
211 
212 protected:
213 
218  double _rhoe;
219  double _Te;
220  double _Up;
222  std::vector<double> _rhoi;
224  std::vector<double> _Ei;
227  double _force_pot;
233  double _plA;
237  double _plB;
241  double _plC;
244  std::vector<double> _plD;
246  std::vector<double> _plE;
256  void shield_newton( double &rhs, double &drhs, double epot ) const;
257 
265  void pexp_newton( double &rhs, double &drhs, double epot ) const;
266 
274  void nsimp_newton( double &rhs, double &drhs, double epot ) const;
275 
284  uint8_t boundary_index( uint32_t i ) const;
285 
294  uint8_t boundary_index( uint32_t i, uint32_t j ) const;
295 
304  uint8_t boundary_index( uint32_t i, uint32_t j, uint32_t k ) const;
305 
314  uint8_t boundary_index_general( uint32_t i, uint32_t j, uint32_t k ) const;
315 
322  void preprocess( MeshScalarField &epot );
323 
329  void postprocess( void );
330 
333  virtual void reset_problem( void ) = 0;
334 
335  MeshScalarField *evaluate_scharge( const ScalarField &__scharge ) const;
336 
339  virtual void subsolve( MeshScalarField &epot, const MeshScalarField &scharge ) = 0;
340 
341 public:
342 
343 /* ************************************** *
344  * Constructors and destructor *
345  * ************************************** */
346 
349  EpotSolver( Geometry &geom );
350 
354  EpotSolver( const EpotSolver &epsolver, Geometry &geom );
355 
358  EpotSolver( Geometry &geom, std::istream &s );
359 
362  virtual ~EpotSolver() {}
363 
364 /* ************************************** *
365  * Problem constructing and solving *
366  * ************************************** */
367 
370  void set_parameters( const EpotSolver &epsolver );
371 
382  void set_forced_potential_volume( double force_pot,
383  CallbackFunctorB_V *force_pot_func );
384 
393  void set_forced_potential_volume( CallbackFunctorD_V *force_pot_func );
394 
400  void set_initial_plasma( double Up,
401  CallbackFunctorB_V *init_plasma_func );
402 
414  void set_plasma_calc_region( CallbackFunctorB_V *plasma_calc_func );
415 
425  void set_pexp_plasma( double rhoe, double Te, double Up );
426 
432  void set_nsimp_initial_plasma( CallbackFunctorB_V *init_plasma_func );
433 
454  void set_nsimp_plasma( double rhop, double Ep,
455  std::vector<double> rhoi, std::vector<double> Ei );
456 
470  void set_shield_plasma( double Tm, double Um );
471 
479  void solve( MeshScalarField &epot, const ScalarField &scharge );
480 
481 /* ************************************** *
482  * Solver interface *
483  * ************************************** */
484 
487  bool linear( void ) const;
488 
489 /* ************************************** *
490  * Misc *
491  * ************************************** */
492 
495  const Geometry &geometry( void ) const;
496 
499  virtual void debug_print( std::ostream &os ) const = 0;
500 
503  virtual void save( std::ostream &s ) const = 0;
504 };
505 
506 
507 #endif
508 
509 
510 
511 
512 
513 
514 
515 
516 
517 
518 
519 
520 
521 
522 
523 
524 
525 
526 
527 
General callback functors.
Definition: callback.hpp:75
Definition: callback.hpp:61
Class for constructing the linear/nonlinear problem for the solver.
Definition: epot_solver.hpp:210
CallbackFunctorB_V * _init_plasma_func
Initial plasma region function.
Definition: epot_solver.hpp:230
CallbackFunctorB_V * _force_pot_func
Force region potential function.
Definition: epot_solver.hpp:228
double _Te
Electron thermal energy, > 0.
Definition: epot_solver.hpp:219
uint8_t boundary_index(uint32_t i) const
Return bitmask indicating to which boundaries the node belongs to.
Definition: epot_solver.cpp:455
double _plA
Plasma parameter. For positive ion extraction: rho_th * h^2 / epsilon_0, for negative ion extraction:...
Definition: epot_solver.hpp:233
void postprocess(void)
Do postprocessing action after solving.
Definition: epot_solver.cpp:352
void set_nsimp_plasma(double rhop, double Ep, std::vector< double > rhoi, std::vector< double > Ei)
Enable plasma model for negative ion extraction problem.
Definition: epot_solver.cpp:164
double _Up
Plasma potential, > 0.
Definition: epot_solver.hpp:220
EpotSolver(Geometry &geom)
Constructor for solver from geom.
Definition: epot_solver.cpp:57
void set_nsimp_initial_plasma(CallbackFunctorB_V *init_plasma_func)
Define initial plasma boundary location to negative ion extraction problem.
Definition: epot_solver.cpp:153
virtual ~EpotSolver()
Destructor.
Definition: epot_solver.hpp:362
double _rhoe
Electron charge density (C/m3), < 0.
Definition: epot_solver.hpp:218
std::vector< double > _plD
Plasma parameter for negative ion extraction. rho_th,i * h^2 / epsilon_0.
Definition: epot_solver.hpp:244
std::vector< double > _plE
Plasma parameter for negative ion extraction. 1/Ti.
Definition: epot_solver.hpp:246
std::vector< double > _Ei
Energy for positive ions, first fast protons, then thermal ions.
Definition: epot_solver.hpp:224
double _plC
Plasma parameter for positive ion extraction. Up/Te.
Definition: epot_solver.hpp:241
double _force_pot
Potential to be forced.
Definition: epot_solver.hpp:227
virtual void reset_problem(void)=0
Reset solver/problem settings.
void pexp_newton(double &rhs, double &drhs, double epot) const
Return non-linear right-hand-side and it's derivative for vacuum node in positive ion plasma.
Definition: epot_solver.cpp:208
void nsimp_newton(double &rhs, double &drhs, double epot) const
Return non-linear right-hand-side and it's derivative for vacuum node in negative ion plasma.
Definition: epot_solver.cpp:215
void set_plasma_calc_region(CallbackFunctorB_V *plasma_calc_func)
Define plasma calculation region.
Definition: epot_solver.cpp:134
void set_initial_plasma(double Up, CallbackFunctorB_V *init_plasma_func)
Define initial plasma to the problem.
Definition: epot_solver.cpp:122
void set_pexp_plasma(double rhoe, double Te, double Up)
Enable plasma model for positive ion extraction problem.
Definition: epot_solver.cpp:141
uint8_t boundary_index_general(uint32_t i, uint32_t j, uint32_t k) const
Return bitmask indicating to which boundaries the node belongs to.
Definition: epot_solver.cpp:500
plasma_mode_e _plasma
Plasma simulation mode.
Definition: epot_solver.hpp:216
std::vector< double > _rhoi
Charge density for positive ions, first fast protons, then thermal ions.
Definition: epot_solver.hpp:222
void set_parameters(const EpotSolver &epsolver)
Copy parameters from solver epsolver.
Definition: epot_solver.cpp:92
CallbackFunctorB_V * _plasma_calc_func
Definition of plasma calculation region.
Definition: epot_solver.hpp:231
CallbackFunctorD_V * _force_pot_func2
Force region potential function.
Definition: epot_solver.hpp:229
void shield_newton(double &rhs, double &drhs, double epot) const
Return non-linear right-hand-side and it's derivative for vacuum node in shielding model plasma.
Definition: epot_solver.cpp:200
Geometry & _geom
Geometry reference.
Definition: epot_solver.hpp:214
double _plB
Plasma parameter. For positive ion extraction: 1/Te, for negative ion extraction: E_f,...
Definition: epot_solver.hpp:237
void preprocess(MeshScalarField &epot)
Do preprocessing action before solving.
Definition: epot_solver.cpp:247
void set_forced_potential_volume(double force_pot, CallbackFunctorB_V *force_pot_func)
Define forced potential volume.
Definition: epot_solver.cpp:108
virtual void subsolve(MeshScalarField &epot, const MeshScalarField &scharge)=0
Solve problem with given mesh based space charge.
Geometry defining class.
Definition: geometry.hpp:180
Initial plasma volume definition.
Definition: epot_solver.hpp:57
~InitialPlasma()
Destructor.
Definition: epot_solver.hpp:74
InitialPlasma(coordinate_axis_e axis, double val)
Constructor setting initial plasma.
Definition: epot_solver.hpp:69
virtual bool operator()(const Vec3D &x) const
Suppression function.
Definition: epot_solver.hpp:78
Scalar field class.
Definition: meshscalarfield.hpp:70
Scalar field.
Definition: scalarfield.hpp:55
Three dimensional vector.
Definition: vec3d.hpp:58
plasma_mode_e
Plasma modes.
Definition: epot_solver.hpp:121
Geometry definition
Mesh based scalar fields.
Base for solvers.
coordinate_axis_e
Coordinate axis identifier.
Definition: types.hpp:170
@ AXIS_R
R axis.
Definition: types.hpp:173
@ AXIS_X
X axis.
Definition: types.hpp:171
@ AXIS_Y
Y axis.
Definition: types.hpp:172
@ AXIS_Z
Z axis.
Definition: types.hpp:174


Reference manual for Ion Beam Simulator 1.0.6dev
Generated by Doxygen 1.9.1 on Thu Sep 11 2025 09:37:24.