Materials and Geometry

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

A structure in rfx is a shape plus a material: pick a library material or register your own with add_material(), then attach it to a shape with sim.add(). This page covers materials, shapes, and exactly how metal is placed on the grid. For the short version of the three conductor kinds, see Core Concepts.

Library materials

MATERIAL_LIBRARY holds common RF materials. Use them by name; no registration is needed.

from rfx import MATERIAL_LIBRARY, Box, Simulation
print(list(MATERIAL_LIBRARY))
sim = Simulation(freq_max=10e9, domain=(0.05, 0.05, 0.02), boundary="cpml")
sim.add(Box((0.005, 0.005, 0.005), (0.045, 0.045, 0.0066)), material="fr4")
# A 1 mm PEC plate. It has real thickness, so it is a volume (see the Conductors page).
sim.add(Box((0.005, 0.005, 0.004), (0.045, 0.045, 0.005)), material="pec")
Nameε_rσ (S/m)Notes
vacuum1.00
air1.00060
fr44.40.025lossy PCB laminate
rogers4003c3.552.67×10⁻³σ from tan δ 0.0027 at 5 GHz
rogers4350b3.487.16×10⁻³σ from tan δ 0.0037 at 10 GHz
rt_duroid_58802.201.10×10⁻³σ from tan δ 0.0009 at 10 GHz
alumina9.80
silicon11.90.01lightly doped
ptfe2.10
copper1.05.8×10⁷treated as PEC
aluminum1.03.5×10⁷treated as PEC
pec1.01×10¹⁰perfect conductor
water_20c4.9 + one Debye pole0water at 20 °C

The laminate σ values are a constant conductivity that matches the datasheet loss tangent at one frequency. Loss away from that frequency scales as 1/f, so it is not a frequency-dependent loss model.

When you omit dx, rfx picks the mesh from your geometry and materials, and preflight(), fidelity_report() and run() all use that same mesh. Adding geometry can change it. To differentiate with respect to geometry or mesh inputs, pass an explicit dx (and any profiles) up front.

Custom materials

sim.add_material("my_ceramic", eps_r=9.0, sigma=0.001, mu_r=1.0)
sim.add(Box((0.01, 0.01, 0.0), (0.04, 0.04, 0.002)), material="my_ceramic")

add_material() and add() return the simulation, so you can chain them:

(sim
.add_material("sub", eps_r=3.55, sigma=0.0)
.add_material("metal", eps_r=1.0, sigma=5.8e7)
.add(Box((0, 0, 0), (0.05, 0.03, 0.001)), material="sub")
.add(Box((0.005, 0.005, 0.001), (0.045, 0.025, 0.0015)), material="metal"))

Any material with σ ≥ 10⁶ S/m, such as "metal" above, becomes a perfect conductor. See How conductors land on the lattice.

Dispersive materials

Debye poles

A Debye pole models dipolar relaxation (water, tissue): ε(ω) = ε_∞ + Δε / (1 + jωτ). eps_r is ε_∞.

from rfx import DebyePole
sim.add_material("water_body", eps_r=4.9,
debye_poles=[DebyePole(delta_eps=74.1, tau=8.3e-12)])

delta_eps is εₛ − ε_∞ and tau is the relaxation time in seconds.

Lorentz and Drude poles

Build Lorentz and Drude poles with the helpers and pass them as lorentz_poles=[...]:

import numpy as np
from rfx import drude_pole, lorentz_pole
# Lorentz oscillator: strength, resonance (rad/s), damping (rad/s).
sim.add_material("resonant", eps_r=1.0, lorentz_poles=[
lorentz_pole(delta_eps=2.0, omega_0=2 * np.pi * 10e9, delta=1e8)])
# Drude plasma: plasma frequency and collision rate, both in rad/s.
sim.add_material("plasma", eps_r=1.0,
lorentz_poles=[drude_pole(omega_p=2 * np.pi * 10e9, gamma=2 * np.pi * 1e9)])

Both helpers return a LorentzPole(omega_0, delta, kappa). Use the helpers rather than building that tuple yourself.

A Drude or Lorentz medium has its own time-step limit, and a medium above it is refused when the model is assembled, with the largest stable step in the message. A metal at its optical plasma frequency (gold: ω_p ≈ 1.37×10¹⁶ rad/s) is far above that limit on any RF cell, and no stable step is found. Model RF metal as a conductor (material="pec", a thin conductor, or a finite sigma) instead.

Shapes

Coordinates are in metres. Shapes are rasterized onto the grid when the simulation is built.

from rfx import Cylinder, Sphere
slab = Box((0.0, 0.0, 0.0), (0.05, 0.05, 0.002)) # corner_lo, corner_hi
ball = Sphere((0.025, 0.025, 0.010), radius=0.005) # center, radius
via = Cylinder((0.025, 0.015, 0.001), radius=0.0005, # center, radius,
height=0.002, axis="z") # height, axis
sim.add(ball, material="alumina")
sim.add(via, material="copper")

Cylinder takes its centre point, not its base: the via above spans z = 0 to 2 mm. rfx also provides PolylineWire, Via and CurvedPatch; see the Geometry and Materials API.

CAD import

MeshShape imports STL, OBJ, PLY and STEP/STP files. All of them need the CAD extra (pip install "rfx-fdtd[cad]>=2.0"), which installs trimesh. scale converts the file’s length unit to metres:

import tempfile
from pathlib import Path
import trimesh
from rfx import MeshShape
# A stand-in CAD part: 30 x 20 x 2 mm, drawn in millimetres.
with tempfile.TemporaryDirectory() as tmp:
stl = Path(tmp) / "bracket.stl"
trimesh.creation.box(extents=(30.0, 20.0, 2.0)).export(stl)
part = MeshShape.from_file(str(stl), scale=1e-3,
translate=(0.025, 0.025, 0.010))
sim.add(part, material="pec")

STL in millimetres needs scale=1e-3. STEP files are converted to metres on import, so use scale=1.0. MeshShape is not differentiable: it raises on traced coordinates. No shape’s size or position is a gradient input either: a gradient with respect to a Box, Sphere or Cylinder dimension raises, because the shape is drawn onto whole cells. To design a shape, put a design region over it and optimise the permittivity of its cells.

Draw order

There is no Boolean CSG. Shapes are rasterized in the order you add them, and where they overlap, a later dielectric overwrites an earlier one. To carve a hole in a dielectric, add the hole’s material second:

sim.add(Box((0.010, 0.010, 0.0), (0.040, 0.040, 0.004)), material="alumina")
sim.add(Box((0.020, 0.020, 0.0), (0.030, 0.030, 0.004)), material="air")

This works for dielectrics only. Conductors accumulate and are never removed, so a later shape cannot cut a hole in metal. Draw metal only where metal should be.

Freeze the mesh before placing geometry from it

With an automatic mesh, adding geometry can refine the mesh and move node planes. If you place conductors using grid coordinates, first register the geometry that drives the mesh, then call sim.freeze_mesh():

frozen = Simulation(freq_max=10e9, domain=(0.03, 0.03, 0.03), boundary="pec")
grid = frozen.freeze_mesh()
d = float(grid.dx)
frozen.add(Box((5 * d, 5 * d, 5 * d), (9 * d, 9 * d, 6 * d)), material="pec")

Reading the grid or running preflight does not freeze it. After freezing, a feature the mesh cannot resolve is still refused. On a non-uniform grid, use the node coordinates, since grid.dx is only the boundary spacing. Register ports and boundaries before you keep array indices, because they can change the padding. Alternatively, pass explicit dx= and profiles from the start.

Conductors

Metal has its own page: Conductors gives the rule for volumes, sheets and wires, thin and lossy conductors, and the worked examples.

Limits

  • Metal loss. Every metal in the library is lossless PEC. For conductor loss on a sheet, use surface_impedance_f0. There is no volumetric metal loss.
  • Laminate loss is constant σ. It matches tan δ at one frequency only. For broadband loss, fit Debye or Lorentz poles to your material data.
  • Off-grid geometry moves. A face between node planes lands on the nearest one, up to half a cell away. Check fidelity_report(), and refine instead of rounding your design to the grid.
  • Surface-impedance sheets run on the uniform and single-device graded-mesh run() and S-parameter paths. Distributed, subgridded, UPML, multimode-waveguide, MSL-junction and optimization paths refuse them. See the support matrix.
  • MeshShape is not differentiable.
Back to top