From 6262d4b2e3ecf6759831f0b41608a0bb1d8e1025 Mon Sep 17 00:00:00 2001 From: gkorompi Date: Thu, 28 Nov 2024 16:54:43 +0200 Subject: [PATCH 1/9] REFACTOR: EDB configuration example for DCIR setup --- examples/use_configuration/dcir.py | 157 +++++++++++++++++++++++++++++ 1 file changed, 157 insertions(+) create mode 100644 examples/use_configuration/dcir.py diff --git a/examples/use_configuration/dcir.py b/examples/use_configuration/dcir.py new file mode 100644 index 0000000000..cea9359841 --- /dev/null +++ b/examples/use_configuration/dcir.py @@ -0,0 +1,157 @@ +# # DCIR Setup Leveraging EDB Configuration Format + +# ## Import the required packages + +import json + +# + +import os +import tempfile + +from ansys.aedt.core import Hfss3dLayout +from ansys.aedt.core.downloads import download_file + +from pyedb import Edb + +AEDT_VERSION = "2024.2" +NG_MODE = False + +# - + +# Download the example BGA Package design. + +temp_folder = tempfile.TemporaryDirectory(suffix=".ansys") +file_edb = download_file(source=r"edb/BGA_Package.aedb", destination=temp_folder.name) + +# ## Load example layout + +edbapp = Edb(file_edb, edbversion=AEDT_VERSION) + +# ## Create config file + +# Define Component with solderballs. + +cfg_components = [ + { + "reference_designator": "FCHIP", + "part_type": "other", + "solder_ball_properties": { + "shape": "cylinder", + "diameter": "0.1mm", + "height": "0.085mm", + "chip_orientation": "chip_up", + }, + "port_properties": { + "reference_offset": 0, + "reference_size_auto": False, + "reference_size_x": 0, + "reference_size_y": 0, + }, + }, + { + "reference_designator": "BGA", + "part_type": "io", + "solder_ball_properties": { + "shape": "cylinder", + "diameter": "0.45mm", + "height": "0.45mm", + "chip_orientation": "chip_down", + }, + "port_properties": { + "reference_offset": 0, + "reference_size_auto": False, + "reference_size_x": 0, + "reference_size_y": 0, + }, + }, +] + +# Define Pin Groups on Components. + +cfg_pin_groups = [ + {"name": "BGA_VSS", "reference_designator": "BGA", "net": "VSS"}, + {"name": "BGA_VDD", "reference_designator": "BGA", "net": "VDD"}, +] + +# Define sources. + +cfg_sources = [ + { + "name": "FCHIP_Current", + "reference_designator": "FCHIP", + "type": "current", + "magnitude": 2, + "distributed": True, + "positive_terminal": {"net": "VDD"}, + "negative_terminal": {"nearest_pin": {"reference_net": "VSS", "search_radius": 5e-3}}, + }, + { + "name": "BGA_Voltage", + "reference_designator": "BGA", + "type": "voltage", + "magnitude": 1, + "positive_terminal": {"pin_group": "BGA_VDD"}, + "negative_terminal": {"pin_group": "BGA_VSS"}, + }, +] + +# Define DCIR setup. + +cfg_setups = [ + { + "name": "siwave_dc", + "type": "siwave_dc", + "dc_slider_position": 1, + "dc_ir_settings": {"export_dc_thermal_data": True}, + } +] + +# Create final configuration. + +cfg = { + "components": cfg_components, + "sources": cfg_sources, + "pin_groups": cfg_pin_groups, + "setups": cfg_setups, +} + +# Create the config file. + +file_json = os.path.join(temp_folder.name, "edb_configuration.json") +with open(file_json, "w") as f: + json.dump(cfg, f, indent=4, ensure_ascii=False) + +# ## Apply Config file + +# Apply configuration to the example layout + +edbapp.configuration.load(config_file=file_json) +edbapp.configuration.run() + +# Save and close EDB. + +edbapp.save() +edbapp.close() + +# The configured EDB file is saved in a temp folder. + +print(temp_folder.name) + +# ## Load edb into HFSS 3D Layout. + +h3d = Hfss3dLayout(edbapp.edbpath, version=AEDT_VERSION, non_graphical=NG_MODE, new_desktop=True) + +# Solve. + +h3d.analyze(setup="siwave_dc") + +# Plot insertion loss. + +h3d.post.create_fieldplot_layers_nets(layers_nets=[["VDD_C1", "VDD"]], quantity="Voltage", setup="siwave_dc") + +# Shut Down Electronics Desktop + +h3d.close_desktop() + +# All project files are saved in the folder ``temp_file.dir``. If you've run this example as a Jupyter notebook you +# can retrieve those project files. From 2ff25fd3b03686567906e8ba2b52c88f6b79f68c Mon Sep 17 00:00:00 2001 From: gkorompi Date: Wed, 14 May 2025 12:51:02 +0300 Subject: [PATCH 2/9] FIX: path to examples --- src/pyedb/misc/downloads.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/pyedb/misc/downloads.py b/src/pyedb/misc/downloads.py index c2ef1c2795..da52ed8ec5 100644 --- a/src/pyedb/misc/downloads.py +++ b/src/pyedb/misc/downloads.py @@ -30,7 +30,7 @@ from pyedb.generic.general_methods import is_linux, settings tmpfold = tempfile.gettempdir() -EXAMPLE_REPO = "https://github.com/ansys/example-data/raw/master/" +EXAMPLE_REPO = "https://github.com/ansys/example-data/raw/main/" EXAMPLES_PATH = os.path.join(tmpfold, "PyAEDTExamples") From aee7cc3b0a06635713a667842d7e84fd65ae2570 Mon Sep 17 00:00:00 2001 From: gkorompi Date: Thu, 26 Jun 2025 10:39:02 +0300 Subject: [PATCH 3/9] FEATURE: compare_edbs --- src/pyedb/dotnet/edb.py | 32 ++++++++++++++++++++++++++++++++ tests/legacy/system/test_edb.py | 7 +++++++ 2 files changed, 39 insertions(+) diff --git a/src/pyedb/dotnet/edb.py b/src/pyedb/dotnet/edb.py index 15510c439c..388575af83 100644 --- a/src/pyedb/dotnet/edb.py +++ b/src/pyedb/dotnet/edb.py @@ -4729,3 +4729,35 @@ def get_variable_value(self, variable_name): return self.variables[variable_name] else: return False + + def compare_with_edb(self, input_file, results=""): + """Compares if two edb files are exactly the same. + + Parameters + ---------- + input_file : str + Path to the edb file. + results: str, optional + Path to directory in which results will be saved. If no path is given, a new "_compare_results" + directory will be created with the same naming and path as the .aedb folder. + Returns + ------- + bool + ``True`` when successful, ``False`` when failed. + """ + self.save() + if not results: + results = self.edbpath[:-5] + "_compare_results" + os.mkdir(results) + command = os.path.join(self.base_path, "EDBDiff") + if is_windows: + command += ".exe" + cmd_input = [command, input_file, self.edbpath, results] + subprocess.run(cmd_input) + + if not os.path.exists(os.path.join(results, "EDBDiff.csv")): + self.logger.error("Comparison execution failed") + return False + else: + self.logger.info("Comparison correctly completed") + return True diff --git a/tests/legacy/system/test_edb.py b/tests/legacy/system/test_edb.py index d76d19a7bb..ef4cdc8d2a 100644 --- a/tests/legacy/system/test_edb.py +++ b/tests/legacy/system/test_edb.py @@ -1987,3 +1987,10 @@ def test_hfss_get_trace_width_for_traces_with_ports(self, edb_examples): trace_widths = edbapp.hfss.get_trace_width_for_traces_with_ports() assert len(trace_widths) > 0 edbapp.close() + + def test_compare_edbs(self, edb_examples): + edbapp = edb_examples.get_si_verse() + edb_base = os.path.join(local_path, "example_models", "TEDB", "ANSYS-HSD_V1.aedb") + assert edbapp.compare_with_edb(edb_base) + folder = edbapp.edbpath[:-5] + "_compare_results" + assert os.path.exists(folder) From 8a4d3dd8f8b56408d0dd240479bababf7d67acae Mon Sep 17 00:00:00 2001 From: gkorompi <156683163+gkorompi@users.noreply.github.com> Date: Thu, 26 Jun 2025 10:51:21 +0300 Subject: [PATCH 4/9] Update src/pyedb/dotnet/edb.py Co-authored-by: svandenb-dev <74993647+svandenb-dev@users.noreply.github.com> --- src/pyedb/dotnet/edb.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/pyedb/dotnet/edb.py b/src/pyedb/dotnet/edb.py index 388575af83..936e0017ce 100644 --- a/src/pyedb/dotnet/edb.py +++ b/src/pyedb/dotnet/edb.py @@ -4731,7 +4731,7 @@ def get_variable_value(self, variable_name): return False def compare_with_edb(self, input_file, results=""): - """Compares if two edb files are exactly the same. + """Compares current open database with another one. Parameters ---------- From 47575ec401e0a29172dcc27d6afe9c16777ed570 Mon Sep 17 00:00:00 2001 From: gkorompi <156683163+gkorompi@users.noreply.github.com> Date: Thu, 26 Jun 2025 10:51:29 +0300 Subject: [PATCH 5/9] Update tests/legacy/system/test_edb.py Co-authored-by: svandenb-dev <74993647+svandenb-dev@users.noreply.github.com> --- tests/legacy/system/test_edb.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/legacy/system/test_edb.py b/tests/legacy/system/test_edb.py index ef4cdc8d2a..8a462ffe6a 100644 --- a/tests/legacy/system/test_edb.py +++ b/tests/legacy/system/test_edb.py @@ -1991,6 +1991,6 @@ def test_hfss_get_trace_width_for_traces_with_ports(self, edb_examples): def test_compare_edbs(self, edb_examples): edbapp = edb_examples.get_si_verse() edb_base = os.path.join(local_path, "example_models", "TEDB", "ANSYS-HSD_V1.aedb") - assert edbapp.compare_with_edb(edb_base) + assert edbapp.compare(edb_base) folder = edbapp.edbpath[:-5] + "_compare_results" assert os.path.exists(folder) From 3884b1c350f22c3cc7b126fc811eb466275d5a83 Mon Sep 17 00:00:00 2001 From: gkorompi <156683163+gkorompi@users.noreply.github.com> Date: Thu, 26 Jun 2025 10:51:35 +0300 Subject: [PATCH 6/9] Update src/pyedb/dotnet/edb.py Co-authored-by: svandenb-dev <74993647+svandenb-dev@users.noreply.github.com> --- src/pyedb/dotnet/edb.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/pyedb/dotnet/edb.py b/src/pyedb/dotnet/edb.py index 936e0017ce..c68431ee10 100644 --- a/src/pyedb/dotnet/edb.py +++ b/src/pyedb/dotnet/edb.py @@ -4730,7 +4730,7 @@ def get_variable_value(self, variable_name): else: return False - def compare_with_edb(self, input_file, results=""): + def compare(self, input_file, results=""): """Compares current open database with another one. Parameters From ab93305822c83bfa67315b40071c7448206c3778 Mon Sep 17 00:00:00 2001 From: gkorompi Date: Thu, 26 Jun 2025 11:14:52 +0300 Subject: [PATCH 7/9] FEATURE: compare_edbs --- src/pyedb/grpc/edb.py | 32 ++++++++++++++++++++++++++++++++ tests/grpc/system/test_edb.py | 7 +++++++ 2 files changed, 39 insertions(+) diff --git a/src/pyedb/grpc/edb.py b/src/pyedb/grpc/edb.py index 093170364b..90b46ae58a 100644 --- a/src/pyedb/grpc/edb.py +++ b/src/pyedb/grpc/edb.py @@ -3921,3 +3921,35 @@ def export_gds_comp_xml(self, comps_to_export, gds_comps_unit="mm", control_path ET.indent(tree, space="\t", level=0) tree.write(control_path) return True if os.path.exists(control_path) else False + + def compare(self, input_file, results=""): + """Compares current open database with another one. + + Parameters + ---------- + input_file : str + Path to the edb file. + results: str, optional + Path to directory in which results will be saved. If no path is given, a new "_compare_results" + directory will be created with the same naming and path as the .aedb folder. + Returns + ------- + bool + ``True`` when successful, ``False`` when failed. + """ + self.save() + if not results: + results = self.edbpath[:-5] + "_compare_results" + os.mkdir(results) + command = os.path.join(self.base_path, "EDBDiff") + if is_windows: + command += ".exe" + cmd_input = [command, input_file, self.edbpath, results] + subprocess.run(cmd_input) + + if not os.path.exists(os.path.join(results, "EDBDiff.csv")): + self.logger.error("Comparison execution failed") + return False + else: + self.logger.info("Comparison correctly completed") + return True diff --git a/tests/grpc/system/test_edb.py b/tests/grpc/system/test_edb.py index 79911b93f1..766427d2fe 100644 --- a/tests/grpc/system/test_edb.py +++ b/tests/grpc/system/test_edb.py @@ -1964,3 +1964,10 @@ def test_hfss_get_trace_width_for_traces_with_ports(self, edb_examples): trace_widths = edbapp.hfss.get_trace_width_for_traces_with_ports() assert len(trace_widths) > 0 edbapp.close() + + def test_compare_edbs(self, edb_examples): + edbapp = edb_examples.get_si_verse() + edb_base = os.path.join(local_path, "example_models", "TEDB", "ANSYS-HSD_V1.aedb") + assert edbapp.compare(edb_base) + folder = edbapp.edbpath[:-5] + "_compare_results" + assert os.path.exists(folder) From 04188269b53328bc4007dd46c5fa20363272a4fe Mon Sep 17 00:00:00 2001 From: gkorompi Date: Thu, 26 Jun 2025 16:56:45 +0300 Subject: [PATCH 8/9] FEATURE: compare_edbs --- src/pyedb/dotnet/edb.py | 4 +--- src/pyedb/grpc/edb.py | 4 +--- 2 files changed, 2 insertions(+), 6 deletions(-) diff --git a/src/pyedb/dotnet/edb.py b/src/pyedb/dotnet/edb.py index c68431ee10..83f8f09832 100644 --- a/src/pyedb/dotnet/edb.py +++ b/src/pyedb/dotnet/edb.py @@ -4749,9 +4749,7 @@ def compare(self, input_file, results=""): if not results: results = self.edbpath[:-5] + "_compare_results" os.mkdir(results) - command = os.path.join(self.base_path, "EDBDiff") - if is_windows: - command += ".exe" + command = os.path.join(self.base_path, "EDBDiff.exe") cmd_input = [command, input_file, self.edbpath, results] subprocess.run(cmd_input) diff --git a/src/pyedb/grpc/edb.py b/src/pyedb/grpc/edb.py index 90b46ae58a..f006aeab04 100644 --- a/src/pyedb/grpc/edb.py +++ b/src/pyedb/grpc/edb.py @@ -3941,9 +3941,7 @@ def compare(self, input_file, results=""): if not results: results = self.edbpath[:-5] + "_compare_results" os.mkdir(results) - command = os.path.join(self.base_path, "EDBDiff") - if is_windows: - command += ".exe" + command = os.path.join(self.base_path, "EDBDiff.exe") cmd_input = [command, input_file, self.edbpath, results] subprocess.run(cmd_input) From c6a92de3d8061d8a1731315323526ee78f7ae619 Mon Sep 17 00:00:00 2001 From: gkorompi Date: Tue, 1 Jul 2025 16:17:08 +0300 Subject: [PATCH 9/9] FEATURE: compare_edbs --- src/pyedb/dotnet/edb.py | 6 +++++- src/pyedb/grpc/edb.py | 6 +++++- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/src/pyedb/dotnet/edb.py b/src/pyedb/dotnet/edb.py index bf58607429..61d8fed97d 100644 --- a/src/pyedb/dotnet/edb.py +++ b/src/pyedb/dotnet/edb.py @@ -4756,7 +4756,11 @@ def compare(self, input_file, results=""): results = self.edbpath[:-5] + "_compare_results" os.mkdir(results) command = os.path.join(self.base_path, "EDBDiff.exe") - cmd_input = [command, input_file, self.edbpath, results] + if is_linux: + mono_path = os.path.join(self.base_path, "common/mono/Linux64/bin/mono") + cmd_input = [mono_path, command, input_file, self.edbpath, results] + else: + cmd_input = [command, input_file, self.edbpath, results] subprocess.run(cmd_input) if not os.path.exists(os.path.join(results, "EDBDiff.csv")): diff --git a/src/pyedb/grpc/edb.py b/src/pyedb/grpc/edb.py index f006aeab04..7908a71a60 100644 --- a/src/pyedb/grpc/edb.py +++ b/src/pyedb/grpc/edb.py @@ -3942,7 +3942,11 @@ def compare(self, input_file, results=""): results = self.edbpath[:-5] + "_compare_results" os.mkdir(results) command = os.path.join(self.base_path, "EDBDiff.exe") - cmd_input = [command, input_file, self.edbpath, results] + if is_linux: + mono_path = os.path.join(self.base_path, "common/mono/Linux64/bin/mono") + cmd_input = [mono_path, command, input_file, self.edbpath, results] + else: + cmd_input = [command, input_file, self.edbpath, results] subprocess.run(cmd_input) if not os.path.exists(os.path.join(results, "EDBDiff.csv")):