PhysProc Class
Overview
The PhysProc
class serves as
the parent class for all physics processes within a simulation. It provides a standard interface for handling processes that interact with the Navigator
,
ParticleArray
, and MagneticLattice
during beam tracking.
This class is designed to be extended for defining custom physics effects such as CSR, space charge, wakefields, laser modulator, and more.
Attributes
Instance Attributes
-
step
(int):
Number of steps inNavigator.unit_step
. Each physics process applies over a distance ofself.step * Navigator.unit_step
(measured in meters). Default is1
. -
energy
(float, optional):
Beam energy associated with the process. Default isNone
. Can be manually set or inferred during tracking. -
indx0
(int, optional):
Index of the starting element in the lattice sequence. Assigned duringnavigator.add_physics_proc()
. -
indx1
(int, optional):
Index of the stopping element in the lattice sequence. Assigned duringnavigator.add_physics_proc()
. -
s_start
(float, optional):
Position of the starting element in the lattice. Assigned duringnavigator.add_physics_proc()
. -
s_stop
(float, optional):
Position of the stopping element in the lattice. Assigned duringnavigator.add_physics_proc()
. -
z0
(float, optional):
Current longitudinal position in the beamline. Updated during tracking before eachapply()
call.
Constructor
__init__(step=1)
Initializes a new instance of the PhysProc
class.
Parameters:
step
(int, optional): The number of steps inNavigator.unit_step
. Default is1
.
Methods
check_step()
Validates that the step
attribute is an integer.
Raises:
ValueError
: Ifself.step
is not an integer.
This is called automatically by the default prepare()
method.
prepare(lat)
(optional)
Called once when the physics process is added to the Navigator
.
Parameters:
lat
(MagneticLattice): The magnetic lattice used in the simulation.
Purpose:
- This method is optional, but can be overridden to perform setup operations such as trajectory calculation or initialization of diagnostic structures.
- In the default implementation, it calls
check_step()
.
Example Uses:
- In the CSR process,
prepare()
is used to calculate the reference trajectory.
apply(p_array, dz)
(Required)
Called on every simulation step to apply the physics process to the particle array.
Parameters:
p_array
(ParticleArray): The current particle distribution.dz
(float): Step size in meters.
Note: This method must be implemented in all subclasses.
finalize(*args, **kwargs)
(optional)
Called at the end of the simulation to perform any final operations, data collection, or cleanup.
Parameters:
*args
: Additional positional arguments.**kwargs
: Additional keyword arguments.
Example Uses:
- In Beam Analysis,
finalize()
is used to store calculated beam diagnostics.
Notes
-
Customization:
To implement a new physics process, subclassPhysProc
and override at least theapply()
method. -
Validation:
Thecheck_step()
method ensures that step values are integers, preventing issues in lattice traversal. -
Integration with Navigator:
Attributes likeindx0
,indx1
,s_start
,s_stop
, andz0
are automatically assigned when the process is added to aNavigator
. -
Optional lifecycle methods:
Bothprepare()
andfinalize()
can be used for pre-tracking setup and post-tracking diagnostics, respectively.
Related Classes
Navigator
: Manages beam propagation and physics process execution.MagneticLattice
: Defines the beamline and magnetic structure.ParticleArray
: Represents the state of the particle beam during simulation.
For a practical example of using and customizing PhysProc
, see: