Skip to main content

kpenvelope

PyPI DOI tests

kpenvelope is a free Python package for nitride semiconductors (GaN, AlN, InN and their alloys). It started as a tool for one question: what energy levels do holes have when they are trapped in a thin GaN layer? It has since grown to cover the whole path from a stack of layers to a working transistor.

Every material number in it comes with a written source, and every model is checked against an exact answer or an independent calculation in tests you can run yourself. When an input cannot give a result you can trust, it stops and tells you why instead of printing a number that only looks right.

What it can do

Layers and charges

  • Energy levels, wavefunctions and masses of holes trapped in thin layers, with the hole gas's own charge included.
  • Light absorption between those levels, and what a measured magnetoresistance (Shubnikov-de Haas) curve says about density and mass.
  • The fixed charge at each interface of a nitride stack, also when a layer has partly relaxed.
  • The electron density of a transistor layer, with error bars, fits to measured C-V curves and Hall data, and a search for the layer design that gives the density and switch-off voltage you want.

Whole devices, in 2D and 3D

  • Current in transistors and diodes, traps that fill and empty over time, self-heating down to the heat sink (with the heat that carriers carry across contacts and junctions, if you want it), and the speed limits f_T and f_max.
  • Breakdown (avalanche, a current limit, or thermal runaway), tunneling through barriers and between bands (including tunnel diodes), hot electrons, and electrons hopping over band steps.
  • Leakage and band gaps that change with temperature, so a leaky device can heat itself into runaway.
  • Shaped devices: films, recesses, field plates, and curved or slanted shapes on triangle meshes.
  • Simple process steps that build the shape and the doping: deposition, etching, oxidation, implants and anneals.

An app that runs many of these calculations in your web browser, with no code: charges, electrons, error bars, data fits, transistors with heat and runaway, tunnel diodes, and process steps.

Install

pip install "kpenvelope[device]"

It needs Python 3.9 or newer and NumPy. The device part also needs SciPy, which the [device] option installs. Then start the app with:

kpenvelope-app

It runs on your own computer only. You build the layers on the left and read the results on the right, and each result starts with a sentence that says what it means.

A first look

Units: energies in eV, lengths in nm, densities in cm^-3 or nm^-3 (the docs say which), currents per millimeter of device width (A/mm).

Energy levels of holes in a 5 nm GaN layer

import numpy as np
from kpenvelope import gan_rinke2008, solve_subbands, band_character

p = gan_rinke2008()                  # cited GaN parameter set
z = np.linspace(0.0, 5.0, 51)        # a 5 nm layer, grid in nm

energies, envelopes = solve_subbands(p, z, n_states=4)
frac = band_character(envelopes, z)  # columns: HH, LH, CH
for e, (hh, lh, ch) in zip(energies, frac):
    print(f"E = {e*1e3:8.2f} meV   HH {hh:.3f}  LH {lh:.3f}  CH {ch:.3f}")
E =     8.26 meV   HH 1.000  LH 0.000  CH 0.000
E =     8.26 meV   HH 1.000  LH 0.000  CH 0.000
E =    -2.28 meV   HH 0.000  LH 0.990  CH 0.010
E =    -2.28 meV   HH 0.000  LH 0.990  CH 0.010

The levels come in pairs with the same energy. The top pair is pure heavy hole (HH); the next is mostly light hole (LH).

The charge at an AlGaN/GaN interface

from kpenvelope import StackLayer, algan, interface_charges

gan, bar = algan(0.0), algan(0.22)                 # PBEsol polarization set
for lc in ("bare", "neutral", "electron-counting"):
    stack = [StackLayer(gan, 2000.0), StackLayer(bar, 103.0, relaxation=0.78)]
    c = interface_charges(stack, line_charge=lc)[0]
    print(f"{lc:18s} Lambda = {c.line_charge:+.3f} e/nm   sigma = {c.sigma_cm2:.3e} cm^-2")
c0 = interface_charges([StackLayer(gan, 2000.0), StackLayer(bar, 103.0)])[0]
print(f"coherent barrier                        sigma = {c0.sigma_cm2:.3e} cm^-2")
print(f"mismatch {c.eps_c:.5f}, misfit lines {c.line_density * 1e7:.3e} cm/cm^2")
bare               Lambda = -2.645 e/nm   sigma = 3.564e+12 cm^-2
neutral            Lambda = +0.000 e/nm   sigma = 1.051e+13 cm^-2
electron-counting  Lambda = +0.085 e/nm   sigma = 1.073e+13 cm^-2
coherent barrier                        sigma = 1.432e+13 cm^-2
mismatch 0.00534, misfit lines 2.626e+05 cm/cm^2

When the barrier relaxes, the charge drops. How far it drops depends on the charge carried by the dislocation lines that let it relax, which no standard recipe decides, so the package asks you to choose and shows the range.

The current of a GaN transistor

from kpenvelope import StackLayer, algan
from kpenvelope.device import Device, Electrode, Mobility, Surface

layers = [StackLayer(algan(0.0), 1000.0, name="buffer"),
          StackLayer(algan(0.25), 20.0, name="barrier")]
mob = Mobility(1704.0, "Alpert et al., Rev. Sci. Instrum. 91 (2020)",
               saturation_velocity=1.0e7, temperature_exponent=2.35)
contacts = [Electrode("source", "ohmic", 0, 500, implant_depth=40, implant_donors=1e20),
            Electrode("gate", "schottky", 1500, 1750, barrier=1.0),
            Electrode("drain", "ohmic", 3000, 3500, implant_depth=40, implant_donors=1e20)]
dev = Device(layers, 3500.0, contacts, mob, Surface("pinned", barrier=1.0),
             dx_fine=10, dx_max=100, dz_fine=1.0, dz_max=100)
for vg in (0.0, -2.0, -4.0):
    st = dev.solve({"gate": vg, "drain": 5.0})
    print(f"gate {vg:+.0f} V, drain 5 V: {st.current['drain']:.3f} A/mm")
gate +0 V, drain 5 V: 1.046 A/mm
gate -2 V, drain 5 V: 0.852 A/mm
gate -4 V, drain 5 V: 0.339 A/mm

The mobility comes from a cited measurement; the top speed of 1e7 cm/s is a round number for the example. Add thermal= to let the current heat the device, and the current drops as it warms (example 28 in the docs).

Learn more

The details live in the docs folder:

  • Examples: 50 worked examples, each with the output it prints, and three tutorials that go from measured data to a result with error bars.
  • Reference: every function and option, the units, a glossary of the terms, the cited material numbers, and the cases where the package refuses to answer.
  • How it is checked: what each test compares against and how closely, and the corrections made in past versions.
  • Limits: what the models leave out, in detail.
  • Changes from version to version.

How it is checked

More than 300 automated tests run on every change, on Python 3.9 to 3.14 and with the oldest NumPy and SciPy the package allows. Most of them compare against an exact formula, a symmetry, or the same quantity worked out a second, different way. Two examples: a 2D device and the same device on a triangle mesh must give the same current to ten digits, and the leakage that drives a device into thermal runaway must match the simple heat-balance model at the voltage where runaway starts. The full list is in How it is checked.

What it does not do

The main gaps, in plain terms:

  • Carriers are treated as classical particles in the device part: no quantum confinement of the transistor channel and no ballistic transport. The quantum solvers handle single layers and stacks, not whole devices.
  • Process steps are simple. Oxidation is one-dimensional in each column (no growth under a mask edge), etching and deposition follow fixed rates (no plasma or gas chemistry), implant ranges and diffusion constants come from you, and the shapes are built from square cells.
  • The built-in meshes are simple. For complex shapes, bring a mesh from a mesh generator.
  • Tunneling between bands follows straight paths in one direction, not paths that bend with the field. Models that depend on each other, such as tunneling and heat, are solved by taking turns, which is slower than solving them together.
  • The heat carried by electrons uses a simple form that comes out too small where the electrons are very dense, as in a transistor channel.
  • No scattering lifetimes, and no material numbers without a source: where a number is missing, you supply it with its source.
  • There is no paid support. Questions and bug reports go to the issue tracker.

The full list is in Limits.

Citing

If kpenvelope helps your work, please cite it with the concept DOI 10.5281/zenodo.22015269, which always points to the latest version (CITATION.cff has the details). The method behind the hole calculations is described in

T. M. Mahim, A. S. M. Mohsin and M. M. Rahman, "Origin of the conflicting hole masses in the GaN/AlN two-dimensional hole gas", Phys. Rev. B 114, L291304 (2026), https://doi.org/10.1103/zn44-nmx8

and follows S. L. Chuang and C. S. Chang, Phys. Rev. B 54, 2491 (1996). The other sources each part builds on are listed in the Reference.

Who makes it

Written and maintained by Tanvir Mahmud Mahim (Department of Electrical and Electronic Engineering, BRAC University), who reviews every change. Contributions are welcome: see CONTRIBUTING.md. A change to the physics comes with a test, and a new number comes with its source.

Licensed under Apache-2.0.

Metadata

Release files for kpenvelope 0.23.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for kpenvelope 0.23.0
File Size Uploaded Provenance Actions
kpenvelope-0.23.0.tar.gz 492.9 kB With provenance Details for kpenvelope-0.23.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for kpenvelope 0.23.0
File Interpreter ABI Platform Actions
kpenvelope-0.23.0-py3-none-any.whl Python 3 none any Details for kpenvelope-0.23.0-py3-none-any.whl

Total release size: 790.3 kB

Release files / kpenvelope-0.23.0.tar.gz

Download URL kpenvelope-0.23.0.tar.gz
Size 492.9 kB
Tags Source
SHA-256 checksum
How to use checksums
980e5f6a1ecbe3b0ea3277e9dfc0ef9372b200870284d2541ef7a0fd06c3cf02
BLAKE2b-256 checksum
How to use checksums
34b9db5aa4b308a9bbb58165523129d9490448906f6d613b4b1780ce61d58d35
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

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.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 20, 2026.

Transparency log

Release files / kpenvelope-0.23.0-py3-none-any.whl

Download URL kpenvelope-0.23.0-py3-none-any.whl
Size 297.5 kB
Tags Python 3
SHA-256 checksum
How to use checksums
238b052aad59ef2c776a4a18047ee742d9814e6b35608409396aa8cea471768a
BLAKE2b-256 checksum
How to use checksums
3d9c988642d5cacdf68e67b040a4f7faffff5fb2f8e09efa6e95e8fe645b7fbf
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

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.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 20, 2026.

Transparency log

Security for kpenvelope 0.23.0

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.

Full provenance

Both files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for kpenvelope-0.23.0.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 20, 2026.

Transparency log

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.

Release history Release notifications | RSS feed

This release

0.23.0 This release

2 release files Full provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page