using System; using L=Science.Physics.GeneralPhysics; namespace Serway.Chapter28 { /// /// Example09: Applying Kirchhoff's Rules /// Find the currents I_1, I_2 and I_3 in the circuit shown in /// Figure 28.17. /// public class Example09 { public Example09() { } private string result; public string Result { get{return result;} } public void Compute() { L.Circuit cir = new L.Circuit(); cir.NumberOfJunctions = 2; L.ElectricPotential[] V = new L.ElectricPotential[2]; V[0] = new L.ElectricPotential(); V[0].V = 0.0; V[1] = new L.ElectricPotential(); V[1].VariableQ = true; cir.PotentialAtJunction = V; cir.NumberOfSegments = 3; L.ElectricCurrent[] I = new L.ElectricCurrent[3]; I[0] = new L.ElectricCurrent(); I[0].VariableQ = true; I[0].FromJunction = 0; I[0].ToJunction = 1; I[1] = new L.ElectricCurrent(); I[1].VariableQ = true; I[1].FromJunction = 0; I[1].ToJunction = 1; I[2] = new L.ElectricCurrent(); I[2].VariableQ = true; I[2].FromJunction = 1; I[2].ToJunction = 0; cir.Current = I; cir.Segment = 0; L.ElectricPotentialDifference v1 = new L.ElectricPotentialDifference(); v1.V = 10.0; L.Resistance r1 = new L.Resistance(); r1.Ohm = 6.0; cir.Add(v1); cir.Add(r1); cir.Segment = 1; L.ElectricPotentialDifference v2 = new L.ElectricPotentialDifference(); v2.V = -14.0; L.Resistance r2 = new L.Resistance(); r2.Ohm = 4.0; cir.Add(v2); cir.Add(r2); cir.Segment = 2; L.Resistance r3 = new L.Resistance(); r3.Ohm = 2.0; cir.Add(r3); cir.KirchhoffRule(); result += I[0].ToString()+" "+ I[1].ToString()+" "+ I[2].ToString()+"\r\n"; } } } //1.99999999999627 +/- 0 (A) -3.00000000000193 +/- 0 (A) -1.00000000000103 +/- 0 (A)