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 |
|---|---|---|---|
|
a uniform field across a gap of width |
the default: a feed of finite width, robust to how the mesh cuts the gap |
the conductor is wider than |
|
a zero-width gap across every RWG edge of a cut from |
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) |
|
a zero-width gap on the one edge nearest to |
a strip one cell wide (where it equals |
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
portsis a list; every port has a name, unique in the list.voltagesholds one complex voltage per port, in the order ofports: amplitude in volts (peak), phase in radians,amplitude * np.exp(1j * phase).resultis aRadiationResult:frequency,z_matrix,voltage(\(V\)),current(\(I\)),surface_current_density, andports, onePortResultper port withvoltage,current(the current across the port),impedance,powerandreactive_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.
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.#
DeltaGapCutandEnhancedGapbehave 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.DeltaGapEdgeon 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.
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, withgap_widthat 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
DeltaGapCutwhen 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 withfragment).Keep
DeltaGapEdgefor strips one cell wide, or to put a port where a lumped load ofrwg3would 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 |
|---|---|
|
|
several feed points in |
one specification per port, each with its own name, and |
|
|
|
|
returned tuple |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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#
One vector per port, the identities, the checks
The gap, the width of the conductor, the cells
Every parameter of radiation_algorithm