morpho.py computes photonic crystal band structures with the plane-wave
expansion (PWE) method.
Installation
The package supports Python 3.9 through 3.15. Add it to a uv project with:
uv add morpho.py
Quick start: 2D square lattice
This example calculates the first four TM and TE bands for alumina rods in air
on a square lattice. The lattice constant is normalized to a = 1.
import matplotlib.pyplot as plt
from morpho import (
BrillouinZonePath,
Geometry,
Solver,
SymmetryPoint,
plot_bands,
plot_brillouin_zone,
)
a = 1.0
radius = 0.2 * a
eps_rod = 8.9
a1, a2 = (a, 0.0), (0.0, a)
gamma = SymmetryPoint((0.0, 0.0), "Γ")
x_point = SymmetryPoint((0.5, 0.0), "X")
m_point = SymmetryPoint((0.5, 0.5), "M")
path = BrillouinZonePath(
a1, a2, [gamma, x_point, m_point, gamma], points_per_segment=40
)
def eps_rf(eps_r, x, y):
eps_r[x**2 + y**2 <= radius**2] = eps_rod
geometry = Geometry(a1, a2, 65, 65, eps_rf=eps_rf)
tm = Solver(geometry, path, P=7, Q=7, pol="TM")
te = Solver(geometry, path, P=7, Q=7, pol="TE")
tm_solution = tm.run()
te_solution = te.run()
_, axis = plt.subplots(figsize=(7, 5), tight_layout=True)
plot_bands((tm_solution, te_solution), n_bands=4, ax=axis)
plot_brillouin_zone(
tm_solution.path, ax=axis, inset=True, inset_bounds=(0.32, 0.12, 0.30, 0.25)
)
plt.show()
This reproduces the square-lattice example in Chapter 5, Figure 2 of Photonic Crystals: Molding the Flow of Light. Its TM gap-to-midgap ratio is about 31.45%, compared with 31.4% in the book.
See the examples documentation for the other demos, their parameters, figures, and comparisons with the book where applicable.
Metadata
Release files for morpho.py 0.2.4
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| morpho_py-0.2.4.tar.gz | 32.3 kB | Without provenance | Details for morpho_py-0.2.4.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| morpho_py-0.2.4-py3-none-any.whl | Python 3 | none | any | Details for morpho_py-0.2.4-py3-none-any.whl |
Total release size: 68.2 kB
Release files / morpho_py-0.2.4.tar.gz
| Download URL | morpho_py-0.2.4.tar.gz |
|---|---|
| Size | 32.3 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
6baa79ae0e08f60650037d4598b52d53782d7ba3846dc3aca0c62ee99dc9d692
|
|
BLAKE2b-256 checksum How to use checksums |
348ef5e6d148753be161be5bd0791aad8b9ead390f739c70e6230684b2438db7
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/2.5.1 CPython/3.14.8 Linux/7.2.11-arch1-1
|
Release files / morpho_py-0.2.4-py3-none-any.whl
| Download URL | morpho_py-0.2.4-py3-none-any.whl |
|---|---|
| Size | 35.9 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
553d683c70a2faeab6bb84221cfd637d27261db75072f51805032aacee71fbaa
|
|
BLAKE2b-256 checksum How to use checksums |
750a0139a65e0ef5c52c3aca0b795467cfec1146d43712f4b04c713427ac26ea
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/2.5.1 CPython/3.14.8 Linux/7.2.11-arch1-1
|
Security for morpho.py 0.2.4
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.