factory module

Define a class to easily create FieldMap objects.

This element has its own factory as I expect that creating field maps will become very complex in the future: 3D, superposed fields…

Todo

This will be subclassed, as the different solvers do not have the same needs. TraceWin does not need to load the electromagnetic fields, so every FIELD_MAP is implemented. Envelope1D cannot support 3D. etc

IMPLEMENTED_FIELD_MAPS = {   70: <class 'lightwin.core.elements.field_maps.field_map_70.FieldMap70'>,     100: <class 'lightwin.core.elements.field_maps.field_map_100.FieldMap100'>,     1100: <class 'lightwin.core.elements.field_maps.field_map_1100.FieldMap1100'>,     7700: <class 'lightwin.core.elements.field_maps.field_map_7700.FieldMap7700'>}
warn_once(geometry)[source]

Raise this warning only once.

https://stackoverflow.com/questions/31953272/logging-print-message-only-once

Parameters:

geometry (int)

class FieldMapFactory(default_field_map_folder, freq_bunch_mhz, default_absolute_phase_flag='0', **factory_kw)[source]

Bases: object

An object to create FieldMap objects.

Parameters:
  • default_field_map_folder (Path)

  • freq_bunch_mhz (float)

  • default_absolute_phase_flag (Literal['0', '1'], default: '0')

  • factory_kw (Any)

__init__(default_field_map_folder, freq_bunch_mhz, default_absolute_phase_flag='0', **factory_kw)[source]

Save the default folder for field maps.

Parameters:
  • default_field_map_folder (Path)

  • freq_bunch_mhz (float)

  • default_absolute_phase_flag (Literal['0', '1'], default: '0')

  • factory_kw (Any)

Return type:

None

run(line, dat_idx=None, **kwargs)[source]

Call proper constructor.

Parameters:
Return type:

FieldMap

_get_proper_field_map_subclass(geometry)[source]

Determine the proper field map subclass.

Warning

As for now, it always raises an error or return the rf electric field 1D class FieldMap100.

Parameters:

geometry (int)

Return type:

ABCMeta