using System; using GP = Science.Physics.GeneralPhysics; namespace ScienceTest.PhysicsTest.GeneralPhysicsTest { /// /// ElectricFluxTest /// public class ElectricPotentialTest { public ElectricPotentialTest() { } private string result; public string Result { get{return result;} } public void Compute() { GP.Scalar.FunctionOfPosition func = new GP.Scalar.FunctionOfPosition(cd); GP.ChargeDensity rho = new GP.ChargeDensity(); rho.ScalarFunctionOfPosition = func; GP.Volume v = new GP.Volume(); v.XTo = 1.0; v.XFrom = -1.0; v.YTo = 2.0; v.YFrom = -2.0; v.ZTo = 2.0; v.ZFrom = -2.0; GP.Position r = new GP.Position(); r.X = 2.0; r.Y = 4.0; r.Z = 4.0; GP.ElectricPotential V = new GP.ElectricPotential(rho,v,r); double k = GP.Constant.CoulombConstant * 4.0 * Math.PI / 3.0; result += V.ToString() + "\r\n"; result += (V.V/k).ToString() + " " + (V.StandardDeviation/k).ToString(); } private GP.Scalar cd(GP.Position r) { GP.Scalar s = new GP.Scalar(); if (r.X * r.X + r.Y * r.Y + r.Z * r.Z <= 1.0) s.Magnitude = 1.0; else s.Magnitude = 0.0; return s; } } } /* 6275244721.94193 +/- 2656907.25807932(V) 0.166687546582762 7.05746742909694E-05 */