TAGGED: ansys-maxwell, python-scripting
-
-
July 28, 2021 at 8:52 pmmabdelraziqSubscriber
Greetings all,
I would like to use Python to interface with ANSYS Maxwell 3D to change parameters, run simulations, and acquire the simulations results. I will be running an optimization algorithm in Python so, this algorithm will need to actively change the model parameters based on the old simulation results (iterative process basically).
Based on my current knowledge, I can go to tools and start recording a script in Python 2. Then, I can open my project and run the script which will do the same actions that I recorded. Also, I know that there is a scripting guide with a list of functions.
However, I have the following questions:
- I recorded a simple .py script that changes the model's parameters values, analyzes the model, and saves some results. However, I cannot run the script since I need to install the ScriptEnv library (I tried to run the script I saved from the command window using the following line: >>python scriptname.py)
- I have installed the latest version of Python 2 (Python 2.7.18) and could not install ScriptEnv
The following screenshots would help illustrate my questions:
July 29, 2021 at 11:12 amPraneethForum Moderator
Did you try running the sample script using the "run script" option in the tools menu?
All the very best.
July 29, 2021 at 2:32 pmmabdelraziqSubscriber
I ran the .py script from ANSYS and it ran successfully changing the model parameter as it is supposed to. However, why cannot I run this script externally in a Python 2 IDE for example, or on the Windows command line?
August 4, 2021 at 12:26 pmjdmacSubscribera couple of things:
It looks like you're trying to use Python to execute the script. HFSS scripts are in IronPython, not Python. IronPython is compiled C# code, not C. It's syntactically identical to Python but with different modules. For example, there's no numpy or scipy in IronPython, but you do have access to the whole .NET framework which is powerful for app development. On the command line make sure you're executing IronPython, which can be found in the AnsysEM install directory: AnsysEM\AnsysEM21.1\Win64\ common\IronPython\ipy64.exe.
When you execute external scripts, make sure you append these 2 locations to your Python path: sys.path.append('path_to_install\\AnsysEM\\AnsysEM21.1\\Win64') and sys.path.append('path_to_install\\AnsysEM\\AnsysEM21.1\\Win64'\\PythonFiles\\DesktopPlugin'). The second location is where ScriptEnv.py is located.
When executing externally you need to include the year version number in the initialization statement.: ScriptEnv.Initialize("Ansoft.ElectronicsDesktop.2021.1"). Executed internally, EM Suite doesn't need the version, ScriptEnv.Initialize("Ansoft.ElectronicsDesktop") suffices, but you do need this in order to run externally.
After calling ScriptEnv.Initialize, you should have the oAnsoftApplication and oDesktop objects in your global scope.
Be sure to call the Shutdown function when your script exits in order to release the COM object. Otherwise your script will lock your instance of EM Suite for about 20 minutes (you won't be able to close the project). Shutdown() releases the COM object, and once it's released, it can't be obtained again by that IronPython process (not even on another thread). You will probably want to copy out the text from ScriptEnv.Shutdown and make your own shutdown function, as the default Shutdown() closes the application, and you don't want that.
March 2, 2023 at 8:24 pmAshishkumar GuptaSubscriberI am facing similar issue in MATLAB with actxserver(progid). which tells me progid is invalid.Â
I am using ANsys EDT student version 2022.2 .
I tried using 'Ansoft.ElectronicsDesktop.2022.2', 'Ansoft.ElectronicsDesktop.2022', 'Ansoft.ElectronicsDesktopStudent.2022', 'Ansoft.ElectronicsDesktop', 'Ansoft.ElectronicsDesktopStudent' but none of them seems to work.Â
Please help me out!!!
August 28, 2023 at 9:24 amOctober 19, 2023 at 2:22 amlarry larryellisonSubscriberBased on your knowledge and I wonder why you don't try with a scripting tutorial with a list of functions?Â
Â
                     Â
                                                                         Â
Â
Viewing 6 reply threads- The topic ‘Questions about Python Scripting in Ansys Electronics Desktop Products’ is closed to new replies.
Ansys Innovation SpaceTrending discussions- HFSS Incident Plane Wave excitement mode
- Question for Maxwell
- Simulation of capacitor combining eddy currents with displacement currents
- How to calculate eddy and hysteresis losses of the core?
- Ansys Maxwell 3D – eddy current
- How to determine initial position in motion setup
- dq graph non-conformity
- How to customize pulse waveform and injection site in microstrip array
- 180 Degree Phase Shift When Measuring S21
- Simplorer+Maxwell Cosimulation results and Maxwell results mismatch
Top Contributors-
1216
-
543
-
523
-
225
-
209
Top Rated Tags© 2024 Copyright ANSYS, Inc. All rights reserved.
Ansys does not support the usage of unauthorized Ansys software. Please visit www.ansys.com to obtain an official distribution.
-