Resources

From Brute Force to Smart Search: A Better Way to Optimize Electric Motors

Written by Ian Chavez | Jun 26, 2025 7:22:25 PM

Electric motor design is a complex dance of trade-offs. Engineers are constantly striving to create motors that are not only powerful and efficient but also lightweight, compact, and cost-effective. Finding the perfect balance between these competing objectives is a monumental task, often requiring thousands of simulations to explore the vast design space. This is where powerful simulation tools like Ansys Motor-CAD come in, allowing for detailed multiphysics analysis of motor designs. However, the challenge remains: how do we efficiently navigate this complex landscape to find the optimal design?

We will first look at the conventional workflow using Ansys optiSLang and then introduce a more efficient and powerful alternative using Bayesian optimization with the Python library Stochos.

The Traditional Path: A Multi-Stage, Brute-Force Approach

The traditional method for optimizing electric motors with Motor-CAD and optiSLang is a multi-stage process that, while effective, can be incredibly time-consuming and computationally expensive. We covered this in greater detail in these previous blogs:

Understanding Sensitivity Analysis in optiSLang: A Deep Dive into Sampling Methods

Building a Robust Metamodel for Electric Motor Optimization with OptiSLang & MotorCAD



The workflow typically involves the following steps:

  • Sensitivity Analysis: The process begins with a large, upfront Design of Experiments (DoE). This involves running a large number of simulations (often hundreds or even thousands) to sample the entire design space. The goal is to understand how different input parameters (like magnet size or winding configuration) affect the motor's performance (the output parameters, such as torque and efficiency).

  • Metamodel Creation: The data from the sensitivity analysis is then used to create a "metamodel," or a "Meta-model of Optimal Prognosis" (MOP) in optiSLang terminology. This metamodel is essentially a simplified mathematical representation of the complex relationships between the input and output parameters. It's a "surrogate" for the full Motor-CAD simulation.

  • Optimization on the Metamodel: Once the metamodel is built, an optimization algorithm is run on this simplified model. This is much faster than running the optimization directly on the full Motor-CAD simulations.

  • Validation: Finally, the optimal designs identified by the optimizer are validated by running them through the full Motor-CAD simulation to ensure the metamodel's predictions were accurate.

While this approach can lead to optimized designs, it has a significant drawback: the initial sensitivity analysis is a "brute-force" method that requires a massive number of simulations, many of which may be in uninteresting or poorly performing regions of the design space. This can lead to wasted time and computational resources.

 

A Smarter Path: Bayesian Optimization with Stochos

 

Stochos, a product of PI Probaligence, is a software company that provides solutions in the fields of engineering, paint & coating, and medicine. Their primary focus is on improving the Design of Experiments (DOE) process, making it more efficient, effective, and insightful, especially for applications in coatings and similar chemical industries.

A key feature of Stochos is their unique DIM-GP algorithm, which combines Artificial Neural Networks (ANNs) and Gaussian processes. This algorithm is designed to set new standards in machine learning for complex classification problems and detailed time series analyses. The software is versatile, accepting a wide range of input types, offering numerous covariance functions, and incorporating an advanced feature for automatic noise level estimation and outlier detection.

Stochos offers a more intelligent and efficient approach to our Motor Design problem in the form of Bayesian optimization.

Instead of a large, upfront DoE, Bayesian optimization uses a sequential, adaptive sampling strategy to intelligently explore the design space. Here's how it works:

The Core Idea of Bayesian Optimization

At its heart, Bayesian optimization is a probabilistic approach to optimizing expensive-to-evaluate "black-box" functions (like a Motor-CAD simulation). It works by building a probabilistic model of the objective function and then using that model to decide where to sample next. This process involves two key components:

  • A Surrogate Model: This is a probabilistic model that approximates the true objective function. A common choice for the surrogate model is a Gaussian Process (GP), which not only provides a prediction for the objective function at a given point but also a measure of uncertainty about that prediction.

  • An Acquisition Function: This function uses the predictions and uncertainties from the surrogate model to decide which point in the design space to evaluate next. The acquisition function balances two competing goals:

    • Exploitation: Sampling in areas where the surrogate model predicts good performance.
    • Exploration: Sampling in areas where the uncertainty is high, to reduce that uncertainty and potentially discover new, promising regions of the design space.

 

The Iterative Process

The Bayesian optimization process is iterative:

  1. Initial Samples: A small number of initial points are sampled from the design space.
  2. Fit the Surrogate Model: The surrogate model is fit to the initial data.
  3. Optimize the Acquisition Function: The acquisition function is optimized to find the next best point to sample.
  4. Evaluate the Objective Function: The objective function (the Motor-CAD simulation) is evaluated at the new point.
  5. Update the Surrogate Model: The new data point is added to the set of observations, and the surrogate model is updated.
  6. Repeat: Steps 3-5 are repeated until a stopping criterion is met (e.g., a certain number of iterations or convergence to an optimal solution).

Stochos and dimgp: The Tools for the Job

 

Stochos is a powerful tool for stochastic optimization that provides the building blocks for implementing Bayesian optimization. It allows engineers and data scientists to apply advanced machine learning models to their simulation and product development workflows.

A key component of Stochos is its use of sophisticated surrogate models. One such model is the Deep Input Mixture of Gaussian Processes (dimgp). At a high level, dimgp is an advanced surrogate model that combines the strengths of deep neural networks and Gaussian Processes. The deep learning component allows the model to handle complex, high-dimensional data, while the Gaussian Process component provides the crucial uncertainty estimates that are essential for Bayesian optimization.

PyMotorCAD

PyMotorCAD is part of the PyAnsys ecosystem that facilitates the use of Motor-CAD within a Python environment in conjunction with other PyAnsys libraries and external Python libraries. It allows you to programmatically create, interact with, and control a Motor-CAD model, with or without using the Motor-CAD GUI. You can achieve Motor-CAD automation by running scripts, either internally via the Motor-CAD Scripting tab or externally. It's an integral component of the PyAnsys ecosystem, simplifies the integration of Motor-CAD into a Python environment, enabling its use alongside other PyAnsys and external Python libraries like Stochos.

PyMotorCAD can be operated in any IDE or in a Jupyter Notebook, as seen below: 

 

 

The Stochos and Motor-CAD Workflow

By combining Stochos with Motor-CAD, we can create a highly efficient optimization workflow:

  1. Define the Problem in Stochos: The optimization problem (input parameters, output parameters, objectives, and constraints) is defined in a Python script using the Stochos library.
  2. Create an Evaluator Function: A Python function is created that takes a set of design parameters as input, runs a Motor-CAD simulation, and returns the performance metrics.
  3. Run the Bayesian Optimization: The Stochos bayesian_opt object is used to run the optimization. Stochos will intelligently call the evaluator function, using the dimgp surrogate model and an acquisition function to guide the search for the optimal design

 

The Advantage of the Bayesian Approach

The key advantage of the Bayesian optimization approach with Stochos over the traditional optiSLang workflow is efficiency. By intelligently exploring the design space, Bayesian optimization can find optimal solutions with significantly fewer simulations.

Traditional optiSLang Workflow

Bayesian Optimization with Stochos

Large, upfront Design of Experiments (DoE)

Sequential, adaptive sampling

Builds a static metamodel (MOP)

Continuously updates a probabilistic surrogate model (dimgp)

Can waste simulations on unpromising regions

Focuses computational effort on the most promising regions

Time-consuming and computationally expensive

More efficient in terms of time and computational resources



Conclusion: A New Era of Motor Optimization

The integration of Bayesian optimization with powerful simulation tools like Motor-CAD represents a significant step forward in the field of electric motor design. By moving away from brute-force methods and embracing intelligent, adaptive search strategies, engineers can accelerate the design cycle, reduce costs, and ultimately, create better products.

As the demand for high-performance electric motors continues to grow, the adoption of these advanced optimization techniques will be crucial for staying ahead of the curve. The combination of Motor-CAD's detailed multiphysics analysis and the intelligent search capabilities of Stochos provides a powerful toolkit for tackling the complex challenges of modern motor design.

Keep an eye out for our future blog entry where we will give a step-by-step example on using Stochos to optimize a MotorCAD design, and directly compare this with the previous optislang based optimization.