using System; using GP = Science.Physics.GeneralPhysics; namespace ScienceTest.PhysicsTest.GeneralPhysicsTest { /// /// AmpereLawTest /// public class FundamentalLawTest { private string result; public string Result { get{return result;} } public FundamentalLawTest() { } public void Compute() { // Ampere Law GP.Vector.Field f = new GP.Vector.Field(func); GP.MagneticField B = new GP.MagneticField(); B.VectorField = f; GP.Line.Parameterization fa = new GP.Line.Parameterization(ff); GP.Line C = new GP.Line(fa); C.ParameterStartValue = 0.0; C.ParameterEndValue = 2.0*Math.PI; GP.ElectricCurrent I = new GP.ElectricCurrent(); I.VariableQ = true; GP.DisplacementCurrent Id = new GP.DisplacementCurrent(); Id.A = 0.0; GP.Time t = new GP.Time(); t.s = 0.0; GP.FundamentalLaw.AmpereLaw(B,C,I,Id,t); result += I.ToString()+"\r\n"; // Momentum Conservation Law GP.Mass m1 = new GP.Mass(); m1.kg = 0.01; GP.Mass m2 = new GP.Mass(); m2.kg = 10.0; GP.Velocity v = new GP.Velocity(); v.XVariableQ = true; GP.Mass ma = new GP.Mass(); ma.kg = m1.kg + m2.kg; GP.Length h = new GP.Length(); h.m = 0.1; GP.Work W = new GP.Work(); W.J = -ma.kg * GP.Constant.AccelerationOfGravity * h.m; GP.KineticEnergy Ki = new GP.KineticEnergy(); Ki.VariableQ = true; GP.KineticEnergy Kf = new GP.KineticEnergy(); Kf.J = 0.0; GP.FundamentalLaw.WorkEnergyTheorem(Ki, W, Kf); GP.Velocity V = new GP.Velocity(ma, Ki); GP.Momentum[] pi = new GP.Momentum[1]; pi[0] = new GP.Momentum(m1, v); GP.Momentum[] pf = new GP.Momentum[1]; pf[0] = new GP.Momentum(ma, V); GP.FundamentalLaw.MomentumConservation(pi, pf); v.X = pi[0].X / m1.kg; result += "v=" + v.ToString() + "\r\n"; result += Convert.ToString((m1.kg + m2.kg) / m1.kg * V.X)+"\r\n"; //Faraday Law GP.ElectricPotentialDifference Vd = new GP.ElectricPotentialDifference(); GP.Scalar.FunctionOfTime fu = new GP.Scalar.FunctionOfTime(func1); GP.MagneticFlux Phi = new GP.MagneticFlux(); Phi.ScalarFunctionOfTime = fu; GP.Time tt = new GP.Time(); tt.s = 3.0; GP.FundamentalLaw.FaradayLaw(Vd,Phi,tt); result += Vd.ToString()+"\r\n"; // Work Energy Theorem GP.Mass m = new GP.Mass(); m.kg = 6.0; GP.Displacement x = new GP.Displacement(); x.X = 3.0; GP.Force f1 = new GP.Force(); f1.X = 12.0; GP.Work w1 = new GP.Work(f1, x); GP.KineticEnergy initial = new GP.KineticEnergy(); initial.J = 0.0; // initially at rest GP.KineticEnergy final = new GP.KineticEnergy(); final.VariableQ = true; // true for only one variable GP.FundamentalLaw.WorkEnergyTheorem(initial, w1, final); GP.Velocity v_f = new GP.Velocity(m, final); result += v_f.ToString(); } private GP.Scalar func1(GP.Time t) { GP.Scalar s = new GP.Scalar(); s.Magnitude = 10.0*t.s+t.s*t.s; return s; } private GP.Vector func(GP.Position x, GP.Time t) { GP.Vector res = new GP.Vector(); double r = Math.Sqrt(x.X*x.X+x.Y*x.Y); res.X = -x.Y/r*GP.Constant.PermeabilityOfFreeSpace*7.0 /2.0/Math.PI/r; res.Y = x.X/r*GP.Constant.PermeabilityOfFreeSpace*7.0 /2.0/Math.PI/r; res.Z = 0.0; return res; } private GP.Position ff(double t) { GP.Position x = new GP.Position(); x.X = 100.0*Math.Cos(t); x.Y = 100.0*Math.Sin(t); x.Z = 0.0; return x; } } } /* 7.0000000000017 +/- 0(A) v=1401.4 +/- 0 i +0 +/- 0 j +0 +/- 0 k (m/s) 1401.4 -15.9999999999999 +/- 0(V) 3.46410161513775 +/- 0 i +0 +/- 0 j +0 +/- 0 k (m/s) */