3.2 SIMPLIS Monte Carlo Analysis

The SIMPLIS Monte Carlo analysis allows you to delve further into a design and see how the design responds to statistical parameter variation. Multiple parameters can also be matched, where two parameter values will track each other every simulation run. Finally, the Monte Carlo log file outputs the actual parameter values used in the simulation and the seed value so that simulation can be repeated.

To download the examples for Module 3, click Module_3_Examples.zip

In this topic:

Key Concepts

This topic addresses the following key concepts:

  • Parameter values can be varied using the statistical distribution functions Gauss(), GaussTrunc(), Unif(), and Wc().
  • Multiple parameter values can be matched.
  • As with the SIMPLIS Multi-Step Analysis, SIMPLIS can use multiple processor cores to speed up a Monte Carlo simulation.
  • You can generate histograms for any scalar measurement, such as the average value of the output voltage, the peak current in a MOSFET, etc.

What You Will Learn

In this topic, you will learn the following:

  • How to setup a SIMPLIS Monte Carlo Analysis.
  • How to apply the Gauss(), Unif(), and Wc() probability distribution functions to vary parameter values.
  • How to match the percentage variation of two or more parameter values.
  • How multiple processor cores can be used to reduce the time required to execute a Monte Carlo simulation.
  • How to plot histograms.
  • How Monte Carlo seed numbers are generated.
  • How to find the seed number for a simulation and how you can repeat a simulation with a known seed number.

Getting Started

  1. Open the schematic 3.1_SelfOscillatingConverter_POP.sxsch.
  2. From the schematic menu, select Monte Carlo > Setup Monte Carlo... .
    Result: The Define SIMPLIS Monte Carlo Analysis dialog opens, displaying the Monte Carlo analysis parameters.
  3. Click Run.
    Result: The SIMPLIS Monte Carlo Analysis executes and the waveform viewer opens with the curves from the 4 Monte Carlo steps:

Discussion

The SIMPLIS Monte Carlo Analysis is similar to the SIMPLIS Multi-Step Analysis except instead of stepping a parameter, the Monte Carlo seed value is stepped. The seed value is used to determine the values of each statistical distribution function used in the design. If no statistical distribution functions are used in the circuit, each seed value will produce identical simulation results.

Statistical Distribution Functions

There are three statistical distribution functions for use in the SIMPLIS Monte Carlo Analysis, Gauss(), GaussTrunc(), Unif(), and Wc(). Each of these functions has a different numerical return value when the function is called. The table and histograms pictured below describe each function. The histograms were generated with tol=0.1, or 10%, a mean value of 1, with 10,000 steps (runs), and 50 histogram bins.

Function Meaning Histogram
Gauss(tol)

Gaussian. Returns a random number with a mean of 1.0 and a standard deviation of tol/3. Random values have a Gaussian or Normal distribution.

Important: The Gauss() function can return values greater than (1 + tol) and less than (1 - tol). This becomes particularly important when you are using a large tolerance, as the return value may be outside of a reasonable range. To use a truncated Gaussian distribution, see GaussTrunc() below.
GaussTrunc(tol)

Truncated Gaussian. As with Gauss() but values greater than (1 + tol) and less than (1 - tol) are rejected, and the program picks another random number inside the Gaussian distribution.

Unif(tol) Uniform. Returns a random value in the range 1.0 +/- tol with a uniform distribution.
WC(tol) Worst-Case. Returns either 1.0-tol or 1.0+tol chosen at random.

Assigning Statistical Distribution Functions to Component Values

You assign statistical distribution functions to component values like any other parametrized value. The statistical distribution function and the nominal value must be enclosed in the curly braces {}, indicating the value is an expression to be evaluated. For example, a 1kΩ, 5% resistor with a Gaussian distribution was a value of:

{1k*Gauss(0.05)}

For each Monte Carlo step, the Gauss(0.05) function will return a value within a Gaussian distribution, which is then multiplied by the nominal value and the resistor is assigned this numerical result. In the next exercise you will edit the value of the input voltage source, V1 to include a statistical distribution.

Exercise #1: Assign Uniform Distribution to the Input Source V1

  1. Select the input voltage source V1.
    Result: The symbol changes from red to blue indicating the symbol is selected.
  2. Use the keyboard shortcut F7 or double-click to open the Edit DC Source value editing dialog.
    Result: The Edit DC Source dialog opens:
  3. Enter the uniform distribution: {Vin*Unif(0.0333)}
    Result: The configured dialog should appear as follows:
  4. Click Ok.
    Result: The property value for the input voltage changes to the uniform distribution of 310V +/- 3.33%.
  5. From the schematic menu, select Monte Carlo > Run Monte Carlo
    Result: The SIMPLIS Monte Carlo Analysis executes and the waveform viewer opens with the curves from the original 4 steps with a constant Input voltage, and the additional 4 steps from the second Monte Carlo Analysis with input voltage variation. The original curves are displayed as dotted lines.

Assigning Matched Statistical Distributions to Component Values

There may be times when you want multiple component values to match or track each other. In the SIMPLIS Monte Carlo analysis, this is accomplished by first assigning a variable statement to depend on a statistical distribution function, then using that variable to parametrize the individual matching components. This "master" variable is evaluated once - from then on, the value is constant. This value is then used to make other parameter values match each other.

One application for matched parameters is for PWL inductors, such as L4 in this example circuit. This inductor is used to model the magnetizing inductance of the transformer including saturation effects. In the next exercise you will verify that the inductance of each segment of the inductor L4 is varied in proportion to a value taken from a Gaussian distribution function.

Exercise #2: Verify L4 Values

  1. Double click on L4.
    Result: The Define PWL Inductor: L4 dialog opens:
  2. Note that each Flux Linkage value is multiplied by a constant value L4_Tol. Since the Flux Linkage values are the "y-axis" values, and the slope of each PWL segment represents the inductance of that segment, the inductance of every PWL segment changes by the same percentage.
  3. Click Cancel on the Define PWL Inductor: L4 dialog.
  4. Press F11 to open the command (F11) window. Scroll down to where the L4_Tol is defined:
    .rvar L4_Tol={Gauss(0.20)}
    { '*' }
    { '*' } L4's tolerance : {L4_Tol}
    { '*' }
    Note: See the .RVAR pre-processor statement section for more information.
    The first line assigns the return value of the Gauss(0.20) function to the variable L4_Tol, which is in turn, used to parametrize each y-axis point for L4. Note that the nominal return value of the Gauss() function is 1.0, so adding the tolerance does NOT shift the nominal value. The other three lines were purposely placed in the F11 window to allow us to easily see the value returned by the Gauss(0.20) function. Each line is a comment, with the middle line also displaying the value of L4_Tol.
  5. As you did in section 3.0.2 What Actual Device is Simulated in SIMPLIS?, you look in the deck file to ascertain exactly what values are used for L4_Tol, and the PWL inductor L4. From the menu bar, select Simulator > Edit Netlist (after preprocess) .
    Result: the SIMPLIS Deck file opens in the netlist editor.
  6. To search for the L4 tolerance comment line:
    1. Use the shortcut key Ctrl+F to open the search dialog.
    2. Type L4's
    3. Click on the Find Next button.
      Result: The deck file scrolls to line # 13 where the debug comment is located:
  7. Finally, to search for the actual L4 device instantiation line:
    1. Use the shortcut key Ctrl+F to open the search dialog.
    2. Type !L$L4
    3. Click on the Find Next button three times.
      Result: The deck file scrolls to line # 49 where the L4 instantiation and its .MODEL line are located:

Piecewise Linear Inductors, such as L4 in this example, are implemented with a .MODEL statement, which in this case, starts on line #50. The PWL points are listed as X,Y pairs starting at X0 and Y0. Notice the X values have the same numerical values defined in the dialog. The Y-values are all multiplied by the constant value L4_Tol. The L4_Tol is constant because the value is evaluated once per Monte Carlo run, and from that point onwards, the same constant value is used in the expressions for L4_Tol. The value of L4_Tol will almost certainly be different for the next Monte Carlo simulation step.

The value of the L4_Tol variable is 1.0696640600968, which represents a 6.97% increase in inductance values. Calculating the change in inductance is left as an independent study exercise.

.RVAR pre-processor statement

The .RVAR statement works the same way as the .VAR statement except:
  1. Its value will be logged directly in the Monte Carlo log file.
  2. Expressions that use its value (such as L4 above) will not be logged in the Monte Carlo log file.

SIMPLIS Multi-Core Capability

As with the SIMPLIS_Multi Step Analysis the SIMetrix/SIMPLIS Pro and Elite licenses can use multiple processor cores to simulate the Monte Carlo steps in parallel.

Using multiple cores allows multiple step values to be simultaneously simulated. The number of cores allowed by the licenses are:
License Number of Physical Cores
Pro 4
Elite 16

In addition to the maximum number of cores allowed by your license, you are obviously limited by the number of cores your computer has. For this limitation, SIMetrix/SIMPLIS only uses the physical cores, not the hyper-threaded cores. In the next exercise you will run a multi-core, Monte Carlo simulation.

Exercise #3: Enable Multi-Core

This exercise assumes your computer has more than one physical core and that you are using a SIMetrix/SIMPLIS Pro license.

  1. Close the waveform viewer.
  2. From the schematic menu, select Monte Carlo > Setup Monte Carlo...
    Result: The Define SIMPLIS Monte Carlo Analysis dialog opens with the Monte Carlo configuration information.
  3. Change the Number of cores to 4, the maximum allowed by the Pro license.
    Note: Note: if your machine has either a single core or two cores, the dialog will limit your Number of cores entry. If you have a single core, you can skip this exercise.
  4. Change the Number of steps to 32.
    Result: The configured dialog will appear as follows:
  5. Click Run.
    Result: The Monte Carlo simulation runs 32 steps on the maximum number of physical cores.

Plotting Histograms

SIMetrix/SIMPLIS has an extremely powerful histogram plotting function. In the last exercise, you executed 32 simulations to get a valid statistical sample, and the histogram plotting functions requires a minimum of 16 runs. In the next exercise you will create a probe to plot the histogram for the converter switching frequency.

Exercise #4: Plotting Histograms

Plotting histograms is different from plotting time domain curves because the histogram function is expecting a single measured value per Monte Carlo step. Compare this to plotting the converter output voltage after a transient simulation - there may be 10,000 points in the output voltage vector, each one representing the voltage at a particular simulation time. If you were to average the output voltage over the simulation time span, you would have just one measurement per Monte Carlo step. This is exactly what a histogram is - the frequency which a particular measured scalar value occurs over a statistical sample of Monte Carlo runs.

Therefore, every histogram will require a function to operate on the voltage or current, and this function must return a single scalar value for each Monte Carlo step. For the above mentioned example, the function used to return the average value of a voltage or current from a time-domain simulation is Mean1(). For this example you will plot the converter switching frequency using the Frequency() function.

  1. From the schematic menu, select Probe > Create and Place Arbitrary Probe .
    Result: The Edit Probe dialog opens:
  2. In the Multi-step mode box, select the Histogram radio button.
    Result: The Edit Probe dialog changes and should appear as follows:
  3. Input the following information:
    1. The Probe expression field is where you enter your goal function. Use V(nnn) for voltages and I(sss) for currents, where nnn and sss may be any string starting with a letter. In the Probe expression field, type Frequency(V(POP)).
    2. The Curve label field is where you enter the name of the curve to appear on the waveform viewer. Enter POP Frequency Histogram.
  4. The default number of histogram bins is defined by the equation:

    \[ N_{Bins} = \text{Floor} \left( \frac {\sqrt{\text{Number of Runs}}}{2} \right) \]

    which for a 32 run simulation will result in only 2 bins. For this exercise, you will change the number of histogram bins on the Define Performance Analysis dialog to 8. To change the number of histogram bins, follow these steps:
    1. In the Histogram options box, uncheck the default checkbox.
    2. Enter 8 in the Number of bins field.
      Result: The Edit Probe dialog should appear as follows:
    3. Click Ok.
      Result: Focus returns to the schematic viewer with a single input probe symbol attached to your mouse:
  5. Place the probe near the POP Trigger
  6. Wire the probe to the output of the POP Trigger
    Result: The probe will appear as follows:
  7. Re-run the Monte Carlo simulation.
    Result: Along with the same waveforms from Exercise #3, you will now have the Histogram of the POP Frequency:

Some Histogram Tips and Tricks

  • A list of functions which can be used to define the histogram expression is available by clicking on the Goal Functions... button.
  • More information on using this dialog to generate plots is available by clicking on the Help button.

Monte Carlo Log File

After the Monte Carlo simulation completes, a log file is created containing the following information for each Monte Carlo Step:
  1. The parameter name and default value.
  2. The evaluated parameter value and the percentage deviation from the default value.
  3. The seed value which was used to create this particular set of parameter values.

The log file is automatically created as a plain text file which can be opened in a spreadsheet program or otherwise machine parsed. A human-readable log file can be viewed using the Monte Carlo > View Log File . A sample log file appears as follows:

Monte Carlo Seed Values

Behind the scenes, a pseudo-random number generator is used to generate the Monte Carlo seed values. The seed values are used by each statistical probability function to generate the function return value. As a result, a particular Monte Carlo step can be repeated if you know the seed number used for that step, and the circuit has not changed at all between the first and second runs.

In the next exercise you will find the run with the lowest frequency and it's seed number, then repeat a simulation using the seed value.

Exercise #5a: Find the Run Number Which Produced the Lowest Frequency

On the waveform viewer window:

  1. Hover your mouse over the target curve until you see the square box:
  2. Look at the far right side of the status bar:

In this exercise, you have found the run number which produced the lowest converter switching frequency. In the next exercise, you will find the seed value and the simulated parameter values from the Monte Carlo Log file.

Exercise #5b: Find the Parameter Values Used for a Particular Run Number

You now know that run number 22 produced the lowest switching frequency. To find the seed value which corresponds to this run number, you open the Monte Carlo Log file. To open the Monte Carlo Log file, follow these steps:

  1. From the schematic menu select Monte Carlo > View Log File .
    Result: The Monte Carlo Log file opens.
  2. Scroll to run #22:

Note the seed value 1988583953 which was used for this run. In this converter, the switching frequency is highly dependent on the inductance value. Not unexpectedly, the evaluated parameter value for the inductance is higher than the default value, which requires longer charging and discharging times, and hence a lower switching frequency results.

In the next exercise, you will run a single step simulation using the same parameter values which generated the lowest frequency simulation run. You do this by running a Monte Carlo simulation using the seed value found in this exercise.

Exercise #5c: Run a Single Step Using a Known Seed Number

  1. From the schematic menu, select Monte Carlo > Setup Monte Carlo... .
    Result: The Define SIMPLIS Monte Carlo Analysis dialog opens with the Monte Carlo configuration information.
  2. Make these three changes to the dialog values:
    1. In the Monte Carlo Seed field, paste the seed value: 1988583953
    2. Change the Number of steps to 1
    3. Change the Number of cores to 1
      Result: The configured dialog should appear as follows:
  3. Click Run to run the known seed value of 1988583953.
    Result: A single Monte Carlo Step is run, reproducing the Monte Carlo run with the lowest frequency:
  4. Press the Home key on the keyboard to zoom the waveform viewer to see the full waveforms:

Monte Carlo in DVM

All actions described in this topic can be automated using the Design Verification Module (DVM). For example, the input voltage source value can be modified to use a statistical distribution function before launching a Monte Carlo simulation. DVM then launches the Monte Carlo simulation and as an additional feature, captures the fixed probe measurements and saves these measurements to a HTML formatted report file.

In this exercise you will run a 32 step Monte Carlo simulation using DVM and, as in exercise #5, you will determine the worst case minimum switching frequency. As discussed in the SIMPLIS Mutli-Step Analysis, DVM requires a schematic with a DVM control symbol and a testplan. We will use schematic 3.2_SelfOscillatingConvert_POP_DVM_basic.sxsch and will create a built-in testplan.

The DVM schematic 3.2_SelfOscillatingConverter_POP_DVM_basic.sxsch is electrically identical to the schematic used in the earlier example with two differences:
  1. Fixed probe measurements have been added to the probes. DVM automatically makes these measurements on each parameter step and outputs the measurements to the DVM report.
  2. The source and load of the circuit has been replaced with a new Power Supply Source and Power Supply Load.
    Note: Power Supply Sources and Loads can be found in the top level of the Part Selector.

Exercise 6: Running Monte Carlo in DVM

  1. Open schematic 3.2_SelfOscillatingConverter_POP_DVM_basic.sxsch schematic.
  2. From the menu bar, select DVM > Built-In Testplans > Monte Carlo > Run Monte Carlo Using DVM Control Symbol Parameters .
    Result: A DVM control symbol is necessary for any DVM simulation. A dialog asking you to place a control symbol will appear:
  3. Click Yes.
    Result: Focus returns to the schematic viewer with a DVM control symbol attached to your mouse.
  4. Place the DVM control symbol on the schematic.
    Result: The DVM control symbol needs the Monte Carlo parameters. A dialog asking if you want to copy the information from the existing Monte Carlo definition file to the control symbol will appear:
    Note: The Monte Carlo configuration file for this example is exactly the same as the final version from Exercise #4.
  5. Click Yes.
    Result: Probes whose names start with DVM will be output to the DVM report. Since there are none with a DVM prefix, a prompt to rename probes will appear:
  6. Select the Inductor Current, POP Trigger, Vout, and POP Frequency Histogram probes and click Ok.
    Result: The selected probes will be renamed on the schematic and a description of changes made will appear on the command shell:
  7. Select the only test in this testplan:
  8. Click Ok.
    Result: DVM creates the Monte Carlo configuration file from the DVM control symbol properties, launches the Monte Carlo Simulation, and creates the DVM report.
  9. The Monte Carlo DVM Report contains all the seed, parameter, and scalar measurement data taken from the simulation run. This table shows the seeds and measured values.

    Note that run #22 is the simulation with the lowest frequency. It should be pointed out that DVM doesn't produce different results than a ordinary SIMPLIS Monte Carlo simulation. Instead, DVM automates the process of setting up the schematic and collecting the results into a HTML formatted report.

Discussion: Exercise #6

There are a few items that should be pointed out about the schematic in it's current state.

DVM Control Symbol

The DVM control symbol stores specification information for the schematic. While the DVM control symbol has several forms, the one used in this example is the most basic version. The key specifications used in this example are the Monte Carlo parameters shown in the image below.

DVM Testplans

DVM runs tests defined in a testplan file. Testplans are merely tab separated text files where each row represents a test to be executed. To run a DVM Monte Carlo simulation, you enter MonteCarlo in the Analysis column. The MonteCarlo analysis keyword tells DVM to use the parameter definitions stored on the DVM Control Symbol. In this example, the POP analysis parameters were previously defined with the Simulator > Choose Analysis... menu. DVM can also change the analysis parameters on a test-by-test basis. The testplan you just ran is shown below. It has one test which runs the Monte Carlo simulation with the parameters you defined on the DVM control symbol.

***  
*** monte_carlo_basic.testplan  
***  
*?@ Analysis Label
***  
MonteCarlo Monte Carlo|Use DVM Control Box Parameters
*** Documentation: http://www.simplis.com/documentation/link/simplis/6077  

Monte Carlo Configuration File

Whether it be DVM or non-DVM, any Monte Carlo simulation requires the Monte Carlo configuration file. In the previous example, the configuration file was created using the informattion located in the control symbol. From this point a non-DVM Monte Carlo simulation can be conducted by clicking menu item Monte Carlo > Run Monte Carlo .

Conclusions and Key Points to Remember

  • Setting up a SIMPLIS Monte Carlo Analysis is similar to a SIMPLIS Multi-Step Analysis; however, instead of stepping a parameter, the Seed value is stepped.
  • The Gauss(), GaussTrunc(), Unif(), and Wc() probability distribution functions allow you to vary parameters during a Monte Carlo Analysis.
  • Matched parameters can be defined by first defining a master variable in the command (F11) window.
  • Histograms are easily plotted using an Arbitrary Probe: Probe > Create and Place Arbitrary Probe .
  • The seed values used for a SIMPLIS Monte Carlo Analysis are saved to the Monte Carlo log file.
  • Any single seed value can be simulated to reproduce a run with unusual or otherwise interesting results.