use crate::diode::{diode_companion, DiodeParams};
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
#[derive(Debug, Clone)]
pub struct SchottkyParams {
pub is: f64,
pub n: f64,
}
impl SchottkyParams {
pub fn standard() -> Self {
Self { is: 1e-8, n: 1.0 }
}
}
impl Default for SchottkyParams {
fn default() -> Self {
Self::standard()
}
}
pub fn schottky_companion(v_d: f64, params: &SchottkyParams) -> (f64, f64) {
diode_companion(
v_d,
&DiodeParams {
is: params.is,
n: params.n,
rs: 0.0,
temperature: 300.15,
},
)
}
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn schottky_forward_voltage_lower_than_silicon() {
let params = SchottkyParams::standard();
let (g_s, _i_s) = schottky_companion(0.3, ¶ms);
assert!(g_s > 1e-6, "Schottky should conduct at 0.3V, got g={}", g_s);
let (g_si, _) = diode_companion(
0.3,
&crate::diode::DiodeParams {
is: 1e-14,
n: 1.0,
rs: 0.0,
temperature: 300.15,
},
);
assert!(
g_s > g_si * 1000.0,
"Schottky should have >> 1000x conductance of silicon at 0.3V"
);
}
#[test]
fn schottky_reverse_bias_near_zero() {
let params = SchottkyParams::standard();
let (g_d, i_eq) = schottky_companion(-5.0, ¶ms);
assert!(
g_d < 1e-6,
"Reverse bias conductance should be near zero, got g={}",
g_d
);
assert!(i_eq.abs() < 1e-6, "Reverse i_eq should be tiny");
}
}