1. Not finding help here? Sign up for a free 30min tutor trial with Chegg Tutors
    Dismiss Notice
Dismiss Notice
Join Physics Forums Today!
The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

Linear Algebra - Analysis of purely resistive DC circuit

  1. Apr 15, 2016 #1
    1. The problem statement, all variables and given/known data

    I'm trying to solve this circuit


    circuit.PNG

    when I try to simulate and run a dc sweep i get that it can't be solved. When I try to find the answer using linear algebra


    circuit.PNG

    Capture.PNG

    I get this answer after I throw it into MATLAB with the warning

    “[w]arning: Matrix is close to singular or badly scaled. Results may be inaccurate. RCOND = 2.312965e-18”.

    2. Relevant equations


    3. The attempt at a solution

    I don't understand what I'm doing wrong. Thanks for any help.
    Capture.PNG

    Capture.PNG
    Capture.PNG

    I'm stuck in the linear algebra part and not the electrical engineering aspect so i figured i'd post it here.

    thanks.
     
  2. jcsd
  3. Apr 15, 2016 #2

    berkeman

    User Avatar

    Staff: Mentor

    In the simulation, can you try to debug it by running separate simulations with one or two of the power sources disabled? Short the voltage source and open a current source to see if that simulation runs. Try each of the 3 simulations with only one power source enabled. Then try combinations of two power sources enabled. Offhand, I don't see why the circuit isn't resolving. You could also try forcing some initial conditions to see if that helps with convergence to the DC operating points...
     
  4. Apr 15, 2016 #3

    berkeman

    User Avatar

    Staff: Mentor

    BTW, are you able to just solve it by hand using the KCL equations?
     
  5. Apr 15, 2016 #4

    vela

    User Avatar
    Staff Emeritus
    Science Advisor
    Homework Helper
    Education Advisor

    i don't think that circuit is consistent with KCL. The current sources inject 5 A into the circuit, but there's no way for that current to leave the circuit.
     
  6. Apr 15, 2016 #5
    Vela - So I have to add in a ground at node 7 so that there's a place for the 5 amps to leave the circuit?

    The simulation ran with the ground at node 7.

    However won't the incidence matrix be the same? MATLAB would still give me that weird error. I think I'm doing something wrong with the linear algebra?

    POSTING NEW PICTURE IN THIS POST OF CIRCUIT

    Capture.PNG
     
  7. Apr 15, 2016 #6
    upload_2016-4-15_20-11-13.png

    upload_2016-4-15_20-12-10.png
    upload_2016-4-15_20-13-19.png

    upload_2016-4-15_20-16-27.png
    upload_2016-4-15_20-16-50.png

    I don't understand what I'm doing wrong or understand why MATLAB is giving me an error

    >> N=[-1,1,0,0,0,0;0,-1,0,1,0,0;-1,0,1,0,0,0;0,0,1,-1,0,0;0,0,-1,0,1,0;0,0,0,0,-1,1];
    >> R=[1,0,0,0,0,0;0,3,0,0,0,0;0,0,2,0,0,0;0,0,0,4,0,0;0,0,0,0,5,0;0,0,0,0,0,6];
    >> E=[0;0;0;0;0;5];
    >> I=[0;0;0;2;3;0];
    >> A=[0,0,0,0,0,0;0,0,0,0,0,0;0,0,0,0,0,0;0,0,0,0,0,0;0,0,0,0,0,0;0,0,0,0,0,0];
    >> inv([R,N;N',A])[I;E]
    inv([R,N;N',A])[I;E]

    Error: Unbalanced or unexpected parenthesis or
    bracket.

    >> inv([R,N;N',A])*[I;E]
    Warning: Matrix is close to singular or badly
    scaled. Results may be inaccurate. RCOND =
    2.312965e-18.


    ans =

    1.0e+16 *

    0.0000
    0.0000
    0.0000
    0.0000
    0.0000
    0.0000
    -4.5036
    -4.5036
    -4.5036
    -4.5036
    -4.5036
    -4.5036

    My simulator says that

    upload_2016-4-15_20-31-52.png
    upload_2016-4-15_20-34-34.png

    I don't see what I'm doing wrong in MATLAB =(
     
  8. Apr 15, 2016 #7

    vela

    User Avatar
    Staff Emeritus
    Science Advisor
    Homework Helper
    Education Advisor

    Did you have a reason to choose node 7 in particular? It seems kind of arbitrary.
     
  9. Apr 15, 2016 #8
    No reason. I'm just use to putting the ground at the negative lead of the voltage source. It shouldn't matter right where we put the ground? I was able to simulate the circuit and got a solution.

    I think MATLAB gets the error when it performs the following calculation
    >>([R,N;N',A])^(-1)

    Indeed just putting this into MATLAB returns the same error (except with different numbers of course). I don't see what's wrong with the calculation. I'm trying to get it to take the inverse of a 12x12 matrix split up in block form so it shouldn't have a problem.

    I even try this
    >>F=([R,N;N',A])
    it does indeed return a matrix that has 12 collumns and 12 rows. I try this calculation
    >>inv(F)
    and I get the same error
    "Matrix is close to singular or badly scaled. REsults may be inaccurate..."

    I don't see what's wrong. =(
     
  10. Apr 15, 2016 #9
    Oh... so MATLAB thinks the matrix is singular? I just tried det(F) and it returned
    1.1102*10^(-15) so even though it's not singular MATLAB thinks it is because the determinant is almost zero?
     
  11. Apr 16, 2016 #10

    The Electrician

    User Avatar
    Gold Member

    Your incidence matrix is singular. Perhaps when you ground a node, the grounded node should vanish from the incidence matrix?
     
  12. Apr 16, 2016 #11

    gneill

    User Avatar

    Staff: Mentor

    @vela had it right in post #4. There are only two ground connections in the circuit and both are affixed to current sources. Ground symbols in this case are really just labels used in place of wiring the common connections together. If you replace the symbols with wires:
    upload_2016-4-16_11-47-11.png

    You can see that there are two problems:

    1. 5 A are injected into the circuit with no return path (might make an excellent Van DeGraff generator replacement!).
    2. Two current sources with different current values are in series. Flash! Bang! Smoke! :smile:
     
  13. Apr 16, 2016 #12
    Hi Gnelli,

    Thanks for your response. Yeah I think your right but I find it strange that the circuit would run in the simulator when it is indeed two current sources in parallel. But is it really in parallel if they are separated by resistors? I have redrawn the circuit and have tried to use MATLAB again by modifying the circuit to remove one of the current sources and to have the only ground in the circuit be the one at the other end of the current source. MATLAB still doesn't seem to like it =(. I don't see what I'm doing wrong. Thanks for any help.
    upload_2016-4-16_21-57-48.png
    Equations on modified circuit
    upload_2016-4-16_21-58-43.png
    upload_2016-4-16_21-59-5.png
    upload_2016-4-16_21-59-18.png
    upload_2016-4-16_21-59-34.png
    upload_2016-4-16_21-59-54.png
    putting my equations into MATLAB provides with the following answer as well as a warning that the matrix is singular
    upload_2016-4-16_22-1-25.png
    MATLAB commands

    >> N=[-1,1,0,0,0,0;0,-1,0,1,0,0;-1,0,1,0,0,0;0,0,1,-1,0,0;0,0,-1,0,1,0;0,0,0,0,-1,1];
    >> R=[1,0,0,0,0,0;0,2,0,0,0,0;0,0,3,0,0,0;0,0,0,4,0,0;0,0,0,0,5,0;0,0,0,0,0,6];
    >> A=[0,0,0,0,0,0;0,0,0,0,0,0;0,0,0,0,0,0;0,0,0,0,0,0;0,0,0,0,0,0;0,0,0,0,0,0];
    >> E=[0;0;0;0;0;5];
    >> I=[0;0;0;0;3;0];
    >> inv([R,N;N',A])*[I;E]
    Warning: Matrix is close to singular or badly
    scaled. Results may be inaccurate. RCOND =
    2.312965e-18.


    ans =

    1.0e+16 *

    0
    0
    0
    0
    0.0000
    0.0000
    4.5036
    4.5036
    4.5036
    4.5036
    4.5036
    4.5036

    and when I try to take the determinant of the matrix [R,N;N',A] I get

    -1.1102e-15

    which may be to close to zero and very close to singular causing the error that I'm getting in MATLAB.

    When I check the values in my simulator it tells me this time that it's unable to get the solution but I'm not sure what's wrong with my circuit. Thanks for any help!
     
  14. Apr 16, 2016 #13
    Where is the return path for the current source?
    upload_2016-4-16_21-57-48-png.99226.png
     
  15. Apr 16, 2016 #14
    I'm not exactly sure what you are talking about by return path to the current source or even what one would like. Can you help? I'm not sure what you are describing.
     
  16. Apr 16, 2016 #15
    I1, if it is a current source then their are electrons flowing out of one of its terminals. What route do they take to get back in the other terminal?
     
  17. Apr 16, 2016 #16
    So your saying that I need to add a ground to the circuit? is node 6 ok to place the ground? This would allow the circuit to be simulated I think?

    Also I think my equations would still be the same and MATLAB would still give me an error? I'm not sure it would effect the linear algebra equations.

    Thanks for all of your help!
     
  18. Apr 16, 2016 #17
    Put a ground anywhere you wish. As it stands, the lower end of I1 is goimg nowhere, as far as the ckt. is concerned it is floating.
     
  19. Apr 16, 2016 #18
    Ok sounds good, but wouldn't my linear equations all be the same and MATLAB still provide me with an error?

    I think I'll place it at node 6 since I'm used to having a ground at the negative end of the battery terminal mostly.

    I just don't see though does this effect the equations at all?
     
  20. Apr 16, 2016 #19
    Well, if you try using KCL you'll find that you can't solve for the lower end of I1.
     
  21. Apr 16, 2016 #20
    You mean the current coming out of the battery?
     
Know someone interested in this topic? Share this thread via Reddit, Google+, Twitter, or Facebook

Have something to add?
Draft saved Draft deleted



Similar Discussions: Linear Algebra - Analysis of purely resistive DC circuit
Loading...