Metadata-Version: 2.4
Name: PyNJ
Version: 0.1.1
Summary: Time-reversal FDFD solver for photonic nanojet (PNJ) generation
Author-email: Tobias Abilock Mikkelsen <tobias.ab.mikk@gmail.com>, Cristian Placinta <s234615@student.dtu.dk>
License: MIT License
        
        Copyright (c) 2026 tmname64
        
        Permission is hereby granted, free of charge, to any person obtaining a copy
        of this software and associated documentation files (the "Software"), to deal
        in the Software without restriction, including without limitation the rights
        to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
        copies of the Software, and to permit persons to whom the Software is
        furnished to do so, subject to the following conditions:
        
        The above copyright notice and this permission notice shall be included in all
        copies or substantial portions of the Software.
        
        THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
        IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
        FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
        AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
        LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
        OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
        SOFTWARE.
        
Project-URL: Homepage, https://github.com/tmname64/PyNJ
Project-URL: Repository, https://github.com/tmname64/PyNJ
Project-URL: Bug Tracker, https://github.com/tmname64/PyNJ/issues
Keywords: photonics,nanojet,FDFD,time-reversal,simulation
Classifier: License :: OSI Approved :: MIT License
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Topic :: Scientific/Engineering :: Physics
Classifier: Intended Audience :: Science/Research
Requires-Python: >=3.10
Description-Content-Type: text/markdown
License-File: LICENSE
Requires-Dist: numpy
Requires-Dist: autograd
Requires-Dist: ceviche
Requires-Dist: svgpathtools
Requires-Dist: shapely
Dynamic: license-file

# PyNJ

A time-reversal FDFD solver for generating photonic nanojets (PNJ) with dielectric lenses.

## Installation

```bash
pip install PyNJ
```

## Quick start

```python
from timereversal import Solver

solver = Solver(
    lambda0=532e-9,   # wavelength in meters
    n_bg=1.0,         # background refractive index
    n_lens=1.5,       # lens refractive index
    Lx=10e-6,         # simulation domain width (m)
    Ly=10e-6,         # simulation domain height (m)
    ppum=20,          # pixels per micrometer
    R_lens=2e-6,      # lens radius (m)
    x0_lens=0.0,      # lens center x (m)
    y0_lens=0.0,      # lens center y (m)
    shape="circle",   # lens shape
)

result = solver.solve(x=0.0, y=3.0)  # target PNJ position in micrometers
```

## Lens shapes

The following shapes are supported via the `shape` parameter:

| Shape | Description |
|---|---|
| `"circle"` | Circular lens |
| `"square"` | Square lens |
| `"superformula"` | Gielis superformula shape (parametric) |
| `"triangle"` | Triangular SVG mask |
| `"triangle_flipped"` | Flipped triangle |
| `"triangle_rounded"` | Rounded triangle |
| `"square_concave"` | Square with concave sides |
| `"square_convex"` | Square with convex sides |
| `"clepsidra"` | Hourglass shape |
| `"clepsidra_flipped"` | Flipped hourglass |
| `"clepsidra_rounded"` | Rounded hourglass |
| `"hz"` | Arbitrary SVG mask (Hz mode) |

Custom SVG masks can be loaded by passing `svg_folder` pointing to a directory of `.svg` files and setting `shape` to the filename stem.

## Result fields

`solver.solve()` returns a `SimulationResult` dataclass with:

- `Hz`, `Ex`, `Ey` — complex field arrays
- `Iz` — normalised intensity `|Hz|`
- `x`, `y` — coordinate axes (meters)
- `x_pnj`, `y_pnj` — snapped PNJ target coordinates
- `entrance`, `src_line` — aperture fields used for the time-reversed source
- `eps_r` — permittivity map
- `i_pnj`, `j_pnj`, `j_src` — grid indices

## License

MIT
