{ "cells": [ { "cell_type": "markdown", "id": "6854fa28", "metadata": {}, "source": [ "# Reflector\n", "\n", "This example shows how to use PyAEDT to create an HFSS SBR+ project from an\n", "HFSS antenna and run a simulation.\n", "\n", "Keywords: **HFSS**, **SBR+**, **reflector**." ] }, { "cell_type": "markdown", "id": "365f059e", "metadata": {}, "source": [ "## Perform imports and define constants\n", "\n", "Perform required imports and set up the local path to the path for the PyAEDT\n", "directory." ] }, { "cell_type": "code", "execution_count": null, "id": "4d8b0114", "metadata": {}, "outputs": [], "source": [ "import tempfile\n", "import time\n", "\n", "import ansys.aedt.core\n", "from ansys.aedt.core.examples.downloads import download_sbr" ] }, { "cell_type": "markdown", "id": "02c9f4a3", "metadata": {}, "source": [ "Define constants." ] }, { "cell_type": "code", "execution_count": null, "id": "7946df0a", "metadata": {}, "outputs": [], "source": [ "AEDT_VERSION = \"2025.1\"\n", "NUM_CORES = 4\n", "NG_MODE = False # Open AEDT UI when it is launched." ] }, { "cell_type": "markdown", "id": "efc585b9", "metadata": {}, "source": [ "## Create temporary directory\n", "\n", "Create a temporary directory where downloaded data or\n", "dumped data can be stored.\n", "If you'd like to retrieve the project data for subsequent use,\n", "the temporary folder name is given by ``temp_folder.name``." ] }, { "cell_type": "code", "execution_count": null, "id": "97038cfc", "metadata": {}, "outputs": [], "source": [ "temp_folder = tempfile.TemporaryDirectory(suffix=\".ansys\")" ] }, { "cell_type": "markdown", "id": "c13029dd", "metadata": {}, "source": [ "## Download project" ] }, { "cell_type": "code", "execution_count": null, "id": "c8d381b3", "metadata": {}, "outputs": [], "source": [ "project_full_name = download_sbr(local_path=temp_folder.name)" ] }, { "cell_type": "markdown", "id": "b952b742", "metadata": {}, "source": [ "## Define designs\n", "\n", "Define two designs, one source and one target, with each design connected to\n", "a different object." ] }, { "cell_type": "code", "execution_count": null, "id": "b10b0dee", "metadata": {}, "outputs": [], "source": [ "target = ansys.aedt.core.Hfss(\n", " project=project_full_name,\n", " design=\"Cassegrain_\",\n", " solution_type=\"SBR+\",\n", " version=AEDT_VERSION,\n", " new_desktop=True,\n", " non_graphical=NG_MODE,\n", ")\n", "\n", "source = ansys.aedt.core.Hfss(\n", " project=target.project_name,\n", " design=\"feeder\",\n", " version=AEDT_VERSION,\n", ")" ] }, { "cell_type": "markdown", "id": "5f3c558c", "metadata": {}, "source": [ "## Define linked antenna\n", "\n", "Define a linked antenna. This is HFSS far field applied to HFSS SBR+." ] }, { "cell_type": "code", "execution_count": null, "id": "cdcd8ab6", "metadata": {}, "outputs": [], "source": [ "target.create_sbr_linked_antenna(\n", " source, target_cs=\"feederPosition\", field_type=\"farfield\"\n", ")" ] }, { "cell_type": "markdown", "id": "2aa361c5", "metadata": {}, "source": [ "## Assign boundaries\n", "\n", "Assign boundaries." ] }, { "cell_type": "code", "execution_count": null, "id": "780a9560", "metadata": {}, "outputs": [], "source": [ "target.assign_perfecte_to_sheets([\"Reflector\", \"Subreflector\"])\n", "target.mesh.assign_curvilinear_elements([\"Reflector\", \"Subreflector\"])" ] }, { "cell_type": "markdown", "id": "e66ee8d6", "metadata": {}, "source": [ "## Create setup and solve\n", "\n", "Create a setup and solve it." ] }, { "cell_type": "code", "execution_count": null, "id": "a4311d83", "metadata": {}, "outputs": [], "source": [ "setup1 = target.create_setup()\n", "setup1.props[\"RadiationSetup\"] = \"ATK_3D\"\n", "setup1.props[\"ComputeFarFields\"] = True\n", "setup1.props[\"RayDensityPerWavelength\"] = 2\n", "setup1.props[\"MaxNumberOfBounces\"] = 3\n", "setup1[\"RangeType\"] = \"SinglePoints\"\n", "setup1[\"RangeStart\"] = \"10GHz\"\n", "target.analyze(cores=NUM_CORES)" ] }, { "cell_type": "markdown", "id": "29412b54", "metadata": {}, "source": [ "## Postprocess\n", "\n", "Plot results in AEDT." ] }, { "cell_type": "code", "execution_count": null, "id": "141a522f", "metadata": {}, "outputs": [], "source": [ "variations = target.available_variations.nominal_w_values_dict\n", "variations[\"Freq\"] = [\"10GHz\"]\n", "variations[\"Theta\"] = [\"All\"]\n", "variations[\"Phi\"] = [\"All\"]\n", "target.post.create_report(\n", " \"db(GainTotal)\",\n", " target.nominal_adaptive,\n", " variations=variations,\n", " primary_sweep_variable=\"Theta\",\n", " context=\"ATK_3D\",\n", " report_category=\"Far Fields\",\n", ")" ] }, { "cell_type": "markdown", "id": "6238ad17", "metadata": {}, "source": [ "Plot results using Matplotlib." ] }, { "cell_type": "code", "execution_count": null, "id": "2f4fa086", "metadata": {}, "outputs": [], "source": [ "solution = target.post.get_solution_data(\n", " \"GainTotal\",\n", " target.nominal_adaptive,\n", " variations=variations,\n", " primary_sweep_variable=\"Theta\",\n", " context=\"ATK_3D\",\n", " report_category=\"Far Fields\",\n", ")\n", "solution.plot()" ] }, { "cell_type": "markdown", "id": "38adaef9", "metadata": {}, "source": [ "## Release AEDT\n", "\n", "Release AEDT and close the example." ] }, { "cell_type": "code", "execution_count": null, "id": "989b4fe1", "metadata": {}, "outputs": [], "source": [ "target.save_project()\n", "target.release_desktop()\n", "# Wait 3 seconds to allow AEDT to shut down before cleaning the temporary directory.\n", "time.sleep(3)" ] }, { "cell_type": "markdown", "id": "999d2dbf", "metadata": {}, "source": [ "## Clean up\n", "\n", "All project files are saved in the folder ``temp_folder.name``. If you've run this example as a Jupyter notebook, you\n", "can retrieve those project files. The following cell removes all temporary files, including the project folder." ] }, { "cell_type": "code", "execution_count": null, "id": "6423927b", "metadata": {}, "outputs": [], "source": [ "temp_folder.cleanup()" ] } ], "metadata": { "jupytext": { "cell_metadata_filter": "-all", "main_language": "python", "notebook_metadata_filter": "-all" } }, "nbformat": 4, "nbformat_minor": 5 }