Skip to content
Merged
1 change: 1 addition & 0 deletions doc/changelog.d/6808.added.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Add TB spectral report context
6 changes: 2 additions & 4 deletions src/ansys/aedt/core/visualization/report/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -605,10 +605,8 @@ def expressions(self, value):
else:
self._legacy_props["expressions"].append({"name": el})
elif isinstance(value, str):
if isinstance(self._legacy_props["expressions"], list):
self._legacy_props["expressions"].append({"name": value})
else:
self._legacy_props["expressions"] = [{"name": value}]
self._legacy_props["expressions"] = []
self._legacy_props["expressions"].append({"name": value})

@property
def report_category(self):
Expand Down
185 changes: 122 additions & 63 deletions src/ansys/aedt/core/visualization/report/standard.py
Original file line number Diff line number Diff line change
Expand Up @@ -555,6 +555,7 @@ def __init__(self, app, report_category, setup_name, expressions=None):
self.max_frequency = "10MHz"
self.plot_continous_spectrum = False
self.primary_sweep = "Spectrum"
self.noise_threshold = "60"

@property
def time_start(self):
Expand Down Expand Up @@ -661,6 +662,21 @@ def max_frequency(self):
def max_frequency(self, value):
self._legacy_props["context"]["max_frequency"] = value

@property
def noise_threshold(self):
"""Noise Threshold in dB.

Returns
-------
str
Noise Threshold.
"""
return self._legacy_props["context"].get("noise_threshold", 0)

@noise_threshold.setter
def noise_threshold(self, value):
self._legacy_props["context"]["noise_threshold"] = value

@property
def _context(self):
if self.algorithm == "FFT":
Expand All @@ -681,65 +697,113 @@ def _context(self):
"Lanzcos": "8",
}
wt = WT[self.window]
arg = [
"NAME:Context",
"SimValueContext:=",
[
2,
0,
2,
0,
False,
False,
-1,
1,
0,
1,
1,
"",
0,
0,
"CP",
False,
"1" if self.plot_continous_spectrum else "0",
"IT",
False,
it,
"MF",
False,
self.max_frequency,
"NUMLEVELS",
False,
"0",
"TE",
False,
self.time_stop,
"TS",
False,
self.time_start,
"WT",
False,
wt,
"WW",
False,
"100",
"KP",
False,
str(self.kaiser_coeff),
"CG",
False,
"1" if self.adjust_coherent_gain else "0",
],
]
if self._app.design_type == "Circuit Design":
arg = [
"NAME:Context",
"SimValueContext:=",
[
2,
0,
2,
0,
False,
False,
-1,
1,
0,
1,
1,
"",
0,
0,
"CP",
False,
"1" if self.plot_continous_spectrum else "0",
"IT",
False,
it,
"MF",
False,
self.max_frequency,
"NUMLEVELS",
False,
"0",
"TE",
False,
self.time_stop,
"TS",
False,
self.time_start,
"WT",
False,
wt,
"WW",
False,
"100",
"KP",
False,
str(self.kaiser_coeff),
"CG",
False,
"1" if self.adjust_coherent_gain else "0",
],
]
elif self._app.design_type == "Twin Builder":
arg = [
"NAME:Context",
"SimValueContext:=",
[
2,
0,
2,
0,
False,
False,
-1,
1,
0,
1,
1,
"",
0,
0,
"CF",
False,
self.max_frequency,
"CG",
False,
"0",
"CP",
False,
"0",
"IT",
False,
it,
"KP",
False,
str(self.kaiser_coeff),
"NTC",
False,
"1",
"TE",
False,
self.time_stop,
"TH",
False,
self.noise_threshold,
"TS",
False,
self.time_start,
"WT",
False,
wt,
"WW",
False,
"100",
],
]
return arg

@property
def _trace_info(self):
if isinstance(self.expressions, list):
return self.expressions
else:
return [self.expressions]

@pyaedt_function_handler()
def create(self, name=None):
"""Create an eye diagram report.
Expand All @@ -766,12 +830,7 @@ def create(self, name=None):
self.setup,
self._context,
self._convert_dict_to_report_sel(self.variations),
[
"X Component:=",
self.primary_sweep,
"Y Component:=",
self._trace_info,
],
self._trace_info,
)
self._post.plots.append(self)
self._is_created = True
Expand Down
2 changes: 1 addition & 1 deletion tests/system/general/test_34_TwinBuilder.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ def desktop():
d.close_desktop()


@pytest.mark.skipif(is_linux, reason="Emit API fails on linux.")
@pytest.mark.skipif(is_linux, reason="Twinbuilder is only available in Windows OS.")
class TestClass:
@pytest.fixture(autouse=True)
def init(self, aedtapp, local_scratch, examples):
Expand Down
Binary file not shown.
22 changes: 22 additions & 0 deletions tests/system/visualization/test_12_PostProcessing.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@
from ansys.aedt.core import Maxwell3d
from ansys.aedt.core import Q2d
from ansys.aedt.core import Q3d
from ansys.aedt.core import TwinBuilder
from ansys.aedt.core.generic.general_methods import is_linux
from ansys.aedt.core.generic.settings import settings
from ansys.aedt.core.visualization.plot.pyvista import _parse_aedtplt
from ansys.aedt.core.visualization.plot.pyvista import _parse_streamline
Expand All @@ -52,6 +54,7 @@
test_emi_name = "EMI_RCV_251"
ipk_post_proj = "for_icepak_post_parasolid"
ipk_markers_proj = "ipk_markers"
tb_spectral = "TB_excitation_model"

test_subfolder = "T12"

Expand Down Expand Up @@ -147,6 +150,13 @@ def m3d_app(add_app):
app.close_project(save=False)


@pytest.fixture()
def tb_app(add_app):
app = add_app(project_name=tb_spectral, application=TwinBuilder, subfolder=test_subfolder)
yield app
app.close_project(save=False)


class TestClass:
def test_circuit_export_results(self, circuit_test):
files = circuit_test.export_results()
Expand Down Expand Up @@ -773,3 +783,15 @@ def test_m3d_get_solution_data_matrix(self, m3d_app):
)
data = m3d_app.post.get_solution_data(expressions=expressions, context="Matrix1")
assert data

@pytest.mark.skipif(is_linux, reason="Twinbuilder is only available in Windows OS.")
def test_twinbuilder_spectral(self, tb_app):
assert tb_app.post.create_report(
expressions="mag(E1.I)", primary_sweep_variable="Spectrum", plot_name="Spectral domain", domain="Spectral"
)
new_report = tb_app.post.reports_by_category.spectral("mag(E1.I)", "TR")
new_report.window = "Rectangular"
new_report.max_frequency = "2.5MHz"
new_report.time_start = "0ns"
new_report.time_stop = "40ms"
assert new_report.create()
Loading