Skip to main content

PyAEDT Client Library Cheat Sheet

| 06.26.2023

This is a quick-reference guide for the PyAEDT Client Library. You can jump to a section of your choosing by using these links:

Launching PyAEDT | Variable Class | Material Class | Geometry Creation | Creating boundaries | Port definitions | Setup Class | Mesh Class | Analysis Class | Post-Processing Class | Calling AEDT Client Library with PyAEDT

 

Launching PyAEDT

 

To launch HFSS instance locally and exit it

# To launch an instance 
import pyaedt

hfss = pyaedt.Hfss(
    specified_version="2023.1",
    non_graphical=False,
    new_desktop_session=True,
    projectname="Project_name",
    designname="Design_name"
)

# To exit the instance 
hfss.release_desktop() 

 

Variable Class

Creating a local and global variable in HFSS

hfss["dim"] = "1mm"   # design variable 
hfss["$dim"] = "1mm"   # project variable 

hfss.variable_manager is the class which handles all the variables. It contains properties and methods useful for variable handling.

 

Material Class

hfss.materialsclass is used to access the material library. A new material is added in HFSS as:

my_mat = hfss.materials.add_material("myMat")
my_mat.permittivity = 3.5
my_mat.conductivity = 450000
my_mat.permeability = 1.5 

 

Geometry Creation

hfss.modeler contains all properties and methods needed to edit a modeler, including primitives methods and properties.

A box is drawn at (x_pos, y_pos, z_pos) position with (x_dim, y_dim, z_dim) dimensions as:

box = hfss.modeler.create_box([x_pos, y_pos, z_pos], [x_dim, y_dim, z_dim], name="airbox", matname="air")

A spiral geometry made of "copper" is created as follows:

ind = hfss.modeler.create_spiral(
    internal_radius=rin,
    width=width,
    spacing=spacing,
    turns=Nr,
    faces=Np,
    thickness=thickness,
    material="copper",
    name="Inductor1"
)

box, ind are the Object3d objects, containing properties and methods related to that object including faces, vertices, colors, and materials.

 

Creating boundaries

In AEDT, open region is created as:

hfss.create_open_region(Frequency="1GHz")

Assigning the radiation boundary to a box is as follows:

hfss.assign_radiation_boundary_to_objects("airbox") 

 

Port definitions

Common port types in HFSS are Lumped-port and Waveguide-port. The Pythonic way of defining thelumped-port is:

box1 = hfss.modeler.create_box([0,0,50], [10,10,5], " Box1", "copper") 
box2 = hfss.modeler.create_box([0,0,60], [10,10,5], " Box2", "copper") 
port_L = hfss.lumped_port(
    signal="Box1",
    reference=" Box2",
    integration_line=hfss.AxisDir.XNeg,
    impedance=50,name="LumpedPort",
    renormalize=True ,
    deembed=False
) 

The Pythonic way of defining Waveguide-port is:

port_W = hfss.wave_port("Box1", "Box2", name="WavePort", integration_line=1) 

 

Setup Class

Setup class is used to define the solution setup in PyAEDT

setup = hfss.create_setup("MySetup")
setup.props["Frequency"] = "50MHz" 
setup["MaximumPasses"] = 10 
hfss.create_linear_count_sweep(
    setupname="any",
    unit=" MHz",
    freqstart=0.1,
    freqstop=100,
    num_of_freq_points=100,
    sweepname="sweep1",
    sweep_type="Interpolating",
    save_fields=False
) 

Parametric sweep and optimizations are accessed using the following classes:

# returns the ParametericsSetups Class
hfss.parametrics 

# returns the OptimizationSetups Class 
hfss.optimizations 

 

Mesh Class

Mesh module manages the mesh functions in PyAEDT

# setting the slider level to 6 
hfss.mesh.assign_initial_mesh_from_slider(level=6) 

# assign model resolutions 
hfss.mesh.assign_model_resolution(names=[object1.name, object2.name], defeature_length=None) 

# assigning the mesh length to the object1 faces 
hfss.mesh.assign_length_mesh(names=object1.faces, isinside=False, maxlength=1, maxel=2000) 

 

Analysis Class

The solution setup (mysetup) in HFSS design is analyzed by calling the following Python command:

hfss.analyze_setup("mysetup") 

 

Post-processing Class

Post-processing class has modules for creating and editing plots in AEDT. They are accessible through the post library.

# This call returns a FieldPlot object
plotf = hfss.post.create_fieldplot_volume(
    object_list,
    quantityname,
    setup_name,
    intrinsic_dict
)

# This call returns a Solution Data object 
my_data = hfss.post.get_solution_data(expression=trace_names)

# This call returns a new standard report object 
standard_report = hfss.post.report_by_category.standard("db(S(1,1))")

# This call creates a report 
standard_report.create()
solution_data = standard_report.get_solution_data() 

 

Calling the AEDT Client Libary with PyAEDT

Most of the critical functionalities are captured in PyAEDT. However, the missing features from the AEDT Client Library method can be converted to the PyAEDT method.

Example: AEDT Client Library module (Optimetrics), is accessible in PyAEDT as:

omodule = hfss.odesign.GetModule("Optimetrics")

 

References from PyAEDT Documentation