Skip to content

Commit

Permalink
Refactoring hfss3dlayout.py Class
Browse files Browse the repository at this point in the history
  • Loading branch information
maxcapodi78 authored and maxcapodi78 committed Apr 18, 2024
1 parent 567fd28 commit ef5e0e7
Show file tree
Hide file tree
Showing 6 changed files with 198 additions and 187 deletions.
10 changes: 2 additions & 8 deletions _unittest/test_01_3dlayout_edb.py
Original file line number Diff line number Diff line change
Expand Up @@ -198,10 +198,7 @@ def test_04_add_mesh_operations(self):
)

def test_05_change_property(self):
ports = self.aedtapp.create_ports_on_component_by_nets(
"U1",
"DDR4_DQS0_P",
)
ports = self.aedtapp.create_ports_on_component_by_nets("U1", "DDR4_DQS0_P")
assert self.aedtapp.modeler.change_property(
"Excitations:{}".format(ports[0].name), "Impedance", "49ohm", "EM Design"
)
Expand Down Expand Up @@ -322,10 +319,7 @@ def test_17_ports_on_components_nets(self):
if "GND" not in self.aedtapp.modeler.pins[i].net_name and self.aedtapp.modeler.pins[i].net_name != ""
]
ports_before = len(self.aedtapp.port_list)
ports = self.aedtapp.create_ports_on_component_by_nets(
"J1",
nets,
)
ports = self.aedtapp.create_ports_on_component_by_nets("J1", nets)
assert ports
ports_after = len(self.aedtapp.port_list)
assert ports_after - ports_before == len(nets)
Expand Down
8 changes: 4 additions & 4 deletions _unittest/test_41_3dlayout_modeler.py
Original file line number Diff line number Diff line change
Expand Up @@ -608,7 +608,7 @@ def test_36_import_gerber(self):
)

aedb_file = os.path.join(self.local_scratch.path, generate_unique_name("gerber_out") + ".aedb")
assert self.aedtapp.import_gerber(gerber_file, aedb_path=aedb_file, control_file=control_file)
assert self.aedtapp.import_gerber(gerber_file, output_dir=aedb_file, control_file=control_file)

@pytest.mark.skipif(is_linux, reason="Fails in linux")
def test_37_import_gds(self):
Expand All @@ -618,21 +618,21 @@ def test_37_import_gds(self):
os.path.join(local_path, "../_unittest/example_models", "cad", "GDS", "gds1.tech")
)
aedb_file = os.path.join(self.local_scratch.path, generate_unique_name("gds_out") + ".aedb")
assert self.aedtapp.import_gds(gds_file, aedb_path=aedb_file, control_file=control_file)
assert self.aedtapp.import_gds(gds_file, output_dir=aedb_file, control_file=control_file)

@pytest.mark.skipif(is_linux, reason="Fails in linux")
def test_38_import_dxf(self):
self.aedtapp.insert_design("dxf")
dxf_file = os.path.join(local_path, "../_unittest/example_models", "cad", "DXF", "dxf1.dxf")
control_file = os.path.join(local_path, "../_unittest/example_models", "cad", "DXF", "dxf1.xml")
aedb_file = os.path.join(self.local_scratch.path, "dxf_out.aedb")
assert self.aedtapp.import_gerber(dxf_file, aedb_path=aedb_file, control_file=control_file)
assert self.aedtapp.import_gerber(dxf_file, output_dir=aedb_file, control_file=control_file)

def test_39_import_ipc(self):
self.aedtapp.insert_design("ipc")
dxf_file = os.path.join(local_path, "../_unittest/example_models", "cad", "ipc", "galileo.xml")
aedb_file = os.path.join(self.local_scratch.path, "ipc_out.aedb")
assert self.aedtapp.import_ipc2581(dxf_file, aedb_path=aedb_file, control_file="")
assert self.aedtapp.import_ipc2581(dxf_file, output_dir=aedb_file, control_file="")

@pytest.mark.skipif(config["desktopVersion"] < "2022.2", reason="Not working on AEDT 22R1")
def test_40_test_flex(self, add_app):
Expand Down
2 changes: 1 addition & 1 deletion examples/01-HFSS3DLayout/Hfss3DComponent.py
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,7 @@
h3d["len"] = str(trace_length) + "mm"
h3d["w1"] = str(trace_width) + "mm"
line = h3d.modeler.create_line("L1", [[0, 0], ["len", 0]], lw="w1", netname="microstrip", name="microstrip")
h3d.create_edge_port(line, h3d.modeler[line].top_edge_x, iswave=True, wave_horizontal_extension=15, )
h3d.create_edge_port(line, h3d.modeler[line].top_edge_x, is_wave_port=True, wave_horizontal_extension=15)

###############################################################################
# Create void on Ground plane for pin
Expand Down
2 changes: 1 addition & 1 deletion examples/04-Icepak/Icepak_ECAD_Import.py
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@
hfss3dLO = Hfss3dLayout('Icepak_ECAD_Import', 'PCB_temp') # adding a dummy HFSS 3D layout to the current project

#edb_full_path = os.path.join(os.getcwd(), Layout_name+'.aedb\edb.def') # path to the EDB file
hfss3dLO.import_edb(def_path) # importing the EDB file
hfss3dLO.import_edb(def_path) # importing the EDB file
hfss3dLO.save_project() # save the new project so files are stored in the path

ipk.delete_design(name='PCB_temp', fallback_design=None) # deleting the dummy layout from the original project
Expand Down
24 changes: 12 additions & 12 deletions pyaedt/application/Analysis3D.py
Original file line number Diff line number Diff line change
Expand Up @@ -1311,17 +1311,17 @@ def import_dxf(
self.oeditor.ImportDXF(vArg1)
return True

@pyaedt_function_handler
def import_gds_3d(self, gds_file, gds_number, unit="um", import_method=1): # pragma: no cover
@pyaedt_function_handler(gds_file="input_file", gds_number="mapping_layers", unit="units")
def import_gds_3d(self, input_file, mapping_layers, units="um", import_method=1): # pragma: no cover
"""Import a GDSII file.
Parameters
----------
gds_file : str
input_file : str
Path to the GDS file.
gds_number : dict
mapping_layers : dict
Dictionary keys are GDS layer numbers, and the value is a tuple with the thickness and elevation.
unit : string, optional
units : string, optional
Length unit values. The default is ``"um"``.
import_method : integer, optional
GDSII import method. The default is ``1``. Options are:
Expand All @@ -1346,23 +1346,23 @@ def import_gds_3d(self, gds_file, gds_number, unit="um", import_method=1): # pr
>>> from pyaedt import Hfss
>>> hfss = Hfss()
>>> gds_number = {7: (100, 10), 9: (110, 5)}
>>> hfss.import_gds_3d(gds_path, gds_number, unit="um", import_method=1)
>>> hfss.import_gds_3d(gds_path,gds_number,units="um",import_method=1)
"""

if self.desktop_class.non_graphical:
self.logger.error("Method is supported only in graphical mode.")
return False
if not os.path.exists(gds_file):
if not os.path.exists(input_file):
self.logger.error("GDSII file does not exist. No layer is imported.")
return False
if len(gds_number) == 0:
if len(mapping_layers) == 0:
self.logger.error("Dictionary for GDSII layer numbers is empty. No layer is imported.")
return False

layermap = ["NAME:LayerMap"]
ordermap = []
for i, k in enumerate(gds_number):
for i, k in enumerate(mapping_layers):
layername = "signal" + str(k)
layermap.append(
[
Expand All @@ -1385,9 +1385,9 @@ def import_gds_3d(self, gds_file, gds_number, unit="um", import_method=1): # pr
"LayerNumber:=",
k,
"Thickness:=",
unit_converter(gds_number[k][1], unit_system="Length", input_units=unit, output_units="meter"),
unit_converter(mapping_layers[k][1], unit_system="Length", input_units=units, output_units="meter"),
"Elevation:=",
unit_converter(gds_number[k][0], unit_system="Length", input_units=unit, output_units="meter"),
unit_converter(mapping_layers[k][0], unit_system="Length", input_units=units, output_units="meter"),
"Color:=",
"color",
],
Expand All @@ -1398,7 +1398,7 @@ def import_gds_3d(self, gds_file, gds_number, unit="um", import_method=1): # pr
[
"NAME:options",
"FileName:=",
gds_file,
input_file,
"FlattenHierarchy:=",
True,
"ImportMethod:=",
Expand Down
Loading

0 comments on commit ef5e0e7

Please sign in to comment.