Q3D Extractor: PCB DCIR analysis#

This example shows how you can use PyAEDT to create a design in Q3D Extractor and run a DC IR Drop simulation starting from an EDB Project.

Perform required imports#

Perform required imports.

import os
import pyaedt

Set AEDT version#

Set AEDT version.

aedt_version = "2024.1"

Set up project files and path#

Download needed project file and set up temporary project directory.

project_dir = pyaedt.generate_unique_folder_name()
aedb_project = pyaedt.downloads.download_file('edb/ANSYS-HSD_V1.aedb', destination=project_dir)
coil = pyaedt.downloads.download_file('inductance_3d_component', 'air_coil.a3dcomp')
res = pyaedt.downloads.download_file('resistors', 'Res_0402.a3dcomp')
project_name = pyaedt.generate_unique_name("HSD")
output_edb = os.path.join(project_dir, project_name + '.aedb')
output_q3d = os.path.join(project_dir, project_name + '_q3d.aedt')

Open EDB#

Open the EDB project and create a cutout on the selected nets before exporting to Q3D.

edb = pyaedt.Edb(aedb_project, edbversion=aedt_version)
edb.cutout(["1.2V_AVDLL_PLL", "1.2V_AVDDL", "1.2V_DVDDL", "NetR106_1"],
           ["GND"],
           output_aedb_path=output_edb,
           use_pyaedt_extent_computing=True,
           )
C:\actions-runner\_work\pyaedt\pyaedt\testenv\lib\site-packages\pyedb\dotnet\edb_core\components.py:185: DeprecationWarning: Use new property :func:`instances` instead.
  warnings.warn("Use new property :func:`instances` instead.", DeprecationWarning)

[[0.022903601428309994, 0.0687375259513446], [0.02304646506556407, 0.06810090632382818], [0.02308056292432885, 0.06798321402755685], [0.025721400460243713, 0.06059405990094516], [0.025832015076226816, 0.06037420643241395], [0.02599290332692254, 0.06013342014927757], [0.026117566301186005, 0.059981517875627256], [0.02651910015861637, 0.059579984018196905], [0.026586056930005972, 0.059518838114455644], [0.02693453943571554, 0.05922843602636434], [0.0269622469688975, 0.05920616873058622], [0.031134053159860956, 0.05597380121231693], [0.031190979485084647, 0.05593280581169422], [0.03137428040859384, 0.0558103280502945], [0.031582858614209536, 0.05570382969879277], [0.03834973057875869, 0.053194377967395214], [0.03869758475453261, 0.05313149807897392], [0.039227070108729535, 0.05313014999960498], [0.03973452671388853, 0.05326427792228474], [0.04026859112194551, 0.05356960588571382], [0.040641624759074686, 0.05393885974328623], [0.04095237573431778, 0.05446978703453285], [0.04109166457619173, 0.054975851382507775], [0.041094466634292184, 0.05534269997333201], [0.04109428367028657, 0.0553709355606793], [0.04104908615549033, 0.0575649272409746], [0.041046981671272235, 0.05761236166846335], [0.04066600191016067, 0.06320005881026784], [0.04064908611307354, 0.06332725593241376], [0.04058481891644457, 0.06365034894807488], [0.040434054803263786, 0.06401432571483504], [0.040278535856694386, 0.0642470762664744], [0.04026188810298574, 0.06427121750045746], [0.03523275742407547, 0.07134000863384793], [0.03512485342105291, 0.07146762763124666], [0.03481552767976474, 0.07177695337253483], [0.03435947005023539, 0.0720402583677096], [0.033891016883249823, 0.07216578001549522], [0.03363108596563051, 0.07220000056999999], [0.029642428636052272, 0.07220000056999999], [0.029627277942905955, 0.07219988579330847], [0.027927438942503855, 0.07217412946752286], [0.027843048529560797, 0.07216927931781611], [0.027220284389757213, 0.07210700322019893], [0.027060706534908142, 0.07207784392640419], [0.026879686158052363, 0.07202933966261212], [0.026800302236482394, 0.07200448861783905], [0.02420720288895093, 0.07107268711201903], [0.024045048376626268, 0.07099747710317793], [0.023683583814363553, 0.07078878544085301], [0.023311214319146782, 0.07041641594563619], [0.023015557008038968, 0.06990432246116815], [0.022879260313195288, 0.06939565627110772], [0.022879260313195333, 0.06895715817774653]]

Identify pin positions#

Identify [x,y] pin locations on the components to define where to assign sources and sinks for Q3D.

pin_u11_scl = [i for i in edb.components["U11"].pins.values() if i.net_name == "1.2V_AVDLL_PLL"]
pin_u9_1 = [i for i in edb.components["U9"].pins.values() if i.net_name == "1.2V_AVDDL"]
pin_u9_2 = [i for i in edb.components["U9"].pins.values() if i.net_name == "1.2V_DVDDL"]
pin_u11_r106 = [i for i in edb.components["U11"].pins.values() if i.net_name == "NetR106_1"]

Append Z Positions#

Compute Q3D 3D position. The factor 1000 converts from “meters” to “mm”.

location_u11_scl = [i * 1000 for i in pin_u11_scl[0].position]
location_u11_scl.append(edb.components["U11"].upper_elevation * 1000)

location_u9_1_scl = [i * 1000 for i in pin_u9_1[0].position]
location_u9_1_scl.append(edb.components["U9"].upper_elevation * 1000)

location_u9_2_scl = [i * 1000 for i in pin_u9_2[0].position]
location_u9_2_scl.append(edb.components["U9"].upper_elevation * 1000)

location_u11_r106 = [i * 1000 for i in pin_u11_r106[0].position]
location_u11_r106.append(edb.components["U11"].upper_elevation * 1000)

Identify pin positions for 3D components#

Identify the pin positions where 3D components of passives are to be added.

location_l2_1 = [i * 1000 for i in edb.components["L2"].pins["1"].position]
location_l2_1.append(edb.components["L2"].upper_elevation * 1000)
location_l4_1 = [i * 1000 for i in edb.components["L4"].pins["1"].position]
location_l4_1.append(edb.components["L4"].upper_elevation * 1000)

location_r106_1 = [i * 1000 for i in edb.components["R106"].pins["1"].position]
location_r106_1.append(edb.components["R106"].upper_elevation * 1000)

Save and close EDB#

Save and close EDB. Then, open EDT in HFSS 3D Layout to generate the 3D model.

edb.save_edb()
edb.close_edb()

h3d = pyaedt.Hfss3dLayout(output_edb, specified_version=aedt_version, non_graphical=False, new_desktop_session=True)
C:\actions-runner\_work\_tool\Python\3.10.9\x64\lib\subprocess.py:1072: ResourceWarning: subprocess 9308 is still running
  _warn("subprocess %s is still running" % self.pid,
C:\actions-runner\_work\pyaedt\pyaedt\testenv\lib\site-packages\pyaedt\generic\settings.py:383: ResourceWarning: unclosed file <_io.TextIOWrapper name='D:\\Temp\\pyaedt_ansys.log' mode='a' encoding='cp1252'>
  self._logger = val

Export to Q3D#

Create a dummy setup and export the layout in Q3D. The keep_net_name parameter reassigns Q3D net names from HFSS 3D Layout.

setup = h3d.create_setup()
setup.export_to_q3d(output_q3d, keep_net_name=True)
h3d.close_project()
True

Open Q3D#

Launch the newly created q3d project.

q3d = pyaedt.Q3d(output_q3d)
q3d.modeler.delete("GND")
q3d.delete_all_nets()
True

Insert inductors#

Create new coordinate systems and place 3D component inductors.

q3d.modeler.create_coordinate_system(location_l2_1, name="L2")
comp = q3d.modeler.insert_3d_component(coil, coordinate_system="L2")
comp.rotate(q3d.AXIS.Z, -90)
comp.parameters["n_turns"] = "3"
comp.parameters["d_wire"] = "100um"
q3d.modeler.set_working_coordinate_system("Global")
q3d.modeler.create_coordinate_system(location_l4_1, name="L4")
comp2 = q3d.modeler.insert_3d_component(coil, coordinate_system="L4")
comp2.rotate(q3d.AXIS.Z, -90)
comp2.parameters["n_turns"] = "3"
comp2.parameters["d_wire"] = "100um"
q3d.modeler.set_working_coordinate_system("Global")

q3d.modeler.set_working_coordinate_system("Global")
q3d.modeler.create_coordinate_system(location_r106_1, name="R106")
comp3 = q3d.modeler.insert_3d_component(res, geometry_parameters={'$Resistance': 2000}, coordinate_system="R106")
comp3.rotate(q3d.AXIS.Z, -90)

q3d.modeler.set_working_coordinate_system("Global")
True

Delete dielectrics#

Delete all dielectric objects since not needed in DC analysis.

q3d.modeler.delete(q3d.modeler.get_objects_by_material("Megtron4"))
q3d.modeler.delete(q3d.modeler.get_objects_by_material("Megtron4_2"))
q3d.modeler.delete(q3d.modeler.get_objects_by_material("Megtron4_3"))
q3d.modeler.delete(q3d.modeler.get_objects_by_material("Solder Resist"))

objs_copper = q3d.modeler.get_objects_by_material("copper")
objs_copper_names = [i.name for i in objs_copper]
q3d.plot(show=False,objects=objs_copper_names, plot_as_separate_objects=False,
         export_path=os.path.join(q3d.working_directory, "Q3D.jpg"), plot_air_objects=False)
Q3D DC IR
<pyaedt.generic.plot.ModelPlotter object at 0x000002799C798310>

Assign source and sink#

Use previously calculated positions to identify faces, select the net “1_Top” and assign sources and sinks on nets.

sink_f = q3d.modeler.create_circle(q3d.PLANE.XY, location_u11_scl, 0.1)
source_f1 = q3d.modeler.create_circle(q3d.PLANE.XY, location_u9_1_scl, 0.1)
source_f2 = q3d.modeler.create_circle(q3d.PLANE.XY, location_u9_2_scl, 0.1)
source_f3= q3d.modeler.create_circle(q3d.PLANE.XY, location_u11_r106, 0.1)
sources_objs = [source_f1, source_f2, source_f3]
q3d.auto_identify_nets()

identified_net = q3d.nets[0]

q3d.sink(sink_f, net_name=identified_net)

source1 = q3d.source(source_f1, net_name=identified_net)

source2 = q3d.source(source_f2, net_name=identified_net)
source3 = q3d.source(source_f3, net_name=identified_net)
sources_bounds = [source1, source2, source3]

q3d.edit_sources(dcrl={"{}:{}".format(source1.props["Net"], source1.name): "-1.0A",
                       "{}:{}".format(source2.props["Net"], source2.name): "-1.0A",
                       "{}:{}".format(source2.props["Net"], source3.name): "-1.0A"})
True

Create setup#

Create a setup and a frequency sweep from DC to 2GHz. Analyze project.

setup = q3d.create_setup()
setup.dc_enabled = True
setup.capacitance_enabled = False
setup.ac_rl_enabled = False
setup.props["SaveFields"] = True
setup.props["DC"]["Cond"]["MaxPass"]=3
setup.analyze()

Field Calculator#

We will create a named expression using field calculator.

drop_name = "Vdrop3_3"
fields = q3d.ofieldsreporter
q3d.ofieldsreporter.CalcStack("clear")
q3d.ofieldsreporter.EnterQty("Phidc")
q3d.ofieldsreporter.EnterScalar(3.3)
q3d.ofieldsreporter.CalcOp("+")
q3d.ofieldsreporter.AddNamedExpression(drop_name, "DC R/L Fields")

Phi plot#

Compute ACL solutions and plot them.

plot1 = q3d.post.create_fieldplot_surface(q3d.modeler.get_objects_by_material("copper"), quantity=drop_name)

q3d.post.plot_field_from_fieldplot(plot1.name, project_path=q3d.working_directory, mesh_plot=False, image_format="jpg",
                                   view="isometric", show=False, plot_cad_objs=False, log_scale=False)
Q3D DC IR
<pyaedt.generic.plot.ModelPlotter object at 0x00000279A159C340>

Computing Voltage on Source Circles#

Using Field Calculator we can compute the voltage on source circles and get the value using get_solution_data method.

curves = []
for source_circle, source_bound in zip(sources_objs, sources_bounds):
    source_sheet_name = source_circle.name

    curves.append("V{}".format(source_bound.name))

    q3d.ofieldsreporter.CalcStack("clear")
    q3d.ofieldsreporter.CopyNamedExprToStack(drop_name)
    q3d.ofieldsreporter.EnterSurf(source_sheet_name)
    q3d.ofieldsreporter.CalcOp("Maximum")
    q3d.ofieldsreporter.AddNamedExpression("V{}".format(source_bound.name), "DC R/L Fields")


data = q3d.post.get_solution_data(
            curves,
            q3d.nominal_adaptive,
            variations={"Freq": "1GHz"},
            report_category="DC R/L Fields",
        )
for curve in curves:
    print(data.data_real(curve))
[3.260417875446388]
[3.2218341951839946]
[3.2863685179632416]

Close AEDT#

After the simulation completes, you can close AEDT or release it using the release_desktop method. All methods provide for saving projects before closing.

q3d.save_project()
q3d.release_desktop()
True

Total running time of the script: (7 minutes 55.226 seconds)

Gallery generated by Sphinx-Gallery