Skip to content

Commit 8595ff7

Browse files
authored
Improved all Examples by adding reports (#968)
* Improved Examples * Improved all Examples by adding reports * Improved all Examples by adding reports * Improved all Examples by adding reports * Improved all Examples by adding reports * Improved all Examples by adding reports * Improved all Examples by adding reports * Improved all Examples by adding reports * Improved all Examples by adding reports * Improved all Examples by adding reports Co-authored-by: maxcapodi78 <Shark78>
1 parent 9d06237 commit 8595ff7

18 files changed

+264
-105
lines changed

_unittest/test_12_PostProcessing.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -213,6 +213,20 @@ def test_09_manipulate_report(self):
213213
if not is_ironpython:
214214
assert data.plot(is_polar=True)
215215
assert data.plot_3d()
216+
self.field_test.modeler.create_polyline([[0, 0, 0], [0, 5, 30]], name="Poly1", non_model=True)
217+
variations2 = self.field_test.available_variations.nominal_w_values_dict
218+
variations2["Theta"] = ["All"]
219+
variations2["Phi"] = ["All"]
220+
variations2["Freq"] = ["30GHz"]
221+
variations2["Distance"] = ["All"]
222+
assert self.field_test.post.create_report(
223+
"Mag_E",
224+
self.field_test.nominal_adaptive,
225+
variations=variations2,
226+
primary_sweep_variable="Distance",
227+
context="Poly1",
228+
report_category="Fields",
229+
)
216230
assert data.primary_sweep == "Theta"
217231
assert data.data_magnitude("GainTotal")
218232
assert not data.data_magnitude("GainTotal2")

_unittest/test_21_Circuit.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,7 @@ def test_08_import_mentor_netlist(self):
118118

119119
def test_09_import_netlist(self):
120120
self.aedtapp.insert_design("SchematicImport")
121+
self.aedtapp.modeler.schematic.limits_mils = 5000
121122
assert self.aedtapp.create_schematic_from_netlist(os.path.join(self.local_scratch.path, netlist1))
122123

123124
def test_10_import_touchstone(self):

examples/00-EDB/03_5G_antenna_example.py

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -214,9 +214,28 @@ def points(self):
214214

215215

216216
###############################################################################
217-
# Solve Setup
218-
#
217+
# Solve Setup and create results
218+
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
219+
# Solves the project and create report.
220+
219221
h3d.analyze_nominal()
220222
h3d.post.create_report(["db(S({0},{1}))".format(port_name, port_name)])
223+
224+
225+
###############################################################################
226+
# Plot Results Outside Electronics Desktop
227+
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
228+
# This example plots results using matplotlib.
229+
230+
solution = h3d.post.get_solution_data(["S({0},{1})".format(port_name, port_name)])
231+
solution.plot()
232+
233+
###############################################################################
234+
# Close AEDT
235+
# ~~~~~~~~~~
236+
# After the simulaton is completed, you can close AEDT or release it using the
237+
# :func:`pyaedt.Desktop.release_desktop` method.
238+
# All methods provide for saving the project before exiting.
239+
221240
h3d.save_project()
222241
h3d.release_desktop()

examples/02-HFSS/HFSS3DLayout_Via.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,16 @@
9494
traces = h3d.get_traces_for_plot(first_element_filter="Port1")
9595
h3d.post.create_report(traces, families_dict=h3d.available_variations.nominal_w_values_dict)
9696

97+
###############################################################################
98+
# Create Report outside AEDT
99+
# ~~~~~~~~~~~~~~~~~~~~~~~~~~
100+
# Create Report using Matplotlib.
101+
traces = h3d.get_traces_for_plot(first_element_filter="Port1", category="S")
102+
103+
solutions = h3d.post.get_solution_data(expressions=traces)
104+
solutions.plot(math_formula="db20")
105+
106+
97107
###############################################################################
98108
# Close AEDT
99109
# ~~~~~~~~~~

examples/02-HFSS/HFSS_Dipole.py

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,36 @@
117117
report_category="Far Fields",
118118
)
119119

120+
###############################################################################
121+
# Postprocessing
122+
# --------------
123+
# The same report can be obtained outside electronic desktop with the
124+
# following commands.
125+
126+
solutions = hfss.post.get_solution_data(
127+
"GainTotal",
128+
hfss.nominal_adaptive,
129+
variations,
130+
primary_sweep_variable="Theta",
131+
context="3D",
132+
report_category="Far Fields",
133+
)
134+
135+
###############################################################################
136+
# 3D Plot
137+
# -------
138+
# plot_3d method created a 3d plot using matplotlib.
139+
140+
solutions.plot_3d()
141+
142+
###############################################################################
143+
# 2D Plot
144+
# -------
145+
# plot method created a 2d plot using matplotlib. is_polar boolean let you
146+
# decide if a polar plot or rectangular plot has to be created.
147+
148+
solutions.plot(math_formula="db20", is_polar=True)
149+
120150
###############################################################################
121151
# Close AEDT
122152
# ~~~~~~~~~~

examples/02-HFSS/SBR_Example.py

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,5 +93,27 @@
9393
context="ATK_3D",
9494
report_category="Far Fields",
9595
)
96+
97+
###############################################################################
98+
# Plot Results Outside Electronics Desktop
99+
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
100+
# This example plots results using matplotlib.
101+
102+
solution = target.post.get_solution_data(
103+
"GainTotal",
104+
target.nominal_adaptive,
105+
variations=variations,
106+
primary_sweep_variable="Theta",
107+
context="ATK_3D",
108+
report_category="Far Fields",
109+
)
110+
solution.plot()
111+
112+
113+
###############################################################################
114+
# Close and Exit Example
115+
# ~~~~~~~~~~~~~~~~~~~~~~
116+
# Release desktop and close example.
117+
96118
if os.name != "posix":
97119
target.release_desktop()

examples/02-Maxwell/Maxwell2D_Transient.py

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -105,9 +105,6 @@
105105
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
106106
# This example creates the output and then plots it using PyVista.
107107

108-
import time
109-
110-
start = time.time()
111108
cutlist = ["Global:XY"]
112109
face_lists = rect1.faces
113110
face_lists += rect2.faces
@@ -124,6 +121,14 @@
124121
export_gif=True,
125122
)
126123

124+
###############################################################################
125+
# Postprocessing
126+
# --------------
127+
# The same report can be obtained outside electronic desktop with the
128+
# following commands.
129+
130+
solutions = maxwell_2d.post.get_solution_data("InputCurrent(PHA)", domain="Time", primary_sweep_variable="Time")
131+
solutions.plot()
127132

128133
###############################################
129134
# Close AEDT

examples/02-Maxwell/Maxwell3DTeam3.py

Lines changed: 38 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -133,27 +133,48 @@
133133

134134
###############################################################################
135135
# Plot mag(Bz) as a function of frequency for both coil positions
136-
Plot = M3D.odesign.GetModule("ReportSetup")
137-
Plot.CreateReport(
138-
"mag(Bz) Along 'Line_AB' Offset Coil",
139-
"Fields",
140-
"Rectangular Plot",
141-
"Setup1 : LastAdaptive",
142-
["Context:=", "Line_AB", "PointCount:=", 1001],
143-
["Distance:=", ["All"], "Freq:=", ["All"], "Phase:=", ["0deg"], "Coil_Position:=", ["-20mm"]],
144-
["X Component:=", "Distance-60mm", "Y Component:=", ["mag(Bz)"]],
136+
variations = {"Distance": ["All"], "Freq": ["All"], "Phase": ["0deg"], "Coil_Position": ["-20mm"]}
137+
M3D.post.create_report(
138+
expressions="mag(Bz)",
139+
report_category="Fields",
140+
context="Line_AB",
141+
variations=variations,
142+
primary_sweep_variable="Distance",
143+
plotname="mag(Bz) Along 'Line_AB' Offset Coil",
145144
)
146145

147-
Plot.CreateReport(
148-
"mag(Bz) Along 'Line_AB' Centred Coil",
149-
"Fields",
150-
"Rectangular Plot",
151-
"Setup1 : LastAdaptive",
152-
["Context:=", "Line_AB", "PointCount:=", 1001],
153-
["Distance:=", ["All"], "Freq:=", ["All"], "Phase:=", ["0deg"], "Coil_Position:=", ["0mm"]],
154-
["X Component:=", "Distance-60mm", "Y Component:=", ["mag(Bz)"]],
146+
variations = {"Distance": ["All"], "Freq": ["All"], "Phase": ["0deg"], "Coil_Position": ["0mm"]}
147+
M3D.post.create_report(
148+
expressions="mag(Bz)",
149+
report_category="Fields",
150+
context="Line_AB",
151+
variations=variations,
152+
primary_sweep_variable="Distance",
153+
plotname="mag(Bz) Along 'Line_AB' Coil",
155154
)
156155

156+
157+
###############################################################################
158+
# Postprocessing
159+
# --------------
160+
# The same report can be obtained outside electronic desktop with the
161+
# following commands.
162+
variations = {"Distance": ["All"], "Freq": ["All"], "Phase": ["0deg"], "Coil_Position": ["All"]}
163+
164+
solutions = M3D.post.get_solution_data(
165+
expressions="mag(Bz)",
166+
report_category="Fields",
167+
context="Line_AB",
168+
variations=variations,
169+
primary_sweep_variable="Distance",
170+
)
171+
solutions.nominal_sweeps["Coil_Position"] = -0.02
172+
solutions.plot()
173+
174+
solutions.nominal_sweeps["Coil_Position"] = 0
175+
solutions.plot()
176+
177+
157178
###############################################################################
158179
# Create a plot Mag_J, the induced current density on the surface of the ladder plate
159180
surflist = primitives.get_object_faces("LadderPlate")

examples/02-Maxwell/Maxwell3DTeam7.py

Lines changed: 29 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -119,20 +119,9 @@
119119
# Turn off displacement currents for all parts
120120
# NB, Eddy effect setting is regardless ignored for stranded conductor type used in Coil
121121

122-
test = M3D.odesign.GetModule("BoundarySetup")
123-
test.SetEddyEffect(
124-
[
125-
"NAME:Eddy Effect Setting",
126-
[
127-
"NAME:EddyEffectVector",
128-
["NAME:Data", "Object Name:=", "Plate", "Eddy Effect:=", True, "Displacement Current:=", False],
129-
["NAME:Data", "Object Name:=", "Coil", "Eddy Effect:=", False, "Displacement Current:=", False],
130-
["NAME:Data", "Object Name:=", "Region", "Eddy Effect:=", False, "Displacement Current:=", False],
131-
["NAME:Data", "Object Name:=", "Line_A1_B1mesh", "Eddy Effect:=", False, "Displacement Current:=", False],
132-
["NAME:Data", "Object Name:=", "Line_A2_B2mesh", "Eddy Effect:=", False, "Displacement Current:=", False],
133-
],
134-
]
135-
)
122+
M3D.eddy_effects_on("Plate")
123+
M3D.eddy_effects_on(["Coil", "Region", "Line_A1_B1mesh", "Line_A2_B2mesh"], False)
124+
136125

137126
################################################################################
138127
# Use Fields Calculator to create an expression for Z Component of B in Gauss
@@ -313,42 +302,34 @@
313302
if item % 2 == 0:
314303
plotname = dataset[item][0:3] + "Along the Line" + dataset[item][2:9] + ", " + dataset[item][9:12] + "Hz"
315304
if dataset[item][9:12] == "000":
316-
Plot.CreateReport(
317-
plotname,
318-
"Fields",
319-
"Rectangular Plot",
320-
"Setup1 : LastAdaptive",
321-
["Context:=", "Line_" + dataset[item][3:8], "PointCount:=", 1001],
322-
[
323-
"Distance:=",
324-
["All"],
325-
"Freq:=",
326-
[str(dc_freq) + "Hz"],
327-
"Phase:=",
328-
["0deg"],
329-
"Coil_Excitation:=",
330-
["All"],
331-
],
332-
["X Component:=", "Distance", "Y Component:=", [dataset[item][0:2]]],
305+
variations = {
306+
"Distance": ["All"],
307+
"Freq": [str(dc_freq) + "Hz"],
308+
"Phase": ["0deg"],
309+
"Coil_Excitation": ["All"],
310+
}
311+
M3D.post.create_report(
312+
plotname=plotname,
313+
report_category="Fields",
314+
context="Line_" + dataset[item][3:8],
315+
primary_sweep_variable="Distance",
316+
variations=variations,
317+
expressions=dataset[item][0:2],
333318
)
334319
else:
335-
Plot.CreateReport(
336-
plotname,
337-
"Fields",
338-
"Rectangular Plot",
339-
"Setup1 : LastAdaptive",
340-
["Context:=", "Line_" + dataset[item][3:8], "PointCount:=", 1001],
341-
[
342-
"Distance:=",
343-
["All"],
344-
"Freq:=",
345-
[dataset[item][9:12] + "Hz"],
346-
"Phase:=",
347-
["0deg", "90deg"],
348-
"Coil_Excitation:=",
349-
["All"],
350-
],
351-
["X Component:=", "Distance", "Y Component:=", [dataset[item][0:2]]],
320+
variations = {
321+
"Distance": ["All"],
322+
"Freq": [dataset[item][9:12] + "Hz"],
323+
"Phase": ["0deg", "90deg"],
324+
"Coil_Excitation": ["All"],
325+
}
326+
M3D.post.create_report(
327+
plotname=plotname,
328+
report_category="Fields",
329+
context="Line_" + dataset[item][3:8],
330+
primary_sweep_variable="Distance",
331+
variations=variations,
332+
expressions=dataset[item][0:2],
352333
)
353334

354335
# Import test data into the correct plot and overlay it with simulation results.

examples/03-Circuit/Circuit_Example.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,19 @@
9999
aedt_app.analyze_setup("MyLNA")
100100

101101
aedt_app.export_fullwave_spice()
102+
103+
104+
###############################################################################
105+
# Postprocessing
106+
# --------------
107+
# Create Report.
108+
109+
solutions = aedt_app.post.get_solution_data(
110+
expressions=aedt_app.get_traces_for_plot(category="S"),
111+
)
112+
fig = solutions.plot()
113+
114+
102115
###############################################################################
103116
# Close AEDT
104117
# ~~~~~~~~~~

examples/04-Icepak/Icepak_Example.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,5 +99,6 @@
9999

100100
plot5 = ipk.post.create_fieldplot_surface(surflist, "SurfTemperature")
101101

102+
102103
ipk.analyze_nominal()
103104
ipk.release_desktop(True, True)

examples/05-Q3D/Q3D_Example.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -145,6 +145,7 @@
145145
a.sweeps["Freq"]
146146
a.data_magnitude()
147147
a.plot()
148+
148149
###############################################################################
149150
# Close AEDT
150151
# ~~~~~~~~~~

pyaedt/application/AnalysisNexxim.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -120,9 +120,9 @@ def excitations(self):
120120
References
121121
----------
122122
123-
>>> oModule.GetExcitations
123+
>>> oModule.GetAllPorts
124124
"""
125-
ports = [p.replace("IPort@", "").split(";")[0] for p in self.modeler.oeditor.GetAllPorts()]
125+
ports = [p.replace("IPort@", "").split(";")[0] for p in self.modeler.oeditor.GetAllPorts() if "IPort@" in p]
126126
return ports
127127

128128
@property

0 commit comments

Comments
 (0)