Skip to main content

Capacitor

Struct Capacitor 

Source
pub struct Capacitor { /* private fields */ }
Expand description

Capacitor component with voltage memory.

Uses backward Euler companion model:

  • Equivalent conductance: G = C / dt
  • Equivalent current source: J = G * V_previous

Implementations§

Source§

impl Capacitor

Source

pub fn new(n1: i32, n2: i32, capacitance: f32) -> Self

Create a new capacitor between two nodes.

§Arguments
  • n1, n2 - Node indices (0 = ground)
  • capacitance - Capacitance in Farads

Trait Implementations§

Source§

impl Component for Capacitor

Source§

fn nodes(&self) -> (i32, i32)

Get the node indices this component connects (node_a, node_b). Node 0 represents ground.
Source§

fn get_conductance(&self, dt: f32) -> f32

Return the equivalent conductance for the static Y matrix. Called once during preprocessing.
Source§

fn get_current_source(&self, dt: f32) -> f32

Return the equivalent current source for the dynamic J vector. Called every sample for reactive components.
Source§

fn update_state(&mut self, v_a: f32, v_b: f32, _dt: f32)

Update internal state after solving node voltages. Called every sample for reactive components to store history.

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> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

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, 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.