Mesh current method
The Mesh Current Method is used to calculate electric circuits with more than one loop. Calculating mesh means to find the currents in all mesh branches. Both Kirchhoff's laws are the basis for that method.
The First Kirchhoff's law says that the total algebraic sum of all branch currents, which are connected to the node, is zero. Some currents are flowing to the node, some are leaving the node, but the total is zero, because the node is not able to accumulate electric charge.
The Second Kirchhoff's law says that the total sum of voltages on resistive elements within a loop is equal to the sum of all voltage sources within that loop.
Consider the following mesh, which we need to calculate:
The total number of nodes: N = 2. The total number of independent node equations we can write is: n = N - 1 = 1. The number of branches (and also unknown currents) is 3. The number of equations we can compose according to Mesh Current Method is: m = M - n = 3 - 1 = 2. In other words, the mesh contains two loops, and we can compose two equations in total.
Next we choose the loops in the mesh, there is some virtual current flowing within each loop. We need to consider some direction for that virtual currents (IA and IB). Direction is not important at this point, we just need to choose one. Then we write the voltage balance equations for each loop, based on the Kirchhoff's second law. The obtained equation system is then resolved around the unknown virtual currents (IA and IB). The real currents (I1, I2, I3) can be then expressed through the virtual ones.
For each loop, the sum of all resistive element voltages equals the sum of voltage sources. If the voltage source direction source is opposite to the chosen loop direction - it enters the equation with "minus" sign.
Let's compose the equations:
There are two virtual currents flowing through R02 - hence they both are present in the equations. Let's rewrite the equations in a bit different way, so that's easier to solve them:
This is the system of linear algebraic equations with two unknowns IA and IB. After we solve it, the real currents can be found as:
If some current has a negative value in the end, this only means that the real current flows in direction opposite to the chosen one.