Skip to main content

Design, analysis, and optimization of programmable electromagnetic metasurfaces

Project description

metasurface-py

CI PyPI Python 3.11+ License: BSD-3 Streamlit

Open-source Python package for design, analysis, and optimization of programmable electromagnetic metasurfaces for wireless communication and sensing.

Installation

pip install -e ".[dev]"

Quickstart

import numpy as np
from metasurface_py.geometry import RectangularLattice
from metasurface_py.elements import PhaseOnlyCell, DiscretePhaseSpace
from metasurface_py.surfaces import Metasurface
from metasurface_py.em import steering_phase, far_field_pattern
from metasurface_py.core.types import AngleGrid
from metasurface_py.plotting import plot_pattern_2d

lattice = RectangularLattice(nx=32, ny=32, dx=5.4e-3, dy=5.4e-3)
cell = PhaseOnlyCell(state_space=DiscretePhaseSpace(num_bits=2))
surface = Metasurface(lattice=lattice, cell=cell, mode="reflect")

freq = 28e9
phase = steering_phase(lattice, theta_steer=np.radians(30), phi_steer=0.0, freq=freq)
state = surface.set_state(phase).quantize(cell.state_space.codebook)

angles = AngleGrid.from_degrees(theta=np.arange(-90, 91, dtype=float), phi=np.array([0.0, 90.0]))
pattern = far_field_pattern(surface, state, freq=freq, angles=angles)
plot_pattern_2d(pattern, cut_phi=0.0)

Features

  • Metasurface modeling — Rectangular/hexagonal lattices, phase-only and lookup-table unit cells, amplitude-phase coupled elements
  • Far-field analysis — Array factor, directivity, sidelobe level, HPBW, beam steering, focusing, multi-beam synthesis
  • Optimization — Continuous (L-BFGS-B, DE), discrete refinement, relax-then-quantize pipeline, multi-objective Pareto sweeps
  • Hardware constraints — Phase quantization, grouped control lines, dead elements, manufacturing noise
  • RIS channel models — Free-space path loss, narrowband SISO RIS-assisted links, optimal phase computation
  • Sensing — Monostatic/bistatic RCS, detection SNR, Fisher information, CRLB for localization
  • Mutual coupling — Canonical dipole coupling approximation
  • Publication-quality plotting — 13+ plot functions, IEEE/Nature/poster presets, colorblind-safe palettes, PDF/PNG export
  • Experiment management — TOML configs, parameter sweeps, reproducibility metadata
  • Interoperability — CSV/HDF5/Touchstone import, scikit-rf adapter, xarray labeled outputs

Tutorials

Interactive Jupyter notebooks that run in Google Colab (no install required):

Notebook Description Colab
01 Getting Started Create a metasurface, steer a beam, compare quantization Open In Colab
02 Optimization Relax-then-quantize with hardware constraints Open In Colab
03 RIS Link RIS-assisted communication link, N² scaling Open In Colab
04 Sensing & ISAC Radar detection, localization CRLB, comms-sensing tradeoff Open In Colab

Citation

If you use metasurface-py in your research, please cite:

@software{metasurface_py,
  author       = {Hodge, John},
  title        = {metasurface-py: Design, analysis, and optimization of programmable electromagnetic metasurfaces},
  year         = {2026},
  url          = {https://github.com/jman4162/metasurface-py},
  version      = {0.1.0},
  license      = {BSD-3-Clause},
}

License

BSD-3-Clause

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

metasurface_py-0.2.0.tar.gz (84.5 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

metasurface_py-0.2.0-py3-none-any.whl (73.4 kB view details)

Uploaded Python 3

File details

Details for the file metasurface_py-0.2.0.tar.gz.

File metadata

  • Download URL: metasurface_py-0.2.0.tar.gz
  • Upload date:
  • Size: 84.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for metasurface_py-0.2.0.tar.gz
Algorithm Hash digest
SHA256 dd97e45c889ca12c6096b4e7b4fdca423255b026f1cb270ad0bb6afe4c224ed4
MD5 4808ca02e840f9a67a4607deec84cdcd
BLAKE2b-256 3446960e015e6c81c70a1e82f3354dad94d8768c3708f5be8249e34a932402ae

See more details on using hashes here.

Provenance

The following attestation bundles were made for metasurface_py-0.2.0.tar.gz:

Publisher: publish.yml on jman4162/metasurface-py

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file metasurface_py-0.2.0-py3-none-any.whl.

File metadata

  • Download URL: metasurface_py-0.2.0-py3-none-any.whl
  • Upload date:
  • Size: 73.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for metasurface_py-0.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 2975f1a7dcd564e9a765d82d554aaa00f0e2620439f4b3fa44755fa9f325e4d6
MD5 a9dbf5b21b1133483f9b80a1413d02fb
BLAKE2b-256 99f4f5b82209afdae1c6433ec22b39e43e76d686e257e209a27d3dec2357234d

See more details on using hashes here.

Provenance

The following attestation bundles were made for metasurface_py-0.2.0-py3-none-any.whl:

Publisher: publish.yml on jman4162/metasurface-py

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page