Changes

Jump to: navigation, search

Running Parametric Sweeps and Monte Carlo Tests

202 bytes added, 15:51, 10 November 2016
/* Monte Carlo Tests */
== Using Device & System Parameters as Variables ==
[[File:b2MAN_Fig4.png|thumb|220px|RF.Spice A/D Circuit Parameters Tab.]]Each part in [[RF.Spice A/D]] has one or more parameters. Most of these parameters have numeric values like the resistance of a resistor, or the capacitance of a capacitor, or the forward beta (bf) of a bipolar junction transistor. Some other parameters might be Boolean, that is, they take only binary values: "True" of "False". There are also string parameters such as the name or label of a part. Most of device parameters can be changed during a simulation. Besides device parameters, there are also system parameters like temperature, time of a transient simulation or frequency of an AC analysis, or SPICE simulation parameters. You can also define your own parameters and use them as the values for other parameters. Device and system parameters can be varied during a "Sweep" or "Monte Carlo" test. To find out more about these types of tests, please refer to the section on "  <table><tr><td> [[Parametric Sweeps and Monte Carlo TestsFile:b2MAN_Fig4.png|thumb|left|250px|RF.Spice A/D Circuit Parameters Tab.]]". </td></tr></table>
You can also vary parameters in real time during a live simulation. Oddly named but quite useful, the Parameters tab of the Toolbox presents a small spreadsheet-like grid which lists all the parts in the circuit available for scrutiny. This includes only those parts which allow value changes such as resistors, capacitors, current and voltage sources, and inductors, but not the ground. The part’s name is displayed in the left cell, while its value is displayed in the right cell. Use the radio buttons labeled "All", "Some" and "Few" (default) to expand to shrink the list of displayed devices and properties. The "Few" button lists just the primitive devices and their values, such as a resistor's resistance, inductor's inductance, and so forth. The "Some" button will add more sources and their properties, and the "All" button lists every device and parameter that is accessible in your project.
<tr>
<td>
[[File:b2MAN_Fig227.png|thumb|left|400px550px|The User-Defined Parameters dialog.]]
</td>
</tr>
===Choosing the Sweep Variables===
[[File:b2MAN_Fig214.png|thumb|480px|RF.Spice's Sweep Settings Dialog.]]
Most [[RF.Spice A/D]] Tests come with an option to "Sweep" or incrementally step a parameter over the entire run of the test. In other words, you can vary a particular parameter for each run of the test. For instance, you can step a particular resistor's resistance from 1K to 10K by increments of 2K during a Transient Test. When you run the transient test, the first run will set the resistor's value to 1K. The second run will set the resistor's value to 3K, since the increment was set at 2K. Each step of the resistor's value will result in a transient test. Therefore, the Transient Sweep test will be run 5 times, with resistor's values of 1K, 3K, 5K, 7K, and 9K. The combined results will be displayed in a graph.
Select the tab that contains the parameter you wish to vary. The Part Parameters tab contains all the available parts and their parameters. The Part Model Names tab lists the simulation models associated with all the parts. The Model Parameters tab lists all the available internal parameters of the simulation models in your circuit. The User Parameters tab lists all the user-defined parameters that you have already defined in your project. The System Parameters contains all the parameters found in the SPICE Simulation Options dialog. There are three radio buttons at the bottom of the list table: All, Some and Few. These buttons control how many parameters should appear in these lists. If you cannot find a particular parameter you are looking for, make sure to select the "All" button.
 
<table>
<tr>
<td>
[[File:b2MAN_Fig214.png|thumb|left|720px|RF.Spice's Sweep Settings Dialog.]]
</td>
</tr>
</table>
===Setting Up a Uniform Sweep===
To select a parameter to sweep, click on the parameter's name in the list table to select and highlight it. The name of the selected parameter shows up in the "Parameter Setup" section of the dialog. Initially, it is designated as "Not a Sweep Parameter" by a respective radio button. There are two other radio buttons to change this designation: "Sweep Parameter" and "Values List". Choose Sweep Parameter if you want to vary the parameter at equal steps by linear, decade or octave scales. With a linear scale, the Start, Stop, and Step Size define the first value, the maximum value and the increment to each step. The above example will step the resistance values at 1K, 3K, 5K, 7K, and 9K, for a total of 5 steps. Note that 10K is actually never reached since that the last step was 9K and stepping by 2K would result in 11K, which is larger than the maximum step value specified. After you enter these values, click the button labeled "Accept Changes". The selected parameter and its range description are added to the "Active Sweep [[Parameters]] List" at the bottom of the dialog. This table also shows the total number of test runs for each sweep parameter.
===Setting Up a Discrete Value Set===
[[File:b2MAN_Fig222.png|thumb|440px|RF.Spice's Select Model dialog.]]
In many cases, a certain parameter may take certain discrete values. Examples of these are the commercial resistor or capacitor part values. In such cases, rather than running a uniform parameter sweep, you may want to set your sweep variable to take a set of discrete values. To do so, after you select your sweep parameter, select the "Values List" radio button in the "Parameter Setup" section of the Sweep Settings Dialog. An edit box appears under the radio button, where you can enter the set of values for your sweep variable. You can separate the values by commas. You can also load the values from a text file using the button labeled "Load From File". The data file can be a very simple file just containing the numeric values separated by spaces or commas or one value per line.
<tr>
<td>
[[File:b2MAN_Fig222.png|thumb|left|550px|RF.Spice's Select Model dialog.]]</td></tr></table> <table><tr><td>[[File:b2MAN_Fig223.png|thumb|480pxleft|640px|Setting a device model as the sweep variable.]]
</td>
</tr>
===Sweeping Different Models for a Part===
[[File:b2MAN_Fig215.png|thumb|480px|A scenario array showing the combination of sweep variable values.]]
It is possible to sweep different models for a certain device or part in your circuit and see the differences in the response of your circuit. For example, you can try out different BJT or MOSFET models, e.g. from different manufacturers, in a amplifier circuit. To sweep models, open up the Sweep Settings dialog, and go to its "Part Model Names" tab. Select a device or model you want to sweep. In the "Parameter Setup" section of the dialog, you will notice that the third radio button, which was originally labeled "Values List", has not changed to "Model List". The edit box underneath this radio button is where you will list all the models to sweep. In the box labeled "Original Model", you will see the current model associated with your selected part. You can add this model to the sweep using the "Add Original Model" button. Click on the "Add New Model" button to open up the "Select Model Dialog". This dialog shows a list of all the available models that match with your selected part. Choose one from the list and click the "Select Model" button to close this dialog and return to the Sweep Settings dialog. You will see that the new model has been added to the model list. You may also delete a model from the list using the "Remove Model" button. Once your model list is complete, press the "Accept Changes" button to finalize your "Model" sweep variable. During each run of the sweep simulation, the designated models are replaced for the selected part one by one.
 
<table>
<tr>
<td>
[[File:b2MAN_Fig215.png|thumb|left|640px|A scenario array showing the combination of sweep variable values.]]
</td>
</tr>
</table>
===Running Multivariable Parametric Sweeps===
<tr>
<td>
[[File:b2MAN_Fig216.png|thumb|640pxleft|720px|The output graph of a parametric sweep.]]
</td>
</tr>
==Monte Carlo Tests==
 
[[File:b2MAN_Fig217.png|thumb|480px|RF.Spice's Monte Carlo Settings Dialog.]]
===Choosing the Monte Carlo Variables===
The parameters listed under each tab are similar to those of the Sweep Settings Dialog, except for the last tab called "Lot Parameters". You can set the number of Monte Carlo runs (i.e. the number of times to randomly vary a chosen parameter) in the box labeled "No. Iterations". For each run, a set of device parameters is assigned randomly according to the parameter's range and distribution type.
 
<table>
<tr>
<td>
[[File:b2MAN_Fig217.png|thumb|left|720px|RF.Spice's Monte Carlo Settings Dialog.]]
</td>
</tr>
</table>
===Setting Statistical Distribution and Tolerance of Device Parameters===
[[RF.Spice A/D]] offers two different ways of settings the statistical distribution and tolerance of various device parameters: (1) from the Schematic Editor, and (2) from the Monte Carlo Settings Dialog. The main types of distributions are Gaussian (Normal) and Uniform. The Gaussian distribution is the bell-shaped distribution concentrated around a mean value and defined by a standard variation (sigma). The Uniform distribution gives any value in the specified range an equal probability. If you specify "Tolerance" as a percentage, then it will be interpreted as a percentage boundary on either side of the individual parameter's given value. The given value is assumed to be the statistical mean. When running a Monte Carlo simulation, at each simulation iteration, parameters are set to values that are different than their specified values according to their tolerances.
 
[[File:b2MAN_Fig221.png|thumb|350px|The Monte Carlo Tolerance Settings dialog accessible from Schematic Editor.]]
===Setting Tolerances from Schematic Editor===
You can set the statistical distributions and tolerances for the resistor values, capacitor values and inductor values as well as all the shared properties of other devices from the Schematic Editor. To do so, open the property dialog of the part by double-clicking its symbol in the schematic editor. If a parameter is available for settings its tolerance, you will see a button labeled "Set Tolerance..." in the property dialog. In the case of active devices with shared process models, you have to choose a parameter from the list and this button appears above the "Accept Value" button. Clicking on the Set Tolerance button, open up the "Monte Carlo Tolerance Settings Dialog". There are two rows of boxes labeled "Tolerance", "Is Percent?", "Distribution" and "Group". The top row is for the selected part's instance in your circuit, while the bottom row is for the lot the part belongs to. Using these boxes you can set the value of Tolerance and whether it is expressed in percent or as an absolute value. You can also assign a statistical distribution to the parameter and finally associate it with a group. More will be discussed later in this section about part groups.
<table><tr><td>[[File:b2MAN_Fig218b2MAN_Fig221.png|thumb|370pxleft|480px|The Parameter Distribution Monte Carlo Tolerance Settings dialog accessible from Monte Carlo Settings DialogSchematic Editor.]]</td></tr></table>
===Setting Tolerances from Monte Carlo Settings Dialog===
To select and set up the statistical properties of parameters from the Monte Carlo Settings Dialog, select the appropriate parameter from the one of the lists in the available tabs. Resistor and capacitor distributions are set through their own dedicated buttons because Monte Carlo tolerance is built into their models and requires its own setup. For other devices, use the "Edit Distribution" button to set up each particular parameter for Monte Carlo analysis. This opens up the "Parameter Distribution Settings Dialog". The name of the Part/Parameter that you are setting the distribution for is displayed in the "Parameter" box. Make sure to check the checkbox labeled "Override Schematic Value". Use the "Random Type" drop-down box to set the distribution type. The "random Type" drop-down list is set to "Fixed" by default, meaning that the selected parameter is currently deterministic. Change the distribution type to "Uniform" or "Gaussian (Normal". You can also choose the "Discrete Value List" option. In that case, either enter the discrete values manually in the edit box provided or use the "Load From File" button to import the numeric values from a text file. Enter the tolerance in the box labeled "Std Deviation" (or sigma) and indicate if it is expressed as a percentage. You can also associate the percentage with multiple sigmas. Enter a value larger than one in the box labeled "# Std Deviations", and the sigma value is adjusted accordingly. You can set "Max Cutoff" and "Min Cutoff" values for the parameter. However, you need to enable these options. In that case, if the designated random distribution generates a parameter value that fall below the Min Cutoff or above the Max Cutoff, it will be eliminated, and a new legitimate value will be generated.
<table>
<tr>
<td>
[[File:b2MAN_Fig218.png|thumb|left|480px|The Parameter Distribution Settings dialog accessible from Monte Carlo Settings Dialog.]]
</td>
</tr>
</table>
===Output of a Monte Carlo Simulation===
<tr>
<td>
[[File:b2MAN_Fig220.png|thumb|640pxleft|720px|The histogram output of a Monte Carlo test.]]
</td>
</tr>
28,333
edits