Skip to content

Geometry

metasurface_py.geometry

Lattice and aperture geometry definitions.

CircularAperture dataclass

Cell-centered polar sampling grid over a circular aperture.

Parameters:

Name Type Description Default
radius float

Aperture radius [m].

required
n_rho int

Number of radial samples.

256
n_phi int

Number of azimuthal samples.

128
area property

Total aperture area [m^2].

cell_areas cached property

Exact annular-sector cell areas, shape (n_rho, n_phi) [m^2].

Uses 0.5(rho_out^2 - rho_in^2)d_phi so the cell areas sum exactly to pi*radius^2.

phi cached property

Azimuthal sample points (cell centers), shape (n_phi,) [rad].

positions cached property

Cartesian sample positions in the z=0 plane, shape (n_rho*n_phi, 3) [m].

Flattened with rho as the slow axis (matches cell_areas.ravel()).

rho cached property

Radial sample points (cell centers), shape (n_rho,) [m].

HexagonalLattice dataclass

Hexagonal (triangular) grid of elements in the xy-plane.

Rows are offset by half the x-spacing on alternating y-indices, creating a close-packed hexagonal arrangement.

Parameters:

Name Type Description Default
nx int

Number of elements per row.

required
ny int

Number of rows.

required
dx float

Element spacing along x [meters].

required
origin NDArray[floating[Any]]

Center of the array, shape (3,). Defaults to (0, 0, 0).

(lambda: zeros(3, dtype=float64))()
element_mask NDArray[bool_] | None

Boolean mask (nx, ny), True = active. None = all active.

None
dy property

Row spacing for hexagonal packing: dx * sqrt(3)/2.

mask property

Boolean mask of active elements.

num_elements property

Number of active elements.

positions property

Element positions, shape (N, 3) in meters, centered on origin.

RectangularLattice dataclass

Rectangular grid of elements in the xy-plane.

Parameters:

Name Type Description Default
nx int

Number of elements along x.

required
ny int

Number of elements along y.

required
dx float

Element spacing along x [meters].

required
dy float

Element spacing along y [meters].

required
origin NDArray[floating[Any]]

Center of the array, shape (3,). Defaults to (0, 0, 0).

(lambda: zeros(3, dtype=float64))()
element_mask NDArray[bool_] | None

Boolean mask (nx, ny), True = active. None = all active.

None
area property

Physical area of the array [m^2].

extent property

Physical extent (width_x, width_y) of the array [meters].

mask property

Boolean mask of active elements.

num_elements property

Number of active elements.

positions property

Element positions, shape (N, 3) in meters, centered on origin.

from_wavelength(nx, ny, spacing_fraction, freq, origin=None) classmethod

Create lattice with spacing as a fraction of wavelength.

Parameters:

Name Type Description Default
nx int

Number of elements along x.

required
ny int

Number of elements along y.

required
spacing_fraction float

Element spacing as fraction of wavelength (e.g., 0.5).

required
freq float

Reference frequency [Hz].

required
origin NDArray[floating[Any]] | None

Center of array. Defaults to (0, 0, 0).

None