Navigation

Main Page
Download
Support
Installation
Tutorial
Examples
Reference Manual
   Version 1.0.5new_solver
      Class Index
      File List
   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 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 
120  PLASMA_NONE = 0,
121  PLASMA_PEXP_INITIAL,
122  PLASMA_NSIMP_INITIAL,
123  PLASMA_PEXP,
124  PLASMA_NSIMP
125 };
126 
127 
128 #define EPOT_SOLVER_BXMIN 1
129 #define EPOT_SOLVER_BXMAX 2
130 #define EPOT_SOLVER_BYMIN 4
131 #define EPOT_SOLVER_BYMAX 8
132 #define EPOT_SOLVER_BZMIN 16
133 #define EPOT_SOLVER_BZMAX 32
134 
135 
136 #define PLASMA_INITIAL PLASMA_PEXP_INITIAL
137 
207 class EpotSolver {
208 
209 protected:
210 
215  double _rhoe;
216  double _Te;
217  double _Up;
219  std::vector<double> _rhoi;
221  std::vector<double> _Ei;
224  double _force_pot;
229  double _plA;
232  double _plB;
235  double _plC;
238  std::vector<double> _plD;
240  std::vector<double> _plE;
251  void pexp_newton( double &rhs, double &drhs, double epot ) const;
252 
260  void nsimp_newton( double &rhs, double &drhs, double epot ) const;
261 
270  uint8_t boundary_index( uint32_t i ) const;
271 
280  uint8_t boundary_index( uint32_t i, uint32_t j ) const;
281 
290  uint8_t boundary_index( uint32_t i, uint32_t j, uint32_t k ) const;
291 
300  uint8_t boundary_index_general( uint32_t i, uint32_t j, uint32_t k ) const;
301 
308  void preprocess( MeshScalarField &epot );
309 
315  void postprocess( void );
316 
319  virtual void reset_problem( void ) = 0;
320 
321  MeshScalarField *evaluate_scharge( const ScalarField &__scharge ) const;
322 
325  virtual void subsolve( MeshScalarField &epot, const MeshScalarField &scharge ) = 0;
326 
327 public:
328 
329 /* ************************************** *
330  * Constructors and destructor *
331  * ************************************** */
332 
335  EpotSolver( Geometry &geom );
336 
340  EpotSolver( const EpotSolver &epsolver, Geometry &geom );
341 
344  EpotSolver( Geometry &geom, std::istream &s );
345 
348  virtual ~EpotSolver() {}
349 
350 /* ************************************** *
351  * Problem constructing and solving *
352  * ************************************** */
353 
356  void set_parameters( const EpotSolver &epsolver );
357 
368  void set_forced_potential_volume( double force_pot,
369  CallbackFunctorB_V *force_pot_func );
370 
379  void set_forced_potential_volume( CallbackFunctorD_V *force_pot_func );
380 
386  void set_initial_plasma( double Up,
387  CallbackFunctorB_V *init_plasma_func );
388 
398  void set_pexp_plasma( double rhoe, double Te, double Up );
399 
405  void set_nsimp_initial_plasma( CallbackFunctorB_V *init_plasma_func );
406 
423  void set_nsimp_plasma( double rhop, double Ep,
424  std::vector<double> rhoi, std::vector<double> Ei );
425 
433  void solve( MeshScalarField &epot, const ScalarField &scharge );
434 
435 /* ************************************** *
436  * Solver interface *
437  * ************************************** */
438 
441  bool linear( void ) const;
442 
443 /* ************************************** *
444  * Misc *
445  * ************************************** */
446 
449  const Geometry &geometry( void ) const;
450 
453  virtual void debug_print( std::ostream &os ) const = 0;
454 
457  virtual void save( std::ostream &s ) const = 0;
458 };
459 
460 
461 #endif
462 
463 
464 
465 
466 
467 
468 
469 
470 
471 
472 
473 
474 
475 
476 
477 
478 
479 
480 
481 
plasma_mode_e _plasma
Plasma simulation mode.
Definition: epot_solver.hpp:213
virtual bool operator()(const Vec3D &x) const
Suppression function.
Definition: epot_solver.hpp:78
virtual void reset_problem(void)=0
Reset solver/problem settings.
Base for solvers.
Geometry definition
virtual ~EpotSolver()
Destructor.
Definition: epot_solver.hpp:348
void postprocess(void)
Do postprocessing action after solving.
Definition: epot_solver.cpp:317
CallbackFunctorB_V * _init_plasma_func
Initial plasma region function.
Definition: epot_solver.hpp:227
void pexp_newton(double &rhs, double &drhs, double epot) const
Return non-linear right-hand-side and it&#39;s derivative for vacuum node in positive ion plasma...
Definition: epot_solver.cpp:177
CallbackFunctorB_V * _force_pot_func
Force region potential function.
Definition: epot_solver.hpp:225
void preprocess(MeshScalarField &epot)
Do preprocessing action before solving.
Definition: epot_solver.cpp:216
void nsimp_newton(double &rhs, double &drhs, double epot) const
Return non-linear right-hand-side and it&#39;s derivative for vacuum node in negative ion plasma...
Definition: epot_solver.cpp:184
virtual void save(std::ostream &s) const =0
Saves problem data to stream.
Geometry & _geom
Geometry reference.
Definition: epot_solver.hpp:211
bool linear(void) const
Return true if problem is linear.
Definition: epot_solver.cpp:401
InitialPlasma(coordinate_axis_e axis, double val)
Constructor setting initial plasma.
Definition: epot_solver.hpp:69
Scalar field class.
Definition: meshscalarfield.hpp:70
double _plA
Plasma parameter. For positive ion extraction: rho_th * h^2 / epsilon_0, for negative ion extraction:...
Definition: epot_solver.hpp:229
Y axis.
Definition: types.hpp:172
double _Up
Plasma potential, &gt; 0.
Definition: epot_solver.hpp:217
uint8_t boundary_index(uint32_t i) const
Return bitmask indicating to which boundaries the node belongs to.
Definition: epot_solver.cpp:419
std::vector< double > _Ei
Energy for positive ions, first fast protons, then thermal ions.
Definition: epot_solver.hpp:221
Geometry defining class.
Definition: geometry.hpp:179
void set_nsimp_initial_plasma(CallbackFunctorB_V *init_plasma_func)
Define initial plasma boundary location to negative ion extraction problem.
Definition: epot_solver.cpp:144
Class for constructing the linear/nonlinear problem for the solver.
Definition: epot_solver.hpp:207
Definition: callback.hpp:61
CallbackFunctorD_V * _force_pot_func2
Force region potential function.
Definition: epot_solver.hpp:226
Initial plasma volume definition.
Definition: epot_solver.hpp:57
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:464
std::vector< double > _rhoi
Charge density for positive ions, first fast protons, then thermal ions.
Definition: epot_solver.hpp:219
double _plC
Plasma parameter for positive ion extraction. Up/Te.
Definition: epot_solver.hpp:235
double _plB
Plasma parameter. For positive ion extraction: 1/Te, for negative ion extraction: E_f...
Definition: epot_solver.hpp:232
R axis.
Definition: types.hpp:173
~InitialPlasma()
Destructor.
Definition: epot_solver.hpp:74
Definition: callback.hpp:75
std::vector< double > _plE
Plasma parameter for negative ion extraction. 1/Ti.
Definition: epot_solver.hpp:240
EpotSolver(Geometry &geom)
Constructor for solver from geom.
Definition: epot_solver.cpp:57
General callback functors.
coordinate_axis_e
Coordinate axis identifier.
Definition: types.hpp:170
void set_parameters(const EpotSolver &epsolver)
Copy parameters from solver epsolver.
Definition: epot_solver.cpp:91
double _Te
Electron thermal energy, &gt; 0.
Definition: epot_solver.hpp:216
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:155
double _force_pot
Potential to be forced.
Definition: epot_solver.hpp:224
X axis.
Definition: types.hpp:171
void set_pexp_plasma(double rhoe, double Te, double Up)
Enable plasma model for positive ion extraction problem.
Definition: epot_solver.cpp:132
const Geometry & geometry(void) const
Get pointer to geometry.
Definition: epot_solver.cpp:558
void set_forced_potential_volume(double force_pot, CallbackFunctorB_V *force_pot_func)
Define forced potential volume.
Definition: epot_solver.cpp:106
Z axis.
Definition: types.hpp:174
virtual void subsolve(MeshScalarField &epot, const MeshScalarField &scharge)=0
Solve problem with given mesh based space charge.
Three dimensional vector.
Definition: vec3d.hpp:58
double _rhoe
Electron charge density (C/m3), &lt; 0.
Definition: epot_solver.hpp:215
plasma_mode_e
Plasma modes.
Definition: epot_solver.hpp:119
virtual void debug_print(std::ostream &os) const =0
Print debugging information to os.
Definition: epot_solver.cpp:564
void solve(MeshScalarField &epot, const ScalarField &scharge)
Solve the problem.
Definition: epot_solver.cpp:513
Scalar field.
Definition: scalarfield.hpp:55
void set_initial_plasma(double Up, CallbackFunctorB_V *init_plasma_func)
Define initial plasma to the problem.
Definition: epot_solver.cpp:120
Mesh based scalar fields.
std::vector< double > _plD
Plasma parameter for negative ion extraction. rho_th,i * h^2 / epsilon_0.
Definition: epot_solver.hpp:238


Reference manual for Ion Beam Simulator 1.0.5new_solver
Generated by Doxygen 1.8.5 on Tue May 19 2015 09:15:42.