simulation_results module
Define an object to store SPARK3D simulation results.
- class Spark3DResults(id, e_acc, time, population, p_rms=None, plotter=None, trim_trailing=False, period=None, parameters=None, **kwargs)[source]
Bases:
SimulationResultsStore a single SPARK3D simulation results.
- Parameters:
- 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], minimum_number_of_points=4, min_points_per_period=2, **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.
minimum_number_of_points (
int, default:4) – Minimum number of fitting points; under this limit, a warning is issued. For CST, should be at least 10 or 20. With SPARK3D, there are two points per RF period so a value of 2 or 4 should be enough.min_points_per_period (
int, default:2) – Minimum number of points per period. In SPARK3D, we only have two points per RF period so this number should be lower to avoid unnecessary warnings.
- Return type:
- _abc_impl = <_abc._abc_data object at 0x75607f5ebec0>
- class Spark3DResultsFactory(plotter=None, freq_ghz=None, *args, **kwargs)[source]
Bases:
SimulationResultsFactoryDefine an object to easily instantiate
Spark3DResults.- __init__(plotter=None, freq_ghz=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 – Path to the
STLfile holding the 3D structure of the system. The default is None.stl_alpha – Transparency setting for the mesh.
- from_file(filepath, e_acc, delimiter=None, **kwargs)[source]
Load a
TXTorCSVfile and create associated objects.- Parameters:
filepath (
Path) – Filepath to aTXTorCSVSPARK3D file. SeeSpark3DResultsFactory._from_csv()andSpark3DResultsFactory._from_txt()for information on how to create/where to find these files.e_acc (
ndarray) – The accelerating fields in \(\mathrm{V/m}\).
- Return type:
- _from_txt(filepath, e_acc, delimiter='\\t', **kwargs)[source]
Create several
Spark3DResultsfromtime_results.txt.This file is generally produced with SPARK3D CLI.
TXTfile looks like this:#Sim num Power(W) Time(s) Num.elec.1 100 0 1000 1 100 1 1010 1 100 2 1020 … … … … 2 50 0 1000 2 50 1 900 2 50 2 500 … … … …
It is typically stored in
<project_name>/Results/@Mod1/@ConfGr1/ @EMConfGr1/@MuConf1/region1/signalCW 1/.Todo
Handle malformed files. In particular what happens if simulation numbers are mixed?
- Parameters:
filepath (Path) – Path to the file to load.
e_acc (np.ndarray) – Accelerating field values in \(\mathrm{V/m}\).
delimiter (str, optional) – Delimiter between columns.
- Return type:
- _from_csv(filepath, e_acc, delimiter=' ', **kwargs)[source]
Create several
Spark3DResultsfromtime_results.csv.Right-click on
Multipactor results,Export to CSV. These files are manually produced by the user.CSVfiles look like this:0 1000 1000 1000 1000 1e-9 1010 900 999 1001 2e-9 1020 500 998 1002 3e-9 1040 100 990 1003 4e-9 1050 0 950 1004 ...
There are no headers. The first column holds the time in seconds. Following columns hold the number of electrons for every simulation (one simulation on one column).
Note
In order to be consistent with CST import, we remove the end of the simulations, when the population is 0.
- _abc_impl = <_abc._abc_data object at 0x75607f4c5ac0>