Skip to main content

MosfetModel

Struct MosfetModel 

pub struct MosfetModel {
    pub vth: f64,
    pub kp: f64,
    pub lambda: f64,
    pub is_n_channel: bool,
}
Expand description

Enhancement-mode MOSFET model parameters.

Uses the SPICE Level 1 square-law model for drain current:

  • Cutoff: Ids = 0 when |Vgs| < |Vth|
  • Triode: Ids = Kp * [(Vgs-Vth)*Vds - 0.5*Vds^2]
  • Saturation: Ids = 0.5*Kp * (Vgs-Vth)^2 * (1 + lambda*|Vds|)

Fields§

§vth: f64

Threshold voltage (V). N-channel: positive, P-channel: negative.

§kp: f64

SPICE Level 1 transconductance parameter (A/V²), before the 1/2 square-law saturation factor.

§lambda: f64

Channel-length modulation parameter (1/V). Typical: 0.01-0.1.

§is_n_channel: bool

True for N-channel, false for P-channel.

Implementations§

§

impl MosfetModel

pub fn n_2n7000() -> MosfetModel

2N7000 N-channel enhancement MOSFET.

Very common in guitar pedal clipping (Fulltone OCD, modern drives). Low threshold voltage, small package, fast switching.

pub fn n_irf520() -> MosfetModel

IRF520 N-channel power MOSFET.

Higher current capability, used in some high-headroom drive circuits.

pub fn p_bs250() -> MosfetModel

BS250 P-channel enhancement MOSFET.

Used in some boost circuits and complementary configurations.

pub fn p_irf9520() -> MosfetModel

IRF9520 P-channel power MOSFET.

pub fn ids(&self, vgs: f64, vds: f64) -> f64

Drain current Ids(Vgs, Vds) — enhancement-mode square-law model.

  • Cutoff: Ids = 0 when the channel is off (N: Vgs <= Vth, P: Vgs >= Vth)
  • Triode: Ids = Kp * [Vov*|Vds| - 0.5*Vds²] * sign(Vds)
  • Saturation: Ids = 0.5*Kp * Vov² * (1 + lambda*|Vds|) * sign(Vds)

The channel conducts symmetrically in both Vds polarities (drain and source are interchangeable in the square-law model).

pub fn ids_vds_derivative(&self, vgs: f64, vds: f64) -> f64

Derivative dIds/dVds at fixed Vgs.

Returns LEAKAGE_CONDUCTANCE in cutoff so Newton-Raphson always sees a non-zero slope.

Trait Implementations§

§

impl Clone for MosfetModel

§

fn clone(&self) -> MosfetModel

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
§

impl Copy for MosfetModel

§

impl Debug for MosfetModel

§

fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error>

Formats the value using the given formatter. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<T> Instrument for T

§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided [Span], returning an Instrumented wrapper. Read more
§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
§

impl<T> WithSubscriber for T

§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a [WithDispatch] wrapper. Read more
§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a [WithDispatch] wrapper. Read more