Skip to content

Commit 6c18479

Browse files
committed
Maxwell external circuit example
1 parent 8a2dffd commit 6c18479

File tree

1 file changed

+166
-0
lines changed

1 file changed

+166
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,166 @@
1+
# # Maxwell 3D Transformer model with zigzag connection
2+
#
3+
# This example ...
4+
5+
# ## Perform required imports
6+
7+
# +
8+
import tempfile, os
9+
10+
from pyaedt import Maxwell3d, MaxwellCircuit
11+
import pyaedt
12+
13+
# -
14+
15+
# Set constant values
16+
17+
AEDT_VERSION = "2024.1"
18+
19+
# ## Create temporary directory
20+
#
21+
# Create temporary directory.
22+
23+
temp_dir = tempfile.TemporaryDirectory(suffix=".ansys")
24+
25+
# ## Initialize and launch Maxwell 2D
26+
#
27+
# Initialize and launch Maxwell 2D, providing the version, path to the project, the design
28+
# name and type.
29+
30+
# +
31+
non_graphical = False
32+
33+
project_name = "Transformer_zigzag"
34+
design_name = "1 Eddy current"
35+
solver = "EddyCurrent"
36+
desktop_version = AEDT_VERSION
37+
38+
m3d = Maxwell3d(
39+
version=desktop_version,
40+
new_desktop=False,
41+
design=design_name,
42+
project=project_name,
43+
solution_type=solver,
44+
non_graphical=non_graphical,
45+
)
46+
47+
mod = m3d.modeler
48+
49+
core_id = mod.create_udp(
50+
dll="RMxprt/TransCore.dll",
51+
parameters=[],
52+
library="syslib",
53+
name="transformer_core"
54+
)
55+
m3d.assign_material(assignment=core_id, material="steel_1008")
56+
57+
winding_size = [-5, 96]
58+
lv_coil_pos = [0, -21, -48]
59+
hv_coil_pos = [0, -31, -48]
60+
a_offset = [-100, 0, 0]
61+
c_offset = [100, 0, 0]
62+
63+
# Create LVB and HVB windings and terminals
64+
lvb_terminal_id = mod.create_rectangle(orientation="YZ", origin=lv_coil_pos,
65+
sizes=winding_size, name="LVB_terminal")
66+
lvb_winding_id = mod.create_rectangle(orientation="YZ", origin=lv_coil_pos, sizes=winding_size, name="LVB_winding")
67+
mod.sweep_around_axis(assignment=lvb_winding_id, axis="Z")
68+
69+
hvb_terminal_id = mod.create_rectangle(orientation="YZ", origin=hv_coil_pos,
70+
sizes=winding_size, name="HVB_terminal")
71+
hvb_winding_id = mod.create_rectangle(orientation="YZ", origin=hv_coil_pos, sizes=winding_size, name="HVB_winding")
72+
mod.sweep_around_axis(assignment=hvb_winding_id, axis="Z")
73+
74+
lvb_winding_id.material_name = "copper"
75+
hvb_winding_id.material_name = "copper"
76+
77+
# duplicate = lvb_winding_id.duplicate_along_line(a_offset)
78+
# lva_winding_id = mod.objects[duplicate[0]]
79+
# lva_winding_id.name = "LVA_winding"
80+
81+
82+
# Duplicate LVB and HVB windings and terminals to create A and C
83+
duplications = [
84+
(lvb_winding_id, a_offset, "lva_winding_id", "LVA_winding"),
85+
(lvb_winding_id, c_offset, "lvc_winding_id", "LVC_winding"),
86+
(lvb_terminal_id, a_offset, "lva_terminal_id", "LVA_terminal"),
87+
(lvb_terminal_id, c_offset, "lvc_terminal_id", "LVC_terminal"),
88+
(hvb_winding_id, a_offset, "hva_winding_id", "HVA_winding"),
89+
(hvb_winding_id, c_offset, "hvc_winding_id", "HVC_winding"),
90+
(hvb_terminal_id, a_offset, "hva_terminal_id", "HVA_terminal"),
91+
(hvb_terminal_id, c_offset, "hvc_terminal_id", "HVC_terminal"),
92+
]
93+
94+
# Dictionary to hold the new objects
95+
new_objects = {}
96+
97+
for obj, offset, var_name, new_name in duplications:
98+
duplicate = obj.duplicate_along_line(offset)
99+
new_obj = mod.objects[duplicate[0]]
100+
new_obj.name = new_name
101+
new_objects[var_name] = new_obj
102+
103+
# Access the new objects using the keys
104+
lva_winding_id = new_objects["lva_winding_id"]
105+
lvc_winding_id = new_objects["lvc_winding_id"]
106+
lva_terminal_id = new_objects["lva_terminal_id"]
107+
lvc_terminal_id = new_objects["lvc_terminal_id"]
108+
hva_winding_id = new_objects["hva_winding_id"]
109+
hvc_winding_id = new_objects["hvc_winding_id"]
110+
hva_terminal_id = new_objects["hva_terminal_id"]
111+
hvc_terminal_id = new_objects["hvc_terminal_id"]
112+
113+
lv_terminals = [lva_terminal_id, lvb_terminal_id, lvc_terminal_id]
114+
hv_terminals = [hva_terminal_id, hvb_terminal_id, hvc_terminal_id]
115+
116+
windings = [lva_winding_id, lvb_winding_id, lvc_winding_id, hva_winding_id, hvb_winding_id, hvc_winding_id]
117+
118+
# Create region
119+
mod.create_region(pad_value=50)
120+
121+
# Assign mesh operations
122+
m3d.mesh.assign_length_mesh(assignment=core_id, maximum_length=50, name="core_inside")
123+
m3d.mesh.assign_length_mesh(assignment=windings, maximum_length=50, name="windings_inside")
124+
125+
# Assign coils
126+
lv_turns = 100
127+
hv_turns = 500
128+
129+
for coil in lv_terminals:
130+
m3d.assign_coil(assignment=coil, conductors_number=lv_turns, name=coil.name)
131+
132+
for coil in hv_terminals:
133+
m3d.assign_coil(assignment=coil, conductors_number=hv_turns, name=coil.name)
134+
135+
136+
m3d.assign_winding(
137+
assignment=None,
138+
winding_type="External",
139+
is_solid=False,
140+
name="LVA",
141+
)
142+
143+
m3d.add_winding_coils(assignment="LVA", coils=["LVA_terminal"])
144+
145+
m3d.assign_winding(
146+
assignment=None,
147+
winding_type="External",
148+
is_solid=False,
149+
name="LVB",
150+
)
151+
152+
solution_setup = m3d.create_setup(name="Setup1")
153+
154+
# Create external circuit
155+
circuit = MaxwellCircuit(project=project_name, design="Circuit1")
156+
157+
circuit.schematic_units = "mil"
158+
ind = circuit.modeler.schematic.create_inductor("Inductor1", 1.5, [-1000, 1000])
159+
res = circuit.modeler.schematic.create_resistor("Resistor1", 10, [1000, 1000])
160+
gnd = circuit.modeler.schematic.create_gnd([0.0, 0.0])
161+
winding1 = circuit.modeler.schematic.create_winding("Winding1")
162+
163+
netlist_file = "C:\\export_netlist.sph"
164+
circuit.export_netlist_from_schematic(netlist_file)
165+
166+
m3d.edit_external_circuit(netlist_file_path=netlist_file, schematic_design_name="Circuit1")

0 commit comments

Comments
 (0)