SBR+ Example

This example shows how you can use PyAEDT to create a Busbar project in in Q3D and run a simulation.

Import Packages

This example sets up the local path to the path for the AEDTLib directory.

import os
import tempfile
from pyaedt import examples, generate_unique_name

project_full_name = examples.download_sbr()
project_name = os.path.basename(project_full_name)[:-5]
tmpfold = tempfile.gettempdir()


temp_folder = os.path.join(tmpfold, generate_unique_name("SBR"))
if not os.path.exists(temp_folder):
    os.mkdir(temp_folder)
from pyaedt import Hfss

Define Designs

Define two designs, one source and one target, with each one connected to a different object.

target = Hfss(
    projectname=project_full_name,
    designname="Cassegrain_",
    solution_type="SBR+",
    specified_version="2021.1",
    new_desktop_session=False,
)
target.save_project(os.path.join(temp_folder, project_name + ".aedt"))
source = Hfss(projectname=project_name, designname="feeder", specified_version="2021.1", new_desktop_session=False)

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 1816.
pyaedt info: Logger Started on C:\Users\ansys\Documents\Ansoft\pyaedt20211026_143409.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: Project Cassegrain has been opened.
pyaedt.generic.LoadAEDTFile._read_aedt_file: 0.015677s
pyaedt info: AEDT Load time 0.14067649841308594
pyaedt info: Design Loaded
pyaedt info: Successfully loaded project materials !
pyaedt info: Materials Loaded
pyaedt info: Saving Cassegrain Project
pyaedt.generic.LoadAEDTFile._read_aedt_file: 0.046855999999999995s
pyaedt info: AEDT Load time 0.18749547004699707
pyaedt info: Design Loaded
pyaedt info: Successfully loaded project materials !
pyaedt info: Materials Loaded

Define a Linked Antenna

This is HFSS Far Field applied to SBR+.

target.create_sbr_linked_antenna(source, target_cs="feederPosition", fieldtype="farfield")

Out:

pyaedt info: Native Component Linked Antenna feeder_OUAZ04 has been correctly created

<pyaedt.modules.Boundary.NativeComponentObject object at 0x000001CD71FB19A0>

Assign Boundaries

These commands assign boundaries.

target.assign_perfecte_to_sheets(["Reflector", "Subreflector"])
target.mesh.assign_curvilinear_elements(["Reflector", "Subreflector"])

Out:

pyaedt info: Boundary PerfectE PerfE_YHNVUH has been correctly created.

<pyaedt.modules.Mesh.MeshOperation object at 0x000001CD720A00A0>

Create a Setup and Solve

This example creates a setup and then solves it.

setup1 = target.create_setup()
setup1.props["RayDensityPerWavelength"] = 2
setup1.props["ComputeFarFields"] = True
setup1.props["MaxNumberOfBounces"] = 3
setup1.props["Sweeps"]["Sweep"]["RangeType"] = "SinglePoints"
setup1.props["Sweeps"]["Sweep"]["RangeStart"] = "10GHz"
setup1.props["RadiationSetup"] = "ATK_3D"
setup1.update()
target.analyze_nominal()

Out:

pyaedt info: Solving design setup MySetupAuto
pyaedt info: Key Desktop/ActiveDSOConfigurations/HFSS correctly changed.
pyaedt info: Design setup MySetupAuto solved correctly

True

Plot Results

This example plots results.

variations = target.available_variations.nominal_w_values_dict
variations["Freq"] = ["10GHz"]
variations["Theta"] = ["All"]
variations["Phi"] = ["All"]
target.post.create_rectangular_plot(
    "db(GainTotal)", target.nominal_adaptive, variations, "Theta", "ATK_3D", report_category="Far Fields"
)
if os.name != "posix":
    target.close_desktop()

Out:

pyaedt info: Report Plot_F3IHFP correctly created.

Total running time of the script: ( 1 minutes 43.907 seconds)

Gallery generated by Sphinx-Gallery