mph- / lcapy

Lcapy is a Python package for symbolic linear circuit analysis and signal processing. It uses SymPy for symbolic mathematics.
GNU Lesser General Public License v2.1
244 stars 46 forks source link

State space Output equations for current source input to series RLC #52

Open abnaidu001 opened 3 years ago

abnaidu001 commented 3 years ago

Hi,

For a current source input to series RLC, The current of inductor is determined by input itself and don't know if we can fit the equations of this circuit into state space model . Reports error as below for this.

cct = Circuit("""
I_in 0 1; R_L 1 2; L_L 2 3; C_L 3 0; """) ss=cct.ss

ValueError: The MNA A matrix is not invertible for time analysis because:

  1. there may be capacitors in series;
  2. a voltage source might be short-circuited;
  3. a current source might be open-circuited;
  4. a dc current source is connected to a capacitor (use step current source).
  5. part of the circuit is not referenced to ground

    V_CL will be a state variable. And the output equations will be as below for this. V3 = V_CL V2 = V_CL + L_L d(I_in)/dt V1 = V_CL + L_L d(I_in)/dt + R_L * I_in

Is there a way to print the output equations for this case? Please help. Thanks.

mph- commented 3 years ago

I'm not sure what is best to do for a degenerate circuit like this. The problem is that there is a cut set with an inductor and a current source; thus the current through the inductor should not be a state variable. (It has been on my todo list to handle loops of voltage sources/capacitors and cut sets of current sources/inductors).

However, even if Lcapy correctly determines that there is a single state variable (the capacitor voltage), the output equation cannot be written in standard form since the voltage across the inductor depends on the derivative of the input variable (the current source). Or have I overlooked something?