Step class¶
Metadata¶
All the major classes are children of the MetaData class that is used to set metadata to the classes attributes.
- twissed.utils.metadata.MetaData.__setattr__(self, name: str, value: Type[Any | Tuple[Any, Dict]]) None ¶
Set attribute for the MetaData object
Example
a = MetaData() a.x = 12 # x is known in the database a.y = 12 # y is known in the database a.tmp = 12 # tmp is not known in the database a.pos = ( 14, { 'name_latex': '$x$', 'units': 'm', 'info': 'Positions x of the macro-particle of the beam.', 'type': 'np.ndarray' } ) # Create an attribute pos = 14, with metadata defined by the dictionnary. a.x = (13, {'units': 'mm', 'new': 'temporary'}) # Update the metadata of x print(a._data) # print metadata
- Parameters:
name (str) – Name of the attribute
value (Type[Any | Tuple[Any | Dict]]) – The value of the attribute. This argument can be a tuple with the wanted value and metadata for the attribute
- Raises:
KeyError – Some attributes are reserved.
Introduction ot Step¶
The main class is the skypiea.Step
class.
- twissed.Step(*args, **kwargs)[source]¶
Main Class for simulation parameters. Include beam, laser and plasma parameters at a given timestep.
Examples
#Creation of the step class step = twissed.Step() # Read data step = steps.read_beam(step,timestep,species='electrons',g=[10.,None]) # Examples print(f"N particle: {step.N}") print(f"Positions {step.x} [m]") step.print('emit_norm_rms_y') step.print('charge') step.print('dt') print(f"Convert dt: {step.convert('dt','ps')} [ps]")
step = twissed.read_dst("treacewin.dst")
Main keys¶
x (float) - Array of position in x, in m
y (float) - Array of position in y, in m
z (float) - Array of position in z, in m
ux (float) - Normalised momenta x \(u_x = \gamma v_x /c = \gamma beta_x\) of the macro-particle of the beam
uy (float) - Normalised momenta y \(u_y = \gamma v_y /c = \gamma beta_y\) of the macro-particle of the beam
uy (float) - Normalised momenta z \(u_z = \gamma v_z /c = \gamma beta_z\) of the macro-particle of the beam
w (float) - Weighs of the macro-particles in term of particles, in number of particles per macro-particles’
g (float) - Lorentz factor of every single macro-particles
Ek (float) - Relativistic kinetic energy of macro-particles
Note
Keys are only available if defined from read or set functions.
Functions¶
- twissed.Step.copy(self) Step ¶
Create copy of Step class
- Returns:
copy of Step class
- Return type:
Step
Beam functions¶
- twissed.Step.set_new_6D_beam(self, x: ndarray, y: ndarray, z: ndarray, ux: ndarray, uy: ndarray, uz: ndarray, w: ndarray) None ¶
Set position and momenta of the beam
- Parameters:
x (np.ndarray) – Positions x of the macro-particle of the beam in m
y (np.ndarray) – Positions y of the macro-particle of the beam in m
z (np.ndarray) – Positions z of the macro-particle of the beam in m
ux (np.ndarray) – Normalised momenta x \(u_x = \gamma v_x /c = \gamma beta_x\) of the macro-particle of the beam
uy (np.ndarray) – Normalised momenta y \(u_y = \gamma v_y /c = \gamma beta_y\) of the macro-particle of the beam
uz (np.ndarray) – Normalised momenta z \(u_z = \gamma v_z /c = \gamma beta_z\) of the macro-particle of the beam
w (np.ndarray) – Weighs of the macro-particles in term of number of particles
- twissed.Step.get_beam(self, **kwargs) None ¶
Generate all the beam data.
step.get_beam(x=[-12*1e-6,12*1e-6], g=[200,None],Ek_avg=[-50,50])
Range arguments accepted for selection¶
x (float) - Array of position in x, in m
y (float) - Array of position in y, in m
z (float) - Array of position in z, in m
ux (float) - Normalised momenta x \(u_x = \gamma v_x /c = \gamma beta_x\) of the macro-particle of the beam
uy (float) - Normalised momenta y \(u_y = \gamma v_y /c = \gamma beta_y\) of the macro-particle of the beam
uy (float) - Normalised momenta z \(u_z = \gamma v_z /c = \gamma beta_z\) of the macro-particle of the beam
w (float) - Weighs of the macro-particles in term of particles, in number of particles per macro-particles
g (float) - Lorentz factor of every single macro-particles
Ek (float) - Relativistic kinetic energy of macro-particles
Note
All the above arguments can be added with the ‘_avg’ suffix to force the selection to be performed around the mean value.
Variables self.w, self.ux, self.uy, self.uz, self.x, self.y and self.z must have be defined.
- twissed.Step.rotationXY(self, angle: float) Step ¶
Counterclockwise rotate the x-y plan to a given angle
Example
# 90 degree rotation of the beam step_new = step.rotationXY(90*np.pi/180)
- Parameters:
angle (float) – Angle of the counterclockwise rotation, in rad
- Returns:
New step class
- Return type:
step