sda.rlc.fit_rlc#

A module for fitting an RLC circuit to a pulsed signal.

The RLC circuit is a linear, second-order differential equation, and it can be used to model the response of a circuit to a pulsed signal. The circuit can be critically damped, underdamped, or overdamped, and the response can be oscillatory or not; For the underline physics, see the Word document in BP25 folder.

The module provides a function to calculate the current across the RLC circuit in response to a pulsed signal, and another function to calculate the current across the RL circuit in response to a pulsed signal. The module also provides a function to calculate the pulsed signal itself.

The module also provides a main block to plot the current across the RLC circuit in response to a pulsed signal, and the current across the RL circuit in response to a pulsed signal.

Attributes#

Functions#

pulsed_signal(t, tau, V)

Return a pulsed signal, serving as an input signal to the RLC circuit.

rlc_current(t, R, L, C, tau, V)

Compute current across the RLC circuit, in response to a pulsed signal.

rl_current(t, R, L, tau, V)

Compute current across the RL circuit, in response to a pulsed signal.

initial_guess(times, current, V[, tau])

Determine the initial guess for the RLC circuit.

fit_signal_with_current(times, current, V[, tau])

Fit the current across the RLC circuit to a pulsed signal.

Module Contents#

sda.rlc.fit_rlc.pulsed_signal(t, tau, V)#

Return a pulsed signal, serving as an input signal to the RLC circuit.

The pulse is defined here as step function that goes from 0 to V at t = 0, and stays at V for 0 < t <= tau. The pulse is 0 for t > tau.

Parameters:
  • t (float) – Time in seconds.

  • tau (float) – Pulse duration in seconds.

  • V (float) – Pulse amplitude in volts.

Returns:

The pulse value at time t.

Return type:

float

sda.rlc.fit_rlc.rlc_current(t, R, L, C, tau, V)#

Compute current across the RLC circuit, in response to a pulsed signal.

Schema of the RLC circuit:

 ----------C----------L------┐
 ↑                           │
 │                           │
e(t)                         R
 │                           │
 │                           │
 ----------------------------┘
Parameters:
  • t (float) – Time in seconds.

  • R (float) – Resistance in Ohms.

  • L (float) – Inductance in Henry.

  • C (float) – Capacitance in Farad.

  • tau (float) – Pulse duration in seconds.

  • V (float) – Pulse amplitude in volts.

Returns:

The current across the RLC circuit at time t.

Return type:

float

Raises:

ValueError – If the circuit is critically damped.

sda.rlc.fit_rlc.rl_current(t, R, L, tau, V)#

Compute current across the RL circuit, in response to a pulsed signal.

Schema of the RL circuit:

----------L-----┐
↑               │
│               │
e(t)            R
│               │
│               │
----------------┘
Parameters:
  • t (float) – Time in seconds.

  • R (float) – Resistance in Ohms.

  • L (float) – Inductance in Henry.

  • tau (float) – Pulse duration in seconds.

  • V (float) – Pulse amplitude in volts.

Returns:

The current across the RL circuit at time t.

Return type:

float

sda.rlc.fit_rlc.initial_guess(times, current, V, tau=None)#

Determine the initial guess for the RLC circuit.

The initial guesses are based on the following assumptions: - The inductance is the inverse of the slope of the current at t = 0. - The resistance is related to the times T the current reaches 0.05 of its maximum value. - The capacitance is linked to oscillations in current.

Parameters:
  • times (np.ndarray) – Time in seconds.

  • current (np.ndarray) – Current in Amperes.

  • V (float) – Pulse amplitude in Volts.

  • tau (float, optional) – Pulse duration in seconds. If None, the pulse duration is estimated as the time at which the current reaches its maximum value. Defaults to None.

Returns:

The initial guesses for the resistance, inductance, capacitance, and pulse duration of the RLC circuit.

Return type:

tuple[float, float, float, float]

sda.rlc.fit_rlc.fit_signal_with_current(times, current, V, tau=None)#

Fit the current across the RLC circuit to a pulsed signal.

Parameters:
  • times (np.ndarray) – Time in seconds.

  • current (np.ndarray) – Current in Amperes.

  • V (float) – Pulse amplitude in Volts.

  • tau (float, optional) – Pulse duration in seconds. If None, the pulse duration is estimated as the time at which the current reaches its maximum value. Defaults to None.

Returns:

The resistance, inductance, and capacitance of the RLC circuit.

Return type:

tuple[float, float, float]

sda.rlc.fit_rlc.times#