HFSS 3D Layout Analysis

This example shows how to use HFSS 3D Layout combined with EDB to interact with a layout.

# sphinx_gallery_thumbnail_path = 'Resources/edb2.png'


import os
import tempfile
from pyaedt import generate_unique_name

tmpfold = tempfile.gettempdir()
temp_folder = os.path.join(tmpfold, generate_unique_name("Example"))
if not os.path.exists(temp_folder):
    os.makedirs(temp_folder)
print(temp_folder)

Out:

C:\Users\ansys\AppData\Local\Temp\Example_SSC0ZD

Copy an Example in the Temp Folder

This exammple copies an example in the temp folder.

from pyaedt import Desktop
from pyaedt import Hfss3dLayout
from pyaedt import examples


targetfile = examples.download_aedb()
print(targetfile)
aedt_file = targetfile[:-12] + "aedt"

Out:

C:\Users\ansys\AppData\Local\Temp\PyAEDTExamples\edb/Galileo.aedb\edb.def

Launch AEDT

This example launches AEDT 2021.1 in graphical model.

# This example uses SI units.

desktopVersion = "2021.1"

Launch AEDT in Non-Graphical Mode

Change the Boolean parameter NonGraphical to False to launch AEDT in graphical mode.

NonGraphical = True
NewThread = False

Initialize AEDT

Launch HFSS 3D Layout. The h3d object will contain the pyaedt.Edb class query methods.

d = Desktop(desktopVersion, NonGraphical, NewThread)
if os.path.exists(aedt_file):
    os.remove(aedt_file)
h3d = Hfss3dLayout(targetfile)
h3d.save_project(os.path.join(temp_folder, "edb_demo.aedt"))

Out:

Launching PyAEDT outside Electronics Desktop with CPython and Pythonnet
Launching AEDT installation C:\Program Files\AnsysEM\AnsysEM21.1\Win64
===================================================================================
pyaedt info: Launching AEDT with module Pythonnet.
pyaedt info:: Ansoft.ElectronicsDesktop.2021.1 Started with process ID 708.
pyaedt info: Logger Started on C:\Users\ansys\Documents\Ansoft\pyaedt20211026_141240.log
pyaedt info: pyaedt v0.4.0
pyaedt info: Python version 3.8.10 (tags/v3.8.10:3d8993a, May  3 2021, 11:48:03) [MSC v.1928 64 bit (AMD64)]
pyaedt info: EDB folder C:\Users\ansys\AppData\Local\Temp\PyAEDTExamples\edb/Galileo.aedb\edb.def has been imported to project Galileo
pyaedt info: Active design is set to Galileo_G87173_204
pyaedt.generic.LoadAEDTFile._read_aedt_file: 0.015602999999999999s
pyaedt info: AEDT Load time 0.10936927795410156
pyaedt info: Design Loaded
pyaedt info: Successfully loaded project materials !
pyaedt info: Materials Loaded
pyaedt info: Analysis Loaded
pyaedt info: Loading Modeler.
pyaedt info: Modeler loaded.
pyaedt info: Logger Initialized in EDB
pyaedt info: EDB Path C:\Users\ansys\AppData\Local\Temp\PyAEDTExamples\edb\Galileo.aedb
pyaedt info: EDB Version 2021.1
pyaedt info: EDB Standalone True
pyaedt info: Database Opened
pyaedt info: Cell Galileo_G87173_204 Opened
pyaedt info: C:\actions-runner\_work\PyAEDT\PyAEDT\pyaedt\dlls\EDBLib
pyaedt info: Refreshing the Components dictionary.
pyaedt info: Objects Initialized
pyaedt info: Builder Initialized
pyaedt info: Edb Initialized
pyaedt info: EDB loaded.
pyaedt info: Layers loaded.
pyaedt info: Primitives loaded.
pyaedt info: Modeler Loaded
pyaedt info: Saving Galileo Project

True

Hide All Nets

This example hides all nets.

h3d.modeler.primitives.change_net_visibility(visible=False)

Out:

pyaedt info: EDB file release time: 0.00ms
pyaedt info: Logger Initialized in EDB
pyaedt info: EDB Path C:\Users\ansys\AppData\Local\Temp\Example_SSC0ZD\edb_demo.aedb
pyaedt info: EDB Version 2021.1
pyaedt info: EDB Standalone True
pyaedt info: Database Opened
pyaedt info: Cell Galileo_G87173_204 Opened
pyaedt info: C:\actions-runner\_work\PyAEDT\PyAEDT\pyaedt\dlls\EDBLib
pyaedt info: Refreshing the Components dictionary.
pyaedt info: Objects Initialized
pyaedt info: Builder Initialized
pyaedt info: Edb Initialized

True

Show Only Two Nets

This examples shows only the two specified nets.

h3d.modeler.primitives.change_net_visibility(["A0_GPIO", "A0_MUX"], visible=True)

Out:

True

Show All Layers

This example shows all layers.

layers = h3d.modeler.layers.all_signal_layers
for lay in layers:
    layer = h3d.modeler.layers.layers[h3d.modeler.layers.layer_id(lay)]
    layer.IsVisible = True
    layer.update_stackup_layer()

Change the Layer Color

This examples changes the layer color.

layer = h3d.modeler.layers.layers[h3d.modeler.layers.layer_id("TOP")]
layer.set_layer_color(0, 255, 0)
h3d.modeler.fit_all()

Disable Component Visibility

The example disable component visibility for "TOP" and "BOTTOM". The pyaedt.modules.LayerStackup.Layer.update_stackup_layer() method will apply modifications to the layout.

top = h3d.modeler.layers.layers[h3d.modeler.layers.layer_id("TOP")]
top.IsVisibleComponent = False
top.update_stackup_layer()

bot = h3d.modeler.layers.layers[h3d.modeler.layers.layer_id("BOTTOM")]
bot.IsVisibleComponent = False
bot.update_stackup_layer()

Out:

True
# Fit All
# ~~~~~~~
# This method fits all so that you can visualize all.

h3d.modeler.fit_all()

Close AEDT

After the simulaton is completed, you can close AEDT or release it using the pyaedt.Desktop.release_desktop() method. All methods provide for saving the project before exiting.

if os.name != "posix":
    h3d.close_project()
    d.force_close_desktop()

Out:

pyaedt info: Closing the active edb_demo AEDT Project
pyaedt info: Project Closed Correctly

Total running time of the script: ( 0 minutes 24.243 seconds)

Gallery generated by Sphinx-Gallery