kicad2ems.core.phased

A phased drive of an antenna with several ports (mode = antenna, drive =
P1@0,P2@60): the far field of each port driven alone, combined afterwards. The
solve is linear, so this is exact at every frequency and keeps the coupling
between the elements: each port's column (its 1 V source, the other ports
shorted) gives a far field E_k and the ports' currents, Y[:, k]; incident waves
a (the drive) need the port voltages

    a = (V + Zc Y V) / (2 sqrt(Zc))  ->  V = 2 (1 + Zc Y)^-1 sqrt(Zc) a,   b =
                                     (V - Zc Y V) / (2 sqrt(Zc))

and the far field is sum_k V_k E_k. Accepted power (|a|^2 - |b|^2) / 2, incident
|a|^2 / 2, the active reflection of each driven port b_k / a_k (what it sees
with its neighbours driven too).

    a = parse_drive(['P1@0', 'P2=0.5@90'], names)  # incident wave per port
                                                   # (undriven: 0)
    a2 = steer(a, 30)  # a phase step of 30 deg from each driven port to the
                       # next
    g = parse_grid('4x4', names)  # a 2D array: {port: (column, row)}, P1..P4
                                  # the top row
    a3 = steer2d(a, names, g, 30, -45)  # +30 deg per column, -45 deg per row
    a5 = aim(a, names, pos, 20, 0, 2.4e9)  # the beam to theta 20, phi 0 at 2.4
                                           # GHz, from the ports' places
    a4 = taper(a, names, g, 'taylor:30')  # amplitudes: a Taylor taper per
                                          # column x per row
    data = load(path)  # mom25d's <name>_mom25d_array.npz
    out = combine(data, a)  # dict(sphere, rows, active, peak)

The .npz: theta, phi (deg; mom25d: the upper hemisphere), freq (Hz), ports, zc
(ohm), Y (nf, n, n), Eth, Eph (nf, n, nphi, ntheta: r E per port column), drive
(the run's a), the sphere's theta (0..180, the lower half 0) and pos (n, 2: each
port's centre, model mm; files written before it have none, and cannot be
aimed).

An FDTD solver (openEMS, gfdtd) runs each driven port once with the others
terminated, which is an incident wave on that port alone: its file holds S (nf,
n, n) in place of Y, Eth / Eph per unit incident wave (r E / a_k), and excited
(n: the ports that were run). Then b = S a and the far field is sum_k a_k E_k; a
drive of a port that was not run is refused.
kicad2ems.core.phased.aim(a, names, pos, theta, phi, f)[source]
The drive a with the phases that point the beam at (theta, phi) (deg) at
frequency f (Hz): a driven port at pos[name] = (x, y) (model mm) gets -k0 (x
sin(theta) cos(phi) + y sin(theta) sin(phi)) more, on top of its own phase
(the far field of a current at r is e^{+j k.r}). Any layout of feeds: rows
and columns, a triangle. The phases are those of phase shifters set at f,
the same at every frequency (the beam squints off f). A feed well off its
element's centre still needs the drive's own phases to make up the
difference. ValueError for a driven port without a place.
kicad2ems.core.phased.combine(data, a, f_pattern=None)[source]
The antenna of drive a from the per-port far fields: sphere (as
load_sphere's: theta, phi, freq, dmax, prad, e_norm), rows (gain_table's),
active ((nf, n) b / a of the driven ports, nan elsewhere) and the beam's
peak at f_pattern (default the data's): dict(theta, phi, gain_dbi).
kicad2ems.core.phased.format_drive(a, names)[source]
The drive items of incident waves a (the driven ports), as parse_drive
reads them.
kicad2ems.core.phased.format_grid(grid, names)[source]
The grid (parse_grid's) as a spec: COLSxROWS when it is the ports in
order row by row, else the items.
kicad2ems.core.phased.load(path)[source]
An array file save() wrote (each port's far field, the drive, the ports),
as numpy arrays: save's inverse.
kicad2ems.core.phased.parse_drive(spec, names)[source]
Incident waves (complex, one per port of names) from
PORT[=amplitude][@phase deg] items; a port not named is not driven
(terminated). ValueError for an unknown port or a bad number.
kicad2ems.core.phased.parse_grid(spec, names)[source]
Each port's place in a 2D array, {port: (column, row)}, for steer2d.
spec: empty (None: no grid), COLSxROWS (the ports in port order fill the
rows, left to right, top row first; e.g. 4x4 for P1..P16), or PORT:COL,ROW
items separated by spaces or semicolons (fractional places too: an offset,
triangular lattice), e.g. 'P1:0,0 P2:1,0 P3:0,1 P4:1,1'. A port not placed
gets no phase step. ValueError for an unknown port or a bad item.
kicad2ems.core.phased.parse_taper(spec)[source]
(kind, sidelobe level in dB, positive) of KIND[:SLL]: uniform, taylor,
chebyshev, cosine; e.g. taylor:30, chebyshev:-25 (either sign). Empty:
uniform. ValueError for an unknown kind or a bad level.
kicad2ems.core.phased.radiated(Eth, Eph, theta, phi, eta=376.730313668)[source]
Radiation intensity U (W/sr, (nphi, ntheta)) and its integral over the
grid (mom25d.farfield.radiated).
kicad2ems.core.phased.save(path, *, theta, phi, theta_sphere, freq, ports, zc, Eth, Eph, drive, f_pattern, Y=None, S=None, excited=None, pos=None)[source]
The array file: Y (mom25d: E per unit port voltage) or S and excited (an
FDTD solver: E per unit incident wave); pos optional.
kicad2ems.core.phased.settings_drive(drive, names, grid_spec=None, steps=None, taper_spec=None, target=None, pos=None, f=None)[source]
The incident waves of a run's settings: --drive (parse_drive), --taper's
amplitudes, --steer's phase steps (X[,Y]) across --grid (steer2d), --aim's
(target: theta, phi) phases from the ports' places pos at f (aim), and the
grid itself (None without one). ValueError for one that does not parse.
kicad2ems.core.phased.steer(a, step_deg)[source]
The drive a with a phase step added from each driven port to the next (in
port order): the first keeps its phase, the k-th driven port gets k x step
more.
kicad2ems.core.phased.steer2d(a, names, grid, step_x, step_y)[source]
The drive a (one per port of names) with phase steps across a 2D array: a
driven port at (column, row) of grid (parse_grid's) gets column x step_x +
row x step_y more phase (deg) on top of its own; ports off the grid are
kept. No grid: steer(a, step_x), the 1D step from each driven port to the
next.
kicad2ems.core.phased.taper(a, names, grid, spec)[source]
The drive a with an amplitude taper (parse_taper's spec) multiplied in,
on top of its own amplitudes. With a grid (parse_grid's) the taper is
separable: a column weight times a row weight, the columns and rows counted
by their distinct places (an offset lattice's half steps are columns of
their own). Without one, across the driven ports in port order. Undriven
ports stay off.
kicad2ems.core.phased.taper_1d(kind, n, sll=25.0)[source]
n amplitude weights across a line of elements, the largest 1.
kicad2ems.core.phased.waves(Y, zc, a)[source]
Port voltages V and reflected waves b for incident waves a (Y: port
currents per 1 V column).