Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 5ca4f27f22 | |||
| 35ec8b4325 | |||
| 35b5a8c5b9 | |||
| 9ef62b92d5 | |||
| 711ce119d0 | |||
| 6937bbf455 | |||
| ce3e47daa9 | |||
| 99461dc129 | |||
| 0ad78271ca | |||
| 2c5c40c1e7 |
132 changed files with 5039 additions and 17998 deletions
4
.gitignore
vendored
4
.gitignore
vendored
|
|
@ -54,10 +54,6 @@ coverage.xml
|
||||||
|
|
||||||
# documentation
|
# documentation
|
||||||
doc/
|
doc/
|
||||||
site/
|
|
||||||
_doc_mathimg/
|
|
||||||
doc.md
|
|
||||||
doc.htex
|
|
||||||
|
|
||||||
# PyBuilder
|
# PyBuilder
|
||||||
target/
|
target/
|
||||||
|
|
|
||||||
158
README.md
158
README.md
|
|
@ -49,28 +49,13 @@ linear systems, ideally with double precision.
|
||||||
|
|
||||||
**Requirements:**
|
**Requirements:**
|
||||||
|
|
||||||
* python >=3.12
|
* python >=3.11
|
||||||
* numpy
|
* numpy
|
||||||
* scipy
|
* scipy
|
||||||
|
|
||||||
|
|
||||||
Install from PyPI with pip:
|
Install from PyPI with pip:
|
||||||
```bash
|
```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]'
|
pip3 install 'meanas[dev]'
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|
@ -95,13 +80,9 @@ source my_venv/bin/activate
|
||||||
# Install in-place (-e, editable) from ./meanas, including development dependencies ([dev])
|
# Install in-place (-e, editable) from ./meanas, including development dependencies ([dev])
|
||||||
pip3 install --user -e './meanas[dev]'
|
pip3 install --user -e './meanas[dev]'
|
||||||
|
|
||||||
# Fast local iteration: excludes slower 3D/integration/example-smoke checks
|
# Run tests
|
||||||
cd meanas
|
cd meanas
|
||||||
python3 -m pytest -q -m "not complete"
|
python3 -m pytest -rsxX | tee test_results.txt
|
||||||
|
|
||||||
# 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:
|
#### See also:
|
||||||
|
|
@ -113,133 +94,6 @@ python3 -m pytest -q | tee test_results.txt
|
||||||
|
|
||||||
## Use
|
## Use
|
||||||
|
|
||||||
`meanas` is a collection of finite-difference electromagnetics tools:
|
See `examples/` for some simple examples; you may need additional
|
||||||
|
packages such as [gridlock](https://mpxd.net/code/jan/gridlock)
|
||||||
- `meanas.fdfd`: frequency-domain wave equations, sparse operators, SCPML, and
|
to run the examples.
|
||||||
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.
|
|
||||||
|
|
|
||||||
|
|
@ -1,3 +0,0 @@
|
||||||
# eigensolvers
|
|
||||||
|
|
||||||
::: meanas.eigensolvers
|
|
||||||
|
|
@ -1,77 +0,0 @@
|
||||||
# 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.
|
|
||||||
|
|
@ -1,26 +0,0 @@
|
||||||
# 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
|
|
||||||
|
|
@ -1,24 +0,0 @@
|
||||||
# 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`.
|
|
||||||
|
|
@ -1,14 +0,0 @@
|
||||||
# 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.
|
|
||||||
|
|
@ -1,3 +0,0 @@
|
||||||
# meanas
|
|
||||||
|
|
||||||
::: meanas
|
|
||||||
|
|
@ -1,153 +0,0 @@
|
||||||
# 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
1
docs/assets/vendor/mathjax/core.js
vendored
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
1
docs/assets/vendor/mathjax/input/mml.js
vendored
1
docs/assets/vendor/mathjax/input/mml.js
vendored
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
34
docs/assets/vendor/mathjax/input/tex-full.js
vendored
34
docs/assets/vendor/mathjax/input/tex-full.js
vendored
File diff suppressed because one or more lines are too long
1
docs/assets/vendor/mathjax/loader.js
vendored
1
docs/assets/vendor/mathjax/loader.js
vendored
File diff suppressed because one or more lines are too long
38
docs/assets/vendor/mathjax/manifest.json
vendored
38
docs/assets/vendor/mathjax/manifest.json
vendored
|
|
@ -1,38 +0,0 @@
|
||||||
{
|
|
||||||
"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
1
docs/assets/vendor/mathjax/output/chtml.js
vendored
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
Binary file not shown.
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