Output
The data which is saved as output from the simulation requires two pieces: a file writer and a description of the data to be saved. The abstract base class of all file writers is KSWriter.
Writers
The file writer is responsible for buffering and writing the desired information to disk. The default writer is based on
ROOT, and stores the output in a TTree
structure:
<kswrite_root
name="write_root"
path="/path/to/desired/output/directory"
base="my_filename.root"
/>
If Kassiopeia is linked against VTK, an additional writer will be made available which can save track and step
information to a .vtp
(VTK polydata) file. This data is useful for visualalization in external tools such as
Paraview. This write may be created using the following statement:
<kswrite_vtk
name="write_vtk"
path="/path/to/desired/output/directory"
base="my_filename_base.vtp"
/>
Note that in principle both data formats are equivalent, but their underlying structure differs. In most cases it is best to write output file in both formats, and delete any files that are no longer needed.
To write output in plaintext ASCII format that can be easily viewed and read into other software such as Gnuplot, one may use the following statement:
<kswrite_ascii
name="write_ascii"
path="/path/to/desired/output/directory"
base="my_filename_base.vtp"
/>
This is not recommended for large-scale simulations because the output file will quickly approach a size that will be extremely difficult to handle.
Output description
The user may tailor the data written to disk to keep precisely the quantities of interest and no more. To do this a
description of the data components to be kept at the track and step level must be given. An example of this (taken from
the QuadrupoleTrapSimulation.xml
example) is shown below:
<ks_component_member name="component_step_final_particle" field="final_particle" parent="step"/>
<ks_component_member name="component_step_position" field="position" parent="component_step_final_particle"/>
<ks_component_member name="component_step_length" field="length" parent="component_step_final_particle"/>
<ks_component_group name="component_step_world">
<component_member name="step_id" field="step_id" parent="step"/>
<component_member name="continuous_time" field="continuous_time" parent="step"/>
<component_member name="continuous_length" field="continuous_length" parent="step"/>
<component_member name="time" field="time" parent="component_step_final_particle"/>
<component_member name="position" field="position" parent="component_step_final_particle"/>
<component_member name="momentum" field="momentum" parent="component_step_final_particle"/>
<component_member name="magnetic_field" field="magnetic_field" parent="component_step_final_particle"/>
<component_member name="electric_field" field="electric_field" parent="component_step_final_particle"/>
<component_member name="electric_potential" field="electric_potential" parent="component_step_final_particle"/>
<component_member name="kinetic_energy" field="kinetic_energy_ev" parent="component_step_final_particle"/>
</ks_component_group>
<ks_component_group name="component_step_cell">
<component_member name="polar_angle_to_z" field="polar_angle_to_z" parent="component_step_final_particle"/>
<component_member name="polar_angle_to_b" field="polar_angle_to_b" parent="component_step_final_particle"/>
<component_member name="guiding_center_position" field="guiding_center_position" parent="component_step_final_particle"/>
<component_member name="orbital_magnetic_moment" field="orbital_magnetic_moment" parent="component_step_final_particle"/>
</ks_component_group>
<ks_component_member name="component_track_initial_particle" field="initial_particle" parent="track"/>
<ks_component_member name="component_track_final_particle" field="final_particle" parent="track"/>
<ks_component_member name="component_track_position" field="position" parent="component_track_final_particle"/>
<ks_component_member name="component_track_length" field="length" parent="component_track_final_particle"/>
<ks_component_member name="z_length" field="continuous_length" parent="step"/>
<ks_component_group name="component_track_world">
<component_member name="creator_name" field="creator_name" parent="track"/>
<component_member name="terminator_name" field="terminator_name" parent="track"/>
<component_member name="total_steps" field="total_steps" parent="track"/>
<component_member name="initial_time" field="time" parent="component_track_initial_particle"/>
<component_member name="initial_position" field="position" parent="component_track_initial_particle"/>
<component_member name="initial_momentum" field="momentum" parent="component_track_initial_particle"/>
<component_member name="initial_magnetic_field" field="magnetic_field" parent="component_track_initial_particle"/>
<component_member name="initial_electric_field" field="electric_field" parent="component_track_initial_particle"/>
<component_member name="initial_electric_potential" field="electric_potential" parent="component_track_initial_particle"/>
<component_member name="initial_kinetic_energy" field="kinetic_energy_ev" parent="component_track_initial_particle"/>
<component_member name="initial_polar_angle_to_z" field="polar_angle_to_z" parent="component_track_initial_particle"/>
<component_member name="initial_azimuthal_angle_to_x" field="azimuthal_angle_to_x" parent="component_track_initial_particle"/>
<component_member name="initial_polar_angle_to_b" field="polar_angle_to_b" parent="component_track_initial_particle"/>
<component_member name="initial_orbital_magnetic_moment" field="orbital_magnetic_moment" parent="component_track_initial_particle"/>
<component_member name="final_time" field="time" parent="component_track_final_particle"/>
<component_member name="final_position" field="position" parent="component_track_final_particle"/>
<component_member name="final_momentum" field="momentum" parent="component_track_final_particle"/>
<component_member name="final_magnetic_field" field="magnetic_field" parent="component_track_final_particle"/>
<component_member name="final_electric_field" field="electric_field" parent="component_track_final_particle"/>
<component_member name="final_electric_potential" field="electric_potential" parent="component_track_final_particle"/>
<component_member name="final_kinetic_energy" field="kinetic_energy_ev" parent="component_track_final_particle"/>
<component_member name="final_polar_angle_to_z" field="polar_angle_to_z" parent="component_track_final_particle"/>
<component_member name="final_azimuthal_angle_to_x" field="azimuthal_angle_to_x" parent="component_track_final_particle"/>
<component_member name="final_polar_angle_to_b" field="polar_angle_to_b" parent="component_track_final_particle"/>
<component_member name="final_orbital_magnetic_moment" field="orbital_magnetic_moment" parent="component_track_final_particle"/>
<component_member name="z_length_internal" field="continuous_length" parent="track"/>
<component_integral name="z_length_integral" parent="z_length"/>
</ks_component_group>
Let us break this down a bit. First of all, the output can be separated into three groups that each define an output segment that will be written to the file:
component_step_world is the base definition for output at the step level. It contains standard parameters of the particle such as its energy, position, or step index.
component_step_cell defines additional output fields that are of interest in a specific region of the simulation. How this feature can be used will be explained below. Generally, one can define as many output groups as necessary to write output only where it is relevant to the simulation.
component_track_world is the base definition for output at the track level. While the step output is written continuously while the particle trajectory is being computed, the track output is only written once after a track has been terminated. As such, the track output contains initial and final parameters of the particle (again, for example, its energy or position) and are derived from the first and last step of the track. There is also an output field
z_length_integral
that stores the integrated length of all tracks performed in the simulation.
For output fields that are not directly available at the step (parent="step"
) or track level, a mapping has to be
defined first. This is done by the lines:
<ks_component_member name="component_step_final_particle" field="final_particle" parent="step"/>
and so on. The field="final_particle"
points to the final particle state after a step has been performed, i.e. this
output is written after the completion of each step. Similary, at the track level there are output fields that point
to the initial and final parameters of a track, i.e. the state at particle generation and termination.
The standard output fields for the particle are defined at the end of the file GitHub: Kassiopeia/Simulation/Source/KSParticle.cxx while the step and track output fields can be found in GitHub: Kassiopeia/Simulation/Source/KSStep.cxx and GitHub: Kassiopeia/Simulation/Source/KSTrack.cxx, respectively. Other specialized output fields are also available for some propagation or interaction terms.
Output fields
Many different output fields can be used and combined in the output configuration. The table below gives an overview of the different fields and their types.
Output fields |
||||
---|---|---|---|---|
Name |
XML Element |
Value Type |
Base class |
Description (main parameters) |
Index Number |
|
|
|
Unique index number of the current step |
Parent Run ID |
|
|
|
Run ID of the parent step/track/event |
Parent Event ID |
|
|
|
Event ID of the parent step/track/event |
Parent Track ID |
|
|
|
Track ID of the parent step/track |
Parent Step ID |
|
|
|
Step ID of the parent step |
Particle ID |
|
|
|
Assigned particle ID (PDG code) |
Particle String ID |
|
|
|
Assigned particle ID (human-readable) |
Particle Mass |
|
|
|
Mass of the particle (in kg) |
Particle Charge |
|
|
|
Charge of the particle (in C) |
Particle Spin |
|
|
|
Spin magnitude of the particle (in hbar) |
Gyromagnetic Ratio |
|
|
|
Gyromagnetic ratio of the particle (in rad/sT) |
Main Quantum No. |
|
|
|
Main quantum number |
Second Quatum No. |
|
|
|
Secondary quantum number |
Time |
|
|
|
Time in the simulation (in s) |
Wallclock Time |
|
|
|
Wallclock time (system time) at the current step |
Step Length |
|
|
|
Length of the current step (in m) |
Position Vector |
|
|
|
Position at the current step (in m) |
Momentum Vector |
|
|
|
Momentum at the current step (in kg*m/s) |
Velocity Vector |
|
|
|
Velocity at the current step (in m/s) |
Spin Vector |
|
|
|
Spin at the current step (in hbar) |
Index Number |
|
|
|
|
Aligned Spin |
|
|
|
|
Spin Angle |
|
|
|
|
Speed |
|
|
|
Total speed at the current step (in m/s) |
Lorentz Factor |
|
|
|
Lorentz factor at the current step |
Kinetic Energy |
|
|
|
Kinetic energy at the current step (in J) |
Kinetic Energy |
|
|
|
Kinetic energy at the current step (in eV) |
Polar Angle |
|
|
|
Polar angle relative to z-axis (in deg) |
Azimuthal Angle |
|
|
|
Azimuthal angle relative to x-axis (in deg) |
Magnetic Field |
|
|
|
Magnetic field at the current step (in T) |
Electric Field |
|
|
|
Electric field at the current step (in V/m) |
Magnetic Gradient |
|
|
|
Magnetic gradient at the current step (in T/m) |
Electric Potential |
|
|
|
Electric potential at the current step (in V) |
Long. Momentum |
|
|
|
Longitudinal momentum at the current step (in kg*m/s) |
Trans. Momentum |
|
|
|
Transversal momentum at the current step (in kg*m/s) |
Long. Velocity |
|
|
|
Longitudinal velocity at the current step (in m/s) |
Trans. Velocity |
|
|
|
Transversal velocity at the current step (in m/s) |
Polar Angle to B |
|
|
|
Polar (pitch) angle relative to magnetic field (in deg) |
Cyclotron Freq. |
|
|
|
Cyclotron frequency at the current step (in Hz) |
Magnetic Moment |
|
|
|
Orbital magnetic moment at the current step (in A*m^2) |
GC Position Vector |
|
|
|
Guiding center position at the current step (in m) |
Current Space |
|
|
|
Name of the nearest space (see |
Current Surface |
|
|
|
Name of the nearest surface (see |
Current Side |
|
|
|
Name of the nearest side (see |
GC Velocity |
|
|
|
Guiding center velocity (in m/s) |
GC Long. Force |
|
|
|
Longitudinal force added by drift terms (in N) |
GC Trans. Force |
|
|
|
Transversal force added by drift terms (in N) |
Gy. Phase Velocity |
|
|
|
Phase velocity of gyration around g.c. (in rad/s) |
Synchrotron Force |
|
|
|
Total force added by synchrotron radiation (in N) |
Min. Distance |
|
|
|
Distance to the nearest surface (in m) |
Interaction Count |
|
|
|
Number of interactions at current step |
Energy loss |
|
|
|
Energy loss at current step (in eV) |
Angular Change |
|
|
|
Angular change at current step (in deg) |
Interaction Count |
|
|
|
Number of interactions at current step |
Energy loss |
|
|
|
Energy loss at current step (in eV) |
Enhancement Factor |
|
|
|
Step modifier enhancement factor |
Run ID |
|
|
|
Run ID of current run |
Run Count |
|
|
|
Total number of runs |
Total Events |
|
|
|
Total number of events in run |
Total Tracks |
|
|
|
Total number of tracks in run |
Total Steps |
|
|
|
Total number of steps in run |
Cont. Time |
|
|
|
Total time of all events/tracks/steps in run |
Cont. Length |
|
|
|
Total length of all events/tracks/steps in run |
Energy Change |
|
|
|
Total energy change during run |
Momentum Change |
|
|
|
Total momentum change during run |
Secondaries Count |
|
|
|
Number of secondaries created during run |
Energy Change |
|
|
|
Total energy change during run |
Momentum Change |
|
|
|
Total momentum change during run |
Number of Turns |
|
|
|
Number of particle turns/reflections during run |
Processing Duration |
|
|
|
Computing time used for run |
Event ID |
|
|
|
Event ID of current event |
Event Count |
|
|
|
Total number of events |
Parent Run ID |
|
|
|
Run ID of parent run |
Total Tracks |
|
|
|
Total number of tracks in event |
Total Steps |
|
|
|
Total number of steps in event |
Cont. Time |
|
|
|
Total time of all tracks/steps in event |
Cont. Length |
|
|
|
Total length of all tracks/steps in event |
Energy Change |
|
|
|
Total energy change during event |
Momentum Change |
|
|
|
Total momentum change during event |
Secondaries Count |
|
|
|
Number of secondaries created during event |
Energy Change |
|
|
|
Total energy change during event |
Momentum Change |
|
|
|
Total momentum change during event |
Number of Turns |
|
|
|
Number of particle turns/reflections during event |
Generator Name |
|
|
|
Name of the generator starting this event |
Generator Flag |
|
|
|
Additional flag of the used generator |
Primary Count |
|
|
|
Number of generated particles |
Generator Energy |
|
|
|
Total energy of the generated particles (in eV) |
Generator Time |
|
|
|
Minimum time of the generated particles (in s) |
Generator Time |
|
|
|
Maximum time of the generated particles (in s) |
Generator Position |
|
|
|
Center position of the generated particles (in m) |
Generator Radius |
|
|
|
Maximum radius of the generated particles (in m) |
Processing Duration |
|
|
|
Computing time used for event |
Track ID |
|
|
|
Track ID of current track |
Track Count |
|
|
|
Total number of tracks |
Parent Event ID |
|
|
|
Event ID of parent track |
Total Steps |
|
|
|
Total number of steps in track |
Cont. Time |
|
|
|
Total time of all steps in track |
Cont. Length |
|
|
|
Total length of all steps in track |
Energy Change |
|
|
|
Total energy change during track |
Momentum Change |
|
|
|
Total momentum change during track |
Secondaries Count |
|
|
|
Number of secondaries created during track |
Energy Change |
|
|
|
Total energy change during track |
Momentum Change |
|
|
|
Total momentum change during track |
Number of Turns |
|
|
|
Number of particle turns/reflections during track |
Creator Name |
|
|
|
Name of the creator starting this track |
Terminator Name |
|
|
|
Name of the terminator ending this track |
Initial Particle |
|
|
|
Pointer to initial particle at begin of the track |
Final particle |
|
|
|
Pointer to final particle at end of the track |
Step ID |
|
|
|
Step ID of current step |
Step Count |
|
|
|
Total number of steps |
Parent Track ID |
|
|
|
Track ID of parent track |
Cont. Time |
|
|
|
Total time of current step |
Cont. Length |
|
|
|
Total length of current step |
Energy Change |
|
|
|
Total energy change during step |
Momentum Change |
|
|
|
Total momentum change during step |
Secondaries Count |
|
|
|
Number of secondaries created during step |
Energy Change |
|
|
|
Total energy change during step |
Momentum Change |
|
|
|
Total momentum change during step |
Number of Turns |
|
|
|
Number of particle turns/reflections during step |
Modifier Name |
|
|
|
Name of the step modifier at this step |
Modifier Flag |
|
|
|
Additional flag for the used terminator |
Terminator Name |
|
|
|
Name of the terminator ending this step |
Terminator Flag |
|
|
|
Additional flag for the used terminator |
Trajectory Name |
|
|
|
Name of the trajectory at this step |
Trajectory Center |
|
|
|
Position of the trajectory bounding sphere (in m) |
Trajectory Radius |
|
|
|
Radius of the trajectory bounding sphere (in m) |
Trajectory Step |
|
|
|
Time of the particle propagation |
Interaction Name |
|
|
|
Space name of the interaction at this step |
Interaction Flag |
|
|
|
Additional flag for the space interaction |
Interaction Step |
|
|
|
Time of the space interaction |
Navigation Name |
|
|
|
Space name of the navigation at this step |
Navigation Flag |
|
|
|
Additional flag for the space navigation |
Navigation Step |
|
|
|
Time of the space navigation |
Interaction Name |
|
|
|
Surface name of the interaction at this step |
Interaction Flag |
|
|
|
Additional flag for the surface interaction |
Navigation Name |
|
|
|
Surface name of the navigation at this step |
Navigation Flag |
|
|
|
Additional flag for the surface navigation |
Initial Particle |
|
|
|
Pointer to initial particle at begin of the step |
Finale Particle |
|
|
|
Pointer to initial particle at begin of the step |
Intermed. Particle |
|
|
|
Pointer to initial particle before interaction |
Intermed. Particle |
|
|
|
Pointer to initial particle before navigation |
Intermed. Particle |
|
|
|
Pointer to initial particle before termination |
Intermed. Particle |
|
|
|
Pointer to initial particle before propagation |
Processing Duration |
|
|
|
Computing time used for step |
Vector and matrix type can be accessed by their components in the written output data. For example, when the position
element is used, the corresponding fields in the output data can be found under the names position_x
, position_y
,
and position_z`. For matrix types, the rows are treated as 3-vectors themselves. Hence, the first element in a matrix
field named ``gradient
can be found under gradient_x_x
, and so on.
The following suffixes are available for the vector and matrix types.
Output field suffixes |
||
---|---|---|
Name |
XML Element Suffix |
Base Type |
X Component |
|
|
Y Component |
|
|
Z Component |
|
|
Vector Magnitude |
|
|
Squared Magnitude |
|
|
Radial Component |
|
|
Squared Radial |
|
|
Polar Angle |
|
|
Azimuthal Angle |
|
|
Determinant |
|
|
Trace |
|
|