{ "cells": [ { "cell_type": "markdown", "id": "05790cce", "metadata": { "papermill": { "duration": 0.001829, "end_time": "2026-05-27T20:02:11.242213+00:00", "exception": false, "start_time": "2026-05-27T20:02:11.240384+00:00", "status": "completed" }, "tags": [] }, "source": [ "### Step in depth antenna\n", "\n", "A step in width microstrip antenna is a design variation where the radiating patch element has a non-uniform width that changes along its length. Instead of a simple rectangular patch, the conducting strip gradually narrows or widens at specific points." ] }, { "cell_type": "code", "execution_count": 15, "id": "3588684c", "metadata": { "execution": { "iopub.execute_input": "2026-05-27T20:02:11.248885Z", "iopub.status.busy": "2026-05-27T20:02:11.248696Z", "iopub.status.idle": "2026-05-27T20:02:11.613372Z", "shell.execute_reply": "2026-05-27T20:02:11.612776Z" }, "papermill": { "duration": 0.367725, "end_time": "2026-05-27T20:02:11.614022+00:00", "exception": false, "start_time": "2026-05-27T20:02:11.246297+00:00", "status": "completed" }, "tags": [] }, "outputs": [], "source": [ "import gmsh\n", "import math\n", "import os\n", "from pathlib import Path\n", "\n", "from palacetoolkit.viz import view_mesh\n", "from palacetoolkit.mesh import (\n", " Entity,\n", " run_meshing_pipeline,\n", " generate_3d_mesh,\n", " refine_near_surfaces,\n", " )\n", "from palacetoolkit.simulation import Simulation, run_palace" ] }, { "cell_type": "markdown", "id": "35e745ba", "metadata": { "papermill": { "duration": 0.003934, "end_time": "2026-05-27T20:02:11.619605+00:00", "exception": false, "start_time": "2026-05-27T20:02:11.615671+00:00", "status": "completed" }, "tags": [] }, "source": [ "### Parameters:\n", "\n", "- l1 : Ground plane length along x-axis, specified as a scalar in meters\n", "- w1 : Ground plane width along y-axis, specified as a scalar in meters\n", "- h : Patch height along z-axis, specified as a scalar in meters.\n", "\n", "- strip_line_length : Notch length along x-axis, specified as a scalar in meters. \n", "- strip_lined_width_near_port: Notch width along x-axis near the port, specified as a scalar in meters. \n", "- strip_lined_width_far: Strip line width along y-axis far from the port, specified as a scalar in meters.\n", "- air_height : Air box height along z-axis, specified as a scalar in meters. \n", "- air_margin : Air box margin along x and y axes, specified as a scalar in meters.\n", "- freq : Simulation frequency in GHz, specified as a scalar.\n", "- filename : Output mesh filename, specified as a string." ] }, { "cell_type": "code", "execution_count": 16, "id": "31e252bf", "metadata": { "execution": { "iopub.execute_input": "2026-05-27T20:02:11.624185Z", "iopub.status.busy": "2026-05-27T20:02:11.623901Z", "iopub.status.idle": "2026-05-27T20:02:11.627548Z", "shell.execute_reply": "2026-05-27T20:02:11.626984Z" }, "papermill": { "duration": 0.007169, "end_time": "2026-05-27T20:02:11.628160+00:00", "exception": false, "start_time": "2026-05-27T20:02:11.620991+00:00", "status": "completed" }, "tags": [] }, "outputs": [], "source": [ "l1: float = 0.06\n", "w1: float = 0.06\n", "strip_line_length: float = 0.06\n", "strip_line_width_near_port: float = 0.001\n", "strip_line_width_far: float = 0.003\n", "h: float = 0.0013\n", "air_height: float = 0.025 \n", "air_margin: float = 0.025 \n", "freq: float = 3.3\n", "filename: str = \"sw_antenna.msh\"\n", "\n", "wavelength = 3e8 / (freq * 1e9)" ] }, { "cell_type": "markdown", "id": "9f0c809a", "metadata": { "papermill": { "duration": 0.001131, "end_time": "2026-05-27T20:02:11.630733+00:00", "exception": false, "start_time": "2026-05-27T20:02:11.629602+00:00", "status": "completed" }, "tags": [] }, "source": [ "### Initialize the model" ] }, { "cell_type": "code", "execution_count": 17, "id": "20a8fc36", "metadata": { "execution": { "iopub.execute_input": "2026-05-27T20:02:11.633711Z", "iopub.status.busy": "2026-05-27T20:02:11.633562Z", "iopub.status.idle": "2026-05-27T20:02:11.636757Z", "shell.execute_reply": "2026-05-27T20:02:11.636264Z" }, "papermill": { "duration": 0.005287, "end_time": "2026-05-27T20:02:11.637175+00:00", "exception": false, "start_time": "2026-05-27T20:02:11.631888+00:00", "status": "completed" }, "tags": [] }, "outputs": [ { "name": "stderr", "output_type": "stream", "text": [ "Warning : Gmsh has aleady been initialized\n" ] } ], "source": [ "gmsh.initialize()\n", "gmsh.model.add(\"patch_antenna\")\n", "kernel = gmsh.model.occ" ] }, { "cell_type": "markdown", "id": "e39ac1fa", "metadata": { "papermill": { "duration": 0.00122, "end_time": "2026-05-27T20:02:11.639655+00:00", "exception": false, "start_time": "2026-05-27T20:02:11.638435+00:00", "status": "completed" }, "tags": [] }, "source": [ "### Geometry generation\n" ] }, { "cell_type": "code", "execution_count": 18, "id": "f07ee82e", "metadata": { "execution": { "iopub.execute_input": "2026-05-27T20:02:11.642649Z", "iopub.status.busy": "2026-05-27T20:02:11.642525Z", "iopub.status.idle": "2026-05-27T20:02:11.649231Z", "shell.execute_reply": "2026-05-27T20:02:11.648753Z" }, "papermill": { "duration": 0.008787, "end_time": "2026-05-27T20:02:11.649618+00:00", "exception": false, "start_time": "2026-05-27T20:02:11.640831+00:00", "status": "completed" }, "tags": [] }, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "Info : Cannot bind existing OpenCASCADE surface 8 to second tag 9 \n", "Info : Could not preserve tag of 2D object 9 (->8)\n" ] } ], "source": [ "# Total domain bounds\n", "total_xmin = -l1/2 - air_margin\n", "total_xmax = l1/2 + air_margin\n", "total_ymin = -w1/2 - air_margin\n", "total_ymax = w1/2 + air_margin\n", "total_zmax = h + air_height\n", "\n", "substrate = kernel.addBox(-l1/2, -w1/2, 0, l1, w1, h)\n", "\n", "ground_plane = kernel.addRectangle(-l1/2, -w1/2, 0, l1, w1)\n", "\n", "strip_line_1 = kernel.addRectangle(-l1/2, -strip_line_width_near_port/2, h, strip_line_length/2, strip_line_width_near_port)\n", "strip_line_2 = kernel.addRectangle(0, -strip_line_width_far/2, h, strip_line_length/2, strip_line_width_far)\n", "\n", "top_conductor, _ = kernel.fuse(\n", " [(2, strip_line_1)], [(2, strip_line_2)],\n", " removeObject=True, removeTool=True\n", ")\n", "kernel.synchronize()\n", "\n", "gap = 0\n", "lumped_port = kernel.addRectangle(-l1/2 + gap, -strip_line_width_near_port/2, 0, h - gap, strip_line_width_near_port)\n", "kernel.rotate([(2, lumped_port)], -l1/2, 0, 0, 0, 1, 0, -math.pi/2)\n", "kernel.synchronize()\n", "\n", "# Replace box with an enclosing air sphere, following the patch_antenna pattern.\n", "airsphere_radius = max(abs(total_xmin), abs(total_xmax), abs(total_ymin), abs(total_ymax), total_zmax)\n", "air_sphere = kernel.addSphere(0.0, 0.0, 0.0, airsphere_radius)\n", "kernel.synchronize()" ] }, { "cell_type": "markdown", "id": "4103d2c6", "metadata": { "papermill": { "duration": 0.001258, "end_time": "2026-05-27T20:02:11.652369+00:00", "exception": false, "start_time": "2026-05-27T20:02:11.651111+00:00", "status": "completed" }, "tags": [] }, "source": [ "### Entities definition" ] }, { "cell_type": "code", "execution_count": 19, "id": "83500869", "metadata": { "execution": { "iopub.execute_input": "2026-05-27T20:02:11.655873Z", "iopub.status.busy": "2026-05-27T20:02:11.655634Z", "iopub.status.idle": "2026-05-27T20:02:17.038104Z", "shell.execute_reply": "2026-05-27T20:02:17.037446Z" }, "papermill": { "duration": 5.400233, "end_time": "2026-05-27T20:02:17.053888+00:00", "exception": false, "start_time": "2026-05-27T20:02:11.653655+00:00", "status": "completed" }, "tags": [] }, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ " Physical group 'air_sphere' (dim=3): pg=1, tags=[2] \n", " Physical group 'substrate' (dim=3): pg=2, tags=[1]\n", " Physical group 'top_conductor' (dim=2): pg=3, tags=[8]\n", " Physical group 'ground_plane' (dim=2): pg=4, tags=[7]\n", " Physical group 'lumped_port' (dim=2): pg=5, tags=[9]\n", " Physical group 'air_sphere__None' (dim=2): pg=6, tags=[17]\n", " Physical group 'air_sphere__substrate' (dim=2): pg=7, tags=[10, 11, 13, 15, 16, 14, 12]\n", " ppw_near=50 ppw_far=30\n", " SizeMax=0.0030 transition=0.0227\n", " global: 8 curves, SizeMin=0.0018\n", " local (2, 9): 4 curves, SizeMin=0.0006\n", " Merged 2 fields with Min → field 5\n", "[Entity('air_sphere', dim=3, order=2, tags=[2]), Entity('substrate', dim=3, order=1, tags=[1]), Entity('top_conductor', dim=2, order=1, tags=[8]), Entity('ground_plane', dim=2, order=1, tags=[7]), Entity('lumped_port', dim=2, order=0, tags=[9])]\n", "Loading mesh file: sw_antenna.msh\n", "Groups to render transparent: air_sphere__None\n", "\n", "Mesh loaded successfully with 2 cell blocks\n", "Found 14864 triangles total\n", "Physical group tags in mesh: {3: 'top_conductor', 4: 'ground_plane', 5: 'lumped_port', 6: 'air_sphere__None', 7: 'air_sphere__substrate'}\n" ] }, { "data": { "text/html": [ "
" ], "text/plain": [ "