Ports: feeding an antenna#

Draft Every code block below is run, unchanged, by documentation/figure_notebooks/theory_ports.ipynb (solver commit 72fb8c6); the outputs shown are its outputs. Awaiting review.

A port says where and how the antenna is fed; the voltages say how much. This page shows how to define ports, which model to choose, and how to move code written for the former feed arguments. The formulas behind the three models are on Ports.

The three models at a glance#

Model

What it feeds

Use it for

Avoid it when

EnhancedGap

a uniform field across a gap of width gap_width, in a cube around feed_point, along 'x', 'y' or 'z' (Ding et al. 2013)

the default: a feed of finite width, robust to how the mesh cuts the gap

the conductor is wider than gap_width (GapSourceWarning), or the feed direction is oblique

DeltaGapCut

a zero-width gap across every RWG edge of a cut from p_start to p_end

a conductor several cells wide whose cut is a line of mesh vertices; the reduced multiport model

the cut is not a line of the mesh (the solver refuses it)

DeltaGapEdge

a zero-width gap on the one edge nearest to point across direction

a strip one cell wide (where it equals DeltaGapCut); the place of a lumped load

the conductor is several cells wide: the rest of the cut shorts the source

Defining a port and solving#

The examples run on the dipole of First simulation (0.47 m × 10 mm along \(y\), 300 MHz, the 50 mm gap drawn as its own surface), whose mesh, path, frequency, width and gap_width are defined on that page.

import numpy as np
from harmolab.utils.ports import EnhancedGap

ports = [EnhancedGap("feed", feed_point=(0.0, 0.0, 0.0), axis="y", gap_width=gap_width)]
result = radiation_algorithm(path, frequency, ports, voltages=[1.0], show=False)

feed = result.port("feed")
print(f"Z_in = {feed.impedance:.2f} Ohm, i = {feed.current * 1e3:.3f} mA, P = {feed.power * 1e3:.3f} mW")
Number of points: 89
Number of triangles: 116
Number of edges: 144
[calculate_z_matrice] Using GPU (NVIDIA T600 Laptop GPU, CuPy 14.1.1) for the impedance matrix assembly (144x144 edges).
Total input power P_in = 0.5*Re(V·I*) = 6.852393e-03 W
Port 'feed': P_in = 6.8524e-03 W  |  Q_in = 3.8490e-04 VAR  |  Z_in = 72.7377+4.0857j Ohm
Z_in = 72.74+4.09j Ohm, i = 13.705-0.770j mA, P = 6.852 mW
  • ports is a list; every port has a name, unique in the list.

  • voltages holds one complex voltage per port, in the order of ports: amplitude in volts (peak), phase in radians, amplitude * np.exp(1j * phase).

  • result is a RadiationResult: frequency, z_matrix, voltage (\(V\)), current (\(I\)), surface_current_density, and ports, one PortResult per port with voltage, current (the current across the port), impedance, power and reactive_power. result.port(name) finds one by name.

  • A port is placed on the mesh after the RWG data are built and before the impedance matrix is assembled, so a port that finds no edge fails at once (last example below).

The three models on the same mesh#

from harmolab.utils.ports import DeltaGapCut, DeltaGapEdge

y_cut = -gap_width / 2                     # an edge of the gap surface: a line of the mesh across the strip
models = {
    "EnhancedGap": EnhancedGap("feed", feed_point=(0.0, 0.0, 0.0), axis="y", gap_width=gap_width),
    "DeltaGapCut": DeltaGapCut("feed", p_start=(-width / 2, y_cut, 0.0), p_end=(width / 2, y_cut, 0.0),
                               direction=(0.0, 1.0, 0.0)),
    "DeltaGapEdge": DeltaGapEdge("feed", point=(0.0, y_cut, 0.0), direction=(0.0, 1.0, 0.0)),
}
for name, spec in models.items():
    with contextlib.redirect_stdout(io.StringIO()):                  # silence the solver's printouts
        r = radiation_algorithm(path, frequency, [spec], voltages=[1.0], show=False)
    print(f"{name:12s} Z_in = {r.ports[0].impedance:.2f} Ohm")
EnhancedGap  Z_in = 72.74+4.09j Ohm
DeltaGapCut  Z_in = 74.11+0.84j Ohm
DeltaGapEdge Z_in = 74.11+0.84j Ohm

(The redirect_stdout line only silences the solver’s printouts; it needs import contextlib, io.) The delta gaps are placed on a line of the mesh, here the lower edge of the gap surface. The strip is one element wide, so the cut is a single edge and the two delta gaps are the same port. They give a lower reactance than the 50 mm enhanced gap: a delta gap has no width.

Several ports#

ports = [EnhancedGap("lower", feed_point=(0.0, -0.1, 0.0), axis="y", gap_width=0.02),
         EnhancedGap("upper", feed_point=(0.0, 0.1, 0.0), axis="y", gap_width=0.02)]
voltages = [1.0, 1.0 * np.exp(1j * np.pi / 2)]           # one complex voltage per port, phase in radians
result = radiation_algorithm(path, frequency, ports, voltages, show=False)
for p in result.ports:
    print(f"{p.name}: v = {p.voltage:.2f} V, Z_in = {p.impedance:.2f} Ohm, P = {p.power * 1e3:.3f} mW")
Number of points: 89
Number of triangles: 116
Number of edges: 144
[calculate_z_matrice] Using GPU (NVIDIA T600 Laptop GPU, CuPy 14.1.1) for the impedance matrix assembly (144x144 edges).
Total input power P_in = 0.5*Re(V·I*) = 9.088517e-03 W
Port 'lower': P_in = 5.4608e-03 W  |  Q_in = -4.7177e-03 VAR  |  Z_in = 52.4299-45.2953j Ohm
Port 'upper': P_in = 3.6277e-03 W  |  Q_in = 4.3601e-03 VAR  |  Z_in = 56.3825+67.7651j Ohm
lower: v = 1.00+0.00j V, Z_in = 52.43-45.30j Ohm, P = 5.461 mW
upper: v = 0.00+1.00j V, Z_in = 56.38+67.77j Ohm, P = 3.628 mW

With several ports driven together, each \(Z_\mathrm{in}\) is an active impedance: it depends on the voltages of the other ports. The port powers add up to the total input power (5.461 + 3.628 = 9.089 mW). The ports may mix models; they must not share an edge.

Frequency sweeps#

frequency_sweep takes the same ports and voltages:

ports = [EnhancedGap("feed", feed_point=(0.0, 0.0, 0.0), axis="y", gap_width=gap_width)]
frequency_sweep(path, 250e6, 350e6, ports, voltages=[1.0], n_points=5)
frequencies, impedances, s11_db, *_ = load_freq_sweep_data(path.mat_freq_sweep)
for f, z, s in zip(frequencies, np.atleast_1d(impedances), np.atleast_1d(s11_db)):
    print(f"{f / 1e6:5.0f} MHz: Z_in = {z:.2f} Ohm, S11 = {s:.2f} dB")
  250 MHz: Z_in = 44.25-127.77j Ohm, S11 = -1.88 dB
  275 MHz: Z_in = 56.98-59.93j Ohm, S11 = -6.16 dB
  300 MHz: Z_in = 72.74+4.09j Ohm, S11 = -14.51 dB
  325 MHz: Z_in = 92.37+65.92j Ohm, S11 = -6.03 dB
  350 MHz: Z_in = 117.04+126.84j Ohm, S11 = -3.30 dB

(It also prints its configuration and progress, not shown; it needs from harmolab.utils.frequency_sweep import frequency_sweep, load_freq_sweep_data.) The value at 300 MHz is the one of radiation_algorithm. The saved file has a port_names key in the order of the ports (Data and files).

When a port is wrong#

from harmolab.utils.ports import PortDefinitionError

try:   # feed point 50 mm beside the 10 mm strip
    radiation_algorithm(path, frequency, [EnhancedGap("feed", feed_point=(0.05, 0.0, 0.0), axis="y",
                                                       gap_width=0.02)], voltages=[1.0], show=False)
except PortDefinitionError as exc:
    print(type(exc).__name__, ":", str(exc)[:160], "...")
Number of points: 89
Number of triangles: 116
Number of edges: 144
GapSourceError : Port 'feed' (feed_point=[0.05 0.   0.  ], axis='y', gap_width=0.02): no RWG edge found within the gap. Check that feed_point lies on (or very near) the mesh, th ...

The mesh is read, the port finds no edge, and the impedance matrix is never assembled. Every port error is a PortDefinitionError (GapSourceError is one); the typical mistakes and their messages are listed on Ports.

Choosing a model#

The three models were compared on the half-wave strip dipole (300 MHz, 0.47 m × 10 mm, 2 cells across, structured mesh), with the cells along the strip refined from λ/10 to λ/160.

Three panels against cells per wavelength. (a) Resistance: DeltaGapCut and EnhancedGap rise together from about 70.5 to 73 ohms. (b) Reactance: both rise, the enhanced gap about 1.5 to 2 ohms above the delta-gap cut. (c) DeltaGapEdge: resistance falls from 21 to 0.2 ohms and reactance from 73 to 8 ohms.

Figure 18 Input impedance against the mesh. (a), (b) DeltaGapCut across the whole strip and EnhancedGap with \(W\) = 20 mm (its edges generally not mesh lines): 70.25 + 0.66j and 70.59 + 1.66j Ω at λ/10, 73.05 + 3.26j and 72.91 + 5.33j Ω at λ/160. (c) DeltaGapEdge on one of the two edges of the cut: 20.74 + 73.48j Ω at λ/10, 0.20 + 7.71j Ω at λ/160. Generated by documentation/figure_notebooks/theory_ports.ipynb on solver commit 72fb8c6; values in ports.json. Click to enlarge.#

  • DeltaGapCut and EnhancedGap behave alike on this thin strip: the resistance converges slowly, as on Choosing the mesh size, and the two agree within 0.4 Ω. Their reactances differ by 1.0 to 2.1 Ω, the effect of the width of the gap, and both still rise by 2.6 and 3.7 Ω between λ/10 and λ/160.

  • DeltaGapEdge on a strip two cells wide is not a feed of the antenna: the second edge of the cut is metal and shorts the source, the input impedance tends to a small inductance.

Three colour maps of the current magnitude near the centre of a 40 mm wide strip, and a plot of the mean current along the strip. With one fed edge the current is confined to the cells around it; with the cut and with the enhanced gap it is spread over the strip, strongest at its edges, and the two profiles along the strip coincide.

Figure 19 \(|\mathbf J|\) on a wide strip (300 MHz, 0.47 m × 40 mm, λ/60 along, 4 cells across), 1 V on each port, each map scaled to its own maximum. (a) DeltaGapEdge on one edge: the current circulates around the fed edge (maximum 10.3 A/m), \(Z_\mathrm{in}\) = 0.03 + 10.19j Ω. (b) DeltaGapCut across the strip: 80.75 + 5.15j Ω. (c) EnhancedGap, \(W\) = 50 mm (dashed): 79.22 + 14.21j Ω. (d) Mean \(|\mathbf J|\) across the width along the strip: the cut and the enhanced gap give the same half-sine (the two curves coincide); the single edge gives a spike at the feed and a current six to eight times weaker elsewhere. Generated by documentation/figure_notebooks/theory_ports.ipynb on solver commit 72fb8c6; values in ports.json. Click to enlarge.#

In short:

  • Start with EnhancedGap, with gap_width at least as wide as the conductor at the feed. Its edges need not be mesh lines; drawing the gap as its own surface keeps the excitation exactly where it is drawn (Choosing the mesh size).

  • Use DeltaGapCut when the feed must be a zero-width gap across a wide conductor, or to match the reduced multiport model (Load and matching optimisation). Make the cut a line of the mesh (structured meshes, or gmsh with fragment).

  • Keep DeltaGapEdge for strips one cell wide, or to put a port where a lumped load of rwg3 would go (same edge selection rule).

Migrating from the former feed arguments#

The arguments feed_point, voltage_amplitude, excitation_unit_vector, gap_width and voltage_phase of the solvers were removed, and so were multiple_gap_sources, rwg4.compute_port_results and the modules harmolab.utils.gap_source and harmolab.optim.ports. The new call gives the same input impedances as the former one (largest relative difference \(2\times10^{-16}\), checked when the ports were refactored).

Before

Now

radiation_algorithm(path, f, feed_point, voltage_amplitude=1, excitation_unit_vector="y", gap_width=w)

radiation_algorithm(path, f, [EnhancedGap("feed", feed_point=(x, y, z), axis="y", gap_width=w)], voltages=[1.0])

several feed points in feed_point, with voltage_amplitude and voltage_phase lists

one specification per port, each with its own name, and voltages=[a1 * np.exp(1j * phi1), ...] (phases in radians, as before)

excitation_unit_vector="x"

axis="x"

gap_width with a default of 0.05 m (1 mm in run_radiation_refinement)

gap_width required, for each port

returned tuple (Z, V, I, J, gap_currents, gap_voltages, impedances, feed_powers)

RadiationResult: z_matrix, voltage, current, surface_current_density, ports[p].current, .voltage, .impedance, .power, .reactive_power

frequency_sweep(path, f1, f2, feed_point, n_points, voltage_amplitude, excitation_unit_vector, gap_width, voltage_phase, ...)

frequency_sweep(path, f1, f2, ports, voltages, n_points=41, ...); the .mat file also has port_names

calculate_current_radiation(path, feed_point, voltage_amplitude, excitation_unit_vector, gap_width, voltage_phase, ...)

calculate_current_radiation(path, ports, voltages, ...) → (frequency, V, I, [PortResult])

run_radiation_refinement(config, grid_points, r_vicinity, path, frequency, feed_point, ...)

run_radiation_refinement(config, grid_points, r_vicinity, path, frequency, ports, voltages)

multiple_gap_sources(...)

enhanced_gap_port(points, triangles, edges, vecteurs_rho, feed_point, axis, gap_width, name), then excitation_vector(ports, edges, voltages)

rwg4.compute_port_results(...)

port_results(ports, edges, current, voltages)

from harmolab.optim.ports import ..., from harmolab.optim import Port

from harmolab.utils.ports import Port, port_from_cut, port_from_edge

from harmolab.utils.gap_source import GapSourceError

from harmolab.utils.ports import GapSourceError

gap_currents in the saved files: the current times \(e^{-j\varphi}\)

the physical current across the port, \(\mathbf b_p^\mathsf T I\)

The centroid (one-point) rule of the former multiple_gap_sources without vertex coordinates no longer exists: the enhanced gap is always integrated exactly (Excitations and input impedance).

Continue#

Theory: ports

One vector per port, the identities, the checks

Ports
Choosing the mesh size

The gap, the width of the conductor, the cells

Choosing the mesh size
Radiation

Every parameter of radiation_algorithm

Radiation: feeding an antenna