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.
  • Electrons in the transistor channel as quantum states (their allowed energies and where they sit), solved together with the current.
  • 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.
  • Process steps that build the shape and the doping: deposition and etching (also with the shadowing of narrow openings), oxidation (also under mask edges), 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, runaway and quantum channels, 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: 54 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:

  • No ballistic transport. The quantum channel is one band, along the grid's vertical lines, for electrons only; holes and the rest of the device stay classical.
  • Process steps stay simple. There is no plasma or gas chemistry and no stress in growing oxide, particles stick where they land, 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.24.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.24.0
File Size Uploaded Provenance Actions
kpenvelope-0.24.0.tar.gz 515.6 kB With provenance Details for kpenvelope-0.24.0.tar.gz

Built distribution (wheel)

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

Total release size: 825.1 kB

Release files / kpenvelope-0.24.0.tar.gz

Download URL kpenvelope-0.24.0.tar.gz
Size 515.6 kB
Tags Source
SHA-256 checksum
How to use checksums
bb2eaf6b21355267f29f73b18bbfd27ebfbb33508588913539698bf3b3660506
BLAKE2b-256 checksum
How to use checksums
9c984affbd3d5c342f5d43b1ab0623f5d3a9cbedaefcbfabe3cefa43dcfa76f9
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.24.0-py3-none-any.whl

Download URL kpenvelope-0.24.0-py3-none-any.whl
Size 309.5 kB
Tags Python 3
SHA-256 checksum
How to use checksums
f1dcc9d4e271d73fbb3db6df301d0fe6036d5eeca6fe7b2eb5bfacdea730e891
BLAKE2b-256 checksum
How to use checksums
2bfe6d1baeb9e19d37497e9f973f3f8498a00a874edcb7fb44b0f794193a7e04
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.24.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.24.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.24.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