monte_carlo_global

circuit_analyzer.all.monte_carlo_global(circuit_model, wavelengths, parameter_distributions, parallel=False, parallel_option='number', save_path=None)

Run a monte carlo simulation, varying CompactModel parameters globally using a set of parameter_distributions.

The use case is to test your circuit under global changes (i.e., n_eff, temperature).

This method modifies all parameters of all CompactModels globally. This happens name-based. For instance, if you provide n_eff, this will modify the n_eff parameter of all CompactModel instances that can be found.

Parameters:
circuit_model: CircuitModel

IPKISS CircuitModel used in the simulation.

wavelengths: array-like

An array of wavelengths, for instance: np.linspace(1.54, 1.56, 1001).

parameter_distributions: dict

Dictionary mapping parameters to distributions.

parallel: bool, optional

Parallelize the calculations to potentially reduce the simulation time.

parallel_option: str

String of what to parallelize, either over ‘wavelengths’ or over the ‘number’ of simulations. Options are ‘wavelengths’ or ‘number’.

save_path: str/path, optional

Path where the save file will be stored, for instance: save_path = “simulation_results.data”.

Returns:
an array of S matrices, one S matrix per sampling.

Examples

>>> import circuit_analyzer.all as ca
>>> cell = MZI()
>>> cm = cell.CircuitModel()
>>>
>>> wavelengths = np.linspace(1.5, 1.6, 501)
>>>
>>> distribution = {
>>>     "n_eff": ca.NormalDistribution(
>>>         mu=2.4,
>>>         sigma=0.001,
>>>         a=2.397,
>>>         b=2.403,
>>>         sample_size=80,
>>>         name="n_eff",
>>>         seed=0,
>>>     ),
>>> }
>>> with ca.setup('/path/to/configuration'):
>>>     smats = ca.monte_carlo_global(
>>>         circuit_model=cm,
>>>         wavelengths=wavelengths,
>>>         parameter_distributions=distribution,
>>>         parallel=False,
>>>         save_path = "simulation_results.data"
>>>     )