Running Parametric Sweeps and Monte Carlo Tests
Back to RF.Spice A/D Wiki Gateway
Contents
- 1 Using Device & System Parameters as Variables
- 2 User-Defined Parameters
- 3 Parametric Sweep Tests
- 4 Monte Carlo Tests
- 4.1 Choosing the Monte Carlo Variables
- 4.2 Setting Statistical Distribution and Tolerance of Device Parameters
- 4.3 Setting Tolerances from Schematic Editor
- 4.4 Setting Tolerances from Monte Carlo Settings Dialog
- 4.5 Output of a Monte Carlo Simulation
- 4.6 More on Shared Models
- 4.7 Tying Up Parameter Tolerances
Using Device & System Parameters as Variables
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 "Parametric Sweeps and Monte Carlo Tests".
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.
Clicking on the value allows you to edit the value either by typing in a new value and then pressing the "Accept" button (Enter Arrow) or using the slider at the top of the tab to control the value. The "Recenter" button makes the current value the center of the slider. This is handy when you hit the end of the slider's range and want to go further. In this case, clicking on the Recenter button will make the slider's end value the new center which will then allow you to continue modifying the parameter.
Using the Parameters Panel in conjunction with a live Simulation, you can examine how changing a part's values will influence the function of your circuit. Once the simulation is running and the circuit is "Live", take advantage of the Parameters Panel to modify device parameters in real time and see the immediate effects on your circuit's response. The results can be observed either on Virtual Instruments or by enabling Circuit Animation. Please keep in mind that while a simulation is running, modification of device parameters by double clicking on the device itself is not allowed. You will receive a warning message telling you to either stop the simulation first or use the Parameters panel instead.
User-Defined Parameters
RF.Spice A/D allows you to define any number of global parameters that you can use as values for various parts of your circuit. This is done by selecting "User-Define Parameters..." from the Edit Menu. At the top of the User-Define Parameters dialog, there is a list of parameters showing the Name, Description and Value of each parameter. In order to introduce a new parameter, click the "New Parameter" button on the right. A new parameter with the default name "NewParam" is inserted in the table. Change the name of the new parameter as you desire. Then select its type from the "Data Type" drop-down list. The available type options include Number, Flag (Boolean) and String. Then enter a value for your parameter and optionally write a description of it in the box provide. Once you are done with the editing, make sure to click the "Accept Parameter" button to save the changes and make them effective. You can select any parameter from the table and delete it using the "Delete Parameter" button on the right.
Parametric Sweep Tests
Choosing the Sweep Variables
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.
To set up a sweep, select the test you would like to run from the Test Panel in the Toolbox. Make sure you check the middle checkbox in the "Sweep" column of the main Test Panel. Then, click the "Setup" button corresponding to your selected test type to open the Test Setup panel. In lower part of the test setup panel, click on the "Sweep" tab. In the Sweep tab, click "Sweep Setup" button to open up the "Sweep Settings" dialog. The top part of this dialog features five tabs:
- Part Parameters
- Part Model Names
- Model Parameters
- User Parameters
- System Parameters
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.
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
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.
Sweeping Different Models for a Part
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.
Running Multivariable Parametric Sweeps
You can define more than one sweep variable. Simply define all the sweep variables one by one and add them to the "Active Sweep Parameters" table at the bottom of the Sweep Settings dialog. Note that the order of definition of sweep variables determines the hierarchy of the nested sweep loops. The topmost variable will constitute the outermost sweep loop, and the bottommost sweep variable will represent the innermost sweep loop. You can change the order of the sweep variables using the "Move Up" and "Move Down" buttons located on the right of the list table. Select a variable name from the table and move its row up or down in the list. You can also delete a sweep variable from the active list using the "Delete" button. Click on the "Preview Scenario Array" to see what your sweep test will look like including all the variables and their respective values.
![]() |
Caution should be exercised in setting up multilevel sweeps as a large number of steps combined with long Test runs can result in very long computation times. |
Output of a Parametric Sweep
The results of a Parametric Sweep Test can be displayed either in a 2D graph or in a table or both. The procedure to define your data plots is very similar to a basic (single-run) test. This is done in the "2D Output" section of the "Sweep" tab at the bottom of the test setup panel. Check either the "Graph" or "Table" or both checkboxes and click one of the buttons labeled "Preset Graph Plots" or "Preset Table Plots" to open up the "Edit Plot List" dialog. The main difference with a basic test graph or table is that the sweep results appear as a family of Cartesian curves on the 2D graph or a set of data columns in a table. Each individual curve or data column corresponds to one sample of the sweep variable. These are differentiated by bracketed indices like variable_name[i], i = 0,1,2, ...
Monte Carlo Tests
Choosing the Monte Carlo Variables
Like Parametric Sweeps, Monte Carlo analysis can be run in conjunction with most RF.Spice A/D tests. Just select the test type you wish to perform from the Test Panel and make sure you check the rightmost checkbox in the "M.C." column of the main Test Panel. Then, click the "Setup" button corresponding to your selected test type to open the Test Setup panel. In lower part of the test setup panel, click on the "Monte Carlo" tab. In the Monte Carlo tab, click "Monte Carlo Setup" button to open up the "Monte Carlo Settings" dialog. The top part of this dialog features five tabs:
- Part Parameters
- Model Parameters
- User Parameters
- System Parameters
- Lot Parameters
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.
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.
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.
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.
Output of a Monte Carlo Simulation
The results of a Monte Carlo Test can be displayed either in a 2D graph or in the form of a histogram or both. A Histogram displays the distribution frequency of the results over the parameter range. Each graph type is set up under the respective tab in the Monte Carlo setup section of the Test Setup Panel. If you specify "2D Output", the results will appear as a set of Cartesian curves on the 2D graph. If you specify "Histogram", the results will appear as a bar chart.
Most active devices like a diode or a transistor have a set of shared model parameters and a model name that identifies that set of shared model parameters. If you add two default bipolar junction transistors to a circuit, then by default, they will share the same model and model parameters. With shared models, the varying parameters will share the same value even though they belong to more than one part. For example, if your circuit has two bipolar junction transistors that share the same model, and if you set the tolerance of the "bf" parameter to 5% and its value to 100, and then you run a Monte Carlo DC Bias test (operating point analysis), the two transistors will have identical bf’s for each iteration of the Monte Carlo analysis.
There is a way to prevent models from being shared when you create them. Open the Schematic Options Dialog from the Edit Menu of the Schematic Editor, then go to its General page/tab and Check the checkbox labeled “New devices have unique models” at the top of the page. Once a part is placed, there is also a way to make it unique. Double-click on the part's symbol to open its property dialog, then click on the “Make Model Unique” button. The model will be made unique if it was previously shared. Resistors, capacitors, and inductors are special cases. With these types of devices do not share model parameters as you place them in the circuit. However, the semiconductor or temperature-dependent versions of these devices do share models and behave like transistors as discussed above.
Tying Up Parameter Tolerances
When you have more than one parameter being offset by a tolerance, sometimes you may want them to move together, and sometimes you may want them to move distinctly. If the former case is desired, there is another way to tie together the tolerances among various parts parameters. This is with the “Group” number. The group number can be set and assigned both from the "Monte Carlo Tolerance Settings Dialog" accessible from the Schematic Editor and from the "Parameter Distribution Settings Dialog" accessible from the Monte Carlo Setting dialog. If two parameters share the same group number, then the number used to scale the deviation will be identical. For example, you could use two resistors, the first one with a tolerance of 10% and a group number of one (1), and the second with a tolerance of 5% and a group number of one (1). So both part parameters have the same group number. Then, when you run the Monte Carlo simulation, the second resistor will deviate from the base (mean) value by one-half of the amount of deviation of the first resistor. The group numbers work across devices, too.