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

  • Thread starter stripes
  • Start date
  • #1
265
0

Homework Statement



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

Homework Equations



--

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

Attachments

Last edited:

Answers and Replies

  • #2
gneill
Mentor
20,803
2,784
Assuming that you are writing mesh equations for the loops, shouldn't there be an i2 term in eq1?
 
  • #3
265
0
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
 
  • #4
gneill
Mentor
20,803
2,784
Check to make sure that the signs of all terms are correct in eq3. Do they agree with your chosen mesh current directions?
 
  • #5
265
0
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.
 
  • #6
gneill
Mentor
20,803
2,784
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)?
 

Attachments

  • #7
1,069
29
Now how do I go about finding V out.
Hint: What is i3*2R and why should that be interesting for you?

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.
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.
 
  • #8
265
0
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)?
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.
 
  • #9
265
0
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...
 
  • #10
265
0
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.
 
  • #11
gneill
Mentor
20,803
2,784
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).
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.
Using the same conventions, the other two equations would be:

eq2 = v -i2*2r + i1*2r -i2*r -i2*2r + i3*2r
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.
eq3 = -v + i3*2r -i2*2r + i3*r + i3*2r
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.
 
  • #12
265
0
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.
 
  • #13
gneill
Mentor
20,803
2,784
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.
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.
 
  • #14
265
0
Then to find Vout, we use

Code:
vout = v + (Subscript[i, 3])*(2 r) /. sol;
or
Code:
vout = v - (Subscript[i, 3])*(2 r) /. sol;
depending on the conventions in the first three equations?
 
  • #15
gneill
Mentor
20,803
2,784
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.
 
  • #16
265
0
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.
 
  • #17
1,069
29
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:

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

Replies
3
Views
2K
Replies
12
Views
3K
  • Last Post
Replies
2
Views
7K
Replies
2
Views
4K
Replies
3
Views
8K
Replies
2
Views
2K
Replies
3
Views
2K
  • Last Post
Replies
1
Views
2K
  • Last Post
Replies
1
Views
2K
Replies
2
Views
15K
Top