sindr_devices/lib.rs
1//! Pure-Rust electronics device physics: linearised companion models for
2//! semiconductor and passive components used by MNA-based circuit simulators.
3//!
4//! `sindr-devices` provides the small-signal linearisation that
5//! Newton–Raphson solvers need at every iteration: given an applied voltage,
6//! each device returns a `(g_eq, i_eq)` pair — an equivalent conductance and
7//! Norton-current source. Stamp those into the MNA matrix and the solver
8//! converges on the operating point.
9//!
10//! This crate has **no dependency** on a particular solver. Use it standalone
11//! if you're building your own MNA implementation, or pair it with the
12//! companion crate [`sindr`](https://crates.io/crates/sindr) for an
13//! end-to-end simulator.
14//!
15//! # Devices
16//!
17//! | Module | Device | Model |
18//! |---|---|---|
19//! | [`diode`] | Silicon diode | Shockley with series resistance + temperature IS scaling |
20//! | [`bjt`] | BJT (NPN/PNP) | Ebers–Moll with Early voltage |
21//! | [`mosfet`] | MOSFET (NMOS/PMOS) | Level-1 |
22//! | [`jfet`] | JFET (N/P-channel) | Shichman–Hodges |
23//! | [`igbt`] | IGBT | MOSFET gate control + BJT output conductance |
24//! | [`led`] | LED | Diode with colour-dependent forward voltage |
25//! | [`zener`] | Zener diode | Shockley + reverse-breakdown branch |
26//! | [`schottky`] | Schottky diode | Shockley with low-N, low-IS parameters |
27//! | [`varactor`] | Varactor | Voltage-dependent junction capacitance |
28//! | [`thermistor`] | NTC thermistor | Beta model `R(T) = R₀·exp(β·(1/T − 1/T₀))` |
29//! | [`photodiode`] | Photodiode | Diode + photocurrent offset |
30//! | [`photoresistor`] | Photoresistor (LDR) | Light-level-dependent resistance |
31//!
32//! # Quick example
33//!
34//! ```
35//! use sindr_devices::diode::{DiodeParams, diode_companion};
36//!
37//! let params = DiodeParams::silicon(); // IS=1e-14, N=1.0, rs=0.0
38//! let v_applied = 0.65; // forward bias, volts
39//! let (g_eq, i_eq) = diode_companion(v_applied, ¶ms);
40//!
41//! // Stamp g_eq into Y(p,p), Y(q,q), -g_eq into Y(p,q)/Y(q,p),
42//! // and i_eq into b(p)/-i_eq into b(q) in your MNA system.
43//! assert!(g_eq > 0.0);
44//! ```
45//!
46//! # Conventions
47//!
48//! - **Voltages and currents** are in SI units (V, A).
49//! - **Temperature** is in kelvin. Default is 300.15 K (≈ 27 °C, the SPICE
50//! default).
51//! - **Sign convention** for two-terminal companions: `v_applied` is the
52//! voltage from `nodes[0]` to `nodes[1]`, and `i_eq` is the current
53//! flowing into `nodes[0]`.
54//! - **Companion form**: each `*_companion` function returns the linearised
55//! `(g_eq, i_eq)` at the operating point — the form Newton–Raphson stamps
56//! directly.
57
58pub mod bjt;
59pub mod diode;
60pub mod igbt;
61pub mod jfet;
62pub mod led;
63pub mod mosfet;
64pub mod photodiode;
65pub mod photoresistor;
66pub mod schottky;
67pub mod thermistor;
68pub mod varactor;
69pub mod zener;