Skip to content

Commit

Permalink
FEAT: Report configuration refactor (#5168)
Browse files Browse the repository at this point in the history
Co-authored-by: maxcapodi78 <Shark78>
Co-authored-by: Sébastien Morais <[email protected]>
Co-authored-by: Samuelopez-ansys <[email protected]>
Co-authored-by: Giulia Malinverno <[email protected]>
  • Loading branch information
4 people authored Sep 26, 2024
1 parent 8161171 commit 4404594
Show file tree
Hide file tree
Showing 179 changed files with 15,858 additions and 14,014 deletions.
3 changes: 1 addition & 2 deletions _unittest/test_01_3dlayout_edb.py
Original file line number Diff line number Diff line change
Expand Up @@ -377,11 +377,10 @@ def test_19_dcir(self):
solution_data = self.dcir_example_project.get_dcir_solution_data("SIwaveDCIR1", "Sources", "Voltage")
assert self.dcir_example_project.post.available_report_quantities(is_siwave_dc=True, context="")
assert self.dcir_example_project.post.create_report(
self.dcir_example_project.post.available_report_quantities(is_siwave_dc=True, context="RL")[0],
self.dcir_example_project.post.available_report_quantities(is_siwave_dc=True, context="Vias")[0],
domain="DCIR",
context="RL",
)
assert isinstance(self.dcir_example_project.get_dcir_element_data_loop_resistance("SIwaveDCIR1"), pd.DataFrame)
assert isinstance(self.dcir_example_project.get_dcir_element_data_current_source("SIwaveDCIR1"), pd.DataFrame)

def test_20_change_options(self):
Expand Down
2 changes: 1 addition & 1 deletion _unittest/test_01_report_file_parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@

import os

from ansys.aedt.core.generic.report_file_parser import parse_rdat_file
from ansys.aedt.core.visualization.advanced.misc import parse_rdat_file
import pytest

local_path = os.path.dirname(os.path.realpath(__file__))
Expand Down
2 changes: 1 addition & 1 deletion _unittest/test_04_SBR.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
import os
from unittest.mock import mock_open

from ansys.aedt.core.sbrplus.hdm_parser import Parser
from ansys.aedt.core.visualization.advanced.sbrplus.hdm_parser import Parser
from mock import patch
import pytest

Expand Down
12 changes: 6 additions & 6 deletions _unittest/test_11_Setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -239,7 +239,7 @@ def test_26_create_optimization(self):
calculation = "db(S(1,1))"
new_setup = self.aedtapp.create_setup("MyOptimSetup")
new_setup.props["Frequency"] = "2.5GHz"
sweep = new_setup.create_linear_step_sweep(freqstart=2, freqstop=10, step_size=0.1)
sweep = new_setup.create_linear_step_sweep(start_frequency=2, stop_frequency=10, step_size=0.1)
setup2 = self.aedtapp.optimizations.add(
calculation, ranges={"Freq": "2.5GHz"}, solution="{} : {}".format(new_setup.name, sweep.name)
)
Expand Down Expand Up @@ -281,7 +281,7 @@ def test_27_create_doe(self):
calculation = "db(S(1,1))"
new_setup = self.aedtapp.create_setup("MyDOESetup")
new_setup.props["Frequency"] = "2.5GHz"
sweep = new_setup.create_linear_step_sweep(freqstart=2, freqstop=10, step_size=0.1)
sweep = new_setup.create_linear_step_sweep(start_frequency=2, stop_frequency=10, step_size=0.1)
setup2 = self.aedtapp.optimizations.add(
calculation,
ranges={"Freq": "2.5GHz"},
Expand All @@ -307,7 +307,7 @@ def test_27_create_doe(self):
def test_28A_create_optislang(self):
new_setup = self.aedtapp.create_setup("MyOptisSetup")
new_setup.props["Frequency"] = "2.5GHz"
sweep = new_setup.create_linear_step_sweep(freqstart=2, freqstop=10, step_size=0.1)
sweep = new_setup.create_linear_step_sweep(start_frequency=2, stop_frequency=10, step_size=0.1)
setup1 = self.aedtapp.optimizations.add(
calculation=None,
ranges=None,
Expand All @@ -333,7 +333,7 @@ def test_28A_create_optislang(self):
def test_28B_create_dx(self):
new_setup = self.aedtapp.create_setup("MyDXSetup")
new_setup.props["Frequency"] = "2.5GHz"
sweep = new_setup.create_linear_step_sweep(freqstart=2, freqstop=10, step_size=0.1)
sweep = new_setup.create_linear_step_sweep(start_frequency=2, stop_frequency=10, step_size=0.1)
setup1 = self.aedtapp.optimizations.add(
None,
ranges=None,
Expand All @@ -359,7 +359,7 @@ def test_29_create_sensitivity(self):
calculation = "db(S(1,1))"
new_setup = self.aedtapp.create_setup("MySensiSetup")
new_setup.props["Frequency"] = "2.5GHz"
sweep = new_setup.create_linear_step_sweep(freqstart=2, freqstop=10, step_size=0.1)
sweep = new_setup.create_linear_step_sweep(start_frequency=2, stop_frequency=10, step_size=0.1)
setup2 = self.aedtapp.optimizations.add(
calculation,
ranges={"Freq": "2.5GHz"},
Expand All @@ -376,7 +376,7 @@ def test_29_create_statistical(self):
calculation = "db(S(1,1))"
new_setup = self.aedtapp.create_setup("MyStatisticsetup")
new_setup.props["Frequency"] = "2.5GHz"
sweep = new_setup.create_linear_step_sweep(freqstart=2, freqstop=10, step_size=0.1)
sweep = new_setup.create_linear_step_sweep(start_frequency=2, stop_frequency=10, step_size=0.1)
setup2 = self.aedtapp.optimizations.add(
calculation,
ranges={"Freq": "2.5GHz"},
Expand Down
11 changes: 8 additions & 3 deletions _unittest/test_12_1_PostProcessing.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,9 @@
from _unittest.conftest import config
from ansys.aedt.core.generic.general_methods import is_linux
from ansys.aedt.core.generic.general_methods import read_json
from ansys.aedt.core.generic.plot import _parse_aedtplt
from ansys.aedt.core.generic.plot import _parse_streamline
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
import pytest

if config["desktopVersion"] > "2022.2":
Expand Down Expand Up @@ -297,7 +297,12 @@ def test_08_manipulate_report(self):
assert not self.aedtapp.post.rename_report("invalid", "MyNewScattering")

def test_09_manipulate_report(self):
assert self.aedtapp.post.create_report("dB(S(1,1))")
plot = self.aedtapp.post.create_report("dB(S(1,1))")
assert plot
assert plot.export_config(os.path.join(self.local_scratch.path, f"{plot.plot_name}.json"))
assert self.aedtapp.post.create_report_from_configuration(
os.path.join(self.local_scratch.path, f"{plot.plot_name}.json"), solution_name=self.aedtapp.nominal_sweep
)
assert self.aedtapp.post.create_report(
expressions="MaxMagDeltaS",
variations={"Pass": ["All"]},
Expand Down
25 changes: 20 additions & 5 deletions _unittest/test_12_PostProcessing.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,10 @@
from ansys.aedt.core import Q2d
from ansys.aedt.core import Q3d
from ansys.aedt.core.generic.general_methods import is_linux
from ansys.aedt.core.generic.pdf import AnsysReport
from ansys.aedt.core.generic.plot import _parse_aedtplt
from ansys.aedt.core.generic.plot import _parse_streamline
from ansys.aedt.core.generic.settings import settings
from ansys.aedt.core.visualization.plot.pdf import AnsysReport
from ansys.aedt.core.visualization.plot.pyvista import _parse_aedtplt
from ansys.aedt.core.visualization.plot.pyvista import _parse_streamline
import pandas as pd
import pytest

Expand Down Expand Up @@ -152,7 +152,7 @@ def test_09_manipulate_report(self, field_test):
plot_type="3D Polar Plot",
context=context,
)
assert field_test.post.create_report(
plot = field_test.post.create_report(
"db(GainTotal)",
field_test.nominal_adaptive,
variations=variations,
Expand All @@ -162,6 +162,11 @@ def test_09_manipulate_report(self, field_test):
plot_type="3D Polar Plot",
context="3D",
)
assert plot
assert plot.export_config(os.path.join(self.local_scratch.path, f"{plot.plot_name}.json"))
assert field_test.post.create_report_from_configuration(
os.path.join(self.local_scratch.path, f"{plot.plot_name}.json"), solution_name=field_test.nominal_adaptive
)
report = AnsysReport()
report.create()
assert report.add_project_info(field_test)
Expand Down Expand Up @@ -324,7 +329,13 @@ def test_17_circuit(self, circuit_test):
assert new_report.create()
data1 = circuit_test.post.get_solution_data(["dB(S(Port1,Port1))", "dB(S(Port1,Port2))"], "LNA")
assert data1.primary_sweep == "Freq"
assert circuit_test.post.create_report(["V(net_11)"], "Transient", "Time")
plot = circuit_test.post.create_report(["V(net_11)"], "Transient", "Time")
assert plot
assert plot.export_config(os.path.join(self.local_scratch.path, f"{plot.plot_name}.json"))
assert circuit_test.post.create_report_from_configuration(
os.path.join(self.local_scratch.path, f"{plot.plot_name}.json"), solution_name="Transient"
)

data11 = circuit_test.post.get_solution_data(setup_sweep_name="LNA", math_formula="dB")
assert data11.primary_sweep == "Freq"
assert "dB(S(Port2,Port1))" in data11.expressions
Expand All @@ -348,6 +359,10 @@ def test_17_circuit(self, circuit_test):
assert new_report.create()
new_report = circuit_test.post.reports_by_category.spectral(["dB(V(net_11))"])
assert new_report.create()
assert plot.export_config(os.path.join(self.local_scratch.path, f"{new_report.plot_name}.json"))
assert circuit_test.post.create_report_from_configuration(
os.path.join(self.local_scratch.path, f"{new_report.plot_name}.json"), solution_name="Transient"
)
new_report = circuit_test.post.reports_by_category.spectral(["dB(V(net_11))", "dB(V(Port1))"], "Transient")
new_report.window = "Kaiser"
new_report.adjust_coherent_gain = False
Expand Down
4 changes: 2 additions & 2 deletions _unittest/test_20_HFSS.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@

small_number = 1e-10 # Used for checking equivalence.

from ansys.aedt.core.generic.near_field_import import convert_nearfield_data
from ansys.aedt.core.visualization.advanced.misc import convert_nearfield_data

test_subfolder = "T20"

Expand Down Expand Up @@ -1432,7 +1432,7 @@ def test_59_test_nastran(self):
assert self.aedtapp.modeler.import_nastran(example_project2, decimation=0.1, preview=True, save_only_stl=True)
assert self.aedtapp.modeler.import_nastran(example_project2, decimation=0.5)
example_project = os.path.join(local_path, "../_unittest/example_models", test_subfolder, "sphere.stl")
from ansys.aedt.core.modules.solutions import simplify_stl
from ansys.aedt.core.visualization.advanced.misc import simplify_stl

out = simplify_stl(example_project, decimation=0.8)
assert os.path.exists(out)
Expand Down
2 changes: 1 addition & 1 deletion _unittest/test_21_Circuit.py
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,7 @@ def test_15_rotate(self):
)

def test_16_read_touchstone(self):
from ansys.aedt.core.generic.touchstone_parser import read_touchstone
from ansys.aedt.core.visualization.advanced.touchstone_parser import read_touchstone

data = read_touchstone(self.touchstone_file)
assert len(data.port_names) > 0
Expand Down
2 changes: 1 addition & 1 deletion _unittest/test_41_3dlayout_modeler.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
from ansys.aedt.core import Maxwell3d
from ansys.aedt.core.generic.general_methods import generate_unique_name
from ansys.aedt.core.generic.general_methods import is_linux
from ansys.aedt.core.generic.pdf import AnsysReport
from ansys.aedt.core.visualization.plot.pdf import AnsysReport
import pytest

test_subfolder = "T41"
Expand Down
4 changes: 2 additions & 2 deletions _unittest/test_44_TouchstoneParser.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ def test_01_get_touchstone_data(self):
assert ts_data.get_fext_xtalk_index_from_prefix("diff1", "diff2")

def test_02_read_ts_file(self):
from ansys.aedt.core.generic.touchstone_parser import TouchstoneData
from ansys.aedt.core.visualization.advanced.touchstone_parser import TouchstoneData

ts1 = TouchstoneData(touchstone_file=os.path.join(test_T44_dir, "port_order_1234.s8p"))
assert ts1.get_mixed_mode_touchstone_data()
Expand All @@ -67,7 +67,7 @@ def test_02_read_ts_file(self):
assert ts1.get_worst_curve(curve_list=ts1.get_return_loss_index(), plot=False)

def test_03_check_touchstone_file(self):
from ansys.aedt.core.generic.touchstone_parser import check_touchstone_files
from ansys.aedt.core.visualization.advanced.touchstone_parser import check_touchstone_files

check = check_touchstone_files(input_dir=test_T44_dir)
assert check
Expand Down
2 changes: 1 addition & 1 deletion _unittest/test_46_FarField.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
import os
import shutil

from ansys.aedt.core.generic.farfield_visualization import FfdSolutionData
from ansys.aedt.core.visualization.advanced.farfield_visualization import FfdSolutionData

# from _unittest.conftest import config
from matplotlib.figure import Figure
Expand Down
19 changes: 13 additions & 6 deletions _unittest/test_98_Icepak.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,8 @@
from ansys.aedt.core.modules.boundary import PCBSettingsPackageParts
from ansys.aedt.core.modules.mesh_icepak import MeshRegion
from ansys.aedt.core.modules.setup_templates import SetupKeys
from ansys.aedt.core.modules.solutions import FolderPlotSettings
from ansys.aedt.core.modules.solutions import SpecifiedScale
from ansys.aedt.core.visualization.post.field_data import FolderPlotSettings
from ansys.aedt.core.visualization.post.field_data import SpecifiedScale
import pytest

test_subfolder = "T98"
Expand Down Expand Up @@ -277,7 +277,7 @@ def test_03_AssignPCBRegion(self):
pcb_mesh_region.MinGapZ = 1
assert pcb_mesh_region.update()
if settings.aedt_version > "2023.2":
assert pcb_mesh_region.assignment.padding_values == ["0"] * 6
assert [str(i) for i in pcb_mesh_region.assignment.padding_values] == ["0"] * 6
assert pcb_mesh_region.assignment.padding_types == ["Percentage Offset"] * 6
pcb_mesh_region.assignment.negative_x_padding = 1
pcb_mesh_region.assignment.positive_x_padding = 1
Expand All @@ -293,10 +293,10 @@ def test_03_AssignPCBRegion(self):
pcb_mesh_region.assignment.positive_z_padding_type = "Transverse Percentage Offset"
assert pcb_mesh_region.assignment.negative_x_padding == "1mm"
assert pcb_mesh_region.assignment.positive_x_padding == "1mm"
assert pcb_mesh_region.assignment.negative_y_padding == "1"
assert str(pcb_mesh_region.assignment.negative_y_padding) == "1"
assert pcb_mesh_region.assignment.positive_y_padding == "1mm"
assert pcb_mesh_region.assignment.negative_z_padding == "1mm"
assert pcb_mesh_region.assignment.positive_z_padding == "1"
assert str(pcb_mesh_region.assignment.positive_z_padding) == "1"
assert pcb_mesh_region.assignment.negative_x_padding_type == "Absolute Offset"
assert pcb_mesh_region.assignment.positive_x_padding_type == "Absolute Position"
assert pcb_mesh_region.assignment.negative_y_padding_type == "Transverse Percentage Offset"
Expand Down Expand Up @@ -1867,7 +1867,14 @@ def test_80_global_mesh_region(self):
g_m_r = self.aedtapp.mesh.global_mesh_region
assert g_m_r
assert g_m_r.global_region.object.name == "Region"
assert g_m_r.global_region.padding_values == ["50", "50", "50", "50", "50", "50"]
assert g_m_r.global_region.padding_values == [
"50",
"50",
"50",
"50",
"50",
"50",
] or g_m_r.global_region.padding_values == [50, 50, 50, 50, 50, 50]
assert g_m_r.global_region.padding_types == [
"Percentage Offset",
"Percentage Offset",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,14 @@
"quantity_type": "3",
"context": {
"Domain": "Time",
"primary_sweep": "Time",
"primary_sweep": "__UnitInterval",
"primary_sweep_range": [
"All"
],
"secondary_sweep": "__Amplitude",
"secondary_sweep_range": [
"All"
],
"variations": {
"__UnitInterval": [
"All"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,21 +39,21 @@
"traces": ["dB(S(X1_TX0,X1_RX0))", "dB(S(X1_TX1,X1_RX1))","dB(S(X1_TX2,X1_RX2))", "dB(S(X1_TX3,X1_RX3))"],
"pass_fail": false,
"group_plots":true

},
{"name": "eye1",
"design_name":"32GTps_circuit",
"type": "statistical eye",
"config": "StatisticalEyeDiagram_Custom.json",
"quantity_type": 3,
"quantity_type": 3,
"traces": ["b_input_67", "b_input_119"],
"pass_fail": true
},
{"name": "eye3",
"design_name":"32GTps_circuit",
"type": "contour eye diagram",
"config": "ContourEyeDiagram_Custom.json",
"quantity_type": 3,
"quantity_type": 3,
"traces": ["b_input_67", "b_input_119"],
"pass_fail": true
},
Expand Down
4 changes: 2 additions & 2 deletions _unittest_solvers/test_00_analyze.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
from ansys.aedt.core import Hfss3dLayout
from ansys.aedt.core import Circuit, Maxwell3d
from _unittest.conftest import config
from ansys.aedt.core.generic.spisim import SpiSim
from ansys.aedt.core.visualization.post.spisim import SpiSim

sbr_platform_name = "satellite_231"
array_name = "array_231"
Expand Down Expand Up @@ -545,7 +545,7 @@ def test_09c_compute_com(self, local_scratch):
)
assert com_0 and com_1

from ansys.aedt.core.misc.spisim_com_configuration_files.com_parameters import COMParametersVer3p4
from ansys.aedt.core.visualization.post.spisim_com_configuration_files.com_parameters import COMParametersVer3p4
com_param = COMParametersVer3p4()
com_param.load(os.path.join(spisim.working_directory, "custom.json"), )
com_param.export_spisim_cfg(str(Path(local_scratch.path) / "test.cfg"))
Expand Down
6 changes: 3 additions & 3 deletions _unittest_solvers/test_01_pdf.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
import pytest

from ansys.aedt.core import Circuit
from ansys.aedt.core.generic.compliance import VirtualCompliance
from ansys.aedt.core.generic.pdf import AnsysReport
from ansys.aedt.core.visualization.post.compliance import VirtualCompliance
from ansys.aedt.core.visualization.plot.pdf import AnsysReport

tol = 1e-12
test_project_name = "ANSYS-HSD_V1_0_test"
Expand Down Expand Up @@ -85,7 +85,7 @@ def test_virtual_compliance(self, local_scratch, aedtapp):
assert v.create_compliance_report()

def test_spisim_raw_read(self, local_scratch):
from ansys.aedt.core.generic.spisim import SpiSimRawRead
from ansys.aedt.core.visualization.post.spisim import SpiSimRawRead

raw_file = os.path.join(local_path, "example_models", test_subfolder, "SerDes_Demo_02_Thru.s4p_ERL.raw")
raw_file = local_scratch.copyfile(raw_file)
Expand Down
Loading

0 comments on commit 4404594

Please sign in to comment.