Create a custom output variable in Motor-CAD, create optiSLang project, and modify the OPF file.
- Find the Automation Names of the Required Output Parameters
- Find the Automation Names of the Required Output Parameters
There are two ways to locate them:
From the Motor-CAD InterfaceHover over the output parameter with your mouse. The automation name will appear in the bottom-left corner of the interface.
Example: For system efficiency, it displays {SystemEfficiency}.
Go to Help > Automation Parameter Names.
A pop-up window will appear. You can search for any parameter and note its Automation Name to include in the optimization.
Navigate to Tools > Ansys optiSLang.

Assign Geometry Ranges and Objective Constraints

You can initially define only torque ripple as an objective and leave the others for later.
If you intend to run only the E-Mag module in the optimization, this helps avoid loading scripts for the thermal and mechanical modules.
Run a test to ensure the model is functioning properly. Even if the Lab module isn't selected, optiSLang runs it by default — we’ll remove it in later steps.
Keep the optiSLang settings as shown below:
Create the optiSLang Project
You may adjust the number of sensitivity analyses and parameter types here. We’ll add the additional objectives later.

Go to the Exported optiSLang Folder Directory
Right-click the file and select Edit with Notepad (or your preferred editor).
Scroll down to where the script builds the Lab model (in some cases around line 338). Remove or comment out the three rows that activate the Lab module:
if mcApp.set_variable("LabMagneticCoupling", 0) # If value is 1, change it to 0
Add Output Parameter Code
Now remove the portion where Motor-CAD runs the Operating Point in the Lab module — this will speed up the process.
Then, use the following template to insert your desired output parameters (from Step 1).
You can copy the existing torque ripple row and paste a new line underneath:
GetOutputValue('ParameterName', 'ParameterName_AnySpecificName', mcApp)
You can use this template to include any of your parameter name.
So for SystemEfficiency it should be as follow
GetOutputValue('SystemEfficiency', 'SystemEfficiency_1050rpm', mcApp)
Your final section should look like this:
Still in the same file, scroll to the section where outputs are declared.
Copy the torque ripple output row and add your new parameter using the following templates:
The template for output parameter assignments
o_ParameterName _SameSpecificNameUsedAbove = float('nan')
For the efficiency,
o_SystemEfficiency_1050rpm = float('nan')
The template for outputs
outputs['ParameterName_ SameSpecificNameUsedAbove '] = o_ParameterName _SameSpecificNameUsed
For the efficiency parameter,
outputs['SystemEfficiency_1050rpm'] = o_SystemEfficiency_1050rpm
‘
Final version of this section should look like below
Open MotorCAD_Outputs in Notepad.
Add the same output parameters using the following format:
The template is
ParameterName_SpecificName=0.0
For efficiency,
SystemEfficiency_1050rpm=0.0
Save and close the file.
- Load the Modified optiSLang Project
Open the optiSLang project, then double-click on the Motor-CAD system block (usually labeled exportedProj).
Click Load to reload the modified code.
Add the Output Parameter to the Optimization
The new parameter (e.g., SystemEfficiency_1050rpm) will appear in the Outputs box in white, indicating it’s recognized but not yet used in the optimization.
Drag it to the Responses section on the right to include it in the optimization.
It should look like this:
Now you can close this window.
Finalize the Optimization Settings
Double-click the outer workflow box to enter the optimization settings.
Go to the Criteria tab and assign your new parameters as needed.
Click OK to close the window.
Now your simulation is ready to run — and the new output variable is included in the optimization
As seen below, efficiency is part of the optimization now!