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

In summary, the author attempted to solve three equations using Mathematica and found that the equation for the first loop (associated with current i1) was -v + i1*2r + i1*2r -i2*2r. However, when he attempted to find V out, he was not able to get the system correct. He recommends that someone more experienced with circuits help him solve the equation for V out.
  • #1
stripes
266
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

  • Capture.JPG
    Capture.JPG
    20.7 KB · Views: 504
Last edited:
Physics news on Phys.org
  • #2
Assuming that you are writing mesh equations for the loops, shouldn't there be an i2 term in eq1?
 
  • #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
 
  • #4
Check to make sure that the signs of all terms are correct in eq3. Do they agree with your chosen mesh current directions?
 
  • #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.
 
  • #6
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

  • Fig1.gif
    Fig1.gif
    6.1 KB · Views: 794
  • #7
stripes said:
Now how do I go about finding V out.

Hint: What is i3*2R and why should that be interesting for you?

stripes said:
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
gneill said:
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
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
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
stripes said:
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
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
stripes said:
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
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
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
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
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:

1. How does Mathematica help in solving Kirchhoff's rules?

Mathematica is a powerful computational software that can handle complex mathematical operations and simulations. It has built-in functions and algorithms that can quickly solve Kirchhoff's rules, making it an efficient tool for finding V out.

2. What are Kirchhoff's rules and how are they used in circuit analysis?

Kirchhoff's rules are two fundamental laws in circuit analysis: Kirchhoff's current law (KCL) and Kirchhoff's voltage law (KVL). KCL states that the algebraic sum of currents entering a node in a circuit must be equal to the algebraic sum of currents leaving that node. KVL states that the algebraic sum of voltages around a closed loop in a circuit must be equal to zero. These rules are used to analyze and solve complex circuits.

3. Is Mathematica the only tool for solving Kirchhoff's rules?

No, there are other computational tools and software that can also be used to solve Kirchhoff's rules. However, Mathematica is a popular choice among scientists and engineers due to its versatility and efficiency in handling complex mathematical operations.

4. Can Mathematica handle both series and parallel circuits?

Yes, Mathematica can handle both series and parallel circuits. It has built-in functions such as "Series" and "Parallel" that can quickly simplify and solve these types of circuits using Kirchhoff's rules.

5. Can Mathematica find V out for circuits with multiple sources?

Yes, Mathematica can solve circuits with multiple sources using Kirchhoff's rules. It can handle circuits with DC and AC sources, making it a suitable tool for a wide range of circuit analysis problems.

Similar threads

  • Introductory Physics Homework Help
Replies
1
Views
431
  • Introductory Physics Homework Help
Replies
2
Views
986
  • Introductory Physics Homework Help
Replies
17
Views
2K
  • Introductory Physics Homework Help
Replies
1
Views
1K
  • Introductory Physics Homework Help
Replies
1
Views
699
  • Introductory Physics Homework Help
Replies
16
Views
1K
  • Introductory Physics Homework Help
Replies
8
Views
2K
  • Introductory Physics Homework Help
Replies
7
Views
2K
  • Introductory Physics Homework Help
Replies
3
Views
1K
  • Engineering and Comp Sci Homework Help
Replies
6
Views
736
Back
Top