Particle database class for three dimensions. More...
#include <particledatabase.hpp>
Public Member Functions | |
ParticleDataBase3D () | |
Constructor. | |
ParticleDataBase3D (const ParticleDataBase3D &pdb) | |
Copy constructor. | |
ParticleDataBase3D (std::istream &s) | |
Constructor for loading particle statistics from a file. | |
~ParticleDataBase3D () | |
Destructor. | |
const ParticleDataBase3D & | operator= (const ParticleDataBase3D &pdb) |
Assignment. | |
virtual Particle3D & | particle (uint32_t i) |
Returns a reference to particle i. | |
virtual const Particle3D & | particle (uint32_t i) const |
Returns a const reference to particle i. | |
virtual const ParticleP3D & | trajectory_point (uint32_t i, uint32_t j) const |
Gets the particle i trajectory point j as particle point. | |
void | add_particle (double IQ, double q, double m, const ParticleP3D &x) |
Add one particle. | |
void | add_particle (const Particle3D &p) |
Add one particle. | |
void | add_cylindrical_beam_with_energy (uint32_t N, double J, double q, double m, double E, double Tp, double Tt, Vec3D c, Vec3D dir1, Vec3D dir2, double r) |
Add a cylindrical beam with energies. | |
void | add_cylindrical_beam_with_velocity (uint32_t N, double J, double q, double m, double v, double dvp, double dvt, Vec3D c, Vec3D dir1, Vec3D dir2, double r) |
Add a cylindrical beam with velocities. | |
void | add_rectangular_beam_with_energy (uint32_t N, double J, double q, double m, double E, double Tp, double Tt, Vec3D c, Vec3D dir1, Vec3D dir2, double size1, double size2) |
Add a rectangular beam with energies. | |
void | add_rectangular_beam_with_velocity (uint32_t N, double J, double q, double m, double v, double dvp, double dvt, Vec3D c, Vec3D dir1, Vec3D dir2, double size1, double size2) |
Add a rectangular beam with velocities. | |
void | add_3d_KV_beam_with_emittance (uint32_t N, double I, double q, double m, double ay, double by, double ey, double az, double bz, double ez, double Ex, double x0, double y0, double z0) |
Add a 3d beam with defined KV emittance. | |
void | add_3d_gaussian_beam_with_emittance (uint32_t N, double I, double q, double m, double E0, double a1, double b1, double e1, double a2, double b2, double e2, Vec3D c, Vec3D dir1, Vec3D dir2) |
Add a 3d beam with defined gaussian emittance. | |
void | trajectories_at_free_plane (TrajectoryDiagnosticData &tdata, const Vec3D &c, const Vec3D &o, const Vec3D &p, const std::vector< trajectory_diagnostic_e > &diagnostics) const |
Get trajectory diagnostic on a plane. | |
void | export_path_manager_data (std::string filename, double ref_E, double ref_q, double ref_m, const Vec3D &c, const Vec3D &o, const Vec3D &p) const |
Export particle data as Path Manager data. | |
virtual void | save (const std::string &filename) const |
Saves data to a new file filename. | |
virtual void | save (std::ostream &s) const |
Saves data to stream. | |
virtual void | debug_print (std::ostream &os) const |
Print debugging information to os. |
Particle database class for three dimensions.
Particle database holds the definitions of particles and possibly the trajectories of particles it the particle iterator has saved them. ParticleDataBase3D provides a variety of convenience functions for defining particle beams.
Particles are always stored in the database in the order they are defined. When reading back the simulation results, the order can be used to identify the particles.
Constructor.
ParticleDataBase3D::ParticleDataBase3D | ( | const ParticleDataBase3D & | pdb | ) |
Copy constructor.
ParticleDataBase3D::ParticleDataBase3D | ( | std::istream & | s | ) |
Constructor for loading particle statistics from a file.
Destructor.
void ParticleDataBase3D::add_3d_gaussian_beam_with_emittance | ( | uint32_t | N, |
double | I, | ||
double | q, | ||
double | m, | ||
double | E0, | ||
double | a1, | ||
double | b1, | ||
double | e1, | ||
double | a2, | ||
double | b2, | ||
double | e2, | ||
Vec3D | c, | ||
Vec3D | dir1, | ||
Vec3D | dir2 | ||
) |
Add a 3d beam with defined gaussian emittance.
Adds a beam consisting of N particles and a total current of I (A). The particles are defined to have equal currents, charge q (in multiples of e) and mass m (u). The starting energy of the beam is E0 (eV) and the starting location c (center point). The beam propagates to the direction dir3 = dir1 x dir2, where dir1 and dir2 are the emittance axes. The beam is made to match Twiss parameters (a1),
(b1),
(e1) in the first projectional direction dir1 and
(a2),
(b2),
(e2) in the second projectional direction dir2.
The beam spread in the projectional space is made according to Gaussian distribution.
void ParticleDataBase3D::add_3d_KV_beam_with_emittance | ( | uint32_t | N, |
double | I, | ||
double | q, | ||
double | m, | ||
double | ay, | ||
double | by, | ||
double | ey, | ||
double | az, | ||
double | bz, | ||
double | ez, | ||
double | Ex, | ||
double | x0, | ||
double | y0, | ||
double | z0 | ||
) |
Add a 3d beam with defined KV emittance.
Adds a beam consisting of N particles and a total current of I (A). The particles are defined to have equal currents, charge q (in multiples of e) and mass m (u). The starting energy of the beam is Ex (eV) and the starting location (x0,y0,z0) (center point). The beam propagates to positive x-direction. The beam is made to match Twiss parameters (a),
(b),
(e) in projectional direction (y,y') and
(a),
(b),
(e) in projectional direction (z,z').
The beam spread in the projectional space is made according to KV/hard-edged (Kapchinsky-Vladimirsky) distribution.
void ParticleDataBase3D::add_cylindrical_beam_with_energy | ( | uint32_t | N, |
double | J, | ||
double | q, | ||
double | m, | ||
double | E, | ||
double | Tp, | ||
double | Tt, | ||
Vec3D | c, | ||
Vec3D | dir1, | ||
Vec3D | dir2, | ||
double | r | ||
) |
Add a cylindrical beam with energies.
Adds a beam consisting of N particles. The beam current density is J (A/m^2), charge of beam particles is q (in multiples of e), mass is m (u). The beam starting surface is a disc of radius r centered at c. The normal direction of the disc is dir3 = dir1 x dir2. The first tangent direction is dir1 and the second is dir1 x dir3. If you want beam to go to positive x-direction, dir1 could be (0,1,0) and dir2 (0,0,1) for example. The beam energy E (eV) is defined in the normal direction. Temperatures are defined in normal (parallel) direction and transverse direction as Tp (eV) and Tt (eV), respectively.
The particle speeds of the beam in direction i are sampled from a gaussian distribution with standard deviation dv_i = sqrt(T_i*e/m), where T_i is the beam temperature in direction (eV), e is electron charge (C) and m is the mass of the ion (kg).
Space charge J/v is added to the rhosum variable.
void ParticleDataBase3D::add_cylindrical_beam_with_velocity | ( | uint32_t | N, |
double | J, | ||
double | q, | ||
double | m, | ||
double | v, | ||
double | dvp, | ||
double | dvt, | ||
Vec3D | c, | ||
Vec3D | dir1, | ||
Vec3D | dir2, | ||
double | r | ||
) |
Add a cylindrical beam with velocities.
Adds a beam consisting of N particles. The beam current density is J (A/m^2), charge of beam particles is q (in multiples of e), mass is m (u). The beam starting surface is a disc of radius r centered at c. The normal direction of the disc is dir3 = dir1 x dir2. The first tangent direction is dir1 and the second is dir1 x dir3. The beam velocity v (m/s) is defined in the normal direction. The velocity distribution standard deviation are defined in normal (parallel) direction and transverse directions as dvp (m/s) and dvt (m/s), respectively
The particle velocities of the beam in direction i are sampled from a gaussian distribution with standard deviation dv_i, which is related to beam temperature by dv_i = sqrt(T_i*e/m), where T_i is the beam temperature in direction (eV), e is electron charge (C) and m is the mass of the ion (kg).
Space charge J/v is added to the rhosum variable.
void ParticleDataBase3D::add_particle | ( | double | IQ, |
double | q, | ||
double | m, | ||
const ParticleP3D & | x | ||
) |
Add one particle.
Adds one particle to particle database. Particle properties are: IQ is the current (A) in time-independent or charge (C) in time-dependent simulations carried by the particle cloud that the simulated particle represents, q is the charge state of the microscopic particle (in multiples of e), m is the mass of the microscopic particle (u) and x contains the time, position (m) and velocity (m/s) of the particle.
void ParticleDataBase3D::add_particle | ( | const Particle3D & | p | ) |
Add one particle.
Adds one particle to database.
void ParticleDataBase3D::add_rectangular_beam_with_energy | ( | uint32_t | N, |
double | J, | ||
double | q, | ||
double | m, | ||
double | E, | ||
double | Tp, | ||
double | Tt, | ||
Vec3D | c, | ||
Vec3D | dir1, | ||
Vec3D | dir2, | ||
double | size1, | ||
double | size2 | ||
) |
Add a rectangular beam with energies.
Very much like add_cylindrical_beam_with_energy(), but the beam shape is rectangular. The beam size is defined with two variables, sizex and sizey. These sizes are half the range, i.e. the beam ranges in the first direction from center point - size1 to center point + size1.
void ParticleDataBase3D::add_rectangular_beam_with_velocity | ( | uint32_t | N, |
double | J, | ||
double | q, | ||
double | m, | ||
double | v, | ||
double | dvp, | ||
double | dvt, | ||
Vec3D | c, | ||
Vec3D | dir1, | ||
Vec3D | dir2, | ||
double | size1, | ||
double | size2 | ||
) |
Add a rectangular beam with velocities.
Very much like add_cylindrical_beam_with_velocity(), but the beam shape is rectangular. The beam size is defined with two variables, sizex and sizey. These sizes are half the range, i.e. the beam ranges in the first direction from center point - size1 to center point + size1.
virtual void ParticleDataBase3D::debug_print | ( | std::ostream & | os | ) | const [virtual] |
Print debugging information to os.
Implements ParticleDataBase.
void ParticleDataBase3D::export_path_manager_data | ( | std::string | filename, |
double | ref_E, | ||
double | ref_q, | ||
double | ref_m, | ||
const Vec3D & | c, | ||
const Vec3D & | o, | ||
const Vec3D & | p | ||
) | const |
Export particle data as Path Manager data.
Makes trajectory diagnostics on a plane defined in three dimensional space by center point vector c and two basis vectors o and p. The vectors o and p are normalized and p is adjusted to be orthogonal to o. This is done by calculating q = cross(o,p) and p = cross(q,o).
The particle properties on the diagnostics plane are written to file filename in the format required by the Path Manager program. Reference particle for the output has energy ref_E (in eV), charge state ref_q and mass ref_m (in atomic mass units).
The file contains a header with information about the reference particle. After the header, the file has a line for each particle, which contain the following columns: x, x', y, y', phase, (p_z-p_ref)/p_ref, 0-flag, q, m.
const ParticleDataBase3D& ParticleDataBase3D::operator= | ( | const ParticleDataBase3D & | pdb | ) |
Assignment.
virtual Particle3D& ParticleDataBase3D::particle | ( | uint32_t | i | ) | [virtual] |
Returns a reference to particle i.
Implements ParticleDataBase.
virtual const Particle3D& ParticleDataBase3D::particle | ( | uint32_t | i | ) | const [virtual] |
Returns a const reference to particle i.
Implements ParticleDataBase.
virtual void ParticleDataBase3D::save | ( | const std::string & | filename | ) | const [virtual] |
Saves data to a new file filename.
Implements ParticleDataBase.
virtual void ParticleDataBase3D::save | ( | std::ostream & | s | ) | const [virtual] |
Saves data to stream.
Implements ParticleDataBase.
void ParticleDataBase3D::trajectories_at_free_plane | ( | TrajectoryDiagnosticData & | tdata, |
const Vec3D & | c, | ||
const Vec3D & | o, | ||
const Vec3D & | p, | ||
const std::vector< trajectory_diagnostic_e > & | diagnostics | ||
) | const |
Get trajectory diagnostic on a plane.
Builds trajectory diagnostics on a plane defined in three dimensional space by center point vector c and two basis vectors o and p. The vectors o and p are normalized and p is adjusted to be orthogonal to o. This is done by calculating q = cross(o,p) and p = cross(q,o).
The diagnostic gathered is defined by diagnostics. Data is returned in tdata.
Valid diagnostic types are DIAG_T, DIAG_X, DIAG_VX, DIAG_Y, DIAG_VY, DIAG_Z, DIAG_VZ, DIAG_O, DIAG_VO, DIAG_P, DIAG_VP, DIAG_Q, DIAG_VQ, DIAG_OP, DIAG_PP, DIAG_CURR, DIAG_EK and DIAG_QM.
virtual const ParticleP3D& ParticleDataBase3D::trajectory_point | ( | uint32_t | i, |
uint32_t | j | ||
) | const [virtual] |
Gets the particle i trajectory point j as particle point.
Implements ParticleDataBase.