Using a Control Program in Maxwell 2D and 3D Transient Solutions
User control programs are externally created executable files, or Python (*.py
) scripts that are called after each time step, and allow you to control the source
input, circuit elements, mechanical quantities, time step, and stopping
criteria, based on the updated solutions.
The user control program uses the file with fixed name user.ctl to output control parameters to control the execution of the transient solver. Each file must use a predefined syntax which is flexible enough to cover a wide range of items.
The process shown in the flowchart can be summarized as:
-
The solver calls the user-control program on initialization.
-
The user-control program writes control information to file user.ctl.
- The transient solver reads control parameters from user.ctl.
- The transient solver solves the current time step.
-
The transient solver copies the previous solution to previous.ctl and writes out solution information to solution.ctl. If requested, the solver exports:
- B, H, J fields (bfield.ctl, hfield.ctl, jfield.ctl, respectively)
- A field afield.ctl (available in 2D and 3D A-Phi only)
- Phi field phifield.ctl (available in 3D A-Phi only).
-
Return to the transient solver if the control program succeeds with exit status 0 or fails with exit status non-zero.
-
Return to step 1 for the next time step.
-
(Optional) Call script after last time step for post processing. If user selects the Call after last time step for post processing check box (refer to Activating a Control Program in Transient Solutions), then the control program is called after the simulation is completed.
If you use a Python control program, the script is called with
--post
flag(for example:
my_script.py --post
).For a compiled control programs the script is called with
-post
flag(for example:
my_tool.exe -post
).
<install_path>\Win64\commonfiles\CPython\37\
winx64\Release\python\python.exe
however, the user can specify a custom python interpreter to be used by setting following environment variable:
EM_CTRL_PROG_PYTHON_PATH=<path_to\python.exe>