Garfield++ 4.0
A toolkit for the detailed simulation of particle detectors based on ionisation measurement in gases and semiconductors
Loading...
Searching...
No Matches
mparticle.h
Go to the documentation of this file.
1#ifndef MPARTICLE_H
2#define MPARTICLE_H
3#include <iostream>
6
7/*
8Copyright (c) 2000 Igor B. Smirnov
9
10The file can be used, copied, modified, and distributed
11according to the terms of GNU Lesser General Public License version 2.1
12as published by the Free Software Foundation,
13and provided that the above copyright notice, this permission notice,
14and notices about any modifications of the original text
15appear in all copies and in supporting documentation.
16The file is provided "as is" without express or implied warranty.
17 */
18
19namespace Heed {
20
21/// Massive particle. A force can be applied.
22
23class mparticle : public gparticle {
24 public:
25 /// Default constructor.
26 mparticle() = default;
27 /// Constructor, \f$\gamma - 1\f$ calculated from the from velocity vector.
28 mparticle(manip_absvol* primvol, const point& pt, const vec& vel,
29 vfloat ftime, double fmass);
30 /// Destructor.
31 virtual ~mparticle() {}
32
33 /// Get the current kinetic energy.
34 double kinetic_energy() const { return m_curr_ekin; }
35
36 void print(std::ostream& file, int l) const override;
37 mparticle* copy() const override { return new mparticle(*this); }
38
39
40 protected:
41 void step(std::vector<gparticle*>& secondaries) override;
42
43 /// Set curvature. Calls force().
44 /// - If force is zero, set curved = false, frelcen = (0, 0, 0).
45 /// - If, in addition, currpos.dir == (0, 0, 0), set fmrange = 0.
46 /// - If currpos.dir == (0, 0, 0), set currpos.dir = unit_vec(f).
47 /// - If force is parallel or anti-parallel to dir,
48 /// set curved = false, frelcen = (0, 0, 0).
49 /// - If force is anti-parallel to dir, restrict range till exceeding
50 /// kinetic energy.
51 void curvature(bool& curved, vec& frelcen, vfloat& fmrange,
52 vfloat prec) override;
53
54 /// The force is considered to be split in two components.
55 /// One component, f, can be in any direction and is
56 /// capable of doing work. The other one is always normal to dir
57 /// and cannot do work. The latter can represent the magnetic component of
58 /// the Lorentz force.
59 /// This splitting improve precision of calculation of kinetic energy.
60 /// But the latter component is not the true force. To derive the force
61 /// one should do vector multiplication of speed by f_perp,
62 /// f_perp2 = currpos.speed * (currpos.dir || f_perp_fl2);
63 /// Return 0 if there is no force, f is initialised to zero anyway.
64 /// mrange is the distance at which the force should not change much.
65 /// The dimension of f is [weight] * [lenght] / [time]^2
66 /// The dimension of f_perp is [weight] / [time];
67 virtual int force(const point& pt, vec& f, vec& f_perp, vfloat& mrange);
68
69 /// Mass (not mass * speed_of_light^2)
70 double m_mass = 0.;
71
72 /// Current kinetic energy
73 double m_curr_ekin = 0.;
74 /// Original kinetic energy
75 double m_orig_ekin = 0.;
76 /// Previous kinetic energy
77 double m_prev_ekin = 0.;
78
79 /// Current \f$\gamma - 1\f$
80 double m_curr_gamma_1 = 0.;
81 /// Original \f$\gamma - 1\f$
82 double m_orig_gamma_1 = 0.;
83 /// Previous \f$\gamma - 1\f$
84 double m_prev_gamma_1 = 0.;
85
86 private:
87 /// Check consistency of kinetic energy, \f$\gamma - 1\f$, speed, and mass.
88 void check_consistency() const;
89 /// Set new speed, direction and time for the current position.
90 void new_speed();
91
92};
93
94std::ostream& operator<<(std::ostream& file, const mparticle& f);
95}
96
97#endif
Abstract base classs for volume "manipulators".
Definition: volume.h:128
Massive particle. A force can be applied.
Definition: mparticle.h:23
double m_prev_ekin
Previous kinetic energy.
Definition: mparticle.h:77
double m_curr_ekin
Current kinetic energy.
Definition: mparticle.h:73
virtual int force(const point &pt, vec &f, vec &f_perp, vfloat &mrange)
Definition: mparticle.cpp:139
void step(std::vector< gparticle * > &secondaries) override
Definition: mparticle.cpp:71
virtual ~mparticle()
Destructor.
Definition: mparticle.h:31
void print(std::ostream &file, int l) const override
Print-out.
Definition: mparticle.cpp:243
double m_curr_gamma_1
Current .
Definition: mparticle.h:80
mparticle()=default
Default constructor.
double m_orig_ekin
Original kinetic energy.
Definition: mparticle.h:75
double m_prev_gamma_1
Previous .
Definition: mparticle.h:84
double kinetic_energy() const
Get the current kinetic energy.
Definition: mparticle.h:34
double m_orig_gamma_1
Original .
Definition: mparticle.h:82
double m_mass
Mass (not mass * speed_of_light^2)
Definition: mparticle.h:70
mparticle * copy() const override
Clone the particle.
Definition: mparticle.h:37
void curvature(bool &curved, vec &frelcen, vfloat &fmrange, vfloat prec) override
Definition: mparticle.cpp:98
Point.
Definition: vec.h:368
Definition: vec.h:179
Definition: BGMesh.cpp:6
std::ostream & operator<<(std::ostream &file, const BGMesh &bgm)
Definition: BGMesh.cpp:37
double vfloat
Definition: vfloat.h:16