using System; using L=Science.Physics.GeneralPhysics; namespace Serway.Chapter28 { /// /// Example08: A Single-Loop Circuit /// A single-loop circuit contains two resistor and two /// batteries, as shown in Figure 28.16. (Neglect the internal /// resistances of the batteries.) /// (A) /// Find the current in the circuit. /// (B) /// What power is delivered to each resistor? /// What power is delivered by the 12-V battery? /// public class Example08 { public Example08() { } private string result; public string Result { get{return result;} } public void Compute() { L.Circuit cir = new L.Circuit(); cir.NumberOfJunctions = 1; L.ElectricPotential[] V = new L.ElectricPotential[1]; V[0] = new L.ElectricPotential(); V[0].V = 0.0; cir.PotentialAtJunction = V; cir.NumberOfSegments = 1; L.ElectricCurrent[] I = new L.ElectricCurrent[1]; I[0] = new L.ElectricCurrent(); I[0].VariableQ = true; I[0].FromJunction = 0; I[0].ToJunction = 0; cir.Current = I; cir.Segment = 0; L.ElectricPotentialDifference v1 = new L.ElectricPotentialDifference(); v1.V = 6.0; L.Resistance r1 = new L.Resistance(); r1.Ohm = 8.0; L.ElectricPotentialDifference v2 = new L.ElectricPotentialDifference(); v2.V = -12.0; L.Resistance r2 = new L.Resistance(); r2.Ohm = 10.0; cir.Add(v1); cir.Add(r1); cir.Add(v2); cir.Add(r2); cir.KirchhoffRule(); //(A) result += I[0].ToString()+"\r\n"; //(B) L.ElectricPower P1 = new L.ElectricPower(r1,I[0]); L.ElectricPower P2 = new L.ElectricPower(r2,I[0]); result += P1.ToString()+"\r\n"; result += P2.ToString()+"\r\n"; } } } /* -0.333333333332361 +/- 0 (A) 0.888888888883705 +/- 0 (W) 1.11111111110463 +/- 0 (W) */