{ "cells": [ { "cell_type": "markdown", "id": "25ea47fd", "metadata": { "papermill": { "duration": 0.003206, "end_time": "2026-05-26T01:20:24.202906+00:00", "exception": false, "start_time": "2026-05-26T01:20:24.199700+00:00", "status": "completed" }, "tags": [] }, "source": [ "### Open ended stub antenna\n", "\n", "An open-ended stub antenna is a simple radiating element consisting of a transmission line (typically microstrip or coaxial cable) with one end open-circuited, allowing electromagnetic energy to radiate directly into free space." ] }, { "cell_type": "code", "execution_count": 1, "id": "6cf089f3", "metadata": { "execution": { "iopub.execute_input": "2026-05-26T01:20:24.210464Z", "iopub.status.busy": "2026-05-26T01:20:24.210137Z", "iopub.status.idle": "2026-05-26T01:20:24.961351Z", "shell.execute_reply": "2026-05-26T01:20:24.959840Z" }, "papermill": { "duration": 0.756522, "end_time": "2026-05-26T01:20:24.962171+00:00", "exception": false, "start_time": "2026-05-26T01:20:24.205649+00:00", "status": "completed" }, "tags": [] }, "outputs": [], "source": [ "import gmsh\n", "import math\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" ] }, { "cell_type": "markdown", "id": "06f22ba1", "metadata": { "papermill": { "duration": 0.002568, "end_time": "2026-05-26T01:20:24.967316+00:00", "exception": false, "start_time": "2026-05-26T01:20:24.964748+00:00", "status": "completed" }, "tags": [] }, "source": [ "### Paramters\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: Notch width along y-axis, specified as a scalar in meters.\n", "- air_height : Air-domain height reference for sizing the enclosing sphere, specified as a scalar in meters.\n", "- air_margin : Air-domain margin along x and y axes used for sphere sizing, 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": 2, "id": "d854dab2", "metadata": { "execution": { "iopub.execute_input": "2026-05-26T01:20:24.973466Z", "iopub.status.busy": "2026-05-26T01:20:24.973022Z", "iopub.status.idle": "2026-05-26T01:20:24.978685Z", "shell.execute_reply": "2026-05-26T01:20:24.977171Z" }, "papermill": { "duration": 0.010682, "end_time": "2026-05-26T01:20:24.980033+00:00", "exception": false, "start_time": "2026-05-26T01:20:24.969351+00:00", "status": "completed" }, "tags": [] }, "outputs": [], "source": [ "l1: float = 0.06\n", "w1: float = 0.06\n", "strip_line_length: float = 0.04\n", "strip_line_width: float = 0.002\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 = \"open_ended_antenna.msh\"\n", "\n", "wavelength = 3e8 / (freq * 1e9)" ] }, { "cell_type": "markdown", "id": "20118c72", "metadata": { "papermill": { "duration": 0.003004, "end_time": "2026-05-26T01:20:24.986047+00:00", "exception": false, "start_time": "2026-05-26T01:20:24.983043+00:00", "status": "completed" }, "tags": [] }, "source": [ "### Model initialization" ] }, { "cell_type": "code", "execution_count": 3, "id": "12cc3554", "metadata": { "execution": { "iopub.execute_input": "2026-05-26T01:20:24.992496Z", "iopub.status.busy": "2026-05-26T01:20:24.992273Z", "iopub.status.idle": "2026-05-26T01:20:24.998432Z", "shell.execute_reply": "2026-05-26T01:20:24.996849Z" }, "papermill": { "duration": 0.010313, "end_time": "2026-05-26T01:20:24.999279+00:00", "exception": false, "start_time": "2026-05-26T01:20:24.988966+00:00", "status": "completed" }, "tags": [] }, "outputs": [], "source": [ "gmsh.initialize()\n", "gmsh.model.add(\"patch_antenna\")\n", "kernel = gmsh.model.occ" ] }, { "cell_type": "markdown", "id": "a4fbf049", "metadata": { "papermill": { "duration": 0.002183, "end_time": "2026-05-26T01:20:25.003612+00:00", "exception": false, "start_time": "2026-05-26T01:20:25.001429+00:00", "status": "completed" }, "tags": [] }, "source": [ "### Geometry construction" ] }, { "cell_type": "code", "execution_count": 4, "id": "f151f6b0", "metadata": { "execution": { "iopub.execute_input": "2026-05-26T01:20:25.008980Z", "iopub.status.busy": "2026-05-26T01:20:25.008710Z", "iopub.status.idle": "2026-05-26T01:20:25.016138Z", "shell.execute_reply": "2026-05-26T01:20:25.014923Z" }, "papermill": { "duration": 0.011502, "end_time": "2026-05-26T01:20:25.017138+00:00", "exception": false, "start_time": "2026-05-26T01:20:25.005636+00:00", "status": "completed" }, "tags": [] }, "outputs": [], "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 box\n", "substrate = kernel.addBox(-l1/2, -w1/2, 0, l1, w1, h)\n", "\n", "# Ground plane\n", "ground_plane = kernel.addRectangle(-l1/2, -w1/2, 0, l1, w1)\n", "\n", "# Top conductor\n", "strip_line_1 = kernel.addRectangle(-l1/2, -strip_line_width/2, h, strip_line_length, strip_line_width)\n", "\n", "# gap bewteen the ground plane and the bottom of the lumped port.\n", "gap = 0\n", "\n", "# lumped port\n", "lumped_port = kernel.addRectangle(-l1/2 + gap, -strip_line_width/2, 0, h - gap, strip_line_width)\n", "kernel.rotate([(2, lumped_port)], -l1/2, 0, 0, 0, 1, 0, -math.pi/2)\n", "\n", "# Air sphere\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", "\n", "# Synchronize everything!\n", "kernel.synchronize()" ] }, { "cell_type": "code", "execution_count": 5, "id": "e4112dbf", "metadata": { "execution": { "iopub.execute_input": "2026-05-26T01:20:25.022947Z", "iopub.status.busy": "2026-05-26T01:20:25.022737Z", "iopub.status.idle": "2026-05-26T01:20:31.877312Z", "shell.execute_reply": "2026-05-26T01:20:31.875843Z" }, "papermill": { "duration": 6.858597, "end_time": "2026-05-26T01:20:31.878229+00:00", "exception": false, "start_time": "2026-05-26T01:20:25.019632+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=[16]\n", " Physical group 'air_sphere__substrate' (dim=2): pg=7, tags=[10, 11, 13, 15, 14, 12]\n", " ppw_near=50 ppw_far=30\n", " SizeMax=0.0030 transition=0.0227\n", " global: 4 curves, SizeMin=0.0018\n", " local (2, 9): 4 curves, SizeMin=0.0006\n", " Merged 2 fields with Min → field 5\n", "Info : Meshing 1D...\n", "Info : [ 0%] Meshing curve 24 (Line)\n", "Info : [ 10%] Meshing curve 25 (Line)\n", "Info : [ 10%] Meshing curve 26 (Line)\n", "Info : [ 20%] Meshing curve 27 (Line)\n", "Info : [ 20%] Meshing curve 28 (Line)\n", "Info : [ 30%] Meshing curve 29 (Line)\n", "Info : [ 30%] Meshing curve 30 (Line)\n", "Info : [ 30%] Meshing curve 31 (Line)\n", "Info : [ 40%] Meshing curve 32 (Line)\n", "Info : [ 40%] Meshing curve 33 (Line)\n", "Info : [ 50%] Meshing curve 34 (Line)\n", "Info : [ 50%] Meshing curve 35 (Line)\n", "Info : [ 60%] Meshing curve 36 (Line)\n", "Info : [ 60%] Meshing curve 37 (Line)\n", "Info : [ 60%] Meshing curve 38 (Line)\n", "Info : [ 70%] Meshing curve 39 (Line)\n", "Info : [ 70%] Meshing curve 40 (Line)\n", "Info : [ 80%] Meshing curve 41 (Line)\n", "Info : [ 80%] Meshing curve 42 (Line)\n", "Info : [ 80%] Meshing curve 43 (Line)\n", "Info : [ 90%] Meshing curve 45 (Circle)\n", "Info : [100%] Meshing curve 47 (Line)\n", "Info : Done meshing 1D (Wall 0.0227882s, CPU 0.023435s)\n", "Info : Meshing 2D...\n", "Info : [ 0%] Meshing surface 7 (Plane, MeshAdapt)\n", "Info : [ 20%] Meshing surface 8 (Plane, MeshAdapt)\n", "Info : [ 30%] Meshing surface 9 (Plane, MeshAdapt)\n", "Info : [ 40%] Meshing surface 10 (Plane, MeshAdapt)\n", "Info : [ 50%] Meshing surface 11 (Plane, MeshAdapt)\n", "Info : [ 60%] Meshing surface 12 (Plane, MeshAdapt)\n", "Info : [ 70%] Meshing surface 13 (Plane, MeshAdapt)\n", "Info : [ 80%] Meshing surface 14 (Plane, MeshAdapt)\n", "Info : [ 90%] Meshing surface 15 (Plane, MeshAdapt)\n", "Info : [100%] Meshing surface 16 (Sphere, MeshAdapt)\n", "Info : Done meshing 2D (Wall 2.3741s, CPU 2.35231s)\n", "Info : Meshing 3D...\n", "Info : 3D Meshing 2 volumes with 1 connected component\n", "Info : Tetrahedrizing 7351 nodes...\n", "Info : Done tetrahedrizing 7359 nodes (Wall 0.0740404s, CPU 0.069042s)\n", "Info : Reconstructing mesh...\n", "Info : - Creating surface mesh\n", "Info : - Identifying boundary edges\n", "Info : - Recovering boundary\n", "Info : Done reconstructing mesh (Wall 0.215381s, CPU 0.197498s)\n", "Info : Found volume 2\n", "Info : Found volume 1\n", "Info : It. 0 - 0 nodes created - worst tet radius 15.8281 (nodes removed 0 0)\n", "Info : It. 500 - 500 nodes created - worst tet radius 3.01409 (nodes removed 0 0)\n", "Info : It. 1000 - 1000 nodes created - worst tet radius 2.48289 (nodes removed 0 0)\n", "Info : It. 1500 - 1500 nodes created - worst tet radius 2.19831 (nodes removed 0 0)\n", "Info : It. 2000 - 2000 nodes created - worst tet radius 2.01023 (nodes removed 0 0)\n", "Info : It. 2500 - 2500 nodes created - worst tet radius 1.87804 (nodes removed 0 0)\n", "Info : It. 3000 - 3000 nodes created - worst tet radius 1.77311 (nodes removed 0 0)\n", "Info : It. 3500 - 3500 nodes created - worst tet radius 1.6934 (nodes removed 0 0)\n", "Info : It. 4000 - 4000 nodes created - worst tet radius 1.62406 (nodes removed 0 0)\n", "Info : It. 4500 - 4500 nodes created - worst tet radius 1.56586 (nodes removed 0 0)\n", "Info : It. 5000 - 5000 nodes created - worst tet radius 1.51457 (nodes removed 0 0)\n", "Info : It. 5500 - 5500 nodes created - worst tet radius 1.4705 (nodes removed 0 0)\n", "Info : It. 6000 - 6000 nodes created - worst tet radius 1.43014 (nodes removed 0 0)\n", "Info : It. 6500 - 6500 nodes created - worst tet radius 1.39468 (nodes removed 0 0)\n", "Info : It. 7000 - 7000 nodes created - worst tet radius 1.36281 (nodes removed 0 0)\n", "Info : It. 7500 - 7500 nodes created - worst tet radius 1.33488 (nodes removed 0 0)\n", "Info : It. 8000 - 8000 nodes created - worst tet radius 1.30946 (nodes removed 0 0)\n", "Info : It. 8500 - 8500 nodes created - worst tet radius 1.28468 (nodes removed 0 0)\n", "Info : It. 9000 - 9000 nodes created - worst tet radius 1.26165 (nodes removed 0 0)\n", "Info : It. 9500 - 9500 nodes created - worst tet radius 1.24006 (nodes removed 0 0)\n", "Info : It. 10000 - 10000 nodes created - worst tet radius 1.21952 (nodes removed 0 0)\n", "Info : It. 10500 - 10500 nodes created - worst tet radius 1.20277 (nodes removed 0 0)\n", "Info : It. 11000 - 11000 nodes created - worst tet radius 1.18561 (nodes removed 0 0)\n", "Info : It. 11500 - 11500 nodes created - worst tet radius 1.16931 (nodes removed 0 0)\n", "Info : It. 12000 - 12000 nodes created - worst tet radius 1.15293 (nodes removed 0 0)\n", "Info : It. 12500 - 12500 nodes created - worst tet radius 1.13751 (nodes removed 0 0)\n", "Info : It. 13000 - 13000 nodes created - worst tet radius 1.12296 (nodes removed 0 0)\n", "Info : It. 13500 - 13500 nodes created - worst tet radius 1.1098 (nodes removed 0 0)\n", "Info : It. 14000 - 14000 nodes created - worst tet radius 1.09709 (nodes removed 0 0)\n", "Info : It. 14500 - 14500 nodes created - worst tet radius 1.08546 (nodes removed 0 0)\n", "Info : It. 15000 - 15000 nodes created - worst tet radius 1.07404 (nodes removed 0 0)\n", "Info : It. 15500 - 15500 nodes created - worst tet radius 1.0625 (nodes removed 0 0)\n", "Info : It. 16000 - 16000 nodes created - worst tet radius 1.05158 (nodes removed 0 0)\n", "Info : It. 16500 - 16500 nodes created - worst tet radius 1.04114 (nodes removed 0 0)\n", "Info : It. 17000 - 17000 nodes created - worst tet radius 1.03064 (nodes removed 0 0)\n", "Info : It. 17500 - 17500 nodes created - worst tet radius 1.02124 (nodes removed 0 0)\n", "Info : It. 18000 - 18000 nodes created - worst tet radius 1.01253 (nodes removed 0 0)\n", "Info : It. 18500 - 18500 nodes created - worst tet radius 1.0038 (nodes removed 0 0)\n", "Info : 3D refinement terminated (26079 nodes total):\n", "Info : - 1 Delaunay cavities modified for star shapeness\n", "Info : - 0 nodes could not be inserted\n", "Info : - 147911 tetrahedra created in 1.26757 sec. (116688 tets/s)\n", "Info : 0 node relocations\n", "Info : Done meshing 3D (Wall 1.88412s, CPU 1.86293s)\n", "Info : Optimizing mesh...\n", "Info : Optimizing volume 1\n", "Info : Optimization starts (volume = 4.68e-06) with worst = 0.043499 / average = 0.765452:\n", "Info : 0.00 < quality < 0.10 : 11 elements\n", "Info : 0.10 < quality < 0.20 : 42 elements\n", "Info : 0.20 < quality < 0.30 : 58 elements\n", "Info : 0.30 < quality < 0.40 : 76 elements\n", "Info : 0.40 < quality < 0.50 : 113 elements\n", "Info : 0.50 < quality < 0.60 : 224 elements\n", "Info : 0.60 < quality < 0.70 : 797 elements\n", "Info : 0.70 < quality < 0.80 : 1513 elements\n", "Info : 0.80 < quality < 0.90 : 1954 elements\n", "Info : 0.90 < quality < 1.00 : 686 elements\n", "Info : 109 edge swaps, 0 node relocations (volume = 4.68e-06): worst = 0.170489 / average = 0.776728 (Wall 0.00127495s, CPU 0.001333s)\n", "Info : 111 edge swaps, 0 node relocations (volume = 4.68e-06): worst = 0.170489 / average = 0.776554 (Wall 0.00161795s, CPU 0.001698s)\n", "Info : No ill-shaped tets in the mesh :-)\n", "Info : 0.00 < quality < 0.10 : 0 elements\n", "Info : 0.10 < quality < 0.20 : 1 elements\n", "Info : 0.20 < quality < 0.30 : 1 elements\n", "Info : 0.30 < quality < 0.40 : 78 elements\n", "Info : 0.40 < quality < 0.50 : 110 elements\n", "Info : 0.50 < quality < 0.60 : 215 elements\n", "Info : 0.60 < quality < 0.70 : 809 elements\n", "Info : 0.70 < quality < 0.80 : 1521 elements\n", "Info : 0.80 < quality < 0.90 : 1956 elements\n", "Info : 0.90 < quality < 1.00 : 684 elements\n", "Info : Optimizing volume 2\n", "Info : Optimization starts (volume = 0.000691485) with worst = 0.00995949 / average = 0.774371:\n", "Info : 0.00 < quality < 0.10 : 299 elements\n", "Info : 0.10 < quality < 0.20 : 929 elements\n", "Info : 0.20 < quality < 0.30 : 1647 elements\n", "Info : 0.30 < quality < 0.40 : 2640 elements\n", "Info : 0.40 < quality < 0.50 : 4182 elements\n", "Info : 0.50 < quality < 0.60 : 7314 elements\n", "Info : 0.60 < quality < 0.70 : 15270 elements\n", "Info : 0.70 < quality < 0.80 : 32557 elements\n", "Info : 0.80 < quality < 0.90 : 51512 elements\n", "Info : 0.90 < quality < 1.00 : 26087 elements\n", "Info : 2833 edge swaps, 108 node relocations (volume = 0.000691485): worst = 0.146052 / average = 0.786592 (Wall 0.0896043s, CPU 0.090486s)\n", "Info : 2850 edge swaps, 110 node relocations (volume = 0.000691485): worst = 0.249473 / average = 0.786642 (Wall 0.117308s, CPU 0.118229s)\n", "Info : No ill-shaped tets in the mesh :-)\n", "Info : 0.00 < quality < 0.10 : 0 elements\n", "Info : 0.10 < quality < 0.20 : 0 elements\n", "Info : 0.20 < quality < 0.30 : 7 elements\n", "Info : 0.30 < quality < 0.40 : 2648 elements\n", "Info : 0.40 < quality < 0.50 : 4039 elements\n", "Info : 0.50 < quality < 0.60 : 7230 elements\n", "Info : 0.60 < quality < 0.70 : 15182 elements\n", "Info : 0.70 < quality < 0.80 : 32926 elements\n", "Info : 0.80 < quality < 0.90 : 51938 elements\n", "Info : 0.90 < quality < 1.00 : 25960 elements\n", "Info : Done optimizing mesh (Wall 0.34924s, CPU 0.326631s)\n", "Info : 26079 nodes 160343 elements\n", "Info : Optimizing mesh (Netgen)...\n", "Info : Optimizing volume 1\n", "Info : CalcLocalH: 1847 Points 5377 Elements 3682 Surface Elements \n", "Info : Remove Illegal Elements \n", "Info : 399 illegal tets \n", "Info : SplitImprove \n", "Info : badmax = 79.1788 \n", "Info : 55 splits performed \n", "Info : SwapImprove \n", "Info : 66 swaps performed \n", "Info : SwapImprove2 \n", "Info : 1 swaps performed \n", "Info : 311 illegal tets \n", "Info : SplitImprove \n", "Info : badmax = 30.1979 \n", "Info : 60 splits performed \n", "Info : SwapImprove \n", "Info : 32 swaps performed \n", "Info : SwapImprove2 \n", "Info : 6 swaps performed \n", "Info : 167 illegal tets \n", "Info : SplitImprove \n", "Info : badmax = 1829.43 \n", "Info : 44 splits performed \n", "Info : SwapImprove \n", "Info : 9 swaps performed \n", "Info : SwapImprove2 \n", "Info : 3 swaps performed \n", "Info : 57 illegal tets \n", "Info : SplitImprove \n", "Info : badmax = 3076.72 \n", "Info : 17 splits performed \n", "Info : SwapImprove \n", "Info : 3 swaps performed \n", "Info : SwapImprove2 \n", "Info : 0 swaps performed \n", "Info : 16 illegal tets \n", "Info : SplitImprove \n", "Info : badmax = 952.702 \n", "Info : 3 splits performed \n", "Info : SwapImprove \n", "Info : 0 swaps performed \n", "Info : SwapImprove2 \n", "Info : 0 swaps performed \n", "Info : 10 illegal tets \n", "Info : SplitImprove \n", "Info : badmax = 952.702 \n", "Info : 2 splits performed \n", "Info : SwapImprove \n", "Info : 0 swaps performed \n", "Info : SwapImprove2 \n", "Info : 0 swaps performed \n", "Info : 7 illegal tets \n", "Info : SplitImprove \n", "Info : badmax = 952.702 \n", "Info : 2 splits performed \n", "Info : SwapImprove \n", "Info : 1 swaps performed \n", "Info : SwapImprove2 \n", "Info : 0 swaps performed \n", "Info : 0 illegal tets \n", "Info : Volume Optimization \n", "Info : CombineImprove \n", "Info : 48 elements combined \n", "Info : ImproveMesh \n", "Info : Total badness = 9677.41 \n", "Info : Total badness = 9485.14 \n", "Info : SplitImprove \n", "Info : badmax = 36.321 \n", "Info : 1 splits performed \n", "Info : ImproveMesh \n", "Info : Total badness = 9490.21 \n", "Info : Total badness = 9477.09 \n", "Info : SwapImprove \n", "Info : 278 swaps performed \n", "Info : SwapImprove2 \n", "Info : 0 swaps performed \n", "Info : ImproveMesh \n", "Info : Total badness = 8983.19 \n", "Info : Total badness = 8900.51 \n", "Info : CombineImprove \n", "Info : 6 elements combined \n", "Info : ImproveMesh \n", "Info : Total badness = 8843.31 \n", "Info : Total badness = 8838.64 \n", "Info : SplitImprove \n", "Info : badmax = 13.2784 \n", "Info : 0 splits performed \n", "Info : ImproveMesh \n", "Info : Total badness = 8838.64 \n", "Info : Total badness = 8838.36 \n", "Info : SwapImprove \n", "Info : 40 swaps performed \n", "Info : SwapImprove2 \n", "Info : 0 swaps performed \n", "Info : ImproveMesh \n", "Info : Total badness = 8768.92 \n", "Info : Total badness = 8747.16 \n", "Info : CombineImprove \n", "Info : 3 elements combined \n", "Info : ImproveMesh \n", "Info : Total badness = 8723.24 \n", "Info : Total badness = 8721.58 \n", "Info : SplitImprove \n", "Info : badmax = 13.2756 \n", "Info : 0 splits performed \n", "Info : ImproveMesh \n", "Info : Total badness = 8721.58 \n", "Info : Total badness = 8721.53 \n", "Info : SwapImprove \n", "Info : 20 swaps performed \n", "Info : SwapImprove2 \n", "Info : 0 swaps performed \n", "Info : ImproveMesh \n", "Info : Total badness = 8699.54 \n", "Info : Total badness = 8688.24 \n", "Info : Optimizing volume 2\n", "Info : CalcLocalH: 26075 Points 139930 Elements 14694 Surface Elements \n", "Info : Remove Illegal Elements \n", "Info : 0 illegal tets \n", "Info : Volume Optimization \n", "Info : CombineImprove \n", "Info : 1265 elements combined \n", "Info : ImproveMesh \n", "Info : Total badness = 181848 \n", "Info : Total badness = 173241 \n", "Info : SplitImprove \n", "Info : badmax = 14.1834 \n", "Info : 0 splits performed \n", "Info : ImproveMesh \n", "Info : Total badness = 173241 \n", "Info : Total badness = 171897 \n", "Info : SwapImprove \n", "Info : 7804 swaps performed \n", "Info : SwapImprove2 \n", "Info : 0 swaps performed \n", "Info : ImproveMesh \n", "Info : Total badness = 158135 \n", "Info : Total badness = 154358 \n", "Info : CombineImprove \n", "Info : 287 elements combined \n", "Info : ImproveMesh \n", "Info : Total badness = 151838 \n", "Info : Total badness = 151261 \n", "Info : SplitImprove \n", "Info : badmax = 8.91933 \n", "Info : 0 splits performed \n", "Info : ImproveMesh \n", "Info : Total badness = 151261 \n", "Info : Total badness = 151150 \n", "Info : SwapImprove \n", "Info : 952 swaps performed \n", "Info : SwapImprove2 \n", "Info : 0 swaps performed \n", "Info : ImproveMesh \n", "Info : Total badness = 150467 \n", "Info : Total badness = 149885 \n", "Info : CombineImprove \n", "Info : 56 elements combined \n", "Info : ImproveMesh \n", "Info : Total badness = 149406 \n", "Info : Total badness = 149297 \n", "Info : SplitImprove \n", "Info : badmax = 7.26293 \n", "Info : 0 splits performed \n", "Info : ImproveMesh \n", "Info : Total badness = 149297 \n", "Info : Total badness = 149269 \n", "Info : SwapImprove \n", "Info : 268 swaps performed \n", "Info : SwapImprove2 \n", "Info : 0 swaps performed \n", "Info : ImproveMesh \n", "Info : Total badness = 149165 \n", "Info : Total badness = 148999 \n", "Info : Done optimizing mesh (Wall 7.31954s, CPU 7.3046s)\n", "Info : Writing 'open_ended_antenna.msh'...\n", "Mesh saved to open_ended_antenna.mshInfo : Done writing 'open_ended_antenna.msh'\n", "\n", " Nodes: 24598\n", " Elements: 144515\n" ] } ], "source": [ "# Define the entities which later will become the physical groups.\n", "entities = [\n", " Entity(\"air_sphere\", dim=3, btype=\"dielectric\", mesh_order=2, tags=[air_sphere], eps_r=1.0, mu_r=1.0, loss_tan=0.0),\n", " Entity(\"substrate\", dim=3, btype=\"dielectric\", mesh_order=1, tags=[substrate], eps_r=2.2, mu_r=1.0, loss_tan=0.0009),\n", " Entity(\"top_conductor\", dim=2, btype=\"pec\", mesh_order=1, tags=[strip_line_1]),\n", " Entity(\"ground_plane\", dim=2, btype=\"pec\", mesh_order=1, tags=[ground_plane]),\n", " Entity(\"lumped_port\", dim=2, btype=\"lumped_port\", mesh_order=0, tags=[lumped_port], R=50.0, direction=\"+Z\")\n", "]\n", "\n", "# Boolean operations to guarantee a nice mesh, algo it returns the\n", "# physical group map.\n", "pg_map = run_meshing_pipeline(entities)\n", "\n", "# Refine near the top conductor and locally the lumped port\n", "refine_near_surfaces(entities[2].dimtags, \n", " wavelength, \n", " ppw_near=50, \n", " ppw_far=30, \n", " set_as_background=True,\n", " local_refinements = {entities[-1].dimtags[0]: 150})\n", "# Mesh sizes\n", "mesh_sizes = {\n", " \"substrate\": wavelength / 12,\n", " \"air_sphere\": wavelength / 4,\n", " \"lumped_port\": wavelength / 150,\n", " \"ground_plane\" : wavelength / 10,\n", " \"top_conductor\": wavelength / 50\n", "}\n", "\n", "# Generate the 3d mesh.\n", "generate_3d_mesh(entities, mesh_sizes, filename, optimize = True)" ] }, { "cell_type": "markdown", "id": "8db52b35", "metadata": { "papermill": { "duration": 0.003364, "end_time": "2026-05-26T01:20:31.885505+00:00", "exception": false, "start_time": "2026-05-26T01:20:31.882141+00:00", "status": "completed" }, "tags": [] }, "source": [ "### Mesh visualization." ] }, { "cell_type": "code", "execution_count": 6, "id": "89d4552b", "metadata": { "execution": { "iopub.execute_input": "2026-05-26T01:20:31.894138Z", "iopub.status.busy": "2026-05-26T01:20:31.893880Z", "iopub.status.idle": "2026-05-26T01:20:33.191724Z", "shell.execute_reply": "2026-05-26T01:20:33.190436Z" }, "papermill": { "duration": 1.303727, "end_time": "2026-05-26T01:20:33.192478+00:00", "exception": false, "start_time": "2026-05-26T01:20:31.888751+00:00", "status": "completed" }, "tags": [] }, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "Loading mesh file: open_ended_antenna.msh\n", "Groups to render transparent: air_sphere__None\n", "\n", "Mesh loaded successfully with 2 cell blocks\n", "Found 14694 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": [ "