{ "cells": [ { "cell_type": "markdown", "id": "ab917a02", "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": "3eeb7650", "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": "fdf0a816", "metadata": {}, "outputs": [], "source": [ "import tempfile\n", "import time" ] }, { "cell_type": "code", "execution_count": null, "id": "4512d7e5", "metadata": {}, "outputs": [], "source": [ "import ansys.aedt.core" ] }, { "cell_type": "markdown", "id": "ac66c5b7", "metadata": {}, "source": [ "Define constants." ] }, { "cell_type": "code", "execution_count": null, "id": "9ec3ef63", "metadata": {}, "outputs": [], "source": [ "AEDT_VERSION = \"2024.2\"\n", "NUM_CORES = 4\n", "NG_MODE = False # Open AEDT UI when it is launched." ] }, { "cell_type": "markdown", "id": "841e4f1b", "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": "05ec6116", "metadata": {}, "outputs": [], "source": [ "temp_folder = tempfile.TemporaryDirectory(suffix=\".ansys\")" ] }, { "cell_type": "markdown", "id": "970bdded", "metadata": {}, "source": [ "## Download project" ] }, { "cell_type": "code", "execution_count": null, "id": "c71cb632", "metadata": {}, "outputs": [], "source": [ "project_full_name = ansys.aedt.core.downloads.download_sbr(destination=temp_folder.name)" ] }, { "cell_type": "markdown", "id": "cf7223cf", "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": "21a6c21c", "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": "ea2a430e", "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": "d424d657", "metadata": {}, "outputs": [], "source": [ "target.create_sbr_linked_antenna(\n", " source, target_cs=\"feederPosition\", field_type=\"farfield\"\n", ")" ] }, { "cell_type": "markdown", "id": "d13099f6", "metadata": {}, "source": [ "## Assign boundaries\n", "\n", "Assign boundaries." ] }, { "cell_type": "code", "execution_count": null, "id": "c14c73f8", "metadata": {}, "outputs": [], "source": [ "target.assign_perfecte_to_sheets([\"Reflector\", \"Subreflector\"])\n", "target.mesh.assign_curvilinear_elements([\"Reflector\", \"Subreflector\"])" ] }, { "cell_type": "markdown", "id": "9736a1bc", "metadata": {}, "source": [ "## Create setup and solve\n", "\n", "Create a setup and solve it." ] }, { "cell_type": "code", "execution_count": null, "id": "ddfb7a63", "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": "03ba2481", "metadata": {}, "source": [ "## Postprocess\n", "\n", "Plot results in AEDT." ] }, { "cell_type": "code", "execution_count": null, "id": "871f00e0", "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": "a54bae94", "metadata": {}, "source": [ "Plot results using Matplotlib." ] }, { "cell_type": "code", "execution_count": null, "id": "5ae74d83", "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": "c67ce39e", "metadata": {}, "source": [ "## Release AEDT\n", "\n", "Release AEDT and close the example." ] }, { "cell_type": "code", "execution_count": null, "id": "cc7b57ac", "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": "b658b84e", "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": "d7751961", "metadata": {}, "outputs": [], "source": [ "temp_folder.cleanup()" ] } ], "metadata": { "jupytext": { "cell_metadata_filter": "-all", "main_language": "python", "notebook_metadata_filter": "-all" } }, "nbformat": 4, "nbformat_minor": 5 }