simulation_output_factory module
Define a class to easily generate the SimulationOutput.
- _load_results_generic(filename, path_cal)[source]
Load the TraceWin results.
This function is not called directly. Instead, every instance of
TraceWinobject has aload_resultsmethod which calls this function with a defaultfilenameargument. The value offilenamedepends on the TraceWin simulation that was run: multiparticle or envelope.
Compute the energy from
gama-1column.
Compute the phases, pos, frequencies.
Also shift position and phase if
ListOfElementsunder study does not start at the beginning of the linac.TraceWin always starts with
z=0andphi_abs=0, even when we are not at the beginning of the linac (subDAT).- Parameters:
results (
dict[str,ndarray[tuple[Any,...],dtype[TypeVar(_ScalarT, bound=generic)]]]) – Dictionary holding the TraceWin results.z_in (
float) – Absolute position in the linac of the beginning of the linac portion under study (can be 0.).phi_in (
float) – Absolute phase of the synch particle at the beginning of the linac portion under study (can be 0.).
- Return type:
dict[str,ndarray[tuple[Any,...],dtype[TypeVar(_ScalarT, bound=generic)]]]- Returns:
Same as input, but with
lambdaandphi_abskeys defined.phi_absandz(m)keys are modified in order to be null the beginning of the linac (not at the beginning of theListOfElementsunder study!).
- _remove_incomplete_line(filepath)[source]
Remove incomplete line from
OUTfile.Todo
fix possible unbound error for
n_columns.
- _add_dummy_data(filepath, elts)[source]
Add dummy data at the end of the
OUTto reach end of linac.We also round the column ‘z’, to avoid a too big mismatch between the z column and what we should have.
Todo
another possibly unbound error to handle
- Parameters:
filepath (
Path)elts (
ListOfElements)
- Return type:
- _load_parameters_of_cavities(path_cal, filename)[source]
Get the cavity parameters calculated by TraceWin.
- Parameters:
- Return type:
- Returns:
Contains the cavity parameters. The keys should be:
"Cav#""SyncPhase_Ref[°]""SyncPhase[°]""Voltage_ref[MV]""Voltage[MV]""RF_phase[°]"
- _uniformize_parameters_of_cavities(parameters, n_elts)[source]
Transform the dict so we have consistent format with other solvers.
- class SimulationOutputFactoryTraceWin(_is_3d, _is_multipart, _solver_id, _beam_kwargs, out_folder, _filename, beam_calc_parameters_factory)[source]
Bases:
SimulationOutputFactoryA class for creating simulation outputs for
TraceWin.- Parameters:
_is_3d (
bool)_is_multipart (
bool)_solver_id (
str)_beam_kwargs (
BeamKwargs)out_folder (
Path)_filename (
Path)beam_calc_parameters_factory (
ElementTraceWinParametersFactory)
-
beam_calc_parameters_factory:
ElementTraceWinParametersFactory
- __post_init__()[source]
Set filepath-related attributes and create factories.
The created factories are
TransferMatrixFactoryandBeamParametersFactory. The sub-class that is used is declared in_transfer_matrix_factory_class()and_beam_parameters_factory_class().- Return type:
- run(elts, path_cal, exception, set_of_cavity_settings)[source]
Create an object holding all relatable simulation results.
- Parameters:
elts (
ListOfElements) – Contains all elements or only a fraction or all the elements.path_cal (
Path) – Path to results folder.exception (
bool) – Indicates if the run was unsuccessful or not.set_of_cavity_settings (
SetOfCavitySettings)
- Return type:
- Returns:
Holds all relatable data in a consistent way between the different
BeamCalculatorobjects.
- _create_main_results_dictionary(path_cal, input_particle)[source]
Load the TraceWin results, compute common interest quantities.
- _save_tracewin_meshing_in_elements(elts, elt_numbers, z_abs)[source]
Take output files to determine where are evaluated
w_kin…- Parameters:
elts (
ListOfElements)elt_numbers (
ndarray)z_abs (
ndarray)
- Return type:
- _get_parameters_of_cavities(path_cal, n_elts, filename=PosixPath('Cav_set_point_res.dat'))[source]
Load and format a dict containing v_cav and phi_s.
It has the same format as
Envelope1Dsolver format.- Parameters:
- Return type:
- Returns:
Contains the cavity parameters. Keys are
"v_cav_mv","phi_s","phi_0".
- __init__(_is_3d, _is_multipart, _solver_id, _beam_kwargs, out_folder, _filename, beam_calc_parameters_factory)
- Parameters:
_is_3d (
bool)_is_multipart (
bool)_solver_id (
str)_beam_kwargs (
BeamKwargs)out_folder (
Path)_filename (
Path)beam_calc_parameters_factory (
ElementTraceWinParametersFactory)
- _abc_impl = <_abc._abc_data object at 0x75e5165a8e80>