# Monte Carlo analysis utility

The Monte Carlo analysis tool allows users to run extensive Monte Carlo analysis, sweeping across multiple parameters. This can be useful for assessing statistical variations of circuit elements on overall circuit performance, as well as the effects of variations in component-level simulations. User can specify the parameters to vary and the variation includes "Process" variation, "Mismatch" variation or both. The analyzed parameters can also be defined in a .lib file and if the same element appears several times in a circuit, they could be grouped up as the same "model" and have the same "Process" variation. The correlation between different parameters can also be defined. The available variational distribution types in the tool are: Uniform, Gaussian, Lognormal, Truncated Gaussian, Truncated lognormal, Discrete and Pearson IV.

The tool runs a number of trials with parameters values generated according to a specified distribution and returns the analysis results include the dispersive statistics and probability density function, etc. The tool can also display histograms showing the distribution of parameter values used and the distribution of results from the trials.

This page describes how to run a Monte Carlo analysis task using an example finite impulse response filter circuit composed of cascaded Mach-Zehnder interferometers. See Optical filters for more information about this circuit.

**In this article:**

- Monte Carlo properties
- Creating the Monte Carlo analysis project
- Using the library file
- Running the Monte Carlo analysis
- Viewing the results

## Monte Carlo properties

- NAME: Monte Carlo analysis name.

### Configuration

- NUMBER OF TRIALS: The number of trials to run.
- INDIVIDUAL TRIAL: Check box to indicate to run the specified individual trial or not.
- SEED: Check box to indicate use specified seed or not.
- VARIATION: Drop down menu to choose the variations to run.
- BATCH SIZE: The number of trails run in each batch.
- UNBOUNDED: Check box to unbound the batch size; when checked, the total number of trials will be ran in one batch.

### Parameters

- NAME: A user specified name for the parameter. Will appear in results dataset.
- PARAMETER: Property to do the Monte Carlo analysis.
- VALUE: Mean value of the property.
- DISTRIBUTION: Parameter statistical distribution settings.
- ADD: Add another parameter to the table.
- REMOVE: Remove a parameter from the table.

### Libraries

- NAME: A user specified name for the library.
- LIBRARY: The .lib file that defines the model's variation properties.
- VARIANT: Drop down menu to choose the variant to analyze.
- ADD: Add another library to the table.
- REMOVE: Remove a library from the table.

Note: This feature is only available in INTERCONNECT. |

### Models

- NAME: A user specified name for the model.
- MODEL: The model to do the analysis.
- VALUE: Mean value of the model property.
- PROCESS: Process variation. This value is the same for all the model elements.
- MISMATCH: Mismatch variation.
- ADD: Add another model to the table.
- REMOVE: Remove a model from the table.

Note: This feature is only available in INTERCONNECT. The "model" property is in the element's "General" setting tab. All the elements have the same "model" are considered to have identical process hence have the same process variation. Select a "model" will select all the elements have this "model" name. |

### Correlations

- NAME: A user specified name for the correlation.
- PARAMETERS: All parameters listed in the "Master table". The "Correlation Selector" allows user to select the parameters that are correlated.
- VALUE: Correlation value, in the range [-1, 1].
- ADD: Add another correlation to the table.
- REMOVE: Remove a correlation from the table.

### Master table

- NAME: The parameter's name.
- PARAMETER: The property to do the analysis.
- VALUE: Mean value of the property.
- DESCRIPTION: Process and Mismatch variation description.

Note: All the parameters that defined in the previous tabs will be listed in the "Master table". The "Master table" is not editable. |

### Results

- NAME: A user specified name for the result. Will appear in results dataset.
- RESULT: Result to collect.
- ESTIMATION: If "true" is selected in the Estimation field, the trial will be considered a pass if the result falls within the specified min/max range. If there is more than one result with a yield estimate, the final yield percentage will be the percent of trials where all of the results fall within the specified ranges.
- MIN/MAX: Min/max range when the Estimation property is set to True.
- ADD: Add another result to the table.
- REMOVE: Remove a result from the table.

## Creating the Monte Carlo analysis project

This Monte Carlo analysis is defined based on the project file run_monte_carlo.icp. Please download this file and follow the following steps to create the Monte Carlo analysis.

Make sure that you can see the Optimizations and Sweeps window. This window can be opened by going into the top menu under View->Windows and selecting Optimizations and Sweeps, or by right-clicking on the upper menu bar for a list of windows and selecting Optimizations and Sweeps from the list.

Click the "Create New Monte Carlo Analysis" button in the Optimizations and Sweeps window to create a new Monte Carlo analysis task. Click the Edit button to open the Edit Monte Carlo analysis dialog window.

Once the Monte Carlo analysis object is open, set the Number of trials to 50. In the "Parameters" tab, add a parameter (button on the right-hand side of the Properties section) and change the name of the property to "cpl_2". Double-cick on the Parameter field and browse the pulldown menu. Select the “coupling coefficient 1” property of the WC2 coupler. Set its distribution type to be "Lognormal" and variation to be 0.02.

Add another parameter for "coupling coefficient 1" of WC3 and name it as "cpl_3". Set its distribution type to be "Uniform" and variation to be 0.04.

In the "Models" tab, add a new model and name it as "wgd_model". Double click on the "Model" field and select the "WGD" model "group index 1". Double click on the "Process" field and set the distribution type to be "Uniform" with 0.12 variation. Double click on the "Mismatch" field and set the distribution type to be "Gaussian" with 0.1 variation.

In the "Correlations" tab, add a new correlation and name it as "wgd_corr". Double click on the "Parameters" field, from the "Master properties" table, select the "SW" entries and add them to the "Selections" table. Set the correlation "Value" to 0.95.

Click on the "Ok" button and go back to the "Correlations" tab.

In the "Master table" tab, all the properties defined in the previous tabs will be listed. Please note that, the "Master table" is not editable; any change of the parameters should be made in the corresponding previous tabs.

Add a result to record using the button on the right-hand side of the Results section of the window and change the name of the result to "fsr". Double-click on the Result field of the result to browse available results and select the “free spectral range” result from input 2 of the Optical Network Analyzer. Double-click on the estimation field of the result and set this to “true”. Next, select the minimum and maximum values of the yield range by setting the value in the Min field to 1e11, and the value in the Max field to 2e11. Next, add two more properties: the bandwidth and the gain from input 1 of the Optical Network analyzer, and set Estimation field to “false” for these two properties. The final yield analysis window should look like the following:

Click OK to accept all settings, and return to the main Optimizations and Sweeps window.

## Using the library file

This option of using the library file to define the model's variation properties is only available in INTERCONNECT. User can define several sets of variations for different models in the same .lib file and choose one of the variation methods in the Monte Carlo analysis tab. Using the library file can really facilitate the interoperability between INTERCONNECT and third party EDA tools, where the .lib file can be loaded directly as a model library during the simulation and it is subsequently included in the netlist for onward simulation into INTERCONNECT. Since INTERCONNECT version 2019a, we introduced protected properties and they can also be used in Monte Carlo .lib files. For more information on varying protected properties in Monte Carlo analysis, please see the page Custom Element with user defined properties.

The "model" property is in the element's "General" setting tab. Primitive elements have empty "model" properties so user has to pre-set their "model"s to be able to define their variations in the .lib file. Elements come from compact model libraries generally have pre-defined "model" properties that can be used directly. All the elements have the same "model" name will follow the same parameter settings and variation settings in the .lib file.

Following is an example wgd.lib file that defines two sets of variations for the "group index 1" property of the elements with the "WGD" model name.

.LIB sigma_1

.LOTGROUP group_a=(normal,0.1)

.MODEL WGD "group index 1"=8.05894 lotgroup=group_a library=""

.ENDL

.LIB sigma_2

.LOTGROUP group_a=(uniform,0.2)

.MODEL WGD "group index 1"=8.05894 lotgroup=group_a library=""

.ENDL

This file can then be loaded to the Monte Carlo analysis "Libraries" tab and the variation method can be chosen from the "Variant" drop down menu. In this example, the variation method "sigma_1" is chosen.

### .lib file syntax

Model sytax (following is the standard Eldo simulator command syntax)

.MODEL MNAME TYPE [PAR=VAL]

.LOTGROUP group_name[/distrib_type]=val[%]

## Running the Monte Carlo analysis

To run the Monte Carlo analysis, select the Monte Carlo analysis task in the Optimizations and Sweeps window and click the run button.

The Monte Carlo analysis runs in UI non-updating mode by default. User can change this setting in the INTERCONNECT Options/Preferences window by un-checking the "Disable UI updates when running sweeps" option in the Preferences tab.

## Viewing the results

The Monte Carlo analysis runs the trials in batches of the value of "Batch size" or less and automatically updates the following window after each batch of trials. After the yield analysis has been run, the parameters and results are listed at the right-hand side of the window. Selecting a result will generate a histogram with 10 bins showing the distribution of values of the result. If the estimation property of the result was set to true, then the minimum and maximum values specified by the user are also indicated in the histogram.

The log at the bottom of the window shows the calculated yield percentage which corresponds to the percentage of trials where all of the results fall within the specified yield estimate ranges.

Selecting a parameter generates a histogram for that parameter.

Selecting both a parameter and result generates a plot showing the value of the parameter versus and result for each trial and the yield estimate range.

Close the "Monte Carlo analysis status" window and click on the Monte Carlo task in the Optimization and Sweeps window, all the calculated results will also be listed in the "Result View" window.

The probability density function of the results are also calculated. The following figure is the the "fsr" result histogram and probability density function plot in one figure:

Monte Carlo analysis results can also be obtained in the script environment with the command getsweepdata, which is similar to the command getdata. The name of each data member is the Name column that you specified when adding the parameters and results, in this case the result is "fsr". For example, the following 2 lines of script will plot the histogram showing the distribution of free spectral range values.

yfsr=getsweepdata("yield ng","fsr");

histc(yfsr);