Skip to content

Improved all Examples by adding reports #968

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 10 commits into from
Mar 18, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions _unittest/test_12_PostProcessing.py
Original file line number Diff line number Diff line change
Expand Up @@ -213,6 +213,20 @@ def test_09_manipulate_report(self):
if not is_ironpython:
assert data.plot(is_polar=True)
assert data.plot_3d()
self.field_test.modeler.create_polyline([[0, 0, 0], [0, 5, 30]], name="Poly1", non_model=True)
variations2 = self.field_test.available_variations.nominal_w_values_dict
variations2["Theta"] = ["All"]
variations2["Phi"] = ["All"]
variations2["Freq"] = ["30GHz"]
variations2["Distance"] = ["All"]
assert self.field_test.post.create_report(
"Mag_E",
self.field_test.nominal_adaptive,
variations=variations2,
primary_sweep_variable="Distance",
context="Poly1",
report_category="Fields",
)
assert data.primary_sweep == "Theta"
assert data.data_magnitude("GainTotal")
assert not data.data_magnitude("GainTotal2")
Expand Down
1 change: 1 addition & 0 deletions _unittest/test_21_Circuit.py
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,7 @@ def test_08_import_mentor_netlist(self):

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

def test_10_import_touchstone(self):
Expand Down
23 changes: 21 additions & 2 deletions examples/00-EDB/03_5G_antenna_example.py
Original file line number Diff line number Diff line change
Expand Up @@ -214,9 +214,28 @@ def points(self):


###############################################################################
# Solve Setup
#
# Solve Setup and create results
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# Solves the project and create report.

h3d.analyze_nominal()
h3d.post.create_report(["db(S({0},{1}))".format(port_name, port_name)])


###############################################################################
# Plot Results Outside Electronics Desktop
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# This example plots results using matplotlib.

solution = h3d.post.get_solution_data(["S({0},{1})".format(port_name, port_name)])
solution.plot()

###############################################################################
# Close AEDT
# ~~~~~~~~~~
# After the simulaton is completed, you can close AEDT or release it using the
# :func:`pyaedt.Desktop.release_desktop` method.
# All methods provide for saving the project before exiting.

h3d.save_project()
h3d.release_desktop()
10 changes: 10 additions & 0 deletions examples/02-HFSS/HFSS3DLayout_Via.py
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,16 @@
traces = h3d.get_traces_for_plot(first_element_filter="Port1")
h3d.post.create_report(traces, families_dict=h3d.available_variations.nominal_w_values_dict)

###############################################################################
# Create Report outside AEDT
# ~~~~~~~~~~~~~~~~~~~~~~~~~~
# Create Report using Matplotlib.
traces = h3d.get_traces_for_plot(first_element_filter="Port1", category="S")

solutions = h3d.post.get_solution_data(expressions=traces)
solutions.plot(math_formula="db20")


###############################################################################
# Close AEDT
# ~~~~~~~~~~
Expand Down
30 changes: 30 additions & 0 deletions examples/02-HFSS/HFSS_Dipole.py
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,36 @@
report_category="Far Fields",
)

###############################################################################
# Postprocessing
# --------------
# The same report can be obtained outside electronic desktop with the
# following commands.

solutions = hfss.post.get_solution_data(
"GainTotal",
hfss.nominal_adaptive,
variations,
primary_sweep_variable="Theta",
context="3D",
report_category="Far Fields",
)

###############################################################################
# 3D Plot
# -------
# plot_3d method created a 3d plot using matplotlib.

solutions.plot_3d()

###############################################################################
# 2D Plot
# -------
# plot method created a 2d plot using matplotlib. is_polar boolean let you
# decide if a polar plot or rectangular plot has to be created.

solutions.plot(math_formula="db20", is_polar=True)

###############################################################################
# Close AEDT
# ~~~~~~~~~~
Expand Down
22 changes: 22 additions & 0 deletions examples/02-HFSS/SBR_Example.py
Original file line number Diff line number Diff line change
Expand Up @@ -93,5 +93,27 @@
context="ATK_3D",
report_category="Far Fields",
)

###############################################################################
# Plot Results Outside Electronics Desktop
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# This example plots results using matplotlib.

solution = target.post.get_solution_data(
"GainTotal",
target.nominal_adaptive,
variations=variations,
primary_sweep_variable="Theta",
context="ATK_3D",
report_category="Far Fields",
)
solution.plot()


###############################################################################
# Close and Exit Example
# ~~~~~~~~~~~~~~~~~~~~~~
# Release desktop and close example.

if os.name != "posix":
target.release_desktop()
11 changes: 8 additions & 3 deletions examples/02-Maxwell/Maxwell2D_Transient.py
Original file line number Diff line number Diff line change
Expand Up @@ -105,9 +105,6 @@
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# This example creates the output and then plots it using PyVista.

import time

start = time.time()
cutlist = ["Global:XY"]
face_lists = rect1.faces
face_lists += rect2.faces
Expand All @@ -124,6 +121,14 @@
export_gif=True,
)

###############################################################################
# Postprocessing
# --------------
# The same report can be obtained outside electronic desktop with the
# following commands.

solutions = maxwell_2d.post.get_solution_data("InputCurrent(PHA)", domain="Time", primary_sweep_variable="Time")
solutions.plot()

###############################################
# Close AEDT
Expand Down
55 changes: 38 additions & 17 deletions examples/02-Maxwell/Maxwell3DTeam3.py
Original file line number Diff line number Diff line change
Expand Up @@ -133,27 +133,48 @@

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

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


###############################################################################
# Postprocessing
# --------------
# The same report can be obtained outside electronic desktop with the
# following commands.
variations = {"Distance": ["All"], "Freq": ["All"], "Phase": ["0deg"], "Coil_Position": ["All"]}

solutions = M3D.post.get_solution_data(
expressions="mag(Bz)",
report_category="Fields",
context="Line_AB",
variations=variations,
primary_sweep_variable="Distance",
)
solutions.nominal_sweeps["Coil_Position"] = -0.02
solutions.plot()

solutions.nominal_sweeps["Coil_Position"] = 0
solutions.plot()


###############################################################################
# Create a plot Mag_J, the induced current density on the surface of the ladder plate
surflist = primitives.get_object_faces("LadderPlate")
Expand Down
77 changes: 29 additions & 48 deletions examples/02-Maxwell/Maxwell3DTeam7.py
Original file line number Diff line number Diff line change
Expand Up @@ -119,20 +119,9 @@
# Turn off displacement currents for all parts
# NB, Eddy effect setting is regardless ignored for stranded conductor type used in Coil

test = M3D.odesign.GetModule("BoundarySetup")
test.SetEddyEffect(
[
"NAME:Eddy Effect Setting",
[
"NAME:EddyEffectVector",
["NAME:Data", "Object Name:=", "Plate", "Eddy Effect:=", True, "Displacement Current:=", False],
["NAME:Data", "Object Name:=", "Coil", "Eddy Effect:=", False, "Displacement Current:=", False],
["NAME:Data", "Object Name:=", "Region", "Eddy Effect:=", False, "Displacement Current:=", False],
["NAME:Data", "Object Name:=", "Line_A1_B1mesh", "Eddy Effect:=", False, "Displacement Current:=", False],
["NAME:Data", "Object Name:=", "Line_A2_B2mesh", "Eddy Effect:=", False, "Displacement Current:=", False],
],
]
)
M3D.eddy_effects_on("Plate")
M3D.eddy_effects_on(["Coil", "Region", "Line_A1_B1mesh", "Line_A2_B2mesh"], False)


################################################################################
# Use Fields Calculator to create an expression for Z Component of B in Gauss
Expand Down Expand Up @@ -313,42 +302,34 @@
if item % 2 == 0:
plotname = dataset[item][0:3] + "Along the Line" + dataset[item][2:9] + ", " + dataset[item][9:12] + "Hz"
if dataset[item][9:12] == "000":
Plot.CreateReport(
plotname,
"Fields",
"Rectangular Plot",
"Setup1 : LastAdaptive",
["Context:=", "Line_" + dataset[item][3:8], "PointCount:=", 1001],
[
"Distance:=",
["All"],
"Freq:=",
[str(dc_freq) + "Hz"],
"Phase:=",
["0deg"],
"Coil_Excitation:=",
["All"],
],
["X Component:=", "Distance", "Y Component:=", [dataset[item][0:2]]],
variations = {
"Distance": ["All"],
"Freq": [str(dc_freq) + "Hz"],
"Phase": ["0deg"],
"Coil_Excitation": ["All"],
}
M3D.post.create_report(
plotname=plotname,
report_category="Fields",
context="Line_" + dataset[item][3:8],
primary_sweep_variable="Distance",
variations=variations,
expressions=dataset[item][0:2],
)
else:
Plot.CreateReport(
plotname,
"Fields",
"Rectangular Plot",
"Setup1 : LastAdaptive",
["Context:=", "Line_" + dataset[item][3:8], "PointCount:=", 1001],
[
"Distance:=",
["All"],
"Freq:=",
[dataset[item][9:12] + "Hz"],
"Phase:=",
["0deg", "90deg"],
"Coil_Excitation:=",
["All"],
],
["X Component:=", "Distance", "Y Component:=", [dataset[item][0:2]]],
variations = {
"Distance": ["All"],
"Freq": [dataset[item][9:12] + "Hz"],
"Phase": ["0deg", "90deg"],
"Coil_Excitation": ["All"],
}
M3D.post.create_report(
plotname=plotname,
report_category="Fields",
context="Line_" + dataset[item][3:8],
primary_sweep_variable="Distance",
variations=variations,
expressions=dataset[item][0:2],
)

# Import test data into the correct plot and overlay it with simulation results.
Expand Down
13 changes: 13 additions & 0 deletions examples/03-Circuit/Circuit_Example.py
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,19 @@
aedt_app.analyze_setup("MyLNA")

aedt_app.export_fullwave_spice()


###############################################################################
# Postprocessing
# --------------
# Create Report.

solutions = aedt_app.post.get_solution_data(
expressions=aedt_app.get_traces_for_plot(category="S"),
)
fig = solutions.plot()


###############################################################################
# Close AEDT
# ~~~~~~~~~~
Expand Down
1 change: 1 addition & 0 deletions examples/04-Icepak/Icepak_Example.py
Original file line number Diff line number Diff line change
Expand Up @@ -99,5 +99,6 @@

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


ipk.analyze_nominal()
ipk.release_desktop(True, True)
1 change: 1 addition & 0 deletions examples/05-Q3D/Q3D_Example.py
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,7 @@
a.sweeps["Freq"]
a.data_magnitude()
a.plot()

###############################################################################
# Close AEDT
# ~~~~~~~~~~
Expand Down
4 changes: 2 additions & 2 deletions pyaedt/application/AnalysisNexxim.py
Original file line number Diff line number Diff line change
Expand Up @@ -120,9 +120,9 @@ def excitations(self):
References
----------

>>> oModule.GetExcitations
>>> oModule.GetAllPorts
"""
ports = [p.replace("IPort@", "").split(";")[0] for p in self.modeler.oeditor.GetAllPorts()]
ports = [p.replace("IPort@", "").split(";")[0] for p in self.modeler.oeditor.GetAllPorts() if "IPort@" in p]
return ports

@property
Expand Down
Loading