particles.hpp
Go to the documentation of this file.
1 
5 /* Copyright (c) 2005-2011 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 <gsl/gsl_errno.h>
50 #include "geometry.hpp"
51 #include "scalarfield.hpp"
52 #include "vectorfield.hpp"
53 #include "vec3d.hpp"
54 #include "callback.hpp"
55 
56 
57 /* Integer error value that is supposed to diffed from internal GSL error values */
58 #define IBSIMU_DERIV_ERROR 201
59 
60 
75 };
76 
77 
78 
79 /* ************************************************************************************* *
80  * Particle point classes *
81  * ************************************************************************************* */
82 
83 
89 {
90 
91 };
92 
93 
99 class ParticleP2D : public ParticlePBase
100 {
101  double _x[5];
103 public:
104 
108 
111  ParticleP2D( double t, double x, double vx, double y, double vy ) {
112  _x[0] = t; _x[1] = x; _x[2] = vx; _x[3] = y; _x[4] = vy;
113  }
114 
117  ParticleP2D( std::istream &s ) {
118  _x[0] = read_double( s );
119  _x[1] = read_double( s );
120  _x[2] = read_double( s );
121  _x[3] = read_double( s );
122  _x[4] = read_double( s );
123  }
124 
127  static geom_mode_e geom_mode() { return(MODE_2D); }
128 
131  static size_t dim() { return(2); }
132 
135  static size_t size() { return(5); }
136 
148  static int get_derivatives( double t, const double *x, double *dxdt, void *data );
149 
154  static int trajectory_intersections_at_plane( std::vector<ParticleP2D> &intsc,
155  int crd, double val,
156  const ParticleP2D &x1,
157  const ParticleP2D &x2,
158  int extrapolate = 0 );
159 
164  static const std::string IQ_unit() { return( "A/m" ); }
165 
168  Vec3D location() const { return( Vec3D( _x[1], _x[3], 0.0 ) ); }
169 
172  Vec3D velocity() const { return( Vec3D( _x[2], _x[4], 0.0 ) ); }
173 
176  double speed() { return( sqrt(_x[2]*_x[2] + _x[4]*_x[4]) ); }
177 
180  double &operator[]( int i ) { return( _x[i] ); }
181 
184  const double &operator[]( int i ) const { return( _x[i] ); }
185 
188  double &operator()( int i ) { return( _x[i] ); }
189 
192  const double &operator()( int i ) const { return( _x[i] ); }
193 
194  ParticleP2D operator+( const ParticleP2D &pp ) const {
195  ParticleP2D res;
196  res[0] = _x[0] + pp[0];
197  res[1] = _x[1] + pp[1];
198  res[2] = _x[2] + pp[2];
199  res[3] = _x[3] + pp[3];
200  res[4] = _x[4] + pp[4];
201  return( res );
202  }
203 
204  ParticleP2D operator-( const ParticleP2D &pp ) const {
205  ParticleP2D res;
206  res[0] = _x[0] - pp[0];
207  res[1] = _x[1] - pp[1];
208  res[2] = _x[2] - pp[2];
209  res[3] = _x[3] - pp[3];
210  res[4] = _x[4] - pp[4];
211  return( res );
212  }
213 
214  ParticleP2D operator*( double x ) const {
215  ParticleP2D res;
216  res[0] = _x[0]*x;
217  res[1] = _x[1]*x;
218  res[2] = _x[2]*x;
219  res[3] = _x[3]*x;
220  res[4] = _x[4]*x;
221  return( res );
222  }
223 
226  void save( std::ostream &s ) const {
227  write_double( s, _x[0] );
228  write_double( s, _x[1] );
229  write_double( s, _x[2] );
230  write_double( s, _x[3] );
231  write_double( s, _x[4] );
232  }
233 
234  friend ParticleP2D operator*( double x, const ParticleP2D &pp );
235 };
236 
237 
238 inline std::ostream &operator<<( std::ostream &os, const ParticleP2D &pp )
239 {
240  os << "("
241  << std::setw(12) << pp(0) << ", "
242  << std::setw(12) << pp(1) << ", "
243  << std::setw(12) << pp(2) << ", "
244  << std::setw(12) << pp(3) << ", "
245  << std::setw(12) << pp(4) << ")";
246  return( os );
247 }
248 
249 
250 inline ParticleP2D operator*( double x, const ParticleP2D &pp )
251 {
252  ParticleP2D res;
253  res[0] = pp[0]*x;
254  res[1] = pp[1]*x;
255  res[2] = pp[2]*x;
256  res[3] = pp[3]*x;
257  res[4] = pp[4]*x;
258  return( res );
259 }
260 
261 
268 {
269  double _x[6];
271 public:
272 
276 
279  ParticlePCyl( double t, double x, double vx, double r, double vr, double w ) {
280  _x[0] = t; _x[1] = x; _x[2] = vx; _x[3] = r; _x[4] = vr; _x[5] = w;
281  }
282 
285  ParticlePCyl( std::istream &s ) {
286  _x[0] = read_double( s );
287  _x[1] = read_double( s );
288  _x[2] = read_double( s );
289  _x[3] = read_double( s );
290  _x[4] = read_double( s );
291  _x[5] = read_double( s );
292  }
293 
296  static geom_mode_e geom_mode() { return(MODE_CYL); }
297 
300  static size_t dim() { return(2); }
301 
304  static size_t size() { return(6); }
305 
322  static int get_derivatives( double t, const double *x, double *dxdt, void *data );
323 
328  static int trajectory_intersections_at_plane( std::vector<ParticlePCyl> &intsc,
329  int crd, double val,
330  const ParticlePCyl &x1,
331  const ParticlePCyl &x2,
332  int extrapolate = 0 );
333 
338  static const std::string IQ_unit() { return( "A" ); }
339 
342  Vec3D location() const { return( Vec3D( _x[1], _x[3], 0.0 ) ); }
343 
346  Vec3D velocity() const { return( Vec3D( _x[2], _x[4], _x[5]*_x[3] ) ); }
347 
350  double speed() { return( sqrt(_x[2]*_x[2] + _x[4]*_x[4] + _x[3]*_x[3]*_x[5]*_x[5]) ); }
351 
354  double &operator[]( int i ) { return( _x[i] ); }
355 
358  const double &operator[]( int i ) const { return( _x[i] ); }
359 
362  double &operator()( int i ) { return( _x[i] ); }
363 
366  const double &operator()( int i ) const { return( _x[i] ); }
367 
368  ParticlePCyl operator+( const ParticlePCyl &pp ) const {
369  ParticlePCyl res;
370  res[0] = _x[0] + pp[0];
371  res[1] = _x[1] + pp[1];
372  res[2] = _x[2] + pp[2];
373  res[3] = _x[3] + pp[3];
374  res[4] = _x[4] + pp[4];
375  res[5] = _x[5] + pp[5];
376  return( res );
377  }
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*( double x ) const {
391  ParticlePCyl res;
392  res[0] = _x[0]*x;
393  res[1] = _x[1]*x;
394  res[2] = _x[2]*x;
395  res[3] = _x[3]*x;
396  res[4] = _x[4]*x;
397  res[5] = _x[5]*x;
398  return( res );
399  }
400 
403  void save( std::ostream &s ) const {
404  write_double( s, _x[0] );
405  write_double( s, _x[1] );
406  write_double( s, _x[2] );
407  write_double( s, _x[3] );
408  write_double( s, _x[4] );
409  write_double( s, _x[5] );
410  }
411 
412  friend ParticlePCyl operator*( double x, const ParticlePCyl &pp );
413 };
414 
415 
416 inline std::ostream &operator<<( std::ostream &os, const ParticlePCyl &pp )
417 {
418  os << "("
419  << std::setw(12) << pp(0) << ", "
420  << std::setw(12) << pp(1) << ", "
421  << std::setw(12) << pp(2) << ", "
422  << std::setw(12) << pp(3) << ", "
423  << std::setw(12) << pp(4) << ", "
424  << std::setw(12) << pp(5) << ")";
425  return( os );
426 }
427 
428 
429 inline ParticlePCyl operator*( double x, const ParticlePCyl &pp )
430 {
431  ParticlePCyl res;
432  res[0] = pp[0]*x;
433  res[1] = pp[1]*x;
434  res[2] = pp[2]*x;
435  res[3] = pp[3]*x;
436  res[4] = pp[4]*x;
437  res[5] = pp[5]*x;
438  return( res );
439 }
440 
441 
447 class ParticleP3D : public ParticlePBase
448 {
449  double _x[7];
451 public:
452 
456 
459  ParticleP3D( double t, double x, double vx, double y, double vy, double z, double vz ) {
460  _x[0] = t; _x[1] = x; _x[2] = vx; _x[3] = y; _x[4] = vy; _x[5] = z; _x[6] = vz;
461  }
462 
465  ParticleP3D( std::istream &s ) {
466  _x[0] = read_double( s );
467  _x[1] = read_double( s );
468  _x[2] = read_double( s );
469  _x[3] = read_double( s );
470  _x[4] = read_double( s );
471  _x[5] = read_double( s );
472  _x[6] = read_double( s );
473  }
474 
477  static geom_mode_e geom_mode() { return(MODE_3D); }
478 
481  static size_t dim() { return(3); }
482 
485  static size_t size() { return(7); }
486 
500  static int get_derivatives( double t, const double *x, double *dxdt, void *data );
501 
506  static int trajectory_intersections_at_plane( std::vector<ParticleP3D> &intsc,
507  int crd, double val,
508  const ParticleP3D &x1,
509  const ParticleP3D &x2,
510  int extrapolate = 0 );
511 
516  static const std::string IQ_unit() { return( "A" ); }
517 
520  Vec3D location() const { return( Vec3D( _x[1], _x[3], _x[5] ) ); }
521 
524  Vec3D velocity() const { return( Vec3D( _x[2], _x[4], _x[6] ) ); }
525 
528  double speed() { return( sqrt(_x[2]*_x[2] + _x[4]*_x[4] + _x[6]*_x[6]) ); }
529 
532  double &operator[]( int i ) { return( _x[i] ); }
533 
536  const double &operator[]( int i ) const { return( _x[i] ); }
537 
540  double &operator()( int i ) { return( _x[i] ); }
541 
544  const double &operator()( int i ) const { return( _x[i] ); }
545 
546  ParticleP3D operator+( const ParticleP3D &pp ) const {
547  ParticleP3D res;
548  res[0] = _x[0] + pp[0];
549  res[1] = _x[1] + pp[1];
550  res[2] = _x[2] + pp[2];
551  res[3] = _x[3] + pp[3];
552  res[4] = _x[4] + pp[4];
553  res[5] = _x[5] + pp[5];
554  res[6] = _x[6] + pp[6];
555  return( res );
556  }
557 
558  ParticleP3D operator-( const ParticleP3D &pp ) const {
559  ParticleP3D res;
560  res[0] = _x[0] - pp[0];
561  res[1] = _x[1] - pp[1];
562  res[2] = _x[2] - pp[2];
563  res[3] = _x[3] - pp[3];
564  res[4] = _x[4] - pp[4];
565  res[5] = _x[5] - pp[5];
566  res[6] = _x[6] - pp[6];
567  return( res );
568  }
569 
570  ParticleP3D operator*( double x ) const {
571  ParticleP3D res;
572  res[0] = _x[0]*x;
573  res[1] = _x[1]*x;
574  res[2] = _x[2]*x;
575  res[3] = _x[3]*x;
576  res[4] = _x[4]*x;
577  res[5] = _x[5]*x;
578  res[6] = _x[6]*x;
579  return( res );
580  }
581 
584  void save( std::ostream &s ) const {
585  write_double( s, _x[0] );
586  write_double( s, _x[1] );
587  write_double( s, _x[2] );
588  write_double( s, _x[3] );
589  write_double( s, _x[4] );
590  write_double( s, _x[5] );
591  write_double( s, _x[6] );
592  }
593 
594  friend ParticleP3D operator*( double x, const ParticleP3D &pp );
595 };
596 
597 
598 inline std::ostream &operator<<( std::ostream &os, const ParticleP3D &pp )
599 {
600  os << "("
601  << std::setw(12) << pp(0) << ", "
602  << std::setw(12) << pp(1) << ", "
603  << std::setw(12) << pp(2) << ", "
604  << std::setw(12) << pp(3) << ", "
605  << std::setw(12) << pp(4) << ", "
606  << std::setw(12) << pp(5) << ", "
607  << std::setw(12) << pp(6) << ")";
608  return( os );
609 }
610 
611 
612 inline ParticleP3D operator*( double x, const ParticleP3D &pp )
613 {
614  ParticleP3D res;
615  res[0] = pp[0]*x;
616  res[1] = pp[1]*x;
617  res[2] = pp[2]*x;
618  res[3] = pp[3]*x;
619  res[4] = pp[4]*x;
620  res[5] = pp[5]*x;
621  res[6] = pp[6]*x;
622  return( res );
623 }
624 
625 
626 
627 
628 /* ************************************************************************************** *
629  * Particle classes *
630  * ************************************************************************************** */
631 
632 
638 {
639 protected:
640 
642  double _IQ;
653  double _q;
654  double _m;
656  ParticleBase( double IQ, double q, double m )
657  : _status(PARTICLE_OK), _q(q) {
658  _m = fabs(m);
659  if( _q < 0 )
660  _IQ = -fabs(IQ);
661  else
662  _IQ = fabs(IQ);
663  }
664 
667  ParticleBase( std::istream &s ) {
669  _IQ = read_double( s );
670  _q = read_double( s );
671  _m = read_double( s );
672  }
673 
675 
676 public:
677 
681 
684  void set_status( particle_status_e status ) { _status = status; }
685 
691  double IQ() const { return( _IQ ); }
692 
695  double q() const { return( _q ); }
696 
699  double m() const { return( _m ); }
700 
703  double qm() const { return( _q/_m ); }
704 
707  void save( std::ostream &s ) const {
708  write_int32( s, _status );
709  write_double( s, _IQ );
710  write_double( s, _q );
711  write_double( s, _m );
712  }
713 };
714 
715 
724 template<class PP> class Particle : public ParticleBase
725 {
726  std::vector<PP> _trajectory;
727  PP _x;
729 public:
730 
739  Particle( double IQ, double q, double m, const PP &x )
740  : ParticleBase(IQ,q,m), _x(x) {}
741 
744  Particle( std::istream &s )
745  : ParticleBase( s ) {
746 
747  uint32_t N = read_int32( s );
748  _trajectory.reserve( N );
749  for( uint32_t a = 0; a < N; a++ )
750  _trajectory.push_back( PP( s ) );
751  _x = PP( s );
752  }
753 
757 
760  double &operator()( int i ) { return( _x(i) ); }
761 
764  const double &operator()( int i ) const { return( _x(i) ); }
765 
768  double &operator[]( int i ) { return( _x(i) ); }
769 
772  const double &operator[]( int i ) const { return( _x(i) ); }
773 
776  Vec3D location() const { return( _x.location() ); }
777 
780  Vec3D velocity() const { return( _x.velocity() ); }
781 
784  PP &x() { return( _x ); }
785 
788  const PP &x() const { return( _x ); }
789 
792  PP &traj( int i ) { return( _trajectory[i] ); }
793 
796  const PP &traj( int i ) const { return( _trajectory[i] ); }
797 
800  size_t traj_size( void ) const { return( _trajectory.size() ); }
801 
804  void add_trajectory_point( const PP &x ) { _trajectory.push_back( x ); }
805 
808  void copy_trajectory( const std::vector<PP> &traj ) { _trajectory = traj; }
809 
812  void clear_trajectory( void ) { _trajectory.clear(); }
813 
816  void save( std::ostream &s ) const {
817  ParticleBase::save( s );
818  write_int32( s, _trajectory.size() );
819  for( uint32_t a = 0; a < _trajectory.size(); a++ )
820  _trajectory[a].save( s );
821  _x.save( s );
822  }
823 
826  void debug_print( std::ostream &os ) const {
827  size_t a;
828  os << "**Particle\n";
829  switch( _status ) {
830  case PARTICLE_OK:
831  os << "stat = PARTICLE_OK\n";
832  break;
833  case PARTICLE_OUT:
834  os << "stat = PARTICLE_OUT\n";
835  break;
836  case PARTICLE_COLL:
837  os << "stat = PARTICLE_COLL\n";
838  break;
839  case PARTICLE_BADDEF:
840  os << "stat = PARTICLE_BADDEF\n";
841  break;
842  case PARTICLE_TIME:
843  os << "stat = PARTICLE_TIME\n";
844  break;
845  case PARTICLE_NSTP:
846  os << "stat = PARTICLE_NSTP\n";
847  break;
848  }
849  os << "IQ = " << _IQ << "\n";
850  os << "q = " << _q << "\n";
851  os << "m = " << _m << "\n";
852  os << "x = " << _x << "\n";
853  os << "Trajectory:\n";
854  for( a = 0; a < _trajectory.size(); a++ )
855  os << "x[" << a << "] = " << _trajectory[a] << "\n";
856 
857  /*
858  std::cout << "Trajectory:\n";
859  for( a = 0; a < _trajectory.size(); a++ ) {
860  std::cout << "x[" << a << "] = (";
861  uint32_t b;
862  const PP &tp = _trajectory[a];
863  if( tp.size() > 0 ) {
864  for( b = 0; b < tp.size()-1; b++ )
865  std::cout << tp[b] << ", ";
866  std::cout << tp[b] << ")\n";
867  } else {
868  std::cout << ")\n";
869  }
870  }
871  */
872  }
873 };
874 
875 
881 
882 
888 
889 
895 
896 
897 
904  const Geometry *_geom;
905  double _qm;
908  ParticleIteratorData( ScalarField *scharge, const VectorField *efield,
909  const VectorField *bfield, const Geometry *geom )
910  : _scharge(scharge), _efield(efield), _bfield(bfield),
911  _geom(geom), _qm(0.0), _bsup_cb(0) {}
912 
916  _bsup_cb = bsup_cb;
917  }
918 
919 };
920 
921 
922 
923 #endif
924 
Particle< ParticlePCyl > ParticleCyl
Particle class in Cylindrical symmetry.
Definition: particles.hpp:887
static const std::string IQ_unit()
Return string representation for unit of current.
Definition: particles.hpp:164
ParticlePCyl operator-(const ParticlePCyl &pp) const
Definition: particles.hpp:379
ParticlePCyl()
Default constuctor.
Definition: particles.hpp:275
Particle point class for cylindrical coordinates.
Definition: particles.hpp:267
const double & operator()(int i) const
Operator for pointing to coordinate data.
Definition: particles.hpp:366
Geometry definition
static size_t dim()
Returns number of dimensions for geometry.
Definition: particles.hpp:300
void write_int32(std::ostream &os, int32_t value)
Write int32_t value into stream os.
const VectorField * _bfield
Magnetic field or NULL.
Definition: particles.hpp:903
Scalar fields.
static geom_mode_e geom_mode()
Returns geometry mode.
Definition: particles.hpp:127
void save(std::ostream &s) const
Saves data to stream.
Definition: particles.hpp:816
static geom_mode_e geom_mode()
Returns geometry mode.
Definition: particles.hpp:296
Vec3D velocity() const
Returns the velocity of particle point in Vec3D.
Definition: particles.hpp:346
Abstract base class for vector field.
Definition: vectorfield.hpp:53
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...
Particle< ParticleP3D > Particle3D
Particle class in 3D.
Definition: particles.hpp:894
const CallbackFunctorD_V * _bsup_cb
B-field plasma suppression callback.
Definition: particles.hpp:906
PP & traj(int i)
Return reference to trajectory data.
Definition: particles.hpp:792
ParticleP2D operator-(const ParticleP2D &pp) const
Definition: particles.hpp:204
Vec3D location() const
Returns the location of particle point in Vec3D.
Definition: particles.hpp:168
static const std::string IQ_unit()
Return string representation for unit of current.
Definition: particles.hpp:338
Vec3D location() const
Returns the location of particle in Vec3D.
Definition: particles.hpp:776
double _m
Mass m [kg].
Definition: particles.hpp:654
ParticlePCyl operator*(double x) const
Definition: particles.hpp:390
ParticleP3D(std::istream &s)
Constructor for loading particle point from a file.
Definition: particles.hpp:465
double speed()
Returns speed of particle.
Definition: particles.hpp:176
static geom_mode_e geom_mode()
Returns geometry mode.
Definition: particles.hpp:477
ParticleBase(double IQ, double q, double m)
Definition: particles.hpp:656
static size_t dim()
Returns number of dimensions for geometry.
Definition: particles.hpp:131
Particle point class for 3D.
Definition: particles.hpp:447
Definition: particles.hpp:70
ParticleP2D operator*(double x) const
Definition: particles.hpp:214
const double & operator[](int i) const
Operator for pointing to coordinate data.
Definition: particles.hpp:184
const double & operator[](int i) const
Operator for pointing to coordinate data.
Definition: particles.hpp:358
double _IQ
Current or charge of particle.
Definition: particles.hpp:642
Particle(std::istream &s)
Constructor for loading particle from a file.
Definition: particles.hpp:744
Definition: particles.hpp:72
Temporary data bundle for particle iterators.
Definition: particles.hpp:900
const PP & traj(int i) const
Return const reference to trajectory data.
Definition: particles.hpp:796
double _q
Charge q [C].
Definition: particles.hpp:653
Particle point base class
Definition: particles.hpp:88
void set_bfield_suppression_callback(const CallbackFunctorD_V *bsup_cb)
Set B-field potential dependent suppression callback.
Definition: particles.hpp:915
geom_mode_e
Geometry mode enum.
Definition: types.hpp:59
void clear_trajectory(void)
Clears the particle trajectory.
Definition: particles.hpp:812
static size_t size()
Returns number of coordinates used for particle point.
Definition: particles.hpp:135
2D geometry
Definition: types.hpp:61
Three dimensional vectors.
particle_status_e
Particle status enum.
Definition: particles.hpp:68
ParticleP2D(std::istream &s)
Constructor for loading particle point from a file.
Definition: particles.hpp:117
Definition: particles.hpp:71
Vec3D location() const
Returns the location of particle point in Vec3D.
Definition: particles.hpp:520
Vec3D velocity() const
Returns the velocity of particle in Vec3D.
Definition: particles.hpp:780
const double & operator[](int i) const
Operator for pointing to coordinate data.
Definition: particles.hpp:536
ParticlePCyl(double t, double x, double vx, double r, double vr, double w)
Constructor for cylindrical particle point.
Definition: particles.hpp:279
void write_double(std::ostream &os, double value)
Write double value into stream os.
Particle base class
Definition: particles.hpp:637
const PP & x() const
Return const reference to coordinate data.
Definition: particles.hpp:788
static const std::string IQ_unit()
Return string representation for unit of current.
Definition: particles.hpp:516
size_t traj_size(void) const
Return number of trajectory points of particle.
Definition: particles.hpp:800
double & operator[](int i)
Operator for pointing to coordinate data.
Definition: particles.hpp:354
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...
Vec3D velocity() const
Returns the velocity of particle point in Vec3D.
Definition: particles.hpp:524
double & operator()(int i)
Operator for pointing to coordinate data.
Definition: particles.hpp:362
Vec3D velocity() const
Returns the velocity of particle point in Vec3D.
Definition: particles.hpp:172
Geometry defining class.
Definition: geometry.hpp:131
const double & operator[](int i) const
Operator for pointing to coordinate data.
Definition: particles.hpp:772
void save(std::ostream &s) const
Saves data to stream.
Definition: particles.hpp:707
static size_t dim()
Returns number of dimensions for geometry.
Definition: particles.hpp:481
ParticleP2D()
Default constuctor.
Definition: particles.hpp:107
ParticleBase(std::istream &s)
Constructor for loading particle from a file.
Definition: particles.hpp:667
void add_trajectory_point(const PP &x)
Add trajectory point to the end of the trajectory.
Definition: particles.hpp:804
particle_status_e _status
Status of particle.
Definition: particles.hpp:641
PP & x()
Return reference to coordinate data.
Definition: particles.hpp:784
Definition: callback.hpp:61
particle_status_e get_status()
Return particle status.
Definition: particles.hpp:680
double & operator[](int i)
Operator for pointing to coordinate data.
Definition: particles.hpp:532
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,vy,z,vz) for one particle.
ParticleP3D(double t, double x, double vx, double y, double vy, double z, double vz)
Constructor for 3D particle point.
Definition: particles.hpp:459
const double & operator()(int i) const
Operator for pointing to coordinate data.
Definition: particles.hpp:544
ParticleP3D operator+(const ParticleP3D &pp) const
Definition: particles.hpp:546
double & operator()(int i)
Operator for pointing to coordinate data.
Definition: particles.hpp:540
static size_t size()
Returns number of coordinates used for particle point.
Definition: particles.hpp:304
double qm() const
Return charge per mass ratio (q/m) [C/kg].
Definition: particles.hpp:703
Definition: particles.hpp:69
void save(std::ostream &s) const
Saves data to stream.
Definition: particles.hpp:584
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...
ParticleP3D operator-(const ParticleP3D &pp) const
Definition: particles.hpp:558
Particle class in some geometry.
Definition: particles.hpp:724
Definition: particles.hpp:74
const VectorField * _efield
Electric field or NULL.
Definition: particles.hpp:902
Color operator*(double x, const Color &c)
Definition: color.hpp:116
Definition: particles.hpp:73
void set_status(particle_status_e status)
Set particle status.
Definition: particles.hpp:684
ScalarField * _scharge
Space charge field or NULL.
Definition: particles.hpp:901
~Particle()
Destructor.
Definition: particles.hpp:756
Particle point class for 2D.
Definition: particles.hpp:99
ParticleP2D(double t, double x, double vx, double y, double vy)
Constructor for 2D particle point.
Definition: particles.hpp:111
ParticlePCyl(std::istream &s)
Constructor for loading particle point from a file.
Definition: particles.hpp:285
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,vr,w) for one particle.
ParticleP3D operator*(double x) const
Definition: particles.hpp:570
int32_t read_int32(std::istream &is)
Read int32_t from stream is.
Particle< ParticleP2D > Particle2D
Particle class in 2D.
Definition: particles.hpp:880
General callback functors.
double _qm
Precalculated q/m.
Definition: particles.hpp:905
double & operator[](int i)
Operator for pointing to coordinate data.
Definition: particles.hpp:768
double IQ() const
Return current or charge carried by trajectory or particle cloud [A/C].
Definition: particles.hpp:691
Vec3D location() const
Returns the location of particle point in Vec3D.
Definition: particles.hpp:342
void save(std::ostream &s) const
Saves data to stream.
Definition: particles.hpp:226
double & operator[](int i)
Operator for pointing to coordinate data.
Definition: particles.hpp:180
ParticleP2D operator+(const ParticleP2D &pp) const
Definition: particles.hpp:194
double & operator()(int i)
Operator for pointing to coordinate data.
Definition: particles.hpp:760
std::ostream & operator<<(std::ostream &os, const Color &c)
Definition: color.hpp:122
const Geometry * _geom
Geometry.
Definition: particles.hpp:904
~ParticleBase()
Definition: particles.hpp:674
Cylindrically symmetric geometry.
Definition: types.hpp:62
Three dimensional vector.
Definition: vec3d.hpp:58
static size_t size()
Returns number of coordinates used for particle point.
Definition: particles.hpp:485
Particle(double IQ, double q, double m, const PP &x)
Constructor for particle.
Definition: particles.hpp:739
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,vy) for one particle.
double q() const
Return particle charge (q) [C].
Definition: particles.hpp:695
double & operator()(int i)
Operator for pointing to coordinate data.
Definition: particles.hpp:188
void copy_trajectory(const std::vector< PP > &traj)
Define trajectory by copying.
Definition: particles.hpp:808
const double & operator()(int i) const
Operator for pointing to coordinate data.
Definition: particles.hpp:764
const double & operator()(int i) const
Operator for pointing to coordinate data.
Definition: particles.hpp:192
ParticlePCyl operator+(const ParticlePCyl &pp) const
Definition: particles.hpp:368
double speed()
Returns speed of particle.
Definition: particles.hpp:350
void save(std::ostream &s) const
Saves data to stream.
Definition: particles.hpp:403
void debug_print(std::ostream &os) const
Print debugging information to os.
Definition: particles.hpp:826
double speed()
Returns speed of particle.
Definition: particles.hpp:528
3D geometry
Definition: types.hpp:63
ParticleP3D()
Default constuctor.
Definition: particles.hpp:455
double m() const
Return particle mass (m) [kg].
Definition: particles.hpp:699
Scalar field class.
Definition: scalarfield.hpp:70
double read_double(std::istream &is)
Readd double from stream is.
ParticleIteratorData(ScalarField *scharge, const VectorField *efield, const VectorField *bfield, const Geometry *geom)
Definition: particles.hpp:908
Vector field base.