Download this example

Download this example as a Jupyter Notebook or as a Python script.


Reflector#

This example shows how to use PyAEDT to create an HFSS SBR+ project from an HFSS antenna and run a simulation.

Keywords: HFSS, SBR+, reflector.

Perform imports and define constants#

Perform required imports and set up the local path to the path for the PyAEDT directory.

[1]:
import tempfile
import time
[2]:
import ansys.aedt.core

Define constants.

[3]:
AEDT_VERSION = "2024.2"
NUM_CORES = 4
NG_MODE = False  # Open AEDT UI when it is launched.

Create temporary directory#

Create a temporary directory where downloaded data or dumped data can be stored. If you’d like to retrieve the project data for subsequent use, the temporary folder name is given by temp_folder.name.

[4]:
temp_folder = tempfile.TemporaryDirectory(suffix=".ansys")

Download project#

[5]:
project_full_name = ansys.aedt.core.downloads.download_sbr(destination=temp_folder.name)

Define designs#

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

[6]:
target = ansys.aedt.core.Hfss(
    project=project_full_name,
    design="Cassegrain_",
    solution_type="SBR+",
    version=AEDT_VERSION,
    new_desktop=True,
    non_graphical=NG_MODE,
)

source = ansys.aedt.core.Hfss(
    project=target.project_name,
    design="feeder",
    version=AEDT_VERSION,
)
PyAEDT INFO: Parsing C:\Users\ansys\AppData\Local\Temp\tmp2zfx_qea.ansys\sbr\Cassegrain.aedt.
PyAEDT INFO: Python version 3.10.11 (tags/v3.10.11:7d4cc5a, Apr  5 2023, 00:38:17) [MSC v.1929 64 bit (AMD64)]
PyAEDT INFO: PyAEDT version 0.12.dev0.
PyAEDT INFO: Initializing new Desktop session.
PyAEDT INFO: Log on console is enabled.
PyAEDT INFO: Log on file C:\Users\ansys\AppData\Local\Temp\pyaedt_ansys_43691663-e2fd-447f-8d07-322dd696c35b.log is enabled.
PyAEDT INFO: Log on AEDT is enabled.
PyAEDT INFO: Debug logger is disabled. PyAEDT methods will not be logged.
PyAEDT INFO: Launching PyAEDT with gRPC plugin.
PyAEDT INFO: New AEDT session is starting on gRPC port 59109
PyAEDT INFO: File C:\Users\ansys\AppData\Local\Temp\tmp2zfx_qea.ansys\sbr\Cassegrain.aedt correctly loaded. Elapsed time: 0m 0sec
PyAEDT INFO: AEDT installation Path C:\Program Files\AnsysEM\v242\Win64
PyAEDT INFO: Ansoft.ElectronicsDesktop.2024.2 version started with process ID 964.
PyAEDT INFO: Project Cassegrain has been opened.
PyAEDT INFO: Aedt Objects correctly read
PyAEDT INFO: Python version 3.10.11 (tags/v3.10.11:7d4cc5a, Apr  5 2023, 00:38:17) [MSC v.1929 64 bit (AMD64)]
PyAEDT INFO: PyAEDT version 0.12.dev0.
PyAEDT INFO: Returning found Desktop session with PID 964!
PyAEDT INFO: Project Cassegrain set to active.
PyAEDT INFO: Aedt Objects correctly read

Define linked antenna#

Define a linked antenna. This is HFSS far field applied to HFSS SBR+.

[7]:
target.create_sbr_linked_antenna(
    source, target_cs="feederPosition", field_type="farfield"
)
PyAEDT INFO: Modeler class has been initialized! Elapsed time: 0m 1sec
PyAEDT INFO: Modeler class has been initialized! Elapsed time: 0m 0sec
PyAEDT INFO: Native component Linked Antenna feeder_LUFKAU has been correctly created.
[7]:
<ansys.aedt.core.modules.boundary.NativeComponentObject at 0x1e924815f30>

Assign boundaries#

Assign boundaries.

[8]:
target.assign_perfecte_to_sheets(["Reflector", "Subreflector"])
target.mesh.assign_curvilinear_elements(["Reflector", "Subreflector"])
PyAEDT INFO: Boundary Perfect E PerfE_5WH60Y has been correctly created.
PyAEDT INFO: Mesh class has been initialized! Elapsed time: 0m 0sec
PyAEDT INFO: Mesh class has been initialized! Elapsed time: 0m 0sec
PyAEDT INFO: Parsing design objects. This operation can take time
PyAEDT INFO: 3D Modeler objects parsed. Elapsed time: 0m 0sec
[8]:
<ansys.aedt.core.modules.mesh.MeshOperation at 0x1e920d1e350>

Create setup and solve#

Create a setup and solve it.

[9]:
setup1 = target.create_setup()
setup1.props["RadiationSetup"] = "ATK_3D"
setup1.props["ComputeFarFields"] = True
setup1.props["RayDensityPerWavelength"] = 2
setup1.props["MaxNumberOfBounces"] = 3
setup1["RangeType"] = "SinglePoints"
setup1["RangeStart"] = "10GHz"
target.analyze(cores=NUM_CORES)
PyAEDT INFO: Key Desktop/ActiveDSOConfigurations/HFSS correctly changed.
PyAEDT INFO: Solving all design setups.
PyAEDT INFO: Key Desktop/ActiveDSOConfigurations/HFSS correctly changed.
PyAEDT INFO: Design setup None solved correctly in 0.0h 1.0m 8.0s
[9]:
True

Postprocess#

Plot results in AEDT.

[10]:
variations = target.available_variations.nominal_w_values_dict
variations["Freq"] = ["10GHz"]
variations["Theta"] = ["All"]
variations["Phi"] = ["All"]
target.post.create_report(
    "db(GainTotal)",
    target.nominal_adaptive,
    variations=variations,
    primary_sweep_variable="Theta",
    context="ATK_3D",
    report_category="Far Fields",
)
PyAEDT INFO: PostProcessor class has been initialized! Elapsed time: 0m 0sec
PyAEDT INFO: Post class has been initialized! Elapsed time: 0m 0sec
[10]:
<ansys.aedt.core.visualization.report.field.FarField at 0x1e924816fe0>

Plot results using Matplotlib.

[11]:
solution = target.post.get_solution_data(
    "GainTotal",
    target.nominal_adaptive,
    variations=variations,
    primary_sweep_variable="Theta",
    context="ATK_3D",
    report_category="Far Fields",
)
solution.plot()
PyAEDT INFO: Solution Data Correctly Loaded.
[11]:
../../../../_images/examples_high_frequency_antenna_large_scenarios_reflector_21_1.png
../../../../_images/examples_high_frequency_antenna_large_scenarios_reflector_21_2.png

Release AEDT#

Release AEDT and close the example.

[12]:
target.save_project()
target.release_desktop()
# Wait 3 seconds to allow AEDT to shut down before cleaning the temporary directory.
time.sleep(3)
PyAEDT INFO: Project Cassegrain Saved correctly
PyAEDT INFO: Desktop has been released and closed.

Clean up#

All project files are saved in the folder temp_folder.name. If you’ve run this example as a Jupyter notebook, you can retrieve those project files. The following cell removes all temporary files, including the project folder.

[13]:
temp_folder.cleanup()

Download this example

Download this example as a Jupyter Notebook or as a Python script.