simulation_results module
Define a base object to store a multipactor simulation results.
- exception ShapeMismatchError[source]
Bases:
ExceptionRaise error when
populationandtimehave different shapes.
- exception MissingDataError[source]
Bases:
ExceptionError raised when trying to access non-existing data.
- class SimulationResults(id, e_acc, time, population, p_rms=None, plotter=None, trim_trailing=False, period=None, parameters=None, **kwargs)[source]
Bases:
ABCStore a single simulation results.
- Parameters:
- __init__(id, e_acc, time, population, p_rms=None, plotter=None, trim_trailing=False, period=None, parameters=None, **kwargs)[source]
Instantiate, post-process.
- Parameters:
id (
int) – Unique simulation identifier.e_acc (
float) – Accelerating field in \(\mathrm{V/m}\).time (
ndarray) – Time in \(\mathrm{ns}\).population (
ndarray) – Evolution of population with time. Same shape astime.p_rms (
float|None, default:None) – RMS power in \(\mathrm{W}\).plotter (
Plotter|None, default:None) – An object allowing to plot data.trim_trailing (
bool, default:False) – To remove the last simulation points, when the population is 0. Used with SPARK3D (CSVimport) for consistency with CST.period (
float|None, default:None) – RF period in \(\mathrm{ns}\). Mandatory for exponential growth fits.parameters (
dict[str,float|bool|str] |None, default:None) – Additional information on the simulation. Typically, value of magnetic field, number of PIC cells, simulation flags…
- _check_consistent_shapes()[source]
Raise an error if
timeandpopulationhave diff shapes.- Return type:
- fit_alpha(fitting_periods, running_mean=False, log_fit=True, minimum_final_number_of_electrons=0, bounds=([1e-10, -10.0], [inf, 10.0]), initial_values=[0.0, 0.0], **kwargs)[source]
Fit exp growth factor.
- Parameters:
fitting_periods (
int) – Number of periods over which the exp growth is searched. Longer is better, but you do not want to start the fit before the exp growth starts.running_mean (
bool, default:False) – To tell if you want to average the number of particles over one period. It is recommended with CST, but does not bring anything for SPARK3D. The default is False.log_fit (
bool, default:True) – To perform the fit onexp_growth_log()rather thanexp_growth(). The default is True, as it generally shows better convergence.minimum_final_number_of_electrons (
int, default:0) – Under this final number of electrons, we do no bother finding the exp growth factor and set all fit parameters toNaN.bounds (
tuple[list[float],list[float]], default:([1e-10, -10.0], [inf, 10.0])) – Upper bound and lower bound for the two variables: initial number of electrons, exp growth factor.initial_values (list[float], optional) – Initial values for the two variables: initial number of electrons, exp growth factor.
- Return type:
- plot(x, y, plotter=None, label=None, grid=True, axes=None, **kwargs)[source]
Plot
yvsxusingplotter.plot()method.- Parameters:
x (
Union[Literal['id','e_acc','p_rms','alpha'],Literal['time','population','modelled_population']]) – Name of properties to plot.y (
Union[Literal['id','e_acc','p_rms','alpha'],Literal['time','population','modelled_population']]) – Name of properties to plot.plotter (
Plotter|None, default:None) – Object to use for plot. If not provided, we use_plotter.label (
Union[str,Literal['auto'],None], default:None) – If provided, overrides the legend. Useful when several simulations are shown on the same plot. Use the magic keyword"auto"to legend with a short description of current object.grid (
bool, default:True) – If grid should be plotted. Default is True.axes (
Any|None, default:None) – Axes to re-use, if provided. The default is None (plot on new axis).kwargs – Other keyword arguments passed to the
Plotter.plot()method.
- Returns:
Objects created by the
Plotter.plot().- Return type:
Any
- to_pandas(*args)[source]
Concatenate all attribute arrays which name is in
argsto a df.- Parameters:
args (
Union[Literal['id','e_acc','p_rms','alpha'],Literal['time','population','modelled_population']]) – Name of arguments as saved in current objects. Example:"population","time"…- Returns:
Concatenates all desired data.
- Return type:
- Raises:
MissingDataError: – If a string in
argsdoes not correspond to any attribute inself(or if corresponding value isNone).ValueError: – If all the
argsare a single value (float/int/bool).
- _abc_impl = <_abc._abc_data object at 0x7e2c7019b9c0>
- class SimulationResultsFactory(plotter=None, freq_ghz=None, stl_path=None, stl_alpha=None, *args, **kwargs)[source]
Bases:
ABCEasily create
SimulationResults.- Parameters:
- __init__(plotter=None, freq_ghz=None, stl_path=None, stl_alpha=None, *args, **kwargs)[source]
Instantiate object.
- Parameters:
plotter (
Plotter|None, default:None) – Object to create the plots.freq_ghz (
float|None, default:None) – RF frequency in \(\mathrm{GHz}\). Used to compute RF period, which is mandatory for exp growth fitting.stl_path (
str|Path|None, default:None) – Path to theSTLfile holding the 3D structure of the system. The default is None.stl_alpha (
float|None, default:None) – Transparency setting for the mesh.
- _abc_impl = <_abc._abc_data object at 0x7e2c7019ba80>