Let’s talk about Monte Carlo Simulation (MCS) and how it can be used to optimize transducer design.

## What is Monte Carlo Simulation?

Monte Carlo simulation is a statistical method used to model the probability of outcomes of a complex system whose behavior cannot be easily determined due to a vast number of variables. This method is useful for multiple industries such as design, manufacturing, finance, and hospitality. Monte Carlo Simulation is used to understand risk, determine probability of outcomes and to optimize outcomes.

## How does Monte Carlo Simulation Work?

MCS is a bit like throwing darts on a dartboard. If you’re not a very good player, and you just start throwing darts with the only aim of getting them on the board, after a certain amount of darts are thrown, you’ll start to see where the darts are accumulating and get a picture of the distribution of outcomes, your player performance that is.

*Figure 1: Dartboard*

So, like a bad dart player, MCS calculates the results (dart score) from multiple simulations (dart throws) and can do this for multiple inputs (e.g. player distance). To obtain an idea of the distribution of outcomes, inputs are randomly generated from a probability distribution. The most commonly used probability distribution is Normal. This means that an input has a mean (expected) value and a standard deviation, which is the amount that value deviates from the mean (in positive and negative direction). Depending on the number of inputs and the input constraints, an MCS simulation usually involves thousands of calculations.

## Why use MCS for Transducer Design?

The complexity of transducer design has increased in recent years due to performance demands. Therefore, the design process is becoming more costly and time-consuming. Simulation is becoming an integral part of the development of such devices to lower cost and time to market. Monte Carlo Simulation is a powerful tool for designers to get quick and accurate representation of the design space to speed up the design process.

## Multi-Layer Transducer Monte Carlo Study

This study looks at a 2D multi-layer transducer.

*Figure 2: 2D multi-layer transducer model*

For this study we analyzed how the matching layer thickness (thkMat) and piezoelectric layer thickness (pzt_thk) affected three key performance indicators (KPIs) of the transducer:

- Center Frequency (Fc)
- Sensitivity
- Fractional Bandwidth (FBW)

To keep the problem size down, it’s important to constrain the input parameters; otherwise you have an infinite problem space. In this study, matching layer thickness was constrained to 3.2 mm ± 3.125% and the piezoelectric layer thickness was constrained to 10 mm ± 5%. This study was set up to use 1000 random inputs from a normal distribution and calculated Fc, sensitivity, and FBW for every input combination.

### Step 1: Generate Input Data

OnScale can run multiple simulations in parallel on cloud supercomputers, sweeping multiple variables at a time. To do this easily, batch simulations can be driven using a CSV-file. This file must contain the names of the variables at the top of the columns followed by the values underneath. The variables must also by defined using ‘symbx’ in the input file. Generating a CSV-file with randomly distributed numbers can be done easily in your software package of choice.

Figure 3: Use of symbx variables for Monte Carlo input variables |
Figure 4: Snippet of CSV-file containing 1000 randomly distributed values for matching layer thickness (thkMat) and piezoelectric layer thickness (pzt_thk). |

### Step 2: Run Simulations and Download Results

Jobs are run in OnScale directly form the software. A parametric sweep can be driven with a CSV-file using the **User Defined Variable File** option. The software sets up a simulation for every row of variables in the file.

*Figure 5: OnScale Cloud Scheduler set up for CSV-file input.*

Loading in the transducer model and selecting **Estimate** then **Run** uploads the 1,000 simulations to the cloud to process in parallel.

When the 1,000 simulations are complete, and in this case it took 11 minutes, the results must be downloaded for processing. The output files have the voltage and charge data from the device that can be used to calculate the KPIs in Review.

### Step 3: Calculate KPIs

Simulation results can be easily batch-processed in Review to obtain relevant KPIs.

__What is Review?__ Review is OnScale’s postprocessing language. To find out more, check out the Review-related articles in our Help Center.

Similarly, results can be processed in MATLAB®. The steps are simple: read in the history files, perform the same KPI calculations on every dataset, output to a CSV-file to plot.

### Step 4: Analyze Results

To make the MCS results easier to understand and analyze, we plotted them using MATLAB®.

*Figure 6: Inputs vs Inputs*

Figure 7: Inputs vs Outputs |
Figure 8: Outputs vs Outputs |

It’s clear from this Monte Carlo Simulation that the piezo thickness inversely correlates to center frequency, as expected, because the thinner the piezoelectric plate, the higher the resonant frequency at which it vibrates. But we can also see aspects of the design space that aren’t obvious like how the matching layer thickness affects the fractional bandwidth. Monte Carlo Simulation is an immensely useful tool for problems like this and can be used to optimize devices like transducers while reducing fabrication cost and time to market.

## How Can You Try It?

Get the software at onscale.com and take a look at this article in our Help Center, which has all the files you need to run this study. If you have any other questions about running Monte Carlo studies in OnScale, please get in touch with via our forum!