Sources

Release · v2.2.0MarkdownLLM docs
이 페이지의 내용

What it is for

A source puts energy into the model without being part of the structure. rfx has two kinds: a point source, which drives one field component at one cell (a short current element), and a plane wave, which illuminates the structure from one side. A source has no impedance and absorbs nothing, so it gives no S-parameters; for those, use a port. This page is how to declare each source, what its amplitude means, and which time signal drives it.

How to use it

Point source

sim.add_source(position, component, waveform=..., amplitude_kind=...) drives "ex", "ey" or "ez" at the cell nearest position (metres). The source is soft: it adds to the field there and leaves the field free to pass through.

amplitude_kind says what the waveform’s amplitude is:

amplitude_kindThe amplitude isUse it when
"current"a current moment I·l in A·m, the strength of a short current elementyou want the radiated field to stay the same when you change the mesh
"field"an increment of E added at the cell every time stepyou need a raw field kick

Leaving amplitude_kind out means "current" and gives one DeprecationWarning per simulation. Pass it explicitly.

The difference shows when the mesh changes. The same source and probe on three cell sizes:

import numpy as np
from rfx import ModulatedGaussian, Simulation
def peak(dx, kind):
sim = Simulation(freq_max=6e9, domain=(0.06, 0.06, 0.06), dx=dx,
boundary="cpml", cpml_layers=8)
sim.add_source((0.03, 0.03, 0.03), "ez", amplitude_kind=kind,
waveform=ModulatedGaussian(f0=3e9, bandwidth=0.5))
sim.add_probe((0.048, 0.03, 0.03), "ez")
n = int(round(400 * 2e-3 / dx)) # the same simulation time
result = sim.run(n_steps=n, skip_preflight=True)
return float(np.max(np.abs(np.asarray(result.time_series))))
for kind in ("current", "field"):
print(kind, " ".join(f"{peak(dx, kind):.4g}" for dx in (2e-3, 1.5e-3, 1e-3)))
current 1.055e+05 1.043e+05 1.035e+05
field 0.00196 0.00109 0.0004805

With "current", the peak field at the probe 18 mm away moves by 1.1 % from 2 mm to 1.5 mm cells and by 0.8 % from 1.5 mm to 1 mm: it converges, as a physical source should. With "field", adding a fixed E increment to one cell every step is a current moment proportional to the cell volume over the time step, so it scales as dx². The peaks follow that: ratios of 0.556 and 0.441 against 0.5625 and 0.444 predicted. The result then depends on the cell size you happened to choose.

Polarized source

sim.add_polarized_source(position, polarization=..., waveform=..., amplitude_kind=...) drives Ex and Ey at one point with fixed weights; a single component ("ez") is the same as add_source with that component. polarization is a component ("ez"), a name ("slant45", "rhcp", "lhcp", "circular"), or a Jones vector (Ex, Ey), normalized for you. A complex weight sets the phase of Ey relative to Ex. Circular polarization is not checked by any test; treat it as unchecked.

Plane wave

sim.add_tfsf_source(...) launches a plane wave along x with the total-field/scattered-field method: inside a box the field is incident plus scattered, outside it only the scattered field remains, so what you measure outside is the structure’s response alone.

ArgumentDefaultMeaning
direction"+x""+x" or "-x"
polarization"ez""ez" or "ey", the E component of the incident wave; "s" or "p" for an oblique closed box
angle_deg0angle from the x axis, below 90°, for the plane wave without a closed box
theta_deg, phi_deg0, 0the direction of an oblique wave in a closed box (closed_box=True), about x; rfx takes the nearest lattice direction within direction_tol_deg (0.1°), and sim.tfsf_incidence() reports the direction it realized
method"bloch"for oblique incidence: "bloch" makes the side axis periodic with the matching phase; "methodB" absorbs on it
closed_boxFalseTrue: a finite box with six faces around the structure, for a single scatterer; False: two planes across the domain
f0, bandwidth, amplitudefreq_max/2, 0.5, 1the pulse
waveform"differentiated_gaussian" at normal incidence, in a closed box and with method="methodB"; "modulated_gaussian" at an angle with method="bloch"also "continuous_wave" (normal incidence) or a CustomWaveform (normal incidence, 3-D). An explicit "differentiated_gaussian" at an angle with method="bloch" is refused: that method carries one transverse wavenumber, which only a pulse around f0 matches
margin3cells between the injection planes and the absorber

The injection planes must lie in vacuum. With closed_box=False the planes span the domain. On the uniform mesh the faces across the beam are solved as periodic, so the structure is repeated along them; CPML, PMC or PEC declared on those faces is refused. A structure that is not uniform across them is refused unless you declare those faces periodic. See Boundaries for the rule. For a single scatterer use closed_box=True.

Waveforms

WaveformWhat it isParameters (defaults)
GaussianPulsederivative of a Gaussian, no carrier, corrected so that it starts at exactly zero and its time integral is zerof0, bandwidth=0.5, amplitude=1.0, cutoff=3.0 (at least 2.5)
ModulatedGaussiana carrier at f0 under a Gaussian envelopef0, bandwidth=0.5, amplitude=1.0, cutoff=5.0
CWSourcea sine at f0, switched on over ramp_steps cycles of f0 (not time steps)f0, amplitude=1.0, ramp_steps=50
CustomWaveformyour function of time, func(t) with t in secondsfunc

bandwidth is a fraction of f0; the pulse peaks cutoff envelope widths after t = 0. A bandwidth given in Hz makes a pulse about 10⁻²⁰ s long that drives nothing, and the run refuses it. add_source and add_port use GaussianPulse(f0=freq_max/2, bandwidth=0.8) when you give no waveform.

A pulse gives the response over its whole band from one run. A CWSource gives one frequency and never switches off, so the settling check, which needs the source to be off before the end of the run, cannot judge it.

Because the default pulse has a zero time integral, a soft current source driven by it leaves no static charge, and so no static field, behind. The correction that makes this so changes the plain differentiated Gaussian only before its peak, by at most 1.7×10⁻³ of its amplitude at cutoff=3 (tests/unit/sources/test_source_dc_floor_guards.py). A ModulatedGaussian has no such correction; its time integral is small but not zero.

How rfx checks it

When you declare a source: the component, amplitude_kind, and for a plane wave every argument in the table above against its allowed values and the faces across the beam. Before the first step, run() and forward() refuse, on either mesh and without depending on preflight, anything other than vacuum on or next to a plane wave’s injection planes (a dielectric, even eps_r = 1 + 1e-6, a dispersive or Kerr medium, a PEC volume, a sheet, a wire, a lumped element or a design region; the message names the plane and what it found), and a soft source on an edge the grid realizes as metal. Every excited drive’s pulse, sampled at the time step, must exceed 10⁻⁶ of its amplitude somewhere. The solver path then checks that it implements the source (below).

Inputs rfx refuses

InputSolver pathWhat happensInstead
a plane wave added after a port or a point source (the message names lumped ports); a port added after a plane waveallrefuseddrive the port alone, or use a probe for the response
a plane wave with boundary="upml", or in a closed (all-metal) domainallrefusedboundary="cpml"
waveform="continuous_wave" at an angleallrefuseda pulse waveform
an explicit waveform="differentiated_gaussian" at an angle with method="bloch", in Python or in a saved interop documentallrefused"modulated_gaussian" or no waveform; for one scatterer in an open domain, method="methodB" takes the differentiated Gaussian
a CustomWaveform plane wave at an angle or in 2-Dallrefusednormal incidence in 3-D
closed_box=True with angle_deg, in 2-D, with a face that is not CPML, on cells that are not cubic, or in a run with no fixed step countuniform meshrefusedtheta_deg/phi_deg for the angle, CPML on all six faces, dx=dy=dz, n_steps
method="methodB" at normal incidence, with "ey", along "-x", or with a waveform other than the two Gaussiansallrefusedmethod="bloch"
a structure that is not uniform across the faces across the beam (closed_box=False)uniform and graded meshrefuseddeclare those faces periodic for an array; closed_box=True on a uniform mesh for one object
anything other than vacuum on or next to an injection plane: a dielectric (even a near-vacuum one), a dispersive or Kerr medium, a PEC volume, a sheet, a wire, a lumped element or a design regionuniform and graded mesh, run() and forward()refused before the first stepmove the structure clear of the planes
a plane wave at an angle, with closed_box=True, or with a CustomWaveformgraded meshrefuseduse a uniform mesh
a plane wave on several devices, other than a closed box (closed_box=True) at normal incidence on a uniform meshseveral devices, either meshrefused by name; nothing runs on one device in its placeone device, or the closed box as Multiple devices describes
a plane wave at an angle on the Bloch path (angle_deg ≠ 0 with the default method="bloch") with an NTFF box, DFT planes, flux monitors, snapshot= or until_decay=uniform meshrefusedprobes and the final state, a fixed n_steps, or compute_rcs for scattering; for one scatterer, a closed box at an angle (closed_box=True with theta_deg/phi_deg) takes all five
a soft source on an edge the grid realizes as PEC (inside a PEC volume, on a sheet or wire), or tangential in a declared PEC wall faceallrefusedmove the source off the metal and at least one cell inside the domain, or use a port
a drive whose pulse samples to zero at every time step (usually bandwidth given in Hz)all, and preflight()refusedgive bandwidth as a fraction of f0
GaussianPulse(cutoff=...) below 2.5when the pulse is createdrefusedkeep the default cutoff=3

Refused inputs explains how refusals read; the support page lists them per solver path.

Accuracy

  • A plane wave at 30° and at 45° leaks less than 1 % of its energy outside the total-field region, and less than 0.1 % at normal incidence, in vacuum on a 1 mm mesh at 5 GHz (tests/unit/sources/test_tfsf_oblique.py).
  • Oblique plane-wave reflection from an εr = 4 slab agrees with the Fresnel coefficient within 10 % at 30° and within 8 % at 45°, on a 2 mm mesh at 5 GHz (tests/oracle/test_oblique_fresnel_magnitude.py).
  • A closed-box plane wave in vacuum reproduces the incident pulse inside the box, and outside it the field stays below 9 float32 rounding steps of the pulse peak (tests/unit/sources/test_tfsf_closed_box.py).
  • A closed-box plane wave at 30° and at (45°, 30°) in vacuum is the lattice plane wave along the direction sim.tfsf_incidence() reports. On a 1 mm mesh at 8–12 GHz its wavenumber differs from the analytic wave by 9e-5 to 7.9e-4, 4× less with half the cell, and its amplitude is 0.1–0.5 % below normal incidence (tests/oracle/test_oblique_closed_box_plane_wave.py). With an NTFF box, the oblique closed-box source on a 120 mm PEC trihedral converged at second order over three grids, and its backscatter is within 0.10 dB of an independent full-wave reference at 5 and 15 GHz (one structure, no always-on test; record kept with the project). No incident spectrum is formed for an oblique box: normalize by an empty-box run.

See also

Back to top