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_multipart, beam_calculator_id, beam_kwargs, filename, beam_calc_parameters_factory)[source]
Bases:
SimulationOutputFactoryA class for creating simulation outputs for
TraceWin.- Parameters:
is_multipart (
bool)beam_calculator_id (
str)beam_kwargs (
BeamKwargs)filename (
Path)beam_calc_parameters_factory (
ElementTraceWinParametersFactory)
- __init__(is_multipart, beam_calculator_id, beam_kwargs, filename, beam_calc_parameters_factory)[source]
Create the object.
- Parameters:
is_multipart (
bool) – IfSimulationOutputare obtained with a multiparticle solver.beam_calculator_id (
str) – ID of solver that created this object. Also used as the name of the subdirectory where results should be saved. Typically,"0_Envelope1D"or"1_TraceWin".beam_kwargs (
BeamKwargs) – Beam properties.filename (
Path)beam_calc_parameters_factory (
ElementTraceWinParametersFactory)
- Return type:
None
- create(accelerator_id, elts, path_cal, exception, set_of_cavity_settings)[source]
Create an object holding all relatable simulation results.
- Parameters:
accelerator_id (
str) – AssociatedAccelerator.id. Looks like:0000001_Solution.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_cav_params(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".
- _abc_impl = <_abc._abc_data object at 0x7318f9d28400>