particle module
Define Particle, created by reading CST ParticleMonitor files.
- class Particle(raw_line)[source]
Bases:
objectHolds evolution of position and adim momentum with time.
Position in \(\mathrm{mm}\), time in \(\mathrm{ns}\).
- position
Position of the particle during the simulation.
- momentum
Momentum of the particle during the simulation.
- _masses
Mass of particle at each time step. An error is raised if it changes between two files.
- mass
Mass of the particle in \(\mathrm{kg}\).
- mass_eV
Mass of the particle in \(\mathrm{eV}\).
- _charges
Charge of particle at each time step. An error is raised if it changes between two files.
- charge
Charge of the particle.
- time
Holds the time steps in \(\mathrm{ns}\) corresponding to every value of
pos,mom, etc.
- particle_id
Unique id for the particle.
- source_id
Gives information on how the particle was created.
- extrapolated_times
Times at which position and momentum are extrapolated.
- _check_constanteness_of_some_attributes()[source]
Ensure that mass and charge did not evolve during simulation.
- Return type:
- _switch_to_mm_ns_units()[source]
Change the system units to limit rounding errors. :rtype:
NoneWarning
In CST Particle Monitor files, the time is given in seconds * 1e-18 (aka nano-nanoseconds). Tested with CST units for time in nanoseconds.
- property collision_energy: float
Determine the impact energy in \(\mathrm{eV}\).
- Returns:
energy – The last known energy in \(\mathrm{eV}\).
- Return type:
- extrapolate_pos_and_mom_one_time_step_further()[source]
Extrapolate position and momentum by one time step.
CST PIC solves the motion with a leapfrog solver (source: Mohamad Houssini from Keonys, private communication). Several possibilities: -
poscorresponds totimeandmomshifted by half time-steps (most probable). -momcorresponds totimeandposshifted by half time-steps (also possible). -posormomis interpolated so that both are expressed at fulltimesteps (what I will consider for now).- Return type:
- determine_if_alive_at_end(max_time, tol=1e-06)[source]
Determine if the particle collisioned before end of simulation.
This method sets
alive_at_endflag.
- find_collision(mesh, warn_no_collision=True, warn_multiple_collisions=False, **kwargs)[source]
Find where the trajectory impacts the structure.
If the particle is alive at the end of the simulation, we do not even try. If it has only one known time step, neither do we.
We first try to detect a collision between the last known position of the particle and the last extrapolated position. If no collision is found, we try to find it between the last known position and the know position just before that.
Note
If the last extrapolated position is too far from the last known position, several collisions may be detected.
Todo
Take only nearest cell instead of the one with the lowest ID as for now.
- Parameters:
mesh (
Mesh) –vedomesh object describing the structure of the rf system.warn_no_collision (
bool, default:True) – If True, a warning is raised when the electron was not alive at the end of the simulation, but no collision was detected. The default is True.warn_multiple_collisions (
bool, default:False) – To warn if several collisions were detected for the same particle. Also remove all collisions but the first one. The default is True.kwargs – kwargs
- Return type:
- compute_emission_angle(mesh)[source]
Compute the angle of emission.
- Parameters:
mesh (
Mesh)- Return type:
- compute_collision_angle(mesh)[source]
Compute the angle of impact.
- Parameters:
mesh (
Mesh)- Return type:
- plot_trajectory(plotter, emission_color=None, collision_color=None, lw=7, r=8, **kwargs)[source]
Plot the trajectory of the particle in 3D.
- Parameters:
plotter (
Plotter) – Objet realizing the plots.emission_color (
str|None, default:None) – If provided, the first known position is colored with this color.collision_color (
str|None, default:None) – If provided, the last known position is colored with this color.collision_point – If provided and
collision_coloris notNone, we plot this point instead of the last ofpoints. This is useful when the extrapolated time is large, and actuel collision point may differ significantly from last position points.lw (
int, default:7) – Trajectory line width.r (
int, default:8) – Size of the emission/collision points.
- Return type: