What it is for
Every FDTD domain ends somewhere, and what happens to a wave at that end is part of the model. An open structure (an antenna, a scatterer, a line that should look infinitely long) needs an absorber that takes the wave without reflecting it. A closed cavity needs metal walls. A symmetry plane can be a metal (PEC) or magnetic (PMC) wall that halves the domain. An array or a metasurface needs periodic walls. This page is how you declare each of them, face by face, and the rules that ports and plane waves put on them.
How to use it
Simulation(boundary=...) takes one word for all six faces: "cpml" (the
default), "upml" or "pec". For different faces, pass a BoundarySpec with
one entry per axis; an entry is a word for both faces of that axis, or a
Boundary(lo=..., hi=...) for two different faces. The words for a face are
"cpml", "upml", "pec", "pmc" and "periodic".
A board over a ground plane, open on top and at the sides, with a thinner absorber on top:
from rfx import Simulationfrom rfx.boundaries.spec import Boundary, BoundarySpec
spec = BoundarySpec( x="cpml", y="cpml", z=Boundary(lo="pec", hi="cpml", hi_thickness=8),)sim = Simulation(freq_max=10e9, domain=(0.03, 0.03, 0.015), dx=0.5e-3, boundary=spec, cpml_layers=12)for axis, side, token in spec.faces(): print(axis, side, token)
try: Boundary(lo="periodic", hi="cpml")except ValueError as err: print(err)else: raise AssertionError("expected a refusal")x lo cpmlx hi cpmly lo cpmly hi cpmlz lo pecz hi cpmlperiodic must be symmetric on an axis; got lo='periodic' hi='cpml'. Use Boundary(lo='periodic', hi='periodic') or rename the asymmetric side.The rules the spec enforces when you build it:
- A periodic axis is periodic on both faces.
lo_thicknessandhi_thicknessapply only to absorbing faces. They set that face’s layer count and may not exceedcpml_layers(preflight refuses it), which is the largest depth rfx allocates; a face without its own thickness getscpml_layers.- CPML and UPML cannot be mixed in one model.
Boundary(lo="pec", hi="pec", conformal=True)adds the Dey–Mittra conformal correction at the two walls. The axis is still a wall axis, so the cell-count rule below applies to it: under the defaultsnap="strict"a length more than 1 % off a whole number of cells is refused, andsnap="declared"accepts it with a warning.
The 1.x arguments pec_faces= and set_periodic_axes() are gone; the error
names the replacement (see Upgrading to 2.0).
Where the absorber sits
The absorber is added outside the domain you declare: the box from 0 to
domain on each axis is free of absorber, and each absorbing face adds its
layers beyond it. A metal, magnetic or periodic face adds nothing. So the
domain is the region you model, solved in whole cells (see
How the domain becomes cells), and the
absorber’s depth is extra memory, not lost space.
What an absorber needs from the model:
- Depth.
cpml_layersdefaults to 16. The CPML reflects less with more layers (see Accuracy). Preflight warns below 8 layers (thin_absorber). - Room. Keep shapes inside the domain: a shape that reaches past the
domain edge enters the absorber (
geometry_in_absorber). Preflight also warns when a probe, source or port is within two cells of the absorber (absorber_proximity), where the fields carry the absorber’s own error; more room is better. - A uniform medium next to each face. On a graded mesh, keep the cells next
to each absorbing face uniform over as many cells as the face has layers
(
nu_grading_reaches_absorber). A substrate that runs into the absorber on purpose (a line meant to look infinitely long) is reported too; read the warning and decide. - CPML for most uses. UPML is accepted on a uniform mesh on one device
only, is refused with a plane wave, and does
not read
cpml_kappa_max. Use CPML unless you have a reason not to.
How the domain becomes cells
The grid holds whole cells, so a declared length is solved as a whole number of them:
- An axis closed by walls on both faces (PEC, PMC, or faces with no
absorber layers) is solved at the nearest whole number of cells. If that is
more than 1 % off the declared length, the default
snap="strict"refuses the model and the message names the nearestdxthat fits;snap="declared"runs it with awall_axis_off_nodewarning. When you leavedxunset, rfx looks for a cell size that fits the walls, no smaller than 0.75 of the one it would otherwise choose. If none fits, it refuses and names the largest smallerdxthat does, searching down to 1/16 of its own choice; below that the message says no fitting spacing was found. A WR-90 cross-section, 22.86 × 10.16 mm, fits atdx = 1.27 mm(18 × 8 cells) and is refused at 1 mm, where 10.16 mm would be solved as 10 mm. - An axis with absorbing faces is covered by whole cells and can be solved
up to one cell longer than declared.
sim.fidelity_report()lists it asdomain-extent-quantizedwith the declared and solved lengths. - A periodic axis follows the rule in Periodic walls.
- A graded axis is solved as the cell profile you give.
Metal and magnetic walls
A "pec" face is a perfect electric conductor: tangential E is zero on it. A
"pmc" face is a perfect magnetic conductor: tangential H is zero on it.
Either can stand for a symmetry plane of the structure and its excitation: a
PEC wall where the tangential E is zero by symmetry, a PMC wall where the
tangential H is zero. A closed cavity is
PEC on every face; do not mix an absorber into it.
A far field cannot be taken through such a wall. The far-field transform
(NTFF) rebuilds no mirror image, so run(), forward() and compute_rcs
refuse a far-field box in a model with a PEC or PMC face, or an absorbing face
with zero layers: a half model cut by a magnetic symmetry plane would give a
pattern 6 dB wrong, not only a scale factor. For a far field, draw a finite
ground plane as geometry and keep every face absorbing.
Periodic walls and a phase across the cell
A "periodic" axis joins its two faces: the field leaving one face enters the
other. With no phase, this models an infinite array at normal incidence. An
axis of length L has exactly L/dx cells, so the structure repeats every L; an
explicit dx that does not divide L is refused with the nearest one that
does. A periodic axis runs on a uniform or a graded mesh on one device; on a
graded mesh the cells along that axis must all have one size. A
phase across the cell (a Bloch condition, for oblique incidence or a scanned
array) is not set on the boundary itself but by the source that needs it:
add_floquet_port(..., scan_theta=..., scan_phi=...)turns on periodic transverse axes for you. A port scanned off normal is refused on every solver path today; at normal incidence it runs on a uniform mesh on one device.- A plane wave (
add_tfsf_source(..., angle_deg=..., method="bloch")) applies the phase across a periodic transverse axis.
Rules that ports and plane waves put on the boundary
- Waveguide port. It needs at least one CPML face (
boundary="cpml", or CPML on some faces of aBoundarySpec) and at least one layer. A full-aperture port (the guide fills the domain cross-section) needs PEC on the transverse faces; on a uniform mesh the default transverse absorbers are solved as PEC with a warning, and on a graded mesh you declare them explicitly. - Plane wave from a slab source. On each axis across the beam, the two
faces must be periodic, or both the matching wall (PEC on the faces normal to
E, PMC on the faces normal to H), or both absorbing. On the uniform mesh
the faces the source wraps (y and z; z only for
method="methodB") are solved as periodic: leaveboundaryout or passboundary="cpml", and preflight warns (tfsf_transverse_periodic); along that axis you model an infinite array of your structure. CPML, PMC or PEC declared on such a face is refused there, naming the faces. The graded mesh solves the declared faces as declared. A structure that is not uniform along such an axis is refused; declare the axis"periodic"to solve an array on purpose, or useclosed_box=Truefor a finite scatterer. For oblique incidence, the finite-scatterer declaration isadd_tfsf_source(closed_box=True, theta_deg=…, phi_deg=…, polarization='s' or 'p')in 3-D with CPML on all six faces. A mixed pair is refused. This uniformity check applies at normal incidence and on the uniform oblique Bloch path, including the tilt axis. Open obliquemethod="methodB"keeps absorbing y faces and periodic z faces. The graded mesh refuses oblique incidence. - Plane wave in a closed box (
closed_box=True, a total-field box with the scattered field around it) needsboundary="cpml", not a PEC cavity.
How rfx checks it
When the spec is built: the face words, a periodic axis on both faces,
thickness only on absorbing faces, and no CPML–UPML mix. A thickness above
cpml_layers is refused by preflight and when the grid is built. Before the
run, preflight checks the absorber depth, the room
around the structure and the mesh next to each absorbing face (warnings), and
the solver path checks that it implements every face (refusals, below).
Inputs rfx refuses
| Input | Solver path | What happens | Instead |
|---|---|---|---|
| an axis closed by walls on both faces (PEC, PMC or zero-depth faces), without a cell profile, whose length is more than 1 % off a whole number of cells | uniform and graded mesh | refused under the default snap="strict"; the message names the nearest dx that fits | that dx, or snap="declared" to run with a warning |
"pmc" face | subgridded | refused | a uniform or graded mesh, on one device or several |
"pmc" face with a wire port or lumped-port S (on a graded mesh, with any port or frequency-domain record) | several devices, either mesh | refused | run on one device |
"periodic" axis | multi-device, subgridded | refused | run on one device |
on a periodic axis: a graded cell profile along it, a plane wave, interface_eps="dual_average" or Bloch phases | graded mesh | refused | keep the cell size constant along the axis; run plane waves on a periodic cell on a uniform mesh |
extract_s_matrix or extract_s_matrix_wire on a model with a periodic axis | all | refused: they solved six PEC walls | run(compute_s_params=True) |
a far-field box (add_ntff_box) with a PEC, PMC or zero-depth absorbing face | all | refused | a finite ground plane drawn as geometry, every face absorbing |
"upml" | graded mesh, multi-device, subgridded | refused | use "cpml" |
"upml" with a plane wave (add_tfsf_source) | all | refused | use "cpml" |
UPML with cpml_kappa_max other than 1 | all | refused: UPML does not read it | use "cpml" |
| a waveguide port with no CPML face | all | refused when the port is added | use CPML |
| a Floquet port scanned off normal | all | refused | normal incidence only |
| a slab plane wave with a mixed pair of side faces, or (at normal incidence) a structure not uniform along a side axis that is not periodic | all | refused | declare that axis "periodic", or use closed_box=True |
an open plane wave with CPML, PMC or PEC declared on a side face it wraps (y and z; z only for method="methodB") | uniform mesh | refused, naming the faces | declare those faces "periodic", leave boundary out, use closed_box=True, or a graded mesh |
closed_box=True plane wave in a PEC domain | all | refused | boundary="cpml" |
Refused inputs explains how refusals read; the support page lists every refusal per solver path.
Accuracy
The CPML’s reflection is measured directly: a plane wave in vacuum on a 1 mm
mesh hits one face, and the reflected wave is separated from the incident one.
At 2, 10 and 30 GHz and on both the low and the high face, the reflection stays
below these bounds (tests/unit/boundaries/test_cpml_reflection_coefficient.py):
| Layers | cpml_kappa_max | Reflection below |
|---|---|---|
| 4 | 1 | −13 dB |
| 8 | 1 | −40 dB |
| 16 (default) | 1 | −90 dB |
| 8 | 3 | −25 dB |
At 45° incidence with 8 layers, the reflection at 10 GHz is below −60 dB (same file). The bounds are test limits set above the measured values, not the measured values themselves.
See also
- Domain and mesh: the domain and the cells next to the absorber.
- Ports and Sources: what each port and source needs.
- Check the model on the grid: the preflight warnings above.
- Known limitations: magnetic faces and plane-wave side faces each have an entry there. A full-aperture guide on a graded mesh needs its walls declared; the support matrix lists that refusal.
