Metadata-Version: 2.4
Name: twpasolver
Version: 0.1.0
Summary: Simulation of kinetic-inductance traveling-wave parametric amplifiers: circuit models, Bloch-mode coupled mode equations, gain and phase matching.
License-Expression: Apache-2.0
License-File: LICENSE
Keywords: TWPA,KI-TWPA,kinetic inductance,parametric amplifier,coupled mode equations,superconducting circuits,Bloch modes
Author: twpalab
Maintainer: Pietro Campana
Maintainer-email: p.campana1@campus.unimib.it
Requires-Python: >=3.10,<4.0
Classifier: Development Status :: 4 - Beta
Classifier: Intended Audience :: Science/Research
Classifier: Topic :: Scientific/Engineering :: Physics
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.13
Requires-Dist: h5py (>=3.10,<4)
Requires-Dist: matplotlib (>=3.7)
Requires-Dist: networkx (>=3.0)
Requires-Dist: numba (>=0.59.0)
Requires-Dist: numpy (>=1.26)
Requires-Dist: pydantic (>=2.6.3)
Requires-Dist: scikit-rf (>=0.32.0)
Requires-Dist: scipy (>=1.12.0)
Requires-Dist: typing-extensions (>=4.6)
Project-URL: Documentation, https://twpalab.github.io/twpasolver/
Project-URL: Repository, https://github.com/twpalab/twpasolver
Description-Content-Type: text/markdown

# twpasolver

Simulation of traveling-wave parametric amplifiers (TWPAs) with coupled mode equations (CMEs).

> **Scope:** this release simulates **kinetic-inductance TWPAs (KI-TWPAs)**. The cells of the line can be any linear
> circuit, but the only nonlinearity is that of a kinetic inductance. Josephson-junction devices are not
> supported yet.

- **Circuit models**: lumped and distributed elements, composed into unit cells, supercells and multi-segment devices.
  ABCD/S/Z parameters of any two-port network. User-defined models are supported.
- **Linear response**: Bloch wavenumber, attenuation and impedance, stopbands, transmission.
- **Two gain models**:
  - `simple`: the traditional forward-only CMEs of a homogeneous line. Fast, for quick sweeps and comparison with
    the literature.
  - `bloch`: forward and backward waves in the exact Bloch-mode basis of the loaded line, with reflections at the
    ends from arbitrary connectors and internal reflections at the junctions between segments.
    Port-resolved gains (S21, S12, S11, S22). Equivalent to harmonic balance simulations in preliminary testing.
- **Mode sets** Automatically builds all 3WM and 4WM interactions with any number of modes and independent tones
  (pump harmonics, frequency conversion sidebands, multiple pumps), with the rotating-wave terms found exactly.

## Documentation

Tutorials, physics notes and the API reference: <https://twpalab.github.io/twpasolver/>.

## Installation

```bash
pip install twpasolver
```

The CME solvers are compiled with Numba and cached to disk on first use. Run the warmup once after installing to
compile them up front (a few minutes), instead of the first time you run an analysis:

```bash
twpasolver-warmup
```

For development, clone the repository and install with Poetry and the pre-commit hooks:

```bash
git clone https://github.com/twpalab/twpasolver
cd twpasolver
poetry install --with docs,analysis
pre-commit install
```

## Example

The gain of the kinetic-inductance TWPA used in the tutorials, at the pump that best phase matches the 4-12 GHz band:

```python
import numpy as np
from twpasolver import TWPAnalysis

an = TWPAnalysis(twpa="docs/source/notebooks/imskit_v3_holotype.json", freqs=(0.2, 40, 2e-3))
pm = an.phase_matching(signal_freqs=(4, 12, 0.1), pump_freqs=(14, 18, 0.05))
result = an.gain(np.linspace(4, 12, 151), pump=pm.optimal_pump_freq, model="bloch")
print(f"pump {pm.optimal_pump_freq:.2f} GHz, mean gain {result.bandwidth()['mean_gain']:.1f} dB")
result.plot()
```

## Citing

If you use twpasolver in published work, please cite the repository: <https://github.com/twpalab/twpasolver>.

## License

twpasolver is licensed under the [Apache License 2.0](https://github.com/twpalab/twpasolver/blob/main/LICENSE).

