Skip to content

Commit 712cc33

Browse files
FEAT: Add TB spectral report context (#6808)
Co-authored-by: pyansys-ci-bot <[email protected]>
1 parent 26cd128 commit 712cc33

File tree

6 files changed

+148
-68
lines changed

6 files changed

+148
-68
lines changed

doc/changelog.d/6808.added.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Add TB spectral report context

src/ansys/aedt/core/visualization/report/common.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -605,10 +605,8 @@ def expressions(self, value):
605605
else:
606606
self._legacy_props["expressions"].append({"name": el})
607607
elif isinstance(value, str):
608-
if isinstance(self._legacy_props["expressions"], list):
609-
self._legacy_props["expressions"].append({"name": value})
610-
else:
611-
self._legacy_props["expressions"] = [{"name": value}]
608+
self._legacy_props["expressions"] = []
609+
self._legacy_props["expressions"].append({"name": value})
612610

613611
@property
614612
def report_category(self):

src/ansys/aedt/core/visualization/report/standard.py

Lines changed: 122 additions & 63 deletions
Original file line numberDiff line numberDiff line change
@@ -555,6 +555,7 @@ def __init__(self, app, report_category, setup_name, expressions=None):
555555
self.max_frequency = "10MHz"
556556
self.plot_continous_spectrum = False
557557
self.primary_sweep = "Spectrum"
558+
self.noise_threshold = "60"
558559

559560
@property
560561
def time_start(self):
@@ -661,6 +662,21 @@ def max_frequency(self):
661662
def max_frequency(self, value):
662663
self._legacy_props["context"]["max_frequency"] = value
663664

665+
@property
666+
def noise_threshold(self):
667+
"""Noise Threshold in dB.
668+
669+
Returns
670+
-------
671+
str
672+
Noise Threshold.
673+
"""
674+
return self._legacy_props["context"].get("noise_threshold", 0)
675+
676+
@noise_threshold.setter
677+
def noise_threshold(self, value):
678+
self._legacy_props["context"]["noise_threshold"] = value
679+
664680
@property
665681
def _context(self):
666682
if self.algorithm == "FFT":
@@ -681,65 +697,113 @@ def _context(self):
681697
"Lanzcos": "8",
682698
}
683699
wt = WT[self.window]
684-
arg = [
685-
"NAME:Context",
686-
"SimValueContext:=",
687-
[
688-
2,
689-
0,
690-
2,
691-
0,
692-
False,
693-
False,
694-
-1,
695-
1,
696-
0,
697-
1,
698-
1,
699-
"",
700-
0,
701-
0,
702-
"CP",
703-
False,
704-
"1" if self.plot_continous_spectrum else "0",
705-
"IT",
706-
False,
707-
it,
708-
"MF",
709-
False,
710-
self.max_frequency,
711-
"NUMLEVELS",
712-
False,
713-
"0",
714-
"TE",
715-
False,
716-
self.time_stop,
717-
"TS",
718-
False,
719-
self.time_start,
720-
"WT",
721-
False,
722-
wt,
723-
"WW",
724-
False,
725-
"100",
726-
"KP",
727-
False,
728-
str(self.kaiser_coeff),
729-
"CG",
730-
False,
731-
"1" if self.adjust_coherent_gain else "0",
732-
],
733-
]
700+
if self._app.design_type == "Circuit Design":
701+
arg = [
702+
"NAME:Context",
703+
"SimValueContext:=",
704+
[
705+
2,
706+
0,
707+
2,
708+
0,
709+
False,
710+
False,
711+
-1,
712+
1,
713+
0,
714+
1,
715+
1,
716+
"",
717+
0,
718+
0,
719+
"CP",
720+
False,
721+
"1" if self.plot_continous_spectrum else "0",
722+
"IT",
723+
False,
724+
it,
725+
"MF",
726+
False,
727+
self.max_frequency,
728+
"NUMLEVELS",
729+
False,
730+
"0",
731+
"TE",
732+
False,
733+
self.time_stop,
734+
"TS",
735+
False,
736+
self.time_start,
737+
"WT",
738+
False,
739+
wt,
740+
"WW",
741+
False,
742+
"100",
743+
"KP",
744+
False,
745+
str(self.kaiser_coeff),
746+
"CG",
747+
False,
748+
"1" if self.adjust_coherent_gain else "0",
749+
],
750+
]
751+
elif self._app.design_type == "Twin Builder":
752+
arg = [
753+
"NAME:Context",
754+
"SimValueContext:=",
755+
[
756+
2,
757+
0,
758+
2,
759+
0,
760+
False,
761+
False,
762+
-1,
763+
1,
764+
0,
765+
1,
766+
1,
767+
"",
768+
0,
769+
0,
770+
"CF",
771+
False,
772+
self.max_frequency,
773+
"CG",
774+
False,
775+
"0",
776+
"CP",
777+
False,
778+
"0",
779+
"IT",
780+
False,
781+
it,
782+
"KP",
783+
False,
784+
str(self.kaiser_coeff),
785+
"NTC",
786+
False,
787+
"1",
788+
"TE",
789+
False,
790+
self.time_stop,
791+
"TH",
792+
False,
793+
self.noise_threshold,
794+
"TS",
795+
False,
796+
self.time_start,
797+
"WT",
798+
False,
799+
wt,
800+
"WW",
801+
False,
802+
"100",
803+
],
804+
]
734805
return arg
735806

736-
@property
737-
def _trace_info(self):
738-
if isinstance(self.expressions, list):
739-
return self.expressions
740-
else:
741-
return [self.expressions]
742-
743807
@pyaedt_function_handler()
744808
def create(self, name=None):
745809
"""Create an eye diagram report.
@@ -766,12 +830,7 @@ def create(self, name=None):
766830
self.setup,
767831
self._context,
768832
self._convert_dict_to_report_sel(self.variations),
769-
[
770-
"X Component:=",
771-
self.primary_sweep,
772-
"Y Component:=",
773-
self._trace_info,
774-
],
833+
self._trace_info,
775834
)
776835
self._post.plots.append(self)
777836
self._is_created = True

tests/system/general/test_34_TwinBuilder.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ def desktop():
7575
d.close_desktop()
7676

7777

78-
@pytest.mark.skipif(is_linux, reason="Emit API fails on linux.")
78+
@pytest.mark.skipif(is_linux, reason="Twinbuilder is only available in Windows OS.")
7979
class TestClass:
8080
@pytest.fixture(autouse=True)
8181
def init(self, aedtapp, local_scratch, examples):
Binary file not shown.

tests/system/visualization/test_12_PostProcessing.py

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,8 @@
3535
from ansys.aedt.core import Maxwell3d
3636
from ansys.aedt.core import Q2d
3737
from ansys.aedt.core import Q3d
38+
from ansys.aedt.core import TwinBuilder
39+
from ansys.aedt.core.generic.general_methods import is_linux
3840
from ansys.aedt.core.generic.settings import settings
3941
from ansys.aedt.core.visualization.plot.pyvista import _parse_aedtplt
4042
from ansys.aedt.core.visualization.plot.pyvista import _parse_streamline
@@ -52,6 +54,7 @@
5254
test_emi_name = "EMI_RCV_251"
5355
ipk_post_proj = "for_icepak_post_parasolid"
5456
ipk_markers_proj = "ipk_markers"
57+
tb_spectral = "TB_excitation_model"
5558

5659
test_subfolder = "T12"
5760

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

149152

153+
@pytest.fixture()
154+
def tb_app(add_app):
155+
app = add_app(project_name=tb_spectral, application=TwinBuilder, subfolder=test_subfolder)
156+
yield app
157+
app.close_project(save=False)
158+
159+
150160
class TestClass:
151161
def test_circuit_export_results(self, circuit_test):
152162
files = circuit_test.export_results()
@@ -773,3 +783,15 @@ def test_m3d_get_solution_data_matrix(self, m3d_app):
773783
)
774784
data = m3d_app.post.get_solution_data(expressions=expressions, context="Matrix1")
775785
assert data
786+
787+
@pytest.mark.skipif(is_linux, reason="Twinbuilder is only available in Windows OS.")
788+
def test_twinbuilder_spectral(self, tb_app):
789+
assert tb_app.post.create_report(
790+
expressions="mag(E1.I)", primary_sweep_variable="Spectrum", plot_name="Spectral domain", domain="Spectral"
791+
)
792+
new_report = tb_app.post.reports_by_category.spectral("mag(E1.I)", "TR")
793+
new_report.window = "Rectangular"
794+
new_report.max_frequency = "2.5MHz"
795+
new_report.time_start = "0ns"
796+
new_report.time_stop = "40ms"
797+
assert new_report.create()

0 commit comments

Comments
 (0)