External Coil Excitation for pyAEDT Maxwell2d
Hi, I am trying to automate AEDT tasks with pyaedt. As part of my workflow, I need to create an external schematic to import a netlist for external excitation of the coils (instead of Current or Voltage).
Using the Ansys AED GUI, this would work as follows:
- Select the machine model in the project on the left
- On the top: Maxwell2d -> Excitations -> external circuit -> edit external circuit -> create circuit
- Design the circuit and export the netlist
- Return to "edit external circuit" -> import netlist
Is there a way to automate this using pyaedt in python?
Best Answer
-
Hi @mebn ,
Please have a look in pyaedt, you will find now the requested feature.
In maxwellcircuit.py there's a new method available called export_netlist_from_schematic() to create a netlist from a schematic circuit and in maxwell.py another new method called edit_external_circuit() to edit the external circuit for the winding.
Hopefully this helps,
Thanks for feedback,
Giulia
0
Answers
-
Hi @mebn ,
Thanks for getting in touch and for the feedback.
We are working on a new implementation to export the netlist from a circuit schematic and then to edit a Maxwell external circuit to give the netlist file path as input.
We'll let you know as soon as it will gone through and will be in the next pyaedt release.
Thanks!
Giulia
1 -
Hi @Giulia M. ,
Thank you very much! THis solves mz problem.
For everyone stumbling onto the same issue, a quick example:
```python
import pyaedt
# Maxwell Circuit
circuit = pyaedt.MaxwellCircuit()
circuit.insert_design("schematic")
# Place components, ect...
# e.g.:
# circuit.modeler.schematic.create_resistor("name", <resistance>)
circuit.export_netlist_from_schematic(<export_filename>)
# Maxwell 2D
M2D = pyaedt.Maxwell2d()
M2D.edit_external_circuit(<netlist_file_path>, <schematic_design_name>)
```
0 -
Hi!
Thank you @mebn for your example.
I was trying to do the same with Ansys 2023.2, pyaedt 0.8.2, Python 3.10 and Ubuntu 22.
I got the following error running the script:PyAEDT ERROR: Failed to execute grpc AEDT command: SetActiveEditor PyAEDT ERROR: Mxw3D.edit_external_circuit('...', '...') PyAEDT ERROR: File ".../python3.10/site-packages/pyaedt/maxwell.py", line 1916, in edit_external_circuit PyAEDT ERROR: Last Electronics Desktop Message - [error] script macro error: unable to locate editor named: schematiceditor. (05:19:13 pm mar 26, 2024)
and in Ansys EDT:
Script macro error: Unable to locate editor named: SchematicEditor
I found that if I change line 1916 of maxwell.py (line of edit_external_circuit function) from
oeditor = odesign.SetActiveEditor("SchematicEditor")
to
oeditor = odesign.SetActiveEditor("3D Modeler")
the function SetActiveEditor is executed without error, but the error is obviously generated in the following line (1917).
@Giulia M., could you please help me with this issue?
Thank you very much for your help,
Marco
0 -
For now I found this solution:
Since I have a very simple circuit, without sources, I can skip all the lines of the function edit_external_circuit, except for the last 2:self.oboundary.EditExternalCircuit(netlist_file_path, sources_array, sources_type_array, [], []) return True
So, I created my edit_external_circuit function with just these 2 lines and it works:
def edit_external_circuit(self, netlist_file_path, schematic_design_name): self.oboundary.EditExternalCircuit(netlist_file_path, [], [], [], []) return True
I will introduce a voltage source in the future, so I would appreciate if you could help me with the original issue.
Thank you,
Marco0 -
Hi @marcob, is it possible for you to share more details so we can reproduce your issue with edit_external_circuit ?
Although you created your method this is not the best solution and the best case is for us to fix the method and make it works for everyone.Thanks,
Giulia
0