using System; using GP = Science.Physics.GeneralPhysics; namespace ScienceTest.PhysicsTest.GeneralPhysicsTest { /// /// KirchhoffTest /// public class CircuitTest { public CircuitTest() { } private string result; public string Result { get{return result;} } public void Compute() { GP.Circuit cir = new GP.Circuit(); cir.NumberOfJunctions = 2; GP.ElectricPotential[] V = new GP.ElectricPotential[2]; V[0] = new GP.ElectricPotential(); V[0].V = 0.0; V[1] = new GP.ElectricPotential(); V[1].VariableQ = true; cir.PotentialAtJunction = V; cir.NumberOfSegments = 3; GP.ElectricCurrent[] I = new GP.ElectricCurrent[3]; I[0] = new GP.ElectricCurrent(); I[0].VariableQ = true; I[0].FromJunction = 0; I[0].ToJunction = 1; I[1] = new GP.ElectricCurrent(); I[1].VariableQ = true; I[1].FromJunction = 0; I[1].ToJunction = 1; I[2] = new GP.ElectricCurrent(); I[2].VariableQ = true; I[2].FromJunction = 1; I[2].ToJunction = 0; cir.Current = I; cir.Segment = 0; GP.ElectricPotentialDifference v1 = new GP.ElectricPotentialDifference(); v1.V = 10.0; GP.Resistance r1 = new GP.Resistance(); r1.Ohm = 6.0; cir.Add(v1); cir.Add(r1); cir.Segment = 1; GP.ElectricPotentialDifference v2 = new GP.ElectricPotentialDifference(); v2.V = -14.0; GP.Resistance r2 = new GP.Resistance(); r2.Ohm = 4.0; cir.Add(v2); cir.Add(r2); cir.Segment = 2; GP.Resistance r3 = new GP.Resistance(); r3.Ohm = 2.0; cir.Add(r3); cir.KirchhoffRule(); result += I[0].A.ToString()+"\r\n"+ I[1].A.ToString() + "\r\n" + I[2].A.ToString() + "\r\n" + V[0].V.ToString() + "\r\n" + V[1].V.ToString() + "\r\n"; } } } /* 2.0000000000183 -2.99999999990646 -0.999999999948423 0 -2.00000000025283 */