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!

Use Mathematica and Kirchhoff's rules to find V out.

  1. Jul 1, 2013 #1
    1. The problem statement, all variables and given/known data

    Find V out by determining three equations with three unknowns. Use Mathematica to solve the system to find V out. See image for details

    2. Relevant equations

    --

    3. The attempt at a solution

    Here is my code:

    [itex]\text{eq1}=v-i_3*(2r)-i_3*r-i_3*(2r)[/itex]
    [itex]\text{eq2}=-v+\left(i_2-i_3\right)*(2r)+i_2*r+\left(i_2-i_1\right)*(2r)[/itex]
    [itex]\text{eq3}=v-\left(i_2-i_1\right)*(2r)-i_1*(2r)[/itex]

    Then I just solve the system in Mathematica by:

    Code (Text):
    sol=Solve[{eq1==0,eq2==0,eq3==0},{i[SUB]1[/SUB],i[SUB]2[/SUB],i[SUB]3[/SUB]}]
     
    So my first question is, did I get the system right? This is actually a third year course where we're programming some stuff from lower-level courses...and I haven't used Kirchhoff's rules in many years. So I have forgotten it.

    After this I'm not sure how to find V out. In mathematica, I figured it would be:

    Code (Text):
    vout = v - i[SUB]3[/SUB]*(2 r) /. sol
    But the answer is not correct. We should end up with V out = (5/8)*v, but when calculate it with the above equations/code, I get v out = (3/5)v.

    If someone could help I would appreciate it.
     

    Attached Files:

    Last edited: Jul 1, 2013
  2. jcsd
  3. Jul 1, 2013 #2

    gneill

    User Avatar

    Staff: Mentor

    Assuming that you are writing mesh equations for the loops, shouldn't there be an i2 term in eq1?
     
  4. Jul 1, 2013 #3
    yes, eq1 should be

    [itex]\text{eq1}=v-i_3*(2r)-i_3*r+\left(i_2-i_3\right)*(2r))[/itex]

    but i still cannot get the right answer of 5/8 v
     
  5. Jul 1, 2013 #4

    gneill

    User Avatar

    Staff: Mentor

    Check to make sure that the signs of all terms are correct in eq3. Do they agree with your chosen mesh current directions?
     
  6. Jul 2, 2013 #5
    Thanks gneill. For eq 3 I now have:

    [itex]\text{eq3}=v+\left(i_2-i_1\right)*(2r)-i_1*(2r)[/itex]

    Now how do I go about finding V out. Like I said my knowledge of circuits is very limited as I don't even remember learning this stuff. If I did it would have been many years ago. I've had to learn it as I go, though it isn't very difficult. I just don't actually know how to find V out. Thanks again.
     
  7. Jul 2, 2013 #6

    gneill

    User Avatar

    Staff: Mentor

    The tricky part about writing mesh equations lies in keeping the current directions consistent and remembering whether, when you're going around a loop, you're summing potential rises or potential drops. Once you've made those choices you've got to stick to them for every loop, otherwise sign errors will creep in for various terms.

    Your equations seem to be exhibiting some effects of the above and I'm not sure that your 'corrections' have been much better, possibly due to lingering inconsistencies with current direction choices in in the remaining equations. So let's redo the equations starting with a firm statement of the conditions. The default choice for loop current direction is clockwise. So here's your circuit with loop currents identified and the resulting potential changes penciled-in for each current.

    attachment.php?attachmentid=60028&stc=1&d=1372764307.gif

    If the choice is to sum potential drops (so potential drops are treated as positive values when writing the equations), can you write the equation for the first loop (associated with current i1)?
     

    Attached Files:

  8. Jul 2, 2013 #7
    Hint: What is i3*2R and why should that be interesting for you?

    If you actually did REALLY learn this stuff once then I urge you to track down the particular textbook you learned this stuff from, maybe on Amazon or Abebooks or any of the other used book warehouses, and buy a copy of that specific book. Often used books of that age can be had for a dollar plus three for shipping.

    Why that particular textbook? Because, despite I cringe when saying this, the font... and the examples and the feel of the pages and even the smell of the pages will help too and probably bring back brain cells that you would think were long since dead.

    I still have my original calculus text on the shelf. When I just cannot see why I am making some stupid mistake I flop that open and page back and forth, wonder how in the world I thought all of this was so hard the first time through it, and the memories start coming back.

    I urge you to not substitute some other introductory DC circuits text, I don't think the effect will be nearly as strong if you do, but it would be better than nothing.

    And learning something all over again the fourth time is the way you really learn it anyway.
     
  9. Jul 3, 2013 #8
    I still think it's:
    eq1 = -v + i1*2r + i1*2r -i2*2r

    which is the same thing that i most recently posted (but the directions are just different). Using the same conventions, the other two equations would be:

    eq2 = v -i2*2r + i1*2r -i2*r -i2*2r + i3*2r

    eq3 = -v + i3*2r -i2*2r + i3*r + i3*2r

    And Bill I'm not that old yet :) regarding your hint...that was in the example he gave us and I also thought about it a little but I have since forgotten why that specific equation is important to be honest.
     
  10. Jul 3, 2013 #9
    Interesting I just put those new equations into my Mathematica notebook and I got the answer 5/8 V. Before i get worked up thinking i've solved the problem...did I do this correctly? Perhaps two wrongs made a right here...and I don't want that...
     
  11. Jul 3, 2013 #10
    posting again...scratch that...i got 5/8 v but...my v out equation it hink was wrong, so i'm back at square one.
     
  12. Jul 3, 2013 #11

    gneill

    User Avatar

    Staff: Mentor

    The voltage source represents a voltage DROP going in the direction of the loop current, so if you're summing voltage drops (as it would appear you are doing with the rest of the terms), v should be positive.
    Despite what you claim, you seem to have changed conventions here, since you're now summing voltage rises rather than drops. But that's okay.
    As in the first equation, you've got the sign of the voltage supply term reversed; the rest of the terms show that you're summing voltage drops, and the supply represents a drop in the direction of i3.
     
  13. Jul 3, 2013 #12
    So they've all got to be positive? I just always figured that for the middle loop, the voltage term would be of a different sign since the battery is placed differently.
     
  14. Jul 3, 2013 #13

    gneill

    User Avatar

    Staff: Mentor

    It would have been of a different sign had you not switched from adding drops to adding rises in that loop. All the other terms would change sign, too.
     
  15. Jul 3, 2013 #14
    Then to find Vout, we use

    Code (Text):
    vout = v + (Subscript[i, 3])*(2 r) /. sol;
    or
    Code (Text):
    vout = v - (Subscript[i, 3])*(2 r) /. sol;
    depending on the conventions in the first three equations?
     
  16. Jul 3, 2013 #15

    gneill

    User Avatar

    Staff: Mentor

    I suppose so. I'm not a frequent user of Mathematica; I make more use of MathCad and tend to use a matrix approach for simultaneous equations. The matrix approach is particularly handy for mesh equations since the matrix can be written by inspection without working up the loop equations individually.
     
  17. Jul 4, 2013 #16
    In the assignment we learned the matrix way of doing things as well. I just chose not to use that method because the code isn't as neat. But thanks again for all of your help everyone.
     
  18. Jul 4, 2013 #17
    I understand that Windows and desktop publishing have made many people think they just have to use subscripts in Mathematica.

    Subscripted variables are not first class citizen "real variables" in Mathematica and they can and will come back to bite you in ways you can't begin to imagine. Sometimes they will work for you. Many many times they will not. That was a design decision made in Mathematica many years ago and it cannot be changed now.

    If you can give up everything you hold dear and just use i3 instead of Subscript[i,3] and even Bold[ReverseItalic[ OldeEnglishFont[BrightPink[ GentlyDancingBackAndForth[ SubscriptedButWithADifferentFontFor3[i,3]]]]]] you will more likely get the correct answer.

    Google for
    Mathematica subscript problem
    and other creative choices for search terms
    to find some incomprehensible problems with these.

    I used to keep a list of the best of these, but I lost that and can't recover it now.
     
    Last edited: Jul 4, 2013
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: Use Mathematica and Kirchhoff's rules to find V out.
Loading...