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: SimulationResults

Store 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 on exp_growth_log() rather than exp_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 to NaN.

  • 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:

None

_abc_impl = <_abc._abc_data object at 0x72ae9639bec0>
class Spark3DResultsFactory(plotter=None, freq_ghz=None, *args, **kwargs)[source]

Bases: SimulationResultsFactory

Define an object to easily instantiate Spark3DResults.

Parameters:
__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 STL file 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 TXT or CSV file and create associated objects.

Parameters:
Return type:

list[Spark3DResults]

_from_txt(filepath, e_acc, delimiter='\\t', **kwargs)[source]

Create several Spark3DResults from time_results.txt.

This file is generally produced with SPARK3D CLI. TXT file 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:

list[Spark3DResults]

_from_csv(filepath, e_acc, delimiter=' ', **kwargs)[source]

Create several Spark3DResults from time_results.csv.

Right-click on Multipactor results, Export to CSV. These files are manually produced by the user. CSV files 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.

Parameters:
  • filepath (Path) – Path to the file to load.

  • e_acc (ndarray) – Accelerating field values in \(\mathrm{V/m}\).

  • delimiter (str | None, default: ' ') – Delimiter between columns.

Return type:

list[Spark3DResults]

_abc_impl = <_abc._abc_data object at 0x72ae952c6280>