SimulationFramework.Codes.CSRTrack package

Submodules

SimulationFramework.Codes.CSRTrack.CSRTrack module

Simframe CSRTrack Module

Various objects and functions to handle CSRTrack lattices and commands. See CSRTrack manual for more details.

Classes:

converting the frameworkObject s defined in the frameworkLattice into a string representation of the lattice suitable for a CSRTrack input file.

CSRTrack instance of a frameworkElement.

calculation type.

tracking step.

particle distribution and format.

class csrtrackLattice(*args, **kwargs)[source]

Bases: frameworkLattice

Class for defining the CSRTrack lattice object, used for converting the frameworkLattice into a string representation of the lattice suitable for a CSRTrack input file.

Parameters:
  • args (Any)

  • kwargs (Any)

CSRTrackelementObjects: Dict = {}

Dictionary representing all CSRTrack object namelists

code: str = 'csrtrack'

String indicating the lattice object type

property dipoles_screens_and_bpms: List

Get a list of the dipoles, screens and BPMs sorted by their position in the lattice

Returns:

A sorted list of frameworkElement

Return type:

List

endScreen(**kwargs)[source]

Create a final screen object for dumping the particle output after tracking.

Return type:

screen

particle_definition: str = ''

String representing the initial particle distribution

postProcess()[source]

Convert the beam file from the CSRTrack output into HDF5 format, see csrtrack_to_hdf5().

Return type:

None

preProcess()[source]

Convert the beam file from the previous lattice section into CSRTrack format and set the number of particles based on the input distribution, see hdf5_to_astra().

Return type:

None

setCSRMode()[source]

Set up the forces key in CSRTrackelementObjects based on the `csr_mode defined in the settings file for this lattice section. csr_mode can be either [“csr_g_to_p” (2D) or “projected” (1D)]

Return type:

None

set_particles_filename()[source]

Set up the CSRTrackelementObjects namelist for the initial particle distribution, based on the `particle_definition and the global_parameters of the lattice.

Return type:

None

write()[source]

Writes the CSRTrack input file from writeElements() to <master_subdir>/csrtrk.in.

Return type:

str

writeElements()[source]

Write the lattice elements defined in this object into a CSRTrack-compatible format; see elementObjects.

The appropriate headers required for ASTRA are written at the top of the file, see the _write_CSRTrack function in csrtrack_element.

Returns:

The lattice represented as a string compatible with CSRTrack

Return type:

str

class csrtrack_element(*args, **kwargs)[source]

Bases: frameworkElement

Base class for CSRTrack elements, including namelists for the lattice file.

Parameters:
  • args (Any)

  • kwargs (Any)

CSRTrack_str(s)[source]

Convert a boolean into a string for CSRTrack.

Parameters:

s (bool) – Boolean to convert

Returns:

‘yes’ for True, ‘no’ for False, or the original string if otherwise

Return type:

str

header: str = ''

Header for CSRtrack file types

class csrtrack_forces(*args, **kwargs)[source]

Bases: csrtrack_element

Class for CSRTrack forces.

Parameters:
  • args (Any)

  • kwargs (Any)

header: str = 'forces'

Header for CSRtrack element

objectname: str = 'forces'

Name of object

objecttype: str = 'csrtrack_forces'

Type of object

class csrtrack_monitor(*args, **kwargs)[source]

Bases: csrtrack_element

Class for defining CSRTrack monitors.

Parameters:
  • args (Any)

  • kwargs (Any)

csrtrack_to_hdf5()[source]

Convert the particle distribution from a CSRTrack monitor into HDF5 format, and write it to master_subdir.

Return type:

None

header: str = 'monitor'

Header for CSRtrack element

name: str = ''

File name for monitor

objectname: str = 'monitor'

Name of object

objecttype: str = 'csrtrack_monitor'

Type of object

class csrtrack_particles(*args, **kwargs)[source]

Bases: csrtrack_element

Class for defining CSRTrack particles.

Parameters:
  • args (Any)

  • kwargs (Any)

array: str = '#file{name=laser.astra}'

File name array

hdf5_to_astra(prefix='')[source]

Convert HDF5 particle distribution to ASTRA format, suitable for inputting to CSRTrack.

Parameters:

prefix (str) – Prefix for filename

Return type:

None

header: str = 'particles'

Header for CSRtrack element

objectname: str = 'particles'

Name of object

objecttype: str = 'csrtrack_particles'

Type of object

particle_definition: str = 'laser.astra'

Particle definition file

class csrtrack_track_step(*args, **kwargs)[source]

Bases: csrtrack_element

Class for defining CSRTrack the tracking step.

Parameters:
  • args (Any)

  • kwargs (Any)

header: str = 'track_step'

Header for CSRtrack element

objectname: str = 'track_step'

Name of object

objecttype: str = 'csrtrack_track_step'

Type of object

class csrtrack_tracker(*args, **kwargs)[source]

Bases: csrtrack_element

Class for defining the CSRTrack tracker.

Parameters:
  • args (Any)

  • kwargs (Any)

end_time_marker: str = ''

Name of end marker

end_time_shift_c0: str | float = 0.0

Time shift for end

header: str = 'tracker'

Header for CSRtrack element

objectname: str = 'tracker'

Name of object

objecttype: str = 'csrtrack_tracker'

Type of object

Module contents