{ "cells": [ { "cell_type": "markdown", "id": "09485832", "metadata": {}, "source": [ "# Doppler setup\n", "\n", "This example shows how to use PyAEDT to create a multipart scenario in HFSS SBR+\n", "and set up a doppler analysis.\n", "\n", "Keywords: **HFSS**, **SBR+**, **doppler**." ] }, { "cell_type": "markdown", "id": "be1c01ed", "metadata": {}, "source": [ "## Perform imports and define constants\n", "\n", "Perform required imports." ] }, { "cell_type": "code", "execution_count": null, "id": "d37dd419", "metadata": {}, "outputs": [], "source": [ "import os\n", "import tempfile\n", "import time" ] }, { "cell_type": "code", "execution_count": null, "id": "087374d8", "metadata": {}, "outputs": [], "source": [ "import ansys.aedt.core" ] }, { "cell_type": "markdown", "id": "63f017d2", "metadata": {}, "source": [ "Define constants." ] }, { "cell_type": "code", "execution_count": null, "id": "bf6272c9", "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": "c8d6f116", "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": "272fa0f3", "metadata": {}, "outputs": [], "source": [ "temp_folder = tempfile.TemporaryDirectory(suffix=\".ansys\")" ] }, { "cell_type": "markdown", "id": "39cfec48", "metadata": {}, "source": [ "## Download 3D component\n", "Download the 3D component that is needed to run the example." ] }, { "cell_type": "code", "execution_count": null, "id": "19c692ad", "metadata": {}, "outputs": [], "source": [ "library_path = ansys.aedt.core.downloads.download_multiparts(\n", " destination=temp_folder.name\n", ")" ] }, { "cell_type": "markdown", "id": "3600fdfb", "metadata": {}, "source": [ "## Launch HFSS and open project\n", "\n", "Launch HFSS and open the project." ] }, { "cell_type": "code", "execution_count": null, "id": "28709433", "metadata": {}, "outputs": [], "source": [ "project_name = os.path.join(temp_folder.name, \"doppler.aedt\")\n", "app = ansys.aedt.core.Hfss(\n", " version=AEDT_VERSION,\n", " solution_type=\"SBR+\",\n", " new_desktop=True,\n", " project=project_name,\n", " close_on_exit=True,\n", " non_graphical=NG_MODE,\n", ")" ] }, { "cell_type": "markdown", "id": "7ec8f6d1", "metadata": {}, "source": [ "Creation of the \"actors\" in the scene is comprised of many editing steps. Disabling the autosave option helps\n", "avoid delays that occur while the project is being saved." ] }, { "cell_type": "code", "execution_count": null, "id": "c70d90c7", "metadata": {}, "outputs": [], "source": [ "app.autosave_disable()" ] }, { "cell_type": "markdown", "id": "85c9bfb2", "metadata": {}, "source": [ "## Save project and rename design\n", "\n", "Save the project to the temporary folder and rename the design." ] }, { "cell_type": "code", "execution_count": null, "id": "7e47bb6f", "metadata": {}, "outputs": [], "source": [ "design = \"doppler_sbr\"\n", "app.rename_design(design)\n", "app.save_project()" ] }, { "cell_type": "markdown", "id": "8f7789df", "metadata": {}, "source": [ "## Set up library paths\n", "\n", "Specify the location of 3D components used to create the scene." ] }, { "cell_type": "code", "execution_count": null, "id": "e54f5ba7", "metadata": {}, "outputs": [], "source": [ "actor_lib = os.path.join(library_path, \"actor_library\")\n", "env_lib = os.path.join(library_path, \"environment_library\")\n", "radar_lib = os.path.join(library_path, \"radar_modules\")\n", "env_folder = os.path.join(env_lib, \"road1\")\n", "person_folder = os.path.join(actor_lib, \"person3\")\n", "car_folder = os.path.join(actor_lib, \"vehicle1\")\n", "bike_folder = os.path.join(actor_lib, \"bike1\")\n", "bird_folder = os.path.join(actor_lib, \"bird1\")" ] }, { "cell_type": "markdown", "id": "abebc38a", "metadata": {}, "source": [ "## Define environment\n", "\n", "Define the background environment." ] }, { "cell_type": "code", "execution_count": null, "id": "61d8ec55", "metadata": {}, "outputs": [], "source": [ "road1 = app.modeler.add_environment(input_dir=env_folder, name=\"Bari\")\n", "prim = app.modeler" ] }, { "cell_type": "markdown", "id": "0eda935b", "metadata": {}, "source": [ "## Place actors\n", "\n", "Place actors in the environment. This code places persons, birds, bikes, and cars\n", "in the environment." ] }, { "cell_type": "code", "execution_count": null, "id": "33b3ae84", "metadata": {}, "outputs": [], "source": [ "person1 = app.modeler.add_person(\n", " input_dir=person_folder,\n", " speed=1.0,\n", " global_offset=[25, 1.5, 0],\n", " yaw=180,\n", " name=\"Massimo\",\n", ")\n", "person2 = app.modeler.add_person(\n", " input_dir=person_folder,\n", " speed=1.0,\n", " global_offset=[25, 2.5, 0],\n", " yaw=180,\n", " name=\"Devin\",\n", ")\n", "car1 = app.modeler.add_vehicle(\n", " input_dir=car_folder, speed=8.7, global_offset=[3, -2.5, 0], name=\"LuxuryCar\"\n", ")\n", "bike1 = app.modeler.add_vehicle(\n", " input_dir=bike_folder,\n", " speed=2.1,\n", " global_offset=[24, 3.6, 0],\n", " yaw=180,\n", " name=\"Alberto_in_bike\",\n", ")\n", "bird1 = app.modeler.add_bird(\n", " input_dir=bird_folder,\n", " speed=1.0,\n", " global_offset=[19, 4, 3],\n", " yaw=120,\n", " pitch=-5,\n", " flapping_rate=30,\n", " name=\"Pigeon\",\n", ")\n", "bird2 = app.modeler.add_bird(\n", " input_dir=bird_folder,\n", " speed=1.0,\n", " global_offset=[6, 2, 3],\n", " yaw=-60,\n", " pitch=10,\n", " name=\"Eagle\",\n", ")" ] }, { "cell_type": "markdown", "id": "68e8522b", "metadata": {}, "source": [ "## Place radar\n", "\n", "Place radar on the car. The radar is created relative to the car's coordinate\n", "system." ] }, { "cell_type": "code", "execution_count": null, "id": "d8f4884b", "metadata": {}, "outputs": [], "source": [ "radar1 = app.create_sbr_radar_from_json(\n", " radar_file=radar_lib,\n", " name=\"Example_1Tx_1Rx\",\n", " offset=[2.57, 0, 0.54],\n", " use_relative_cs=True,\n", " relative_cs_name=car1.cs_name,\n", ")" ] }, { "cell_type": "markdown", "id": "101b9a32", "metadata": {}, "source": [ "## Create setup\n", "\n", "Create setup and validate it. The ``create_sbr_pulse_doppler_setup()`` method\n", "creates a setup and a parametric sweep on the time variable with a\n", "duration of two seconds. The step is computed automatically from CPI." ] }, { "cell_type": "code", "execution_count": null, "id": "e73bcce4", "metadata": {}, "outputs": [], "source": [ "setup, sweep = app.create_sbr_pulse_doppler_setup(sweep_time_duration=2)\n", "app.set_sbr_current_sources_options()\n", "app.validate_simple()" ] }, { "cell_type": "markdown", "id": "add37417", "metadata": {}, "source": [ "## Solve and release AEDT\n", "\n", "Solve and release AEDT. To solve, uncomment the ``app.analyze_setup`` command\n", "to activate the simulation." ] }, { "cell_type": "code", "execution_count": null, "id": "36e5503c", "metadata": {}, "outputs": [], "source": [ "# app.analyze_setup(sweep.name)" ] }, { "cell_type": "markdown", "id": "1e9b2bfa", "metadata": {}, "source": [ "## Release AEDT\n", "\n", "Release AEDT and close the example." ] }, { "cell_type": "code", "execution_count": null, "id": "91693456", "metadata": {}, "outputs": [], "source": [ "app.save_project()\n", "app.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": "5c4bda70", "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": "c3a40553", "metadata": {}, "outputs": [], "source": [ "temp_folder.cleanup()" ] } ], "metadata": { "jupytext": { "cell_metadata_filter": "-all", "main_language": "python", "notebook_metadata_filter": "-all" } }, "nbformat": 4, "nbformat_minor": 5 }