using System; using Science.Mathematics; using L=Science.Physics.GeneralPhysics; namespace Serway.Chapter24 { /// /// Example02: Flux Through a Cube /// Consider a uniform electric field E oriented in the /// x direction. Find the net electric flux through the /// surface of a cube of edge length l, oriented as shown /// in Figure 24.5. /// \Phi_E = 0.0 /// public class Example02 { public Example02() { } private string result; public string Result { get{return result;} } double length = 1.0; public void Compute() { L.Vector.Field vf = new L.Vector.Field(efield); L.ElectricField E = new L.ElectricField(); E.VectorField = vf; L.Surface.Parameterization paraToPosition = new L.Surface.Parameterization(func); L.Surface S = new L.Surface(); S.ParameterToPosition = paraToPosition; L.Length l = new L.Length(); l.m = length; S.Parameter1StartValue = 0.0; S.Parameter1EndValue = 6.0*l.m; S.Parameter2StartValue = 0.0; S.Parameter2EndValue = l.m; L.Time t = new L.Time(); L.ElectricFlux Phi = new L.ElectricFlux(E,S,t); result+=Phi.ToString(); } private L.Vector efield(L.Position r, L.Time t) { L.Vector v = new L.Vector(); v.X = 3.0; // constant v.Y = 0.0; v.Z = 0.0; return v; } private L.Position func(double x, double y) { L.Position r = new L.Position(); if(x < length && x > 0.0) { r.X = 0.0; r.Y = x; r.Z = y; } else if(x < 2.0*length && x > length) { r.X = 1.0; r.Y = x-length; r.Z = y; } else if(x < 3.0*length && x > 2.0*length) { r.X = y; r.Y = 0.0; r.Z = x-2.0*length; } else if(x < 4.0*length && x > 3.0*length) { r.X = y; r.Y = 1.0; r.Z = x-3.0*length; } else if(x < 5.0*length && x > 4.0*length) { r.X = x-4.0*length; r.Y = y; r.Z = 0.0; } else { r.X = x-5.0*length; r.Y = y; r.Z = 1.0; } return r; } } } //-2.76933799514629 +/- 0.049429744209711 (Vm)