Repository navigation
Description
Setting subpixel_smoothing=True on an ExtrudedPolygon gives exactly the same permittivity as leaving it off. ExtrudedPolygon does not override get_fill_fraction_for_shape, so it uses the default in StaticMultiMaterialObject, which returns the binary voxel mask. Every fill fraction is then 0 or 1, and the Farjadpour blend reduces to the bulk values. No warning is raised, so it looks as if smoothing is on.
I see this on 0.6.3 and on main at 5634922.
import jax
import jax.numpy as jnp
import numpy as np
import fdtdx
DX = 20e-9
def eps_xx(smooth, symmetry=(0, 0, 0)):
cfg = fdtdx.SimulationConfig(grid=fdtdx.UniformGrid(spacing=DX), time=1e-15, dtype=jnp.float32, symmetry=symmetry)
air, diel = fdtdx.Material(permittivity=1.0), fdtdx.Material(permittivity=12.0)
vol = fdtdx.SimulationVolume(partial_grid_shape=(40, 40, 2), material=air)
th = np.linspace(0, 2 * np.pi, 128, endpoint=False)
ellipse = fdtdx.ExtrudedPolygon(
materials={"air": air, "diel": diel}, material_name="diel", axis=2,
vertices=np.column_stack([300e-9 * np.cos(th), 200e-9 * np.sin(th)]),
partial_real_shape=(None, None, 2 * DX), subpixel_smoothing=smooth,
)
_, arrays, *_ = fdtdx.place_objects(
object_list=[vol, ellipse], config=cfg,
constraints=[ellipse.place_at_center(vol, axes=(0, 1, 2))], key=jax.random.PRNGKey(0),
)
return 1 / np.asarray(arrays.inv_permittivities)[0, :, :, 0]
binary, smooth = eps_xx(False), eps_xx(True)
print("distinct eps with smoothing:", np.unique(smooth))
print("identical to binary:", np.array_equal(binary, smooth))
half = eps_xx(False, symmetry=(0, -1, 0))
print("dielectric cells in kept half, full run vs mirror run:", (binary[:, 20:] > 6).sum(), (half > 6).sum())Output on main (CPU, a few seconds):
distinct eps with smoothing: [ 1. 12.]
identical to binary: True
dielectric cells in kept half, full run vs mirror run: 238 238
I expected fractional permittivities on the boundary cells, which GDSLayerObject has produced since #395. Until polygons have a fill fraction, a warning would help when the flag is set on an object that falls back to the binary mask. The fractional polygon mask l-berg posted in #368 might fit here.
The last line checks a related mirror-symmetry bug. On 0.6.3 the same script prints 238 288: with a mirror plane through the ellipse, the kept half rasterizes as nearly its bounding rectangle. #468 fixes this on main, but pip still installs 0.6.3. Is a release with #468 planned?
Activity