Skip to content

fix(py): make subthreshold_swing fail loudly, and state its units - #10

Open
reneotten wants to merge 1 commit into
mainfrom
fix/subthreshold-swing-errors
Open

fix(py): make subthreshold_swing fail loudly, and state its units#10
reneotten wants to merge 1 commit into
mainfrom
fix/subthreshold-swing-errors

Conversation

@reneotten

Copy link
Copy Markdown
Owner

fix(py): make subthreshold_swing fail loudly, and state its units

Two problems, both about the same function.

  1. Silent NaN. Device() defaults to v_ds = 0, where the Landauer
    integrand vanishes and every swept current is exactly zero. The
    log10(I) fit then produced -inf, and 1/-inf returned nan with only
    a numpy RuntimeWarning. Device().sweep_v_g(0, 0.5, 0.05).subthreshold_swing()
    quietly handed back nan instead of explaining that a drain bias is
    needed. Non-positive currents, empty fit windows and degenerate slopes now
    raise ValueError naming the likely cause.

  2. Contradictory units. sweep.rs described the result as "mV/decade
    equivalent, in the original's V/decade units", which asserts two different
    units in one clause, and the Python docstring gave none at all. The value
    is volts/decade; the only place that was resolved was a * 1000 in a
    notebook cell.

Both doc comments now say V/decade and give the 300 K thermal limit
(0.0596 V/decade) as a sanity anchor. Verified against the model: the
default device gives 65.8 mV/decade at 300 K and 43.8 mV/decade at 200 K,
each just above the corresponding ln(10)kT/e limit, which is the expected
behaviour for a thermally-limited barrier.

Two problems, both about the same function.

1. Silent NaN. `Device()` defaults to `v_ds = 0`, where the Landauer
   integrand vanishes and every swept current is exactly zero. The
   `log10(I)` fit then produced `-inf`, and `1/-inf` returned `nan` with only
   a numpy RuntimeWarning. `Device().sweep_v_g(0, 0.5, 0.05).subthreshold_swing()`
   quietly handed back `nan` instead of explaining that a drain bias is
   needed. Non-positive currents, empty fit windows and degenerate slopes now
   raise `ValueError` naming the likely cause.

2. Contradictory units. `sweep.rs` described the result as "mV/decade
   equivalent, in the original's V/decade units", which asserts two different
   units in one clause, and the Python docstring gave none at all. The value
   is volts/decade; the only place that was resolved was a `* 1000` in a
   notebook cell.

Both doc comments now say V/decade and give the 300 K thermal limit
(0.0596 V/decade) as a sanity anchor. Verified against the model: the
default device gives 65.8 mV/decade at 300 K and 43.8 mV/decade at 200 K,
each just above the corresponding ln(10)kT/e limit, which is the expected
behaviour for a thermally-limited barrier.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants