Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
c8615f6989 | ||
|
|
4452dad609 | ||
|
|
112d88cac1 | ||
|
|
cde834582d | ||
|
|
4f75d63842 | ||
|
|
89c8ad0318 | ||
|
|
be574d1a5b | ||
|
|
b52ee4f622 | ||
|
|
b9aa06355b | ||
|
|
34075a7456 | ||
|
|
247e3b0f73 | ||
|
|
282ed2c38b | ||
|
|
a08e9ce71b | ||
|
|
7b01ddd789 | ||
|
|
553cdf948c | ||
|
|
7e407dd1ac | ||
|
|
153536ee91 | ||
|
|
0e89fe0460 | ||
|
|
e851e25568 | ||
|
|
37ed9d10bc | ||
|
|
f3500e497b | ||
|
|
cd3deb87fb | ||
|
|
c249e78cd9 | ||
|
|
bb4322ded9 | ||
|
|
f1b1efdb39 | ||
|
|
444ae49a74 | ||
|
|
7e6363ea04 | ||
|
|
bf99f35f9b | ||
|
|
39291a8314 | ||
|
|
061c3f2e90 | ||
|
|
35fc67faa3 | ||
|
|
a1568a6f16 | ||
|
|
c6c9159b13 | ||
|
|
eec3fc28a7 | ||
|
|
010da1ccf5 | ||
|
|
1a2c6ab524 | ||
|
|
8b67696d7f | ||
|
|
f8ad0250d1 | ||
|
|
9a0c693848 | ||
|
|
bb920b8e33 | ||
|
|
ff278e6fa1 | ||
|
|
dc92d4a79d | ||
|
|
40efe7a450 | ||
|
|
e50637dc1c | ||
|
|
f7aa21a42a | ||
|
|
3e4aee1197 | ||
|
|
4b8a462df7 | ||
|
|
c0b41752e1 | ||
|
|
318c43d62d | ||
|
|
6f29dd89a8 | ||
| bedb338ac9 | |||
| a82eb5858a | |||
| 5e95d66a7e | |||
| 0568e1ba50 | |||
| d4c1082ca9 | |||
| d99ef96c96 | |||
| 8cdcd08ba0 | |||
| 267d161769 | |||
| 0afe2297b0 | |||
| 0ff23542ac | |||
| 9ac24892d6 | |||
| f3d13e1486 | |||
| e6756742be | |||
| 87bb3af3f9 | |||
| 07b16ad86a | |||
| f35b334100 | |||
| 593098bf8f | |||
| 38a5c1a9aa | |||
| bc55baf4a6 | |||
| 7eea919f94 | |||
| 74bebea837 | |||
| 8d49901b58 | |||
| 9d419aa3ea | |||
| 4913211883 | |||
| f5af0fef55 | |||
| 7e8ff23356 | |||
| be647658d3 | |||
| c46bed8298 | |||
| fb3bef23bf | |||
| d4f1008c5c | |||
| b486fa325b | |||
| b7ad5dea2b | |||
| 684b891e0f | |||
| 4a80ca8b12 | |||
| e3169b9e20 | |||
| 35ecbad15e | |||
| 43e01a814d | |||
| 9eb0e28bcb | |||
| c858b20d47 | |||
| 777ecbc024 | |||
| c4f8749941 | |||
| cd5cc9eb83 | |||
| 99e8d32eb1 | |||
| 1cb0cb2e4f | |||
| 234e8d7ac3 | |||
| 83f4d87ad8 | |||
| 1987ee473a | |||
| 4afc6cf62e | |||
| 53d5812b4a | |||
| 651e255704 | |||
| 71c2bbfada | |||
| 6a56921c12 | |||
| 006833acf2 | |||
| 155f30068f | |||
| 7987dc796f | |||
| 829007c672 | |||
| 659566750f | |||
| 76701f593c | |||
| 4e3a163522 | |||
| 50f92e1cc8 | |||
| b3c2fd391b | |||
| c543868c0b | |||
| e54735d9c6 | |||
| 4f2433320d | |||
| 47415a0beb | |||
| e459b5e61f | |||
| 36431cd0e4 | |||
| 739e96df3d | |||
| 63e7cb949f | |||
| c53a3c4d84 | |||
| 5dd9994e76 | |||
| 1021768e30 | |||
| 95e923d7b7 | |||
| 3f8802cb5f | |||
| 43bb0ba379 | |||
| e19968bb9f | |||
| 43f038d761 | |||
| d5fca741d1 | |||
| ca94ad1b25 | |||
| 10f26c12b4 | |||
| ee51c7db49 | |||
| 36bea6a593 | |||
| b16b35d84a | |||
| 6f3ae5a64f | |||
| 99c22d572f | |||
| 2f00baf0c6 | |||
| 2712d96f2a | |||
| dc3e733e7f | |||
| 95e3f71b40 | |||
| 639f88bba8 | |||
| ccfd4fbf04 | |||
| 77715da8b4 | |||
| 2d48858973 | |||
| 8c49710861 | |||
| 22565328ab | |||
| 4c8a07bf20 |
128 changed files with 17996 additions and 3934 deletions
4
.gitignore
vendored
4
.gitignore
vendored
|
|
@ -54,6 +54,10 @@ coverage.xml
|
|||
|
||||
# documentation
|
||||
doc/
|
||||
site/
|
||||
_doc_mathimg/
|
||||
doc.md
|
||||
doc.htex
|
||||
|
||||
# PyBuilder
|
||||
target/
|
||||
|
|
|
|||
158
README.md
158
README.md
|
|
@ -49,13 +49,28 @@ linear systems, ideally with double precision.
|
|||
|
||||
**Requirements:**
|
||||
|
||||
* python >=3.11
|
||||
* python >=3.12
|
||||
* numpy
|
||||
* scipy
|
||||
|
||||
|
||||
Install from PyPI with pip:
|
||||
```bash
|
||||
pip3 install meanas
|
||||
```
|
||||
|
||||
Optional extras:
|
||||
|
||||
- `meanas[test]`: pytest and coverage
|
||||
- `meanas[docs]`: MkDocs-based documentation toolchain
|
||||
- `meanas[examples]`: optional runtime dependencies used by the tracked examples
|
||||
- `meanas[dev]`: the union of `test`, `docs`, and `examples`, plus local lint/docs-publish helpers
|
||||
|
||||
Examples:
|
||||
```bash
|
||||
pip3 install 'meanas[test]'
|
||||
pip3 install 'meanas[docs]'
|
||||
pip3 install 'meanas[examples]'
|
||||
pip3 install 'meanas[dev]'
|
||||
```
|
||||
|
||||
|
|
@ -80,9 +95,13 @@ source my_venv/bin/activate
|
|||
# Install in-place (-e, editable) from ./meanas, including development dependencies ([dev])
|
||||
pip3 install --user -e './meanas[dev]'
|
||||
|
||||
# Run tests
|
||||
# Fast local iteration: excludes slower 3D/integration/example-smoke checks
|
||||
cd meanas
|
||||
python3 -m pytest -rsxX | tee test_results.txt
|
||||
python3 -m pytest -q -m "not complete"
|
||||
|
||||
# Complete pre-commit confidence run: includes the slower integration tests and
|
||||
# tracked example smoke tests
|
||||
python3 -m pytest -q | tee test_results.txt
|
||||
```
|
||||
|
||||
#### See also:
|
||||
|
|
@ -94,6 +113,133 @@ python3 -m pytest -rsxX | tee test_results.txt
|
|||
|
||||
## Use
|
||||
|
||||
See `examples/` for some simple examples; you may need additional
|
||||
packages such as [gridlock](https://mpxd.net/code/jan/gridlock)
|
||||
to run the examples.
|
||||
`meanas` is a collection of finite-difference electromagnetics tools:
|
||||
|
||||
- `meanas.fdfd`: frequency-domain wave equations, sparse operators, SCPML, and
|
||||
iterative solves for driven problems.
|
||||
- `meanas.fdfd.waveguide_2d` / `meanas.fdfd.waveguide_3d`: waveguide mode
|
||||
solvers, including targeted complex bases from the default half-sized
|
||||
beta-squared or explicit signed-beta formulations, transpose-left and
|
||||
Lorentz-dual projection fields on a shared field-array axis, separately
|
||||
returned PML-mode diagnostics, overlap-based tracking,
|
||||
mode-source construction, and overlap windows for port-based excitation and
|
||||
analysis.
|
||||
- `meanas.fdtd`: Yee-step updates, CPML boundaries, flux/energy accounting, and
|
||||
on-the-fly phasor extraction for comparing time-domain runs against FDFD.
|
||||
- `meanas.fdmath`: low-level finite-difference operators, vectorization helpers,
|
||||
and derivations shared by the FDTD and FDFD layers.
|
||||
|
||||
For most users, the tracked examples under `examples/` are the right entry
|
||||
point. The library API is primarily a toolbox; the module docstrings and API
|
||||
pages are there to document the mathematical conventions and derivations behind
|
||||
those tools.
|
||||
|
||||
## Documentation
|
||||
|
||||
API and workflow docs are generated from the package docstrings with
|
||||
[MkDocs](https://www.mkdocs.org/), [Material for MkDocs](https://squidfunk.github.io/mkdocs-material/),
|
||||
and [mkdocstrings](https://mkdocstrings.github.io/).
|
||||
|
||||
Install the docs toolchain with:
|
||||
|
||||
```bash
|
||||
pip3 install -e './meanas[docs]'
|
||||
```
|
||||
|
||||
Then build the docs site with:
|
||||
|
||||
```bash
|
||||
./make_docs.sh
|
||||
```
|
||||
|
||||
This produces:
|
||||
|
||||
- a normal multi-page site under `site/`
|
||||
- a combined printable single-page HTML site under `site/print_page/`
|
||||
- an optional fully inlined `site/standalone.html` when `htmlark` is available
|
||||
|
||||
The docs build uses a local MathJax bundle vendored under `docs/assets/`, so
|
||||
the rendered HTML does not rely on external services for equation rendering.
|
||||
|
||||
The tracked examples under `examples/` are the intended entry points for users:
|
||||
|
||||
- `examples/fdtd.py`: broadband FDTD pulse excitation, phasor extraction, and a
|
||||
residual check against the matching FDFD operator.
|
||||
- `examples/waveguide.py`: waveguide mode solving, unidirectional mode-source
|
||||
construction, overlap readout, and FDTD/FDFD comparison on a guided structure.
|
||||
- `examples/waveguide_real.py`: real-valued continuous-wave FDTD on a straight
|
||||
guide, with late-time monitor slices, guided-core windows, and mode-weighted
|
||||
errors compared directly against real fields reconstructed from the matching
|
||||
FDFD solution, plus a guided-mode / orthogonal-residual split.
|
||||
- `examples/eme.py`: straight-interface mode matching / EME, including port
|
||||
mode solving, interface scattering, and modal field visualization.
|
||||
- `examples/eme_bend.py`: straight-to-bent waveguide mode matching with
|
||||
cylindrical bend modes, interface scattering, and a cascaded bend-network
|
||||
example built with `scikit-rf`.
|
||||
- `examples/eme_taper_cmt.py`: sampled-interface EME with stable S cascading for a
|
||||
continuously varying rib-waveguide taper.
|
||||
- `examples/eme_taper_pml_modes.py`: targeted complex/PML mode solving,
|
||||
tracking, and construction of EME taper sections.
|
||||
- `examples/fdfd.py`: direct frequency-domain waveguide excitation and overlap /
|
||||
Poynting analysis without a time-domain run.
|
||||
|
||||
Several examples rely on optional packages such as
|
||||
[gridlock](https://mpxd.net/code/jan/gridlock).
|
||||
|
||||
### Frequency-domain waveguide workflow
|
||||
|
||||
For a structure with a constant cross-section in one direction:
|
||||
|
||||
1. Build `dxes` and the diagonal `epsilon` / `mu` distributions on the Yee grid.
|
||||
2. Solve the port mode with `meanas.fdfd.waveguide_3d.solve_mode(...)`.
|
||||
3. Build a unidirectional source with `compute_source(...)`.
|
||||
4. Build a matching overlap window with `compute_overlap_e(...)`.
|
||||
5. Solve the full FDFD problem and project the result onto the overlap window or
|
||||
evaluate plane flux with `meanas.fdfd.functional.poynting_e_cross_h(...)`.
|
||||
|
||||
### Time-domain phasor workflow
|
||||
|
||||
For a broadband or continuous-wave FDTD run:
|
||||
|
||||
1. Advance the fields with `meanas.fdtd.maxwell_e/maxwell_h` or
|
||||
`updates_with_cpml(...)`.
|
||||
2. Inject electric current using the same sign convention used throughout the
|
||||
examples and library: `E -= dt * J / epsilon`.
|
||||
3. Accumulate the desired phasor with `accumulate_phasor(...)` or the Yee-aware
|
||||
wrappers `accumulate_phasor_e/h/j(...)`.
|
||||
4. Build the matching FDFD operator on the stretched `dxes` if CPML/SCPML is
|
||||
part of the simulation, and compare the extracted phasor to the FDFD field or
|
||||
residual.
|
||||
|
||||
This is the primary FDTD/FDFD equivalence workflow. The phasor extraction step
|
||||
filters the time-domain run down to the guided `+\omega` content that FDFD
|
||||
solves for directly, so it is the cleanest apples-to-apples comparison.
|
||||
|
||||
### Real-field reconstruction workflow
|
||||
|
||||
For a continuous-wave real-valued FDTD run:
|
||||
|
||||
1. Build the analytic source phasor for the structure, for example with
|
||||
`waveguide_3d.compute_source(...)`.
|
||||
2. Run the real-valued FDTD simulation using the real part of that source.
|
||||
3. Solve the matching FDFD problem from the analytic source phasor on the
|
||||
stretched `dxes`.
|
||||
4. Reconstruct late real `E/H/J` snapshots with
|
||||
`reconstruct_real_e/h/j(...)` and compare those directly against the
|
||||
real-valued FDTD fields, ideally on a monitor window or mode-weighted norm
|
||||
centered on the guided field rather than on the full transverse plane. When
|
||||
needed, split the monitor field into guided-mode and orthogonal residual
|
||||
pieces to see whether the remaining mismatch is actually in the mode or in
|
||||
weak nonguided tails.
|
||||
|
||||
This is a stricter diagnostic, not the primary equivalence benchmark. A raw
|
||||
monitor slice contains both the guided field and the remaining orthogonal
|
||||
content on that plane,
|
||||
|
||||
$$ E_{\text{monitor}} = E_{\text{guided}} + E_{\text{residual}} , $$
|
||||
|
||||
so its full-plane instantaneous error is naturally noisier than the extracted
|
||||
phasor comparison even when the underlying guided `+\omega` content matches
|
||||
well.
|
||||
|
||||
`examples/waveguide_real.py` is the reference implementation of this workflow.
|
||||
|
|
|
|||
3
docs/api/eigensolvers.md
Normal file
3
docs/api/eigensolvers.md
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
# eigensolvers
|
||||
|
||||
::: meanas.eigensolvers
|
||||
77
docs/api/fdfd.md
Normal file
77
docs/api/fdfd.md
Normal file
|
|
@ -0,0 +1,77 @@
|
|||
# fdfd
|
||||
|
||||
::: meanas.fdfd
|
||||
|
||||
## Core operator layers
|
||||
|
||||
::: meanas.fdfd.functional
|
||||
|
||||
::: meanas.fdfd.operators
|
||||
|
||||
::: meanas.fdfd.solvers
|
||||
|
||||
::: meanas.fdfd.scpml
|
||||
|
||||
::: meanas.fdfd.farfield
|
||||
|
||||
## Bloch magnetic materials
|
||||
|
||||
Bloch state vectors store the transverse Fourier coefficients of magnetic flux
|
||||
`B = mu * H`. They equal `H` when permeability is omitted. Pass the same `mu`
|
||||
to `bloch.hmn_2_hxyz(...)` and `bloch.hmn_2_exyz(...)` when converting solved
|
||||
vectors to fields. The eigensolver uses the projected `mu**-1` energy metric
|
||||
for finite positive real permeability, including anisotropic and spatially
|
||||
varying profiles. Its preconditioner remains finite at the Gamma point.
|
||||
|
||||
## Far-field normalization
|
||||
|
||||
The near-to-far transform includes the cell area `dx * dy`, so normalized
|
||||
far-field amplitudes describe a Fourier integral and converge under spatial
|
||||
refinement. This changes amplitudes previously returned as unweighted FFT sums.
|
||||
The inverse applies the matching Fourier quadrature and returns spacings for
|
||||
the requested output shape. Both transforms center their origins at index
|
||||
`size // 2`; padding and cropping preserve that sample. The inverse does not
|
||||
modify input spectra.
|
||||
|
||||
Transforms use the library's `exp(+i omega t)` time convention: outgoing plane
|
||||
waves vary as `exp(-i k dot r)`, so the angular projection uses a positive
|
||||
Fourier phase. The inverse uses a negative phase. Far-field vector pairs are
|
||||
ordered as polar and azimuthal components; near-field pairs are Cartesian.
|
||||
|
||||
## Solver and port calibration
|
||||
|
||||
The default QMR wrapper raises `RuntimeError` on breakdown or failure to
|
||||
converge. PEC rows impose zero electric fields with unit diagonal entries;
|
||||
`solvers.generic` zeroes the corresponding source and initial-guess entries.
|
||||
H-only and EH operators impose analogous constraints for PMC locations.
|
||||
|
||||
FDFD port calibration uses the complete incoming-amplitude matrix from all
|
||||
excitations, solving `S @ incoming_amplitudes = raw_outgoing_amplitudes`.
|
||||
Diagnostics include these matrices and the incoming/outgoing flux Gram
|
||||
matrices. Guided powers retain cross terms between nonorthogonal modes.
|
||||
|
||||
Lossless modes at or above the propagation-grid band edge require a finer
|
||||
mesh for power normalization. Lorentz-normalized evanescent modes use the
|
||||
decaying spatial branch. Expansion on graded grids uses each electric
|
||||
component's own Yee intervals.
|
||||
|
||||
## SCPML conventions
|
||||
|
||||
`stretch_with_scpml` now uses `-1` for the low-index face and `+1` for the
|
||||
high-index face, matching CPML and propagation conventions. It returns copied
|
||||
widths by default; pass `copy=False` to request mutation explicitly.
|
||||
|
||||
Both SCPML builders accept `kappa_function(depth)` for real stretching and
|
||||
`max_imag_ratio` to limit the final dimensionless `abs(Im(s))/Re(s)`. Start a
|
||||
mode-solver convergence study with `max_imag_ratio=1.0`: overly strong imaginary
|
||||
stretching can produce above-light-line PML artifacts. The cap is not a general
|
||||
spectral guarantee, and weaker absorption can increase boundary reflections.
|
||||
Check domain size, PML thickness, strength, mode localization, and residuals.
|
||||
The general scattering profile remains uncapped by default.
|
||||
|
||||
`uniform_grid_scpml` builds unit widths by applying `stretch_with_scpml` to
|
||||
both faces of each enabled axis. Both builders divide imaginary grading by
|
||||
physical layer thickness and sample electric widths at cell centers and
|
||||
magnetic widths at cell edges. This corrects the uniform builder's previous
|
||||
thickness-independent strength and reversed E/H sample offsets; retune existing
|
||||
uniform-builder profiles using domain/PML convergence checks.
|
||||
26
docs/api/fdmath.md
Normal file
26
docs/api/fdmath.md
Normal file
|
|
@ -0,0 +1,26 @@
|
|||
# fdmath
|
||||
|
||||
For Gridlock's default E-field Yee shifts, construct solver spacings as
|
||||
`dxes = [grid.autoshifted_dxyz(), grid.dxyz]`. The forward E curl needs
|
||||
distances between adjacent base-cell centers; the backward H curl needs
|
||||
distances between adjacent upper cell edges. Reversing these two width families
|
||||
introduces an error on graded grids that uniform grids hide.
|
||||
|
||||
If constructing the mesh directly from **forward derivative intervals** `d`,
|
||||
with H samples at their midpoints, the backward intervals instead follow
|
||||
`(d + numpy.roll(d, 1)) / 2` for periodic boundaries. These `d` arrays are
|
||||
already center-to-center distances, whereas `grid.dxyz` contains base-cell
|
||||
volume widths. Applying this averaging rule to `grid.dxyz` does not fix the
|
||||
ordering error above.
|
||||
|
||||
::: meanas.fdmath
|
||||
|
||||
## Functional and sparse operators
|
||||
|
||||
::: meanas.fdmath.functional
|
||||
|
||||
::: meanas.fdmath.operators
|
||||
|
||||
::: meanas.fdmath.vectorization
|
||||
|
||||
::: meanas.fdmath.types
|
||||
24
docs/api/fdtd.md
Normal file
24
docs/api/fdtd.md
Normal file
|
|
@ -0,0 +1,24 @@
|
|||
# fdtd
|
||||
|
||||
::: meanas.fdtd
|
||||
|
||||
## Core update and analysis helpers
|
||||
|
||||
::: meanas.fdtd.base
|
||||
|
||||
::: meanas.fdtd.pml
|
||||
|
||||
::: meanas.fdtd.boundaries
|
||||
|
||||
::: meanas.fdtd.energy
|
||||
|
||||
::: meanas.fdtd.phasor
|
||||
|
||||
CPML derivatives use electric widths for forward differences and magnetic
|
||||
widths for backward differences. `cpml_params(..., dx=1.0)` specifies the uniform
|
||||
physical cell width normal to a face; arbitrary nonuniform PML grading is not
|
||||
implemented by this constructor. Scale the timestep consistently with the grid.
|
||||
|
||||
`ln_R_per_layer` must be finite and strictly negative. Zero attenuation raises
|
||||
`ValueError`; disable individual CPML faces with `None` in the parameter table
|
||||
passed to `updates_with_cpml`.
|
||||
14
docs/api/index.md
Normal file
14
docs/api/index.md
Normal file
|
|
@ -0,0 +1,14 @@
|
|||
# API Overview
|
||||
|
||||
The package is documented directly from its docstrings. The most useful entry
|
||||
points are:
|
||||
|
||||
- [meanas](meanas.md): top-level package overview
|
||||
- [eigensolvers](eigensolvers.md): generic eigenvalue utilities used by the mode solvers
|
||||
- [fdfd](fdfd.md): frequency-domain operators, sources, PML, solvers, and far-field transforms
|
||||
- [waveguides](waveguides.md): straight, cylindrical, and 3D waveguide mode helpers
|
||||
- [fdtd](fdtd.md): timestepping, CPML, energy/flux helpers, and phasor extraction
|
||||
- [fdmath](fdmath.md): shared discrete operators, vectorization helpers, and derivation background
|
||||
|
||||
The waveguide and FDTD pages are the best places to start if you want the
|
||||
mathematical derivations rather than just the callable reference.
|
||||
3
docs/api/meanas.md
Normal file
3
docs/api/meanas.md
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
# meanas
|
||||
|
||||
::: meanas
|
||||
153
docs/api/waveguides.md
Normal file
153
docs/api/waveguides.md
Normal file
|
|
@ -0,0 +1,153 @@
|
|||
# waveguides
|
||||
|
||||
::: meanas.fdfd.waveguide_2d
|
||||
|
||||
::: meanas.fdfd.waveguide_3d
|
||||
|
||||
::: meanas.fdfd.waveguide_cyl
|
||||
|
||||
## Overlap measures and normalization
|
||||
|
||||
`waveguide_2d.inner_product(..., measure="physical", conj_h=True)` uses real
|
||||
Yee widths for physical Poynting power. `measure="stretched"` keeps complex
|
||||
widths for coordinate reaction. `lorentz_metric` and `lorentz_overlap` default
|
||||
to the stretched measure. Use the same grid and measure when constructing and
|
||||
using dual fields. A real overlap grid still defines a consistent constructed
|
||||
dual basis, even when the eigenproblem uses a separate PML grid.
|
||||
|
||||
`normalized_fields_e/h(..., normalization="lorentz")` normalizes unconjugated
|
||||
self-reaction to one. This fixes phase up to a sign and is distinct from unit
|
||||
forward power, which remains the default. Zero-power or self-orthogonal modes
|
||||
raise `ValueError`; open self-orthogonal modes require paired primal/dual
|
||||
normalization through `ModeBasis`.
|
||||
|
||||
## Targeted and reproducible mode solving
|
||||
|
||||
For modes near an effective index guess, use `solve_modes_near` with
|
||||
`target_wavenumbers=[omega * n_guess]`. It targets the electric beta-squared
|
||||
operator at `(omega * n_guess)**2`; `solve_modes_near_beta` instead targets the
|
||||
first-order signed-beta operator. Both use the LU shift-invert backend and
|
||||
support `eigensolver_opts={"v0": starting_vector}`. Factorization cost and
|
||||
memory depend on the grid, so this is not universally faster than indexed
|
||||
solving. `solve_modes` keeps its global mode-number semantics and now accepts
|
||||
`rng` or `v0` for reproducible initialization.
|
||||
|
||||
`waveguide_3d.mode_from_2d` accepts a supplied transverse electric eigenvector
|
||||
and reuses field reconstruction, normalization, numerical-dispersion
|
||||
correction, Yee staggering, rotation, and full-grid embedding without solving
|
||||
an eigenproblem.
|
||||
|
||||
## Interface and sampled-taper scattering
|
||||
|
||||
All scattering matrices use outgoing rows and incoming columns, ordered
|
||||
`[left, right]`:
|
||||
|
||||
```text
|
||||
[b_left ] [R_left T_right_to_left] [a_left ]
|
||||
[b_right] = [T_left_to_right R_right] [a_right]
|
||||
```
|
||||
|
||||
`get_s` and `get_abcd` require explicit `dxes`. Mixed Petrov-Galerkin testing is
|
||||
the default: left electric duals test H continuity, and right magnetic duals
|
||||
test E continuity. Both incidence directions are solved together with full
|
||||
projection matrices. Mixed scattering supports unequal mode counts.
|
||||
`formulation="galerkin"` selects equal-count left testing of both equations.
|
||||
Neither formulation silently clips transmission. The optional `force_nogain`
|
||||
and `force_reciprocal` flags are numerical projections, not general physical
|
||||
tests for arbitrary open or evanescent modal coordinates.
|
||||
|
||||
`get_taper_s` replaces finite-difference CMT with half propagation in the left
|
||||
basis, a midpoint interface, and half propagation in the right basis for each
|
||||
sampled interval. Redheffer composition avoids growing passive backward
|
||||
transfer branches. Refine section sampling and modal/PML bases to establish
|
||||
convergence. The ineffective `rtol`, `atol`, and `max_step` arguments have been
|
||||
removed. The existing `eme_taper_cmt.py` example filename is retained.
|
||||
|
||||
```python
|
||||
prepared = eme.prepare_taper(sections, dxes)
|
||||
s_original = eme.evaluate_taper_s(prepared)
|
||||
s_longer = eme.evaluate_taper_s(prepared, z_coords=prepared.z_coords * 1.2)
|
||||
s_changed_beta = eme.evaluate_taper_s(
|
||||
prepared, wavenumber_matrices=beta_matrices,
|
||||
)
|
||||
```
|
||||
|
||||
`PreparedTaper` owns read-only copies of phase-aligned interface data. Beta
|
||||
matrix overrides have shape `(section, mode, mode)` in the original supplied
|
||||
section bases; recorded basis transforms are applied automatically. Explicit
|
||||
backward branches require backward beta overrides when forward beta is changed.
|
||||
Evaluation performs no field overlaps or eigensolves. Length sweeps reuse the
|
||||
sampled model; wavelength sweeps with reused fields are explicitly frozen-basis
|
||||
approximations. Reprepare when fields, duals, grids, or formulations change.
|
||||
|
||||
`cascade_s(left, right, internal_modes=...)` connects spatially ordered S
|
||||
matrices, including unequal external ports. Public `abcd_to_s` and `s_to_abcd`
|
||||
use `[f_right, b_right] = ABCD @ [f_left, b_left]` and require equal port counts.
|
||||
`get_taper_abcd` converts the stable S result; zero transmission or an
|
||||
unrepresentable transfer matrix raises `LinAlgError`. Prefer S for long lossy
|
||||
devices. Singular interface and cascade systems also raise contextual errors
|
||||
rather than silently substituting pseudoinverses.
|
||||
|
||||
::: meanas.fdfd.eme
|
||||
|
||||
## Orientation bias under modal truncation
|
||||
|
||||
Mixed testing is a projected approximation: H continuity is tested on the left
|
||||
and E continuity on the right. Swapping the ports changes the testing spaces
|
||||
when the retained modal subspaces are incomplete. This effect survives checks
|
||||
of reciprocity and unitarity.
|
||||
|
||||
A reproducible Maxwell counterexample is a uniform isotropic medium with two
|
||||
degenerate linear polarizations. Keep one polarization on each port, rotated
|
||||
so their overlap is `a=0.8`. There is no material interface: true reflection is
|
||||
zero and transmission into the retained receiver is `a`. The other polarization
|
||||
carries the remaining transmitted power, `1-a**2=0.36`.
|
||||
|
||||
| Calculation | R_left | R_right | T_left_to_right | T_right_to_left |
|
||||
| --- | ---: | ---: | ---: | ---: |
|
||||
| Exact full basis, then restrict ports | 0 | 0 | 0.8 | 0.8 |
|
||||
| Truncated mixed | 0.219512 | -0.219512 | 0.975610 | 0.975610 |
|
||||
| Swap ports, mixed, then reorder | -0.219512 | 0.219512 | 0.975610 | 0.975610 |
|
||||
| Truncated left Galerkin | 0 | 0 | 1.25 | 0.8 |
|
||||
| Euclidean E/H least squares | 0 | 0 | 0.8 | 0.8 |
|
||||
|
||||
An independent driven 3D FDFD solve with PML agrees with the exact reference
|
||||
from either incidence direction: transmission is 0.8 within `1e-12`, with
|
||||
reflection below `2e-8` in the test fixture. Keeping both polarizations makes
|
||||
mixed testing match the exact complete scattering matrix and restores
|
||||
port-relabeling covariance.
|
||||
|
||||
For the single retained polarization, mixed testing yields
|
||||
`r=(1-a**2)/(1+a**2)` and `t=2*a/(1+a**2)`. The spurious reflection is quadratic
|
||||
in a small angle between adjacent retained polarizations. However, longitudinal
|
||||
refinement alone is insufficient: rotating a single retained vector through a
|
||||
uniform degenerate medium makes the sampled chain approach artificial following
|
||||
of that vector (`|T|` approaches 1), while the physical endpoint overlap remains
|
||||
0.8. Keeping the complete degenerate block recovers the physical result at every
|
||||
sampling density tested.
|
||||
|
||||
Two tempting corrections are insufficient. Averaging the two port orientations
|
||||
cancels reflection in this example but leaves transmission at 0.975610. Plain
|
||||
Euclidean E/H least squares gives the correct uniform-medium result, but is not
|
||||
a general replacement. A second fixture uses exact degenerate modes of diagonal
|
||||
positive epsilon/mu tensors, with electric scaling `(1,2)` on the left and
|
||||
`(1,3)` on the right and a 30-degree polarization rotation on both ports. After
|
||||
single-mode truncation, least squares has unequal directional transmissions
|
||||
(approximately 0.850839 and 1.092163) and a maximum singular value of 1.104947.
|
||||
The complete Fresnel solution is reciprocal and lossless.
|
||||
|
||||
The mixed default remains unchanged. Retain complete coupled/degenerate blocks
|
||||
when the geometry can mix them, check modal-basis convergence as well as section
|
||||
sampling, and compare against independent full-field results. Neither orientation
|
||||
averaging nor gain/reciprocity postprocessing recovers omitted-channel physics.
|
||||
Orientation discrepancy is a useful diagnostic, not a bound on transmission
|
||||
error. These examples use real power-orthonormal propagating modes; for general
|
||||
complex modes, the reciprocity constraint involves the modal orthogonality
|
||||
matrix, as derived by [Svendsen, Haakestad, and Skaar](https://arxiv.org/abs/1301.2458).
|
||||
|
||||
Reproduce the analytic, full-basis, candidate-formulation, taper-refinement, and
|
||||
driven-FDFD checks with:
|
||||
|
||||
```sh
|
||||
OPENBLAS_NUM_THREADS=1 python -m pytest meanas/test/test_eme_orientation.py -q
|
||||
```
|
||||
1
docs/assets/vendor/mathjax/core.js
vendored
Normal file
1
docs/assets/vendor/mathjax/core.js
vendored
Normal file
File diff suppressed because one or more lines are too long
1
docs/assets/vendor/mathjax/input/asciimath.js
vendored
Normal file
1
docs/assets/vendor/mathjax/input/asciimath.js
vendored
Normal file
File diff suppressed because one or more lines are too long
1
docs/assets/vendor/mathjax/input/mml.js
vendored
Normal file
1
docs/assets/vendor/mathjax/input/mml.js
vendored
Normal file
File diff suppressed because one or more lines are too long
1
docs/assets/vendor/mathjax/input/mml/entities.js
vendored
Normal file
1
docs/assets/vendor/mathjax/input/mml/entities.js
vendored
Normal file
File diff suppressed because one or more lines are too long
34
docs/assets/vendor/mathjax/input/tex-full.js
vendored
Normal file
34
docs/assets/vendor/mathjax/input/tex-full.js
vendored
Normal file
File diff suppressed because one or more lines are too long
1
docs/assets/vendor/mathjax/loader.js
vendored
Normal file
1
docs/assets/vendor/mathjax/loader.js
vendored
Normal file
File diff suppressed because one or more lines are too long
38
docs/assets/vendor/mathjax/manifest.json
vendored
Normal file
38
docs/assets/vendor/mathjax/manifest.json
vendored
Normal file
|
|
@ -0,0 +1,38 @@
|
|||
{
|
||||
"etag": "7ab8013dfc2c395304109fe189c1772ef87b366a",
|
||||
"files": {
|
||||
"core.js": 212262,
|
||||
"loader.js": 16370,
|
||||
"startup.js": 22870,
|
||||
"input/tex-full.js": 270711,
|
||||
"input/asciimath.js": 107690,
|
||||
"input/mml.js": 13601,
|
||||
"input/mml/entities.js": 32232,
|
||||
"output/chtml.js": 211041,
|
||||
"output/chtml/fonts/tex.js": 104359,
|
||||
"output/chtml/fonts/woff-v2/MathJax_Zero.woff": 1368,
|
||||
"output/chtml/fonts/woff-v2/MathJax_Vector-Regular.woff": 1136,
|
||||
"output/chtml/fonts/woff-v2/MathJax_Vector-Bold.woff": 1116,
|
||||
"output/chtml/fonts/woff-v2/MathJax_Typewriter-Regular.woff": 17604,
|
||||
"output/chtml/fonts/woff-v2/MathJax_Size4-Regular.woff": 5148,
|
||||
"output/chtml/fonts/woff-v2/MathJax_Size3-Regular.woff": 3244,
|
||||
"output/chtml/fonts/woff-v2/MathJax_Size2-Regular.woff": 5464,
|
||||
"output/chtml/fonts/woff-v2/MathJax_Size1-Regular.woff": 5792,
|
||||
"output/chtml/fonts/woff-v2/MathJax_Script-Regular.woff": 11852,
|
||||
"output/chtml/fonts/woff-v2/MathJax_SansSerif-Regular.woff": 12660,
|
||||
"output/chtml/fonts/woff-v2/MathJax_SansSerif-Italic.woff": 14628,
|
||||
"output/chtml/fonts/woff-v2/MathJax_SansSerif-Bold.woff": 15944,
|
||||
"output/chtml/fonts/woff-v2/MathJax_Math-Regular.woff": 19288,
|
||||
"output/chtml/fonts/woff-v2/MathJax_Math-Italic.woff": 19360,
|
||||
"output/chtml/fonts/woff-v2/MathJax_Math-BoldItalic.woff": 19776,
|
||||
"output/chtml/fonts/woff-v2/MathJax_Main-Regular.woff": 34160,
|
||||
"output/chtml/fonts/woff-v2/MathJax_Main-Italic.woff": 20832,
|
||||
"output/chtml/fonts/woff-v2/MathJax_Main-Bold.woff": 34464,
|
||||
"output/chtml/fonts/woff-v2/MathJax_Fraktur-Regular.woff": 21480,
|
||||
"output/chtml/fonts/woff-v2/MathJax_Fraktur-Bold.woff": 22340,
|
||||
"output/chtml/fonts/woff-v2/MathJax_Calligraphic-Regular.woff": 9600,
|
||||
"output/chtml/fonts/woff-v2/MathJax_Calligraphic-Bold.woff": 9908,
|
||||
"output/chtml/fonts/woff-v2/MathJax_AMS-Regular.woff": 40808
|
||||
},
|
||||
"version": "3.1.4"
|
||||
}
|
||||
1
docs/assets/vendor/mathjax/output/chtml.js
vendored
Normal file
1
docs/assets/vendor/mathjax/output/chtml.js
vendored
Normal file
File diff suppressed because one or more lines are too long
1
docs/assets/vendor/mathjax/output/chtml/fonts/tex.js
vendored
Normal file
1
docs/assets/vendor/mathjax/output/chtml/fonts/tex.js
vendored
Normal file
File diff suppressed because one or more lines are too long
BIN
docs/assets/vendor/mathjax/output/chtml/fonts/woff-v2/MathJax_AMS-Regular.woff
vendored
Normal file
BIN
docs/assets/vendor/mathjax/output/chtml/fonts/woff-v2/MathJax_AMS-Regular.woff
vendored
Normal file
Binary file not shown.
BIN
docs/assets/vendor/mathjax/output/chtml/fonts/woff-v2/MathJax_Calligraphic-Bold.woff
vendored
Normal file
BIN
docs/assets/vendor/mathjax/output/chtml/fonts/woff-v2/MathJax_Calligraphic-Bold.woff
vendored
Normal file
Binary file not shown.
Some files were not shown because too many files have changed in this diff Show more
Loading…
Reference in a new issue