SimulationFramework.Codes.GPT package

Submodules

SimulationFramework.Codes.GPT.GPT module

Simframe GPT Module

Various objects and functions to handle GPT lattices and commands.

Classes:

converting the frameworkObject s defined in the frameworkLattice into a string representation of the lattice suitable for GPT input and lattice files.

commands in a GPT input file.

input files for the GPT input file.

bunch charge for the GPT input file.

number of particles for the GPT input file.

accuracy for GPT tracking.

space charge setup for the GPT input file.

number of steps for particle distribution output for the GPT input file.

CSR calculations for the GPT input file.

writing of the lattice floor plan for the GPT input file.

minimum and maximum z-positions for the GPT input file.

scattering parameters for the GPT input file.

scattering object for the GPT input file.

step size(s) for the GPT input file.

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

Bases: frameworkLattice

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

Parameters:
  • args (Any)

  • kwargs (Any)

Brho: UnitValue | None = None
accuracy: int = 6

Tracking accuracy

allow_negative_drifts: bool = True

Flag to indicate whether negative drifts are allowed

bunch_charge: float | None = None

Bunch charge

code: str = 'gpt'

String indicating the lattice object type

endScreen(**kwargs)[source]

Make the final position in the lattice a screen object.

Returns:

The final screen in the lattice

Return type:

screen

endScreenObject: screen | None = None

Final screen object for dumping particle distributions

hdf5_to_gdf(prefix='')[source]

Convert the HDF5 beam distribution to GDF format.

Certain properties of this class, including sample_interval, override_meanBz, override_tout are also used to update headers.

Parameters:

prefix (str) – HDF5 file prefix

Return type:

None

headers: Dict = {}

Headers to be included in the GPT lattice file

ignore_start_screen: screen | None = None

Flag to indicate whether to ignore the first screen in the lattice

override_meanBz: float | int | None = None

Set the average particle longitudinal velocity manually

override_tout: float | int | None = None

Set the time step output manually

postProcess()[source]

Convert the beam file(s) from the GPT output into HDF5 format, see gdf_to_hdf5().

Return type:

None

preProcess()[source]

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

Return type:

None

run()[source]

Run the code with input ‘filename’

GPTLICENSE must be provided in global_parameters.

Average properties of the distribution are also calculated and written to an <>emit.gdf file in master_subdir.

Return type:

None

screen_step_size: float = 0.1

Step size for screen output

property space_charge_mode: str | None

Get the space charge mode based on globalSettings or file_block.

Returns:

Space charge mode as string, or None if not provided.

Return type:

str

time_step_size: str = '0.1/c'

Step size for tracking

write()[source]

Writes the GPT input file from writeElements() to <master_subdir>/<self.objectname>.in.

Return type:

str

writeElements()[source]

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

The appropriate headers required for GPT are written at the top of the file, see the write_GPT function in gpt_element.

Returns:

The lattice represented as a string compatible with GPT

Return type:

str

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

Bases: gpt_element

Class for setting the boundaries in z for discarding particles via Zminmax

Parameters:
  • args (Any)

  • kwargs (Any)

ECS: str = '"wcs", "I"'

Element coordinate system as a string

objectname: str = 'Zminmax'

Name of object

objecttype: str = 'gpt_Zminmax'

Type of object

zmax: float = 0.0

Maximum longitudinal position

zmin: float = 0.0

Minimum longitudinal position

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

Bases: gpt_element

Class for setting the accuracy of tracking via accuracy in GPT.

Parameters:
  • args (Any)

  • kwargs (Any)

accuracy: int = 6

Accuracy for GPT tracking

objectname: str = 'accuracy'

Name of object

objecttype: str = 'gpt_accuracy'

Type of object

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

Bases: gpt_element

Class for generating the settotalcharge namelist for GPT.

Parameters:
  • args (Any)

  • kwargs (Any)

charge: float = 0.0

Bunch charge

objectname: str = 'settotalcharge'

Name of object

objecttype: str = 'gpt_charge'

Type of object

set: str = '"beam"'

Name of beam for settotalcharge

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

Bases: gpt_element

Class for preparing CSR calculations via csr1d.

Parameters:
  • args (Any)

  • kwargs (Any)

objectname: str = 'csr1d'

Name of object

objecttype: str = 'gpt_csr1d'

Type of object

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

Bases: gpt_element

Class for setting up minimum, maximmum temporal step sizes for tracking via dtmaxt.

Parameters:
  • args (Any)

  • kwargs (Any)

dtmax: float = 0.0

Maximum temporal step size

objectname: str = 'dtmaxt'

Name of object

objecttype: str = 'gpt_dtmaxt'

Type of object

tend: float = 0.0

Final time value

tstart: float = 0.0

Initial time value

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

Bases: frameworkElement

Generic class for generating headers for GPT.

Parameters:
  • args (Any)

  • kwargs (Any)

write_GPT(*args, **kwargs)[source]

Write the text for the GPT namelist based on its objectdefaults, objectname.

Returns:

GPT-compatible string representing the namelist

Return type:

str

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

Bases: gpt_element

Class for scattering particles via forwardscatter.

Parameters:
  • args (Any)

  • kwargs (Any)

ECS: str = '"wcs", "I"'

Element coordinate system

objectname: str = 'forwardscatter'

Name of object

objecttype: str = 'gpt_forwardscatter'

Type of object

probability: float = 0.0

Scattering probability

zmax: float = 0.0

Maximum longitudinal position

zmin: float = 0.0

Minimum longitudinal position

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

Bases: gpt_element

Class for scattering particles off a plate via scatterplate.

Parameters:
  • args (Any)

  • kwargs (Any)

ECS: str = '"wcs", "I"'

Element coordinate system

a: float = 0.0

Plate length in x-direction

b: float = 0.0

Plate length in y-direction

model: str = 'cathode'

Scattering model to be used [‘cathode’, ‘remove’]

objectname: str = 'scatterplate'

Name of object

objecttype: str = 'gpt_scatterplate'

Type of object

zmax: float = 0.0

Maximum longitudinal position

zmin: float = 0.0

Minimum longitudinal position

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

Bases: gpt_element

Class for setting filenames in GPT via setfile.

Parameters:
  • args (Any)

  • kwargs (Any)

objectname: str = 'setfile'

Name of object

objecttype: str = 'gpt_setfile'

Type of object

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

Bases: gpt_element

Class for reducing the number of particles via setreduce.

Parameters:
  • args (Any)

  • kwargs (Any)

objectname: str = 'setreduce'

Name of object

objecttype: str = 'gpt_setreduce'

Type of object

set: str = '"beam"'

Name of the beam for setreduce

setreduce: int = 1

Factor by which to reduce the number of particles

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

Bases: gpt_element

Class for preparing space charge calculations in GPT via spacecharge.

Parameters:
  • args (Any)

  • kwargs (Any)

cathode: bool = False

Flag indicating whether the bunch was emitted from a cathode

grids: getGrids = None

Class for calculating the required number of space charge grids

ngrids: int | None = None

Number of space charge grids

objectname: str = 'spacecharge'

Name of object

objecttype: str = 'gpt_spacecharge'

Type of object

space_charge_mode: str | None = None

Space charge mode [‘2D’, ‘3D’]

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

Bases: gpt_element

Class for setting up the beam dump rate via tout.

Parameters:
  • args (Any)

  • kwargs (Any)

endpos: float = 0.0

End position

objectname: str = 'tout'

Name of object

objecttype: str = 'gpt_tout'

Type of object

startpos: float = 0.0

Starting position

starttime: float = 0.0

Start time for dumping

step: str = '0.1/c'

Dump step as a string [distance / c]

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

Bases: gpt_element

Class for writing the lattice floor plan via writefloorplan.

Parameters:
  • args (Any)

  • kwargs (Any)

filename: str = ''

Floor plan filename

objectname: str = 'writefloorplan'

Name of object

objecttype: str = 'gpt_writefloorplan'

Type of object

Module contents