Skip to content

added create_report method to replace create_rectangular plot method … #954

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 9 commits into from
Mar 15, 2022
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
$begin 'Models'
$end 'Models'
13,908 changes: 13,908 additions & 0 deletions _unittest/example_models/Switching_Speed_FET_And_Diode.aedt

Large diffs are not rendered by default.

56 changes: 55 additions & 1 deletion _unittest/test_12_PostProcessing.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,13 @@

from _unittest.conftest import BasisTest
from _unittest.conftest import config
from pyaedt import Circuit
from pyaedt import Hfss
from pyaedt.generic.general_methods import is_ironpython

# Import required modules
# Setup paths for module imports

try:
import pytest
except ImportError:
Expand All @@ -20,6 +24,7 @@

test_project_name = "coax_setup_solved"
test_field_name = "Potter_Horn"
test_circuit_name = "Switching_Speed_FET_And_Diode"


class TestClass(BasisTest, object):
Expand All @@ -28,6 +33,10 @@ def setup_class(self):
BasisTest.my_setup(self)
self.aedtapp = BasisTest.add_app(self, project_name=test_project_name)
self.field_test = BasisTest.add_app(self, project_name=test_field_name)
self.circuit_test = BasisTest.add_app(
self, project_name=test_circuit_name, design_name="Diode", application=Circuit
)
self.diff_test = Circuit(designname="diff", projectname=self.circuit_test.project_name)

def teardown_class(self):
BasisTest.my_teardown(self)
Expand Down Expand Up @@ -174,8 +183,28 @@ def test_08_manipulate_report(self):
assert self.aedtapp.post.rename_report("MyTestScattering", "MyNewScattering")

def test_09_manipulate_report(self):
assert self.aedtapp.post.create_rectangular_plot("dB(S(1,1))")
assert self.aedtapp.post.create_report("dB(S(1,1))")
assert len(self.aedtapp.post.all_report_names) > 0
variations = self.field_test.available_variations.nominal_w_values_dict
variations["Theta"] = ["All"]
variations["Phi"] = ["All"]
variations["Freq"] = ["30GHz"]
assert self.field_test.post.create_report(
"db(GainTotal)",
self.field_test.nominal_adaptive,
variations=variations,
primary_sweep_variable="Phi",
secondary_sweep_variable="Theta",
plot_type="3D Polar Plot",
context="3D",
report_category="Far Fields",
)
self.field_test.post.create_report(
"S(1,1)",
self.field_test.nominal_sweep,
variations=variations,
plot_type="Smith Chart",
)

def test_09b_export_report(self):
files = self.aedtapp.export_results()
Expand Down Expand Up @@ -240,6 +269,31 @@ def test_16_create_field_plot(self):
)
assert plot

def test_17_circuit(self):
self.circuit_test.analyze_setup("LNA")
self.circuit_test.analyze_setup("Transient")
assert self.circuit_test.post.create_report(["dB(S(Port1, Port1))", "dB(S(Port1, Port2))"], "LNA")
assert self.circuit_test.post.create_report(["V(net_11)"], "Transient", "Time")

def test_18_diff_plot(self):
self.diff_test.analyze_setup("LinearFrequency")
variations = self.diff_test.available_variations.nominal_w_values_dict
variations["Freq"] = ["1GHz"]
variations["l1"] = ["All"]
assert self.diff_test.post.create_report(
["dB(S(Diff1, Diff1))"],
"LinearFrequency",
variations=variations,
primary_sweep_variable="l1",
context="Differential Pairs",
)
assert self.diff_test.create_touchstone_report(
plot_name="Diff_plot",
curvenames=["dB(S(Diff1, Diff1))"],
solution_name="LinearFrequency",
differential_pairs=True,
)

def test_51_get_efields(self):
if is_ironpython:
assert True
Expand Down
1 change: 1 addition & 0 deletions _unittest/test_31_Q3D.py
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,7 @@ def test_13_matrix_reduction(self):
mutual_list = q3d.matrices[0].get_sources_for_plot(
get_self_terms=False, category=q3d.matrices[0].CATEGORIES.Q3D.ACL
)
assert q3d.get_traces_for_plot() == q3d.matrices[0].get_sources_for_plot()
assert len(full_list) > len(mutual_list)
assert q3d.matrices[0].get_sources_for_plot(first_element_filter="Box?", second_element_filter="B*2") == [
"C(Box1,Box1_2)"
Expand Down
2 changes: 1 addition & 1 deletion examples/00-EDB/03_5G_antenna_example.py
Original file line number Diff line number Diff line change
Expand Up @@ -217,6 +217,6 @@ def points(self):
# Solve Setup
#
h3d.analyze_nominal()
h3d.post.create_rectangular_plot(["db(S({0},{1}))".format(port_name, port_name)])
h3d.post.create_report(["db(S({0},{1}))".format(port_name, port_name)])
h3d.save_project()
h3d.release_desktop()
2 changes: 1 addition & 1 deletion examples/02-HFSS/HFSS3DLayout_Via.py
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@

h3d.analyze_nominal()
traces = h3d.get_traces_for_plot(first_element_filter="Port1")
h3d.post.create_rectangular_plot(traces, families_dict=h3d.available_variations.nominal_w_values_dict)
h3d.post.create_report(traces, families_dict=h3d.available_variations.nominal_w_values_dict)

###############################################################################
# Close AEDT
Expand Down
9 changes: 7 additions & 2 deletions examples/02-HFSS/HFSS_Dipole.py
Original file line number Diff line number Diff line change
Expand Up @@ -108,8 +108,13 @@
variations["Freq"] = ["1GHz"]
variations["Theta"] = ["All"]
variations["Phi"] = ["All"]
hfss.post.create_rectangular_plot(
"db(GainTotal)", hfss.nominal_adaptive, variations, "Theta", "3D", report_category="Far Fields"
hfss.post.create_report(
"db(GainTotal)",
hfss.nominal_adaptive,
variations,
primary_sweep_variable="Theta",
context="3D",
report_category="Far Fields",
)

###############################################################################
Expand Down
9 changes: 7 additions & 2 deletions examples/02-HFSS/SBR_Example.py
Original file line number Diff line number Diff line change
Expand Up @@ -85,8 +85,13 @@
variations["Freq"] = ["10GHz"]
variations["Theta"] = ["All"]
variations["Phi"] = ["All"]
target.post.create_rectangular_plot(
"db(GainTotal)", target.nominal_adaptive, variations, "Theta", "ATK_3D", report_category="Far Fields"
target.post.create_report(
"db(GainTotal)",
target.nominal_adaptive,
variations=variations,
primary_sweep_variable="Theta",
context="ATK_3D",
report_category="Far Fields",
)
if os.name != "posix":
target.release_desktop()
4 changes: 2 additions & 2 deletions examples/02-Maxwell/Maxwell2D_Transient.py
Original file line number Diff line number Diff line change
Expand Up @@ -89,8 +89,8 @@
# ~~~~~~~~~~~~~~~~~~~~~~~~~
# This command creates a rectangular plot.

maxwell_2d.post.create_rectangular_plot(
"InputCurrent(PHA)", primary_sweep_variable="Time", families_dict={"Time": ["All"]}, plotname="Winding Plot 1"
maxwell_2d.post.create_report(
"InputCurrent(PHA)", domain="Time", primary_sweep_variable="Time", plotname="Winding Plot 1"
)

###############################################################################
Expand Down
6 changes: 3 additions & 3 deletions examples/05-Q3D/Q3D_Example.py
Original file line number Diff line number Diff line change
Expand Up @@ -113,17 +113,17 @@
# This command simplify the way you can get curves to be plotted.

data_plot_self = q.matrices[0].get_sources_for_plot(get_self_terms=True, get_mutual_terms=False)
data_plot_mutual = q.get_traces_for_plot(get_self_terms=False, get_mutual_terms=True)
data_plot_mutual = q.get_traces_for_plot(get_self_terms=False, get_mutual_terms=True, category="C")
data_plot_self
data_plot_mutual

###############################################################################
# Create a Rectangular Plot
# ~~~~~~~~~~~~~~~~~~~~~~~~~
# This command creates a rectangular plot and a Data Table.
q.post.create_rectangular_plot(expression=data_plot_self, context="Original")
q.post.create_report(expressions=data_plot_self)

q.post.create_rectangular_plot(expression=data_plot_mutual, context="Original", plot_type="Data Table")
q.post.create_report(expressions=data_plot_mutual, context="Original", plot_type="Data Table")

###############################################################################
# Solve the Setup
Expand Down
2 changes: 1 addition & 1 deletion pyaedt/application/Analysis.py
Original file line number Diff line number Diff line change
Expand Up @@ -974,7 +974,7 @@ def nominal_w_values_dict(self):
>>> oDesign.GetVariableValue
>>> oDesign.GetNominalVariation"""
families = {}
if self._app.design_type == "HFSS 3D Layout Design":
if self._app.design_type in ["HFSS 3D Layout Design", "Circuit Design", "Twin Builder"]:
if self._app._is_object_oriented_enabled():
listvar = list(self._app._odesign.GetChildObject("Variables").GetChildNames())
else:
Expand Down
10 changes: 10 additions & 0 deletions pyaedt/application/AnalysisNexxim.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,16 @@ def post(self):
"""
return self._post

@property
def existing_analysis_sweeps(self):
"""Analysis setups.

References
----------

>>> oModule.GetAllSolutionSetups"""
return self.existing_analysis_setups

@property
def existing_analysis_setups(self):
"""Analysis setups.
Expand Down
17 changes: 8 additions & 9 deletions pyaedt/circuit.py
Original file line number Diff line number Diff line change
Expand Up @@ -965,6 +965,7 @@ def create_touchstone_report(
curvenames,
solution_name=None,
variation_dict=None,
differential_pairs=False,
subdesign_id=None,
):
"""
Expand All @@ -980,9 +981,10 @@ def create_touchstone_report(
Name of the solution. The default value is ``None``.
variation_dict : dict, optional
Dictionary of variation names. The default value is ``None``.
differential_pairs : bool, optional
Specify if the plot is on differential pairs tracs. The default value is ``False``.
subdesign_id : int, optional
Specify a subdesign ID to export a Touchstone file of this subdesign. The default value is ``None``.

Returns
-------
bool
Expand All @@ -999,14 +1001,11 @@ def create_touchstone_report(
if variation_dict:
for el in variation_dict:
variations[el] = [variation_dict[el]]
ctxt = ["NAME:Context", "SimValueContext:=", [3, 0, 2, 0, False, False, -1, 1, 0, 1, 1, "", 0, 0]]
if subdesign_id:
ctxt_temp = ["NUMLEVELS", False, "0", "SUBDESIGNID", False, str(subdesign_id)]
for el in ctxt_temp:
ctxt[2].append(el)

return self.post.create_rectangular_plot(
curvenames, solution_name, variations, plotname=plot_name, context=ctxt
dif = None
if differential_pairs:
dif = "Differential Pairs"
return self.post.create_report(
curvenames, solution_name, variations=variations, plotname=plot_name, context=dif, subdesign_id=subdesign_id
)

@pyaedt_function_handler()
Expand Down
49 changes: 10 additions & 39 deletions pyaedt/hfss.py
Original file line number Diff line number Diff line change
Expand Up @@ -3949,7 +3949,7 @@ def create_scattering(

Parameters
----------
PlotName : str, optional
plot_name : str, optional
Name of the plot. The default is ``"S Parameter Plot Nominal"``.
sweep_name : str, optional
Name of the sweep. The default is ``None``.
Expand Down Expand Up @@ -3981,48 +3981,19 @@ def create_scattering(

"""

Families = ["Freq:=", ["All"]]
if variations:
Families += variations
else:
Families += self.get_nominal_variation()
if not sweep_name:
sweep_name = self.existing_analysis_sweeps[1]
elif sweep_name not in self.existing_analysis_sweeps:
self.logger.error("Setup %s doesn't exist in the Setup list.", sweep_name)
return False
if not port_names:
port_names = self.excitations
full_matrix = False
if not port_excited:
port_excited = port_names
full_matrix = True
if type(port_names) is str:
port_names = [port_names]
if type(port_excited) is str:
port_excited = [port_excited]
list_y = []
for p in list(port_names):
for q in list(port_excited):
if not full_matrix:
list_y.append("dB(S(" + p + "," + q + "))")
elif port_excited.index(q) >= port_names.index(p):
list_y.append("dB(S(" + p + "," + q + "))")

Trace = ["X Component:=", "Freq", "Y Component:=", list_y]
solution_data = ""
solution_data = "Standard"
if "Modal" in self.solution_type:
solution_data = "Modal Solution Data"
elif "Terminal" in self.solution_type:
solution_data = "Terminal Solution Data"
if solution_data != "":
# run CreateReport function

self.post.oreportsetup.CreateReport(
plot_name, solution_data, "Rectangular Plot", sweep_name, ["Domain:=", "Sweep"], Families, Trace, []
)
return True
return False
if not port_names:
port_names = self.excitations
if not port_excited:
port_excited = port_names
traces = ["dB(S(" + p + "," + q + "))" for p, q in zip(list(port_names), list(port_excited))]
return self.post.create_report(
traces, sweep_name, variations=variations, report_category=solution_data, plotname=plot_name
)

@pyaedt_function_handler()
def create_qfactor_report(self, project_dir, outputlist, setupname, plotname, Xaxis="X"):
Expand Down
39 changes: 10 additions & 29 deletions pyaedt/hfss3dlayout.py
Original file line number Diff line number Diff line change
Expand Up @@ -497,7 +497,7 @@ def create_scattering(

Parameters
----------
PlotName : str, optional
plot_name : str, optional
Name of the plot. The default is ``"S Parameter Plot Nominal"``.
sweep_name : str, optional
Name of the sweep. The default is ``None``.
Expand All @@ -518,38 +518,19 @@ def create_scattering(

>>> oModule.CreateReport
"""
Families = ["Freq:=", ["All"]]
if variations:
Families += variations
else:
Families += self.get_nominal_variation()
if not sweep_name:
sweep_name = self.existing_analysis_sweeps[1]
if not port_names:
port_names = self.excitations
if not port_excited:
port_excited = port_names
Trace = [
"X Component:=",
"Freq",
"Y Component:=",
["dB(S(" + p + "," + q + "))" for p, q in zip(list(port_names), list(port_excited))],
]
solution_data = ""
solution_data = "Standard"
if "Modal" in self.solution_type:
solution_data = "Modal Solution Data"
elif "Terminal" in self.solution_type:
solution_data = "Terminal Solution Data"
elif self.solution_type == "HFSS3DLayout":
solution_data = "Standard"
if solution_data != "":
# run CreateReport function
self.post.oreportsetup.CreateReport(
plot_name, solution_data, "Rectangular Plot", sweep_name, ["Domain:=", "Sweep"], Families, Trace, []
)
return True
else:
return False
if not port_names:
port_names = self.excitations
if not port_excited:
port_excited = port_names
traces = ["dB(S(" + p + "," + q + "))" for p, q in zip(list(port_names), list(port_excited))]
return self.post.create_report(
traces, sweep_name, variations=variations, report_category=solution_data, plotname=plot_name
)

@pyaedt_function_handler()
def export_touchstone(self, solutionname, sweepname, filename, variation, variations_value):
Expand Down
Loading