Design, analysis, and optimization of programmable electromagnetic metasurfaces
Project description
metasurface-py
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 | |
| 02 Optimization | Relax-then-quantize with hardware constraints | |
| 03 RIS Link | RIS-assisted communication link, N² scaling | |
| 04 Sensing & ISAC | Radar detection, localization CRLB, comms-sensing tradeoff |
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
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
dd97e45c889ca12c6096b4e7b4fdca423255b026f1cb270ad0bb6afe4c224ed4
|
|
| MD5 |
4808ca02e840f9a67a4607deec84cdcd
|
|
| BLAKE2b-256 |
3446960e015e6c81c70a1e82f3354dad94d8768c3708f5be8249e34a932402ae
|
Provenance
The following attestation bundles were made for metasurface_py-0.2.0.tar.gz:
Publisher:
publish.yml on jman4162/metasurface-py
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
metasurface_py-0.2.0.tar.gz -
Subject digest:
dd97e45c889ca12c6096b4e7b4fdca423255b026f1cb270ad0bb6afe4c224ed4 - Sigstore transparency entry: 1173812858
- Sigstore integration time:
-
Permalink:
jman4162/metasurface-py@1ec8d0f73d90f7001530aa678f20b4805f0fffbf -
Branch / Tag:
refs/tags/v0.2.0 - Owner: https://github.com/jman4162
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@1ec8d0f73d90f7001530aa678f20b4805f0fffbf -
Trigger Event:
release
-
Statement type:
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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
2975f1a7dcd564e9a765d82d554aaa00f0e2620439f4b3fa44755fa9f325e4d6
|
|
| MD5 |
a9dbf5b21b1133483f9b80a1413d02fb
|
|
| BLAKE2b-256 |
99f4f5b82209afdae1c6433ec22b39e43e76d686e257e209a27d3dec2357234d
|
Provenance
The following attestation bundles were made for metasurface_py-0.2.0-py3-none-any.whl:
Publisher:
publish.yml on jman4162/metasurface-py
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
metasurface_py-0.2.0-py3-none-any.whl -
Subject digest:
2975f1a7dcd564e9a765d82d554aaa00f0e2620439f4b3fa44755fa9f325e4d6 - Sigstore transparency entry: 1173812927
- Sigstore integration time:
-
Permalink:
jman4162/metasurface-py@1ec8d0f73d90f7001530aa678f20b4805f0fffbf -
Branch / Tag:
refs/tags/v0.2.0 - Owner: https://github.com/jman4162
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@1ec8d0f73d90f7001530aa678f20b4805f0fffbf -
Trigger Event:
release
-
Statement type: