Specifying a Custom Core Loss
In addition to the standard core loss excitation detailed in Setting Core Loss for Transient and Eddy Current Solvers, users can also specify a custom core loss formulation. Using a Python script and a data file, the user defines fields and mesh information that are passed on the solver through the Solve Setup window. The core loss formulation in the Python script is used by Maxwell to evaluate core loss, element by element.
This custom core loss capability extends the available core loss formulation for the Maxwell 2D Magnetic Transient solver and the Maxwell 3D Magnetic Transient solver (T-Omega formulation only). It can be used with Distribute solve technology (DSO) and Large-Scale Distribute solve technology (LS-DSO) on Windows and Linux. Time Domain Decomposition is not supported.
Several specialty formulations are included in the //AnsysEM/SoftwareVersion#/ComputerPlatform/Examples/Maxwell/CustomCoreloss directory.
Required Files
To use a custom core loss excitation, the user must provide two files: the control program Python file and the data file that contains the core loss settings.
The control program (a Python file) must be referenced in the Advanced tab of the Solve Setup window:
-
In the Arguments field, the command
--compute --location $ProjectDir
must be specified (most common use case; see below for all the options for arguments). -
The Call after last timestep for post processing check box can be used to delete all temporary files.
The file that contains the core loss settings must be named coreloss_user.data and be placed in same directory as the Maxwell project (if –location $ProjectDir
argument is used). Its format is described below.
When running the Maxwell magnetic transient simulation, the core loss program will be called at each timestep. The core loss values are exported in a text file (Result_CoreLoss.txt). In the case of a parametric sweep, the text file name is indexed with the sweep variables (i.e., Im_100A_Gamma_90deg_Results_CoreLoss.txt)
Examples and Templates
Ansys Electronic Desktop provides users with examples and templates, which are located in the \\AnsysEM\VersionNumber\OS\Examples\Maxwell\CustomCoreloss.
The following example formulations are available for the users, without having the necessity to know any Python programming skills:
-
Same core loss model as Maxwell (Steinmetz’s model)
-
Steinmetz’s model with anisotropy (different values of core loss coefficients for X, Y and Z directions)
The material properties to enable those formulations are specified in coreloss_used.data file, which is included in each example directory.
The following templates are available and can be readily modified:
-
2D_maxwell_formulation replicates the Maxwell model.
-
2D_parametric_sweep contains a 2D transient model with anisotropy, along with an example of parametric sweep. For the model to function, the user has to provide Khx, Khy, Kcx, Kcy, Kex, Key coefficients for each object.
-
3D_maxwell_formulation contains ExampleCoreLoss3D.py, which allows anisotropy. The user has to provide Khx, Khy, Khz, Kcx,Kcy,Kcz,Kex,Key,Kez coefficients for each object.
Defining the coreloss_user.data File
The custom core loss program does not use material properties from Maxwell. The coreloss_user.data file contains all the material properties and settings for the core loss simulation. Here is an example for calculating the core loss on the object Stator using the Steinmetz method, in 2D:
The file must start with begin_data
and ends with end_data
. Comments can be added, as shown in line 1.
The following keywords can be entered and provide information on the settings:
Keyword | Description | Default |
---|---|---|
SimType | 1 for electric machine, 0 otherwise | 0 |
Ncoord | 2 for Maxwell 2D, 3 for Maxwell 3D | 2 |
SymmetryMultiplier | Enter the Symmetry multiplier present in Maxwell | 1 |
ObjectNames | Names of the objects where the custom core loss is applied | None |
ObjectIDs | IDs of the objects listed with ObjectNames; see below for instructions on how to get IDs | None |
Kh,Kc,Ke (or Khx,Khy,Khz, Kcx,Kcy,Kcz, Kex,Key,Kez), Alpha, Beta, Stacking, ModelDepth |
Coreloss coefficients for each object as well as the stacking factor and the ModelDepth (in meters, for 2D only) |
None |
VarNames | Names of the swept variables when a parametric sweep is defined | None |
To obtain the ID of the object, open the Python console (Tools > Open Command Window) and type the following commands, in order (this example assumes there is an object names Stator in the project):
Examples of coreloss_user.dat
Ansys Electronic Desktop provides coreloss_user.data file samples for the most common use cases in the \\Examples\Maxwell\CustomCoreloss directory:
-
2D simulation, similar core loss model to the Maxwell model
-
2D simulation, core loss model with anisotropy
-
2D simulation, core loss model used with a parametric sweep
Writing Your Own Formulations
When writing your own Python formulations, you can use existing examples as starting point or you can start from scratch.
To use an existing example as starting point:
-
From the list of examples available in \\Examples\Maxwell\CustomCoreloss, copy the file and rename it.
-
Provide a Python file to Maxwell that does the following:
-
Imports libraries (import
Coreloss
,import
utilities) -
Writes a class that derives from the base method
-
Defines your own version of the method
compute_coreloss_loss_in_a_2D_element
, orcompute_coreloss_loss_in_a_3D_element
. -
Calls the
compute_coreloss
method from the main function.
To write your own Python formulation from scratch:
-
Set up the Python environment: You do not need to install Python itself. Instead, you need to ensure that Ansys Electronic Desktop is installed on your computer and you have the licenses needed to run a Maxwell transient solve.
-
Create your own
coreloss
routine: Use existing examples ofcompute_core_loss_in_a_2D_element
orcompute_core_loss_in_a_3D_element
to define imports/inputs and outputs. -
Add your own parameters/material properties to coreloss_user.data. You can add any parameter (integer/floating/list …) in coreloss_user.data that is needed for your formulation. In the example below, we have added 3 new parameters: KH_0, KC_0 and KE_0. Those parameters will be available in your local coreloss definition.
-
Read your parameters in core loss definition. To use KH_0, KC_0 and KE_0 in your own core loss definition, use the syntax below. Note that the parameters are read as strings:
-
Send your core loss calculation back to the framework. Once you have defined your own formulation, return the values into the following predefined variables:
Using Your Control Program with a Maxwell Design:
To use your control program with a Maxwell design:
-
Open the project in Ansys Electronics Desktop.
-
Open the properties of the desired analysis setup.
-
In the Advanced tab, for the Control Program Path:
-
Update the Control Program Path property in your Ansys Electronics Desktop project file to point to the location of your final Python calculation program.
-
Ensure that the path is correctly specified, including the file name and extension, and that it matches the actual location of your Python program on your system.
-
For the Control Program Arguments:
-
Update the Control Program Arguments property in your Ansys Electronics Desktop project file to include the appropriate arguments for your computation process.
-
The argument string can begin with the keyword
extract
instead ofcompute
. WithExtract
mode, you can run the custom core loss simulation without having to run the Maxwell simulation. Contact Ansys support for more details.
Frequently Asked Questions
-
What are the key features and functionalities provided by the library?
-
Custom computation in Python: Enables Maxwell's core loss formulation to be replaced or extended using code written in Python.
-
Output file format: Core loss data to be saved in any format, which enables easier processing.
-
Input file format: The coreloss_user.data file can be in user specified format (such as json).
-
Do I need to install Python? What version of Python is supported?
-
The custom coreloss module uses the CPython version from the Ansys Electronic Desktop installation. It uses version 3.10.
-
Can you explain how the library integrates with Ansys Electronics Desktop and supports core loss computations?
-
The library enables you to write a control program and provide data to control the core loss computation.
-
Ansys Electronic Desktop runs the control program for each timestep of transient analysis, including at the beginning and at the end.
-
During initialization, the library uses your input data file to create a user.ctl file as needed by Ansys Electronic Desktop .
-
During each timestep, the library reads the field information provided by Ansys Electronic Desktop and calls your code to compute core loss for each element in the specified interesting objects.
-
How does the library handle the specific engineering parameters or calculations relevant to core loss computation?
-
In your input data file, you can specify material properties for each object of interest.
-
In the time domain, it computes the value of magnetic field vectors and their derivatives needed for core loss computation.
-
What is the level of customization and extensibility offered by the library to accommodate my specific requirements?
You can override many of the methods of the base class and write your own methods.
Related Topics
Selecting Solution Quantities to Plot
Setting Core Loss for Transient and Eddy Current Solvers
Core Loss Model for a Maxwell Material
Calculating Properties for Core Loss BP Curve
Core Loss Coefficients for Electrical Steel
Core Loss Coefficient Extraction from Single-Frequency Loss Curve
Core Loss Coefficient Extraction from Multi-Frequency Loss Curves
Core Loss Parameter Extraction for Power Ferrite Materials
Technical Notes: 3D Transient Excitations (Sources)
Technical Notes: 2D Sources/Excitations