diff --git a/doc/changelog.d/6808.added.md b/doc/changelog.d/6808.added.md new file mode 100644 index 00000000000..54cc199d9cf --- /dev/null +++ b/doc/changelog.d/6808.added.md @@ -0,0 +1 @@ +Add TB spectral report context diff --git a/src/ansys/aedt/core/visualization/report/common.py b/src/ansys/aedt/core/visualization/report/common.py index 504e91862df..3f331e9bf70 100644 --- a/src/ansys/aedt/core/visualization/report/common.py +++ b/src/ansys/aedt/core/visualization/report/common.py @@ -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): diff --git a/src/ansys/aedt/core/visualization/report/standard.py b/src/ansys/aedt/core/visualization/report/standard.py index baa7da7a326..970ff0fc0e6 100644 --- a/src/ansys/aedt/core/visualization/report/standard.py +++ b/src/ansys/aedt/core/visualization/report/standard.py @@ -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): @@ -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": @@ -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. @@ -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 diff --git a/tests/system/general/test_34_TwinBuilder.py b/tests/system/general/test_34_TwinBuilder.py index f2da2790208..769447dc560 100644 --- a/tests/system/general/test_34_TwinBuilder.py +++ b/tests/system/general/test_34_TwinBuilder.py @@ -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): diff --git a/tests/system/visualization/example_models/T12/TB_excitation_model.aedtz b/tests/system/visualization/example_models/T12/TB_excitation_model.aedtz new file mode 100644 index 00000000000..56e8d19adb3 Binary files /dev/null and b/tests/system/visualization/example_models/T12/TB_excitation_model.aedtz differ diff --git a/tests/system/visualization/test_12_PostProcessing.py b/tests/system/visualization/test_12_PostProcessing.py index 14672865bdd..d1e1d2d0b35 100644 --- a/tests/system/visualization/test_12_PostProcessing.py +++ b/tests/system/visualization/test_12_PostProcessing.py @@ -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 @@ -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" @@ -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() @@ -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()