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
particles.hpp
Go to the documentation of this file.
1 
5 /* Copyright (c) 2005-2012,2015 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 PARTICLES_HPP
44 #define PARTICLES_HPP 1
45 
46 
47 #include <vector>
48 #include <string>
49 #include <string.h>
50 #include <gsl/gsl_errno.h>
51 #include "geometry.hpp"
52 #include "meshscalarfield.hpp"
53 #include "vectorfield.hpp"
54 #include "vec3d.hpp"
55 #include "callback.hpp"
56 #include "constants.hpp"
57 
58 
59 /* Integer error value that is supposed to differ from internal GSL
60  * error values */
61 #define IBSIMU_DERIV_ERROR 201
62 
63 
72  PARTICLE_OK = 0,
73  PARTICLE_OUT,
74  PARTICLE_COLL,
75  PARTICLE_BADDEF,
76  PARTICLE_TIME,
77  PARTICLE_NSTP
78 };
79 
80 
81 
82 /* ************************************************************************************* *
83  * Particle point classes *
84  * ************************************************************************************* */
85 
86 
92 {
93 
94 };
95 
96 
102 class ParticleP2D : public ParticlePBase
103 {
104  double _x[5];
106 public:
107 
111 
114  ParticleP2D( double t, double x, double vx, double y, double vy ) {
115  _x[0] = t; _x[1] = x; _x[2] = vx; _x[3] = y; _x[4] = vy;
116  }
117 
120  ParticleP2D( std::istream &s ) {
121  _x[0] = read_double( s );
122  _x[1] = read_double( s );
123  _x[2] = read_double( s );
124  _x[3] = read_double( s );
125  _x[4] = read_double( s );
126  }
127 
130  static geom_mode_e geom_mode() { return(MODE_2D); }
131 
134  static size_t dim() { return(2); }
135 
138  static size_t size() { return(5); }
139 
151  static int get_derivatives( double t, const double *x, double *dxdt, void *data );
152 
157  static int trajectory_intersections_at_plane( std::vector<ParticleP2D> &intsc,
158  int crd, double val,
159  const ParticleP2D &x1,
160  const ParticleP2D &x2,
161  int extrapolate = 0 );
162 
167  static const std::string IQ_unit() { return( "A/m" ); }
168 
171  void clear() { memset( (void *)_x, 0, 5*sizeof(double) ); }
172 
175  Vec3D location() const { return( Vec3D( _x[1], _x[3], 0.0 ) ); }
176 
179  Vec3D velocity() const { return( Vec3D( _x[2], _x[4], 0.0 ) ); }
180 
183  double speed() { return( sqrt(_x[2]*_x[2] + _x[4]*_x[4]) ); }
184 
187  double &operator[]( int i ) { return( _x[i] ); }
188 
191  const double &operator[]( int i ) const { return( _x[i] ); }
192 
195  double &operator()( int i ) { return( _x[i] ); }
196 
199  const double &operator()( int i ) const { return( _x[i] ); }
200 
201  ParticleP2D operator+( const ParticleP2D &pp ) const {
202  ParticleP2D res;
203  res[0] = _x[0] + pp[0];
204  res[1] = _x[1] + pp[1];
205  res[2] = _x[2] + pp[2];
206  res[3] = _x[3] + pp[3];
207  res[4] = _x[4] + pp[4];
208  return( res );
209  }
210 
211  ParticleP2D operator-( const ParticleP2D &pp ) const {
212  ParticleP2D res;
213  res[0] = _x[0] - pp[0];
214  res[1] = _x[1] - pp[1];
215  res[2] = _x[2] - pp[2];
216  res[3] = _x[3] - pp[3];
217  res[4] = _x[4] - pp[4];
218  return( res );
219  }
220 
221  ParticleP2D operator*( double x ) const {
222  ParticleP2D res;
223  res[0] = _x[0]*x;
224  res[1] = _x[1]*x;
225  res[2] = _x[2]*x;
226  res[3] = _x[3]*x;
227  res[4] = _x[4]*x;
228  return( res );
229  }
230 
233  void save( std::ostream &s ) const {
234  write_double( s, _x[0] );
235  write_double( s, _x[1] );
236  write_double( s, _x[2] );
237  write_double( s, _x[3] );
238  write_double( s, _x[4] );
239  }
240 
241  friend ParticleP2D operator*( double x, const ParticleP2D &pp );
242 };
243 
244 
245 inline std::ostream &operator<<( std::ostream &os, const ParticleP2D &pp )
246 {
247  os << "("
248  << std::setw(12) << pp(0) << ", "
249  << std::setw(12) << pp(1) << ", "
250  << std::setw(12) << pp(2) << ", "
251  << std::setw(12) << pp(3) << ", "
252  << std::setw(12) << pp(4) << ")";
253  return( os );
254 }
255 
256 
257 inline ParticleP2D operator*( double x, const ParticleP2D &pp )
258 {
259  ParticleP2D res;
260  res[0] = pp[0]*x;
261  res[1] = pp[1]*x;
262  res[2] = pp[2]*x;
263  res[3] = pp[3]*x;
264  res[4] = pp[4]*x;
265  return( res );
266 }
267 
268 
275 {
276  double _x[6];
278 public:
279 
283 
286  ParticlePCyl( double t, double x, double vx, double r, double vr, double w ) {
287  _x[0] = t; _x[1] = x; _x[2] = vx; _x[3] = r; _x[4] = vr; _x[5] = w;
288  }
289 
292  ParticlePCyl( std::istream &s ) {
293  _x[0] = read_double( s );
294  _x[1] = read_double( s );
295  _x[2] = read_double( s );
296  _x[3] = read_double( s );
297  _x[4] = read_double( s );
298  _x[5] = read_double( s );
299  }
300 
303  static geom_mode_e geom_mode() { return(MODE_CYL); }
304 
307  static size_t dim() { return(2); }
308 
311  static size_t size() { return(6); }
312 
329  static int get_derivatives( double t, const double *x, double *dxdt, void *data );
330 
335  static int trajectory_intersections_at_plane( std::vector<ParticlePCyl> &intsc,
336  int crd, double val,
337  const ParticlePCyl &x1,
338  const ParticlePCyl &x2,
339  int extrapolate = 0 );
340 
345  static const std::string IQ_unit() { return( "A" ); }
346 
349  void clear() { memset( (void *)_x, 0, 6*sizeof(double) ); }
350 
353  Vec3D location() const { return( Vec3D( _x[1], _x[3], 0.0 ) ); }
354 
357  Vec3D velocity() const { return( Vec3D( _x[2], _x[4], _x[5]*_x[3] ) ); }
358 
361  double speed() { return( sqrt(_x[2]*_x[2] + _x[4]*_x[4] + _x[3]*_x[3]*_x[5]*_x[5]) ); }
362 
365  double &operator[]( int i ) { return( _x[i] ); }
366 
369  const double &operator[]( int i ) const { return( _x[i] ); }
370 
373  double &operator()( int i ) { return( _x[i] ); }
374 
377  const double &operator()( int i ) const { return( _x[i] ); }
378 
379  ParticlePCyl operator+( const ParticlePCyl &pp ) const {
380  ParticlePCyl res;
381  res[0] = _x[0] + pp[0];
382  res[1] = _x[1] + pp[1];
383  res[2] = _x[2] + pp[2];
384  res[3] = _x[3] + pp[3];
385  res[4] = _x[4] + pp[4];
386  res[5] = _x[5] + pp[5];
387  return( res );
388  }
389 
390  ParticlePCyl operator-( const ParticlePCyl &pp ) const {
391  ParticlePCyl res;
392  res[0] = _x[0] - pp[0];
393  res[1] = _x[1] - pp[1];
394  res[2] = _x[2] - pp[2];
395  res[3] = _x[3] - pp[3];
396  res[4] = _x[4] - pp[4];
397  res[5] = _x[5] - pp[5];
398  return( res );
399  }
400 
401  ParticlePCyl operator*( double x ) const {
402  ParticlePCyl res;
403  res[0] = _x[0]*x;
404  res[1] = _x[1]*x;
405  res[2] = _x[2]*x;
406  res[3] = _x[3]*x;
407  res[4] = _x[4]*x;
408  res[5] = _x[5]*x;
409  return( res );
410  }
411 
414  void save( std::ostream &s ) const {
415  write_double( s, _x[0] );
416  write_double( s, _x[1] );
417  write_double( s, _x[2] );
418  write_double( s, _x[3] );
419  write_double( s, _x[4] );
420  write_double( s, _x[5] );
421  }
422 
423  friend ParticlePCyl operator*( double x, const ParticlePCyl &pp );
424 };
425 
426 
427 inline std::ostream &operator<<( std::ostream &os, const ParticlePCyl &pp )
428 {
429  os << "("
430  << std::setw(12) << pp(0) << ", "
431  << std::setw(12) << pp(1) << ", "
432  << std::setw(12) << pp(2) << ", "
433  << std::setw(12) << pp(3) << ", "
434  << std::setw(12) << pp(4) << ", "
435  << std::setw(12) << pp(5) << ")";
436  return( os );
437 }
438 
439 
440 inline ParticlePCyl operator*( double x, const ParticlePCyl &pp )
441 {
442  ParticlePCyl res;
443  res[0] = pp[0]*x;
444  res[1] = pp[1]*x;
445  res[2] = pp[2]*x;
446  res[3] = pp[3]*x;
447  res[4] = pp[4]*x;
448  res[5] = pp[5]*x;
449  return( res );
450 }
451 
452 
458 class ParticleP3D : public ParticlePBase
459 {
460  double _x[7];
462 public:
463 
467 
470  ParticleP3D( double t, double x, double vx, double y, double vy, double z, double vz ) {
471  _x[0] = t; _x[1] = x; _x[2] = vx; _x[3] = y; _x[4] = vy; _x[5] = z; _x[6] = vz;
472  }
473 
476  ParticleP3D( std::istream &s ) {
477  _x[0] = read_double( s );
478  _x[1] = read_double( s );
479  _x[2] = read_double( s );
480  _x[3] = read_double( s );
481  _x[4] = read_double( s );
482  _x[5] = read_double( s );
483  _x[6] = read_double( s );
484  }
485 
488  static geom_mode_e geom_mode() { return(MODE_3D); }
489 
492  static size_t dim() { return(3); }
493 
496  static size_t size() { return(7); }
497 
511  static int get_derivatives( double t, const double *x, double *dxdt, void *data );
512 
517  static int trajectory_intersections_at_plane( std::vector<ParticleP3D> &intsc,
518  int crd, double val,
519  const ParticleP3D &x1,
520  const ParticleP3D &x2,
521  int extrapolate = 0 );
522 
527  static const std::string IQ_unit() { return( "A" ); }
528 
531  void clear() { memset( (void *)_x, 0, 7*sizeof(double) ); }
532 
535  Vec3D location() const { return( Vec3D( _x[1], _x[3], _x[5] ) ); }
536 
539  Vec3D velocity() const { return( Vec3D( _x[2], _x[4], _x[6] ) ); }
540 
543  double speed() { return( sqrt(_x[2]*_x[2] + _x[4]*_x[4] + _x[6]*_x[6]) ); }
544 
547  double &operator[]( int i ) { return( _x[i] ); }
548 
551  const double &operator[]( int i ) const { return( _x[i] ); }
552 
555  double &operator()( int i ) { return( _x[i] ); }
556 
559  const double &operator()( int i ) const { return( _x[i] ); }
560 
561  ParticleP3D operator+( const ParticleP3D &pp ) const {
562  ParticleP3D res;
563  res[0] = _x[0] + pp[0];
564  res[1] = _x[1] + pp[1];
565  res[2] = _x[2] + pp[2];
566  res[3] = _x[3] + pp[3];
567  res[4] = _x[4] + pp[4];
568  res[5] = _x[5] + pp[5];
569  res[6] = _x[6] + pp[6];
570  return( res );
571  }
572 
573  ParticleP3D operator-( const ParticleP3D &pp ) const {
574  ParticleP3D res;
575  res[0] = _x[0] - pp[0];
576  res[1] = _x[1] - pp[1];
577  res[2] = _x[2] - pp[2];
578  res[3] = _x[3] - pp[3];
579  res[4] = _x[4] - pp[4];
580  res[5] = _x[5] - pp[5];
581  res[6] = _x[6] - pp[6];
582  return( res );
583  }
584 
585  ParticleP3D operator*( double x ) const {
586  ParticleP3D res;
587  res[0] = _x[0]*x;
588  res[1] = _x[1]*x;
589  res[2] = _x[2]*x;
590  res[3] = _x[3]*x;
591  res[4] = _x[4]*x;
592  res[5] = _x[5]*x;
593  res[6] = _x[6]*x;
594  return( res );
595  }
596 
599  void save( std::ostream &s ) const {
600  write_double( s, _x[0] );
601  write_double( s, _x[1] );
602  write_double( s, _x[2] );
603  write_double( s, _x[3] );
604  write_double( s, _x[4] );
605  write_double( s, _x[5] );
606  write_double( s, _x[6] );
607  }
608 
609  friend ParticleP3D operator*( double x, const ParticleP3D &pp );
610 };
611 
612 
613 inline std::ostream &operator<<( std::ostream &os, const ParticleP3D &pp )
614 {
615  os << "("
616  << std::setw(12) << pp(0) << ", "
617  << std::setw(12) << pp(1) << ", "
618  << std::setw(12) << pp(2) << ", "
619  << std::setw(12) << pp(3) << ", "
620  << std::setw(12) << pp(4) << ", "
621  << std::setw(12) << pp(5) << ", "
622  << std::setw(12) << pp(6) << ")";
623  return( os );
624 }
625 
626 
627 inline ParticleP3D operator*( double x, const ParticleP3D &pp )
628 {
629  ParticleP3D res;
630  res[0] = pp[0]*x;
631  res[1] = pp[1]*x;
632  res[2] = pp[2]*x;
633  res[3] = pp[3]*x;
634  res[4] = pp[4]*x;
635  res[5] = pp[5]*x;
636  res[6] = pp[6]*x;
637  return( res );
638 }
639 
640 
641 
642 
643 /* ************************************************************************************** *
644  * Particle classes *
645  * ************************************************************************************** */
646 
647 
653 {
654 protected:
655 
657  double _IQ;
668  double _q;
669  double _m;
671  ParticleBase( double IQ, double q, double m )
672  : _status(PARTICLE_OK), _q(q) {
673  _m = fabs(m);
674  if( _q < 0 )
675  _IQ = -fabs(IQ);
676  else
677  _IQ = fabs(IQ);
678  }
679 
682  ParticleBase( std::istream &s ) {
684  _IQ = read_double( s );
685  _q = read_double( s );
686  _m = read_double( s );
687  }
688 
689  ~ParticleBase() {}
690 
691 public:
692 
696 
699  void set_status( particle_status_e status ) { _status = status; }
700 
706  double IQ() const { return( _IQ ); }
707 
710  double q() const { return( _q ); }
711 
714  double m() const { return( _m ); }
715 
718  double qm() const { return( _q/_m ); }
719 
722  void save( std::ostream &s ) const {
723  write_int32( s, _status );
724  write_double( s, _IQ );
725  write_double( s, _q );
726  write_double( s, _m );
727  }
728 };
729 
730 
739 template<class PP> class Particle : public ParticleBase
740 {
741  std::vector<PP> _trajectory;
742  PP _x;
744 public:
745 
753  Particle( double IQ, double q, double m, const PP &x )
754  : ParticleBase(IQ,q,m), _x(x) {}
755 
758  Particle( std::istream &s )
759  : ParticleBase( s ) {
760 
761  uint32_t N = read_int32( s );
762  _trajectory.reserve( N );
763  for( uint32_t a = 0; a < N; a++ )
764  _trajectory.push_back( PP( s ) );
765  _x = PP( s );
766  }
767 
771 
774  double &operator()( int i ) { return( _x(i) ); }
775 
778  const double &operator()( int i ) const { return( _x(i) ); }
779 
782  double &operator[]( int i ) { return( _x(i) ); }
783 
786  const double &operator[]( int i ) const { return( _x(i) ); }
787 
790  Vec3D location() const { return( _x.location() ); }
791 
794  Vec3D velocity() const { return( _x.velocity() ); }
795 
798  PP &x() { return( _x ); }
799 
802  const PP &x() const { return( _x ); }
803 
806  PP &traj( int i ) { return( _trajectory[i] ); }
807 
810  const PP &traj( int i ) const { return( _trajectory[i] ); }
811 
814  size_t traj_size( void ) const { return( _trajectory.size() ); }
815 
818  void add_trajectory_point( const PP &x ) { _trajectory.push_back( x ); }
819 
822  void copy_trajectory( const std::vector<PP> &traj ) { _trajectory = traj; }
823 
826  void clear_trajectory( void ) { _trajectory.clear(); }
827 
834  void reset_trajectory( void ) {
835  _status = PARTICLE_OK;
836  if( _trajectory.size() != 0 ) {
837  _x = _trajectory[0];
838  _trajectory.clear();
839  }
840  }
841 
844  void save( std::ostream &s ) const {
845  ParticleBase::save( s );
846  write_int32( s, _trajectory.size() );
847  for( uint32_t a = 0; a < _trajectory.size(); a++ )
848  _trajectory[a].save( s );
849  _x.save( s );
850  }
851 
854  void debug_print( std::ostream &os ) const {
855  size_t a;
856  os << "**Particle\n";
857  switch( _status ) {
858  case PARTICLE_OK:
859  os << "stat = PARTICLE_OK\n";
860  break;
861  case PARTICLE_OUT:
862  os << "stat = PARTICLE_OUT\n";
863  break;
864  case PARTICLE_COLL:
865  os << "stat = PARTICLE_COLL\n";
866  break;
867  case PARTICLE_BADDEF:
868  os << "stat = PARTICLE_BADDEF\n";
869  break;
870  case PARTICLE_TIME:
871  os << "stat = PARTICLE_TIME\n";
872  break;
873  case PARTICLE_NSTP:
874  os << "stat = PARTICLE_NSTP\n";
875  break;
876  }
877  os << "IQ = " << _IQ << "\n";
878  os << "q = " << _q << "\n";
879  os << "m = " << _m << "\n";
880  os << "x = " << _x << "\n";
881  os << "Trajectory:\n";
882  for( a = 0; a < _trajectory.size(); a++ )
883  os << "x[" << a << "] = " << _trajectory[a] << "\n";
884 
885  /*
886  std::cout << "Trajectory:\n";
887  for( a = 0; a < _trajectory.size(); a++ ) {
888  std::cout << "x[" << a << "] = (";
889  uint32_t b;
890  const PP &tp = _trajectory[a];
891  if( tp.size() > 0 ) {
892  for( b = 0; b < tp.size()-1; b++ )
893  std::cout << tp[b] << ", ";
894  std::cout << tp[b] << ")\n";
895  } else {
896  std::cout << ")\n";
897  }
898  }
899  */
900  }
901 };
902 
903 
909 
910 
916 
917 
923 
924 
925 
932  const Geometry *_geom;
933  double _qm;
937  ParticleIteratorData( MeshScalarField *scharge, const VectorField *efield,
938  const VectorField *bfield, const Geometry *geom )
939  : _scharge(scharge), _efield(efield), _bfield(bfield),
940  _geom(geom), _qm(0.0), _bsup_cb(0), _relativistic(false) {}
941 
945  _bsup_cb = bsup_cb;
946  }
947 
950  void set_relativistic( bool enable ) {
951  _relativistic = enable;
952  }
953 
954 };
955 
956 
957 #endif
958 
General callback functors.
Definition: callback.hpp:61
Geometry defining class.
Definition: geometry.hpp:180
Scalar field class.
Definition: meshscalarfield.hpp:70
Particle base class
Definition: particles.hpp:653
double _q
Charge q [C].
Definition: particles.hpp:668
void set_status(particle_status_e status)
Set particle status.
Definition: particles.hpp:699
double q() const
Return particle charge (q) [C].
Definition: particles.hpp:710
double m() const
Return particle mass (m) [kg].
Definition: particles.hpp:714
double _m
Mass m [kg].
Definition: particles.hpp:669
ParticleBase(std::istream &s)
Constructor for loading particle from a file.
Definition: particles.hpp:682
double IQ() const
Return current or charge carried by trajectory or particle cloud [A/C].
Definition: particles.hpp:706
void save(std::ostream &s) const
Saves data to stream.
Definition: particles.hpp:722
particle_status_e _status
Status of particle.
Definition: particles.hpp:656
particle_status_e get_status()
Return particle status.
Definition: particles.hpp:695
double _IQ
Current or charge of particle.
Definition: particles.hpp:657
double qm() const
Return charge per mass ratio (q/m) [C/kg].
Definition: particles.hpp:718
Particle point class for 2D.
Definition: particles.hpp:103
void clear()
Clear point to zero.
Definition: particles.hpp:171
double & operator[](int i)
Operator for pointing to coordinate data.
Definition: particles.hpp:187
static int trajectory_intersections_at_plane(std::vector< ParticleP2D > &intsc, int crd, double val, const ParticleP2D &x1, const ParticleP2D &x2, int extrapolate=0)
Return the number of trajectory intersections with plane crd = val on the trajectory from x1 to x2....
Definition: particles.cpp:120
double speed()
Returns speed of particle.
Definition: particles.hpp:183
ParticleP2D()
Default constuctor.
Definition: particles.hpp:110
const double & operator[](int i) const
Operator for pointing to coordinate data.
Definition: particles.hpp:191
ParticleP2D(std::istream &s)
Constructor for loading particle point from a file.
Definition: particles.hpp:120
void save(std::ostream &s) const
Saves data to stream.
Definition: particles.hpp:233
static size_t size()
Returns number of coordinates used for particle point.
Definition: particles.hpp:138
Vec3D velocity() const
Returns the velocity of particle point in Vec3D.
Definition: particles.hpp:179
ParticleP2D(double t, double x, double vx, double y, double vy)
Constructor for 2D particle point.
Definition: particles.hpp:114
Vec3D location() const
Returns the location of particle point in Vec3D.
Definition: particles.hpp:175
const double & operator()(int i) const
Operator for pointing to coordinate data.
Definition: particles.hpp:199
double & operator()(int i)
Operator for pointing to coordinate data.
Definition: particles.hpp:195
static const std::string IQ_unit()
Return string representation for unit of current.
Definition: particles.hpp:167
static size_t dim()
Returns number of dimensions for geometry.
Definition: particles.hpp:134
static int get_derivatives(double t, const double *x, double *dxdt, void *data)
Returns time derivatives dxdt of coordinates at time t and coordinates x = (x,vx,y,...
Definition: particles.cpp:67
static geom_mode_e geom_mode()
Returns geometry mode.
Definition: particles.hpp:130
Particle point class for 3D.
Definition: particles.hpp:459
const double & operator()(int i) const
Operator for pointing to coordinate data.
Definition: particles.hpp:559
double & operator()(int i)
Operator for pointing to coordinate data.
Definition: particles.hpp:555
ParticleP3D(std::istream &s)
Constructor for loading particle point from a file.
Definition: particles.hpp:476
static size_t size()
Returns number of coordinates used for particle point.
Definition: particles.hpp:496
void save(std::ostream &s) const
Saves data to stream.
Definition: particles.hpp:599
Vec3D location() const
Returns the location of particle point in Vec3D.
Definition: particles.hpp:535
static geom_mode_e geom_mode()
Returns geometry mode.
Definition: particles.hpp:488
double & operator[](int i)
Operator for pointing to coordinate data.
Definition: particles.hpp:547
static int trajectory_intersections_at_plane(std::vector< ParticleP3D > &intsc, int crd, double val, const ParticleP3D &x1, const ParticleP3D &x2, int extrapolate=0)
Return the number of trajectory intersections with plane crd = val on the trajectory from x1 to x2....
Definition: particles.cpp:287
void clear()
Clear point to zero.
Definition: particles.hpp:531
static int get_derivatives(double t, const double *x, double *dxdt, void *data)
Returns time derivatives dxdt of coordinates at time t and coordinates x = (x,vx,y,...
Definition: particles.cpp:227
static const std::string IQ_unit()
Return string representation for unit of current.
Definition: particles.hpp:527
ParticleP3D(double t, double x, double vx, double y, double vy, double z, double vz)
Constructor for 3D particle point.
Definition: particles.hpp:470
const double & operator[](int i) const
Operator for pointing to coordinate data.
Definition: particles.hpp:551
static size_t dim()
Returns number of dimensions for geometry.
Definition: particles.hpp:492
double speed()
Returns speed of particle.
Definition: particles.hpp:543
Vec3D velocity() const
Returns the velocity of particle point in Vec3D.
Definition: particles.hpp:539
ParticleP3D()
Default constuctor.
Definition: particles.hpp:466
Particle point base class
Definition: particles.hpp:92
Particle point class for cylindrical coordinates.
Definition: particles.hpp:275
const double & operator[](int i) const
Operator for pointing to coordinate data.
Definition: particles.hpp:369
static geom_mode_e geom_mode()
Returns geometry mode.
Definition: particles.hpp:303
Vec3D velocity() const
Returns the velocity of particle point in Vec3D.
Definition: particles.hpp:357
ParticlePCyl(std::istream &s)
Constructor for loading particle point from a file.
Definition: particles.hpp:292
static int get_derivatives(double t, const double *x, double *dxdt, void *data)
Returns time derivatives dxdt of coordinates at time t and coordinates x = (x,vx,r,...
Definition: particles.cpp:147
void clear()
Clear point to zero.
Definition: particles.hpp:349
static int trajectory_intersections_at_plane(std::vector< ParticlePCyl > &intsc, int crd, double val, const ParticlePCyl &x1, const ParticlePCyl &x2, int extrapolate=0)
Return the number of trajectory intersections with plane crd = val on the trajectory from x1 to x2....
Definition: particles.cpp:200
double speed()
Returns speed of particle.
Definition: particles.hpp:361
static const std::string IQ_unit()
Return string representation for unit of current.
Definition: particles.hpp:345
static size_t size()
Returns number of coordinates used for particle point.
Definition: particles.hpp:311
double & operator()(int i)
Operator for pointing to coordinate data.
Definition: particles.hpp:373
ParticlePCyl()
Default constuctor.
Definition: particles.hpp:282
const double & operator()(int i) const
Operator for pointing to coordinate data.
Definition: particles.hpp:377
double & operator[](int i)
Operator for pointing to coordinate data.
Definition: particles.hpp:365
static size_t dim()
Returns number of dimensions for geometry.
Definition: particles.hpp:307
Vec3D location() const
Returns the location of particle point in Vec3D.
Definition: particles.hpp:353
void save(std::ostream &s) const
Saves data to stream.
Definition: particles.hpp:414
ParticlePCyl(double t, double x, double vx, double r, double vr, double w)
Constructor for cylindrical particle point.
Definition: particles.hpp:286
Particle class in some geometry.
Definition: particles.hpp:740
void reset_trajectory(void)
Resets the particle trajectory.
Definition: particles.hpp:834
double & operator[](int i)
Operator for pointing to coordinate data.
Definition: particles.hpp:782
~Particle()
Destructor.
Definition: particles.hpp:770
const PP & x() const
Return const reference to coordinate data.
Definition: particles.hpp:802
void debug_print(std::ostream &os) const
Print debugging information to os.
Definition: particles.hpp:854
PP & x()
Return reference to coordinate data.
Definition: particles.hpp:798
void save(std::ostream &s) const
Saves data to stream.
Definition: particles.hpp:844
Particle(std::istream &s)
Constructor for loading particle from a file.
Definition: particles.hpp:758
PP & traj(int i)
Return reference to trajectory data.
Definition: particles.hpp:806
size_t traj_size(void) const
Return number of trajectory points of particle.
Definition: particles.hpp:814
Vec3D location() const
Returns the location of particle in Vec3D.
Definition: particles.hpp:790
const double & operator[](int i) const
Operator for pointing to coordinate data.
Definition: particles.hpp:786
void clear_trajectory(void)
Clears the particle trajectory.
Definition: particles.hpp:826
const double & operator()(int i) const
Operator for pointing to coordinate data.
Definition: particles.hpp:778
const PP & traj(int i) const
Return const reference to trajectory data.
Definition: particles.hpp:810
double & operator()(int i)
Operator for pointing to coordinate data.
Definition: particles.hpp:774
Vec3D velocity() const
Returns the velocity of particle in Vec3D.
Definition: particles.hpp:794
void add_trajectory_point(const PP &x)
Add trajectory point to the end of the trajectory.
Definition: particles.hpp:818
void copy_trajectory(const std::vector< PP > &traj)
Define trajectory by copying.
Definition: particles.hpp:822
Particle(double IQ, double q, double m, const PP &x)
Constructor for particle.
Definition: particles.hpp:753
Three dimensional vector.
Definition: vec3d.hpp:58
Vector field.
Definition: vectorfield.hpp:56
Physical constants.
void write_double(std::ostream &s, double value)
Write double value into stream os.
Definition: file.cpp:88
void write_int32(std::ostream &s, int32_t value)
Write int32_t value into stream os.
Definition: file.cpp:70
double read_double(std::istream &s)
Readd double from stream is.
Definition: file.cpp:157
int32_t read_int32(std::istream &s)
Read int32_t from stream is.
Definition: file.cpp:135
Geometry definition
Mesh based scalar fields.
Particle< ParticlePCyl > ParticleCyl
Particle class in Cylindrical symmetry.
Definition: particles.hpp:915
Particle< ParticleP3D > Particle3D
Particle class in 3D.
Definition: particles.hpp:922
particle_status_e
Particle status enum.
Definition: particles.hpp:71
Particle< ParticleP2D > Particle2D
Particle class in 2D.
Definition: particles.hpp:908
Temporary data bundle for particle iterators.
Definition: particles.hpp:928
const VectorField * _bfield
Magnetic field or NULL.
Definition: particles.hpp:931
const VectorField * _efield
Electric field or NULL.
Definition: particles.hpp:930
const CallbackFunctorD_V * _bsup_cb
B-field plasma suppression callback.
Definition: particles.hpp:934
double _qm
Precalculated q/m.
Definition: particles.hpp:933
void set_relativistic(bool enable)
Set relativistic particle iteration.
Definition: particles.hpp:950
bool _relativistic
Do relativistic particle calc?
Definition: particles.hpp:935
MeshScalarField * _scharge
Space charge field or NULL.
Definition: particles.hpp:929
void set_bfield_suppression_callback(const CallbackFunctorD_V *bsup_cb)
Set B-field potential dependent suppression callback.
Definition: particles.hpp:944
const Geometry * _geom
Geometry.
Definition: particles.hpp:932
geom_mode_e
Geometry mode enum.
Definition: types.hpp:59
@ MODE_3D
3D geometry
Definition: types.hpp:63
@ MODE_CYL
Cylindrically symmetric geometry.
Definition: types.hpp:62
@ MODE_2D
2D geometry
Definition: types.hpp:61
Three dimensional vectors.
Vec4D operator*(double x, const Vec4D &vec)
Definition: vec4d.hpp:287
Vector field base.


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