// maxwell_eqn.c computer many of Maxwell's Equations #include #include #include // constants static double c = 299.792458E+6 ; // speed of light, meters per second, L/T static double pi = 3.1415926535897932384626433832795028841971 ; // pi, radians static double eps0 = 8.854E-12; // permittivity vacuum, farads/meter, // units T^2Q^2/ML^3 static double mu0 = 0.0; // pi*4E-7 permeability vacuum, henry/meter, // units ML/Q^2 (eps0*mu0 units T^2/L^2) // dimensional units // L length in meters // T time in seconds // M mass in kilograms // Q charge in int main(int argc, char *argv[]) { double Q; // electric charge in coulombs, units Q, 6.291E+18 electrons // charge on one farad capacitor to produce one volt double mass; // mass in kilograms, units M double T; // time in seconds, units T double length; // length in meters, units L double speed; // speed in meters per second, units L/T double E[3]; // electric field in volts per meter, units ML/T^2Q double D[3]; // electric displacement in coulomb per square meter, units Q/L^2 double B[3]; // magnetic flux in weber per square meter, units M/TQ double H[3]; // magnetic intensity in ampere per meter, Q/TL double J; // current density in amperes per square meter, units Q/TL^2 double I; // current in amperes, coulombs per second, units Q/T double V; // voltage in volts, units ML^2/T^2Q ( V=IR ) double R; // resistance in ohms, units ML^2/TQ^2 double C; // capacitance in farads, units T^2Q^2/ML^2 // C = Q/V, parallel plate C = eps0*area/spacing double L; // inductance in henrys, units ML^2/Q^2 double rho; // charge density in coulomb per cubic meter, units Q/L^3 double lambda; // wave length in meters, units L double omega; // angular frequency in radians per second, units 1/T double F; // frequency in hertz, cycles per second, units 2*pi/T double impedance; // free space 120*pi ohm, units ML^2/TQ^2 // capacitor Z = 1/omega*C*i = 1/2*pi*f*c*i , i=sqrt(-1) // inductor Z = omega*L = 2*pi*F*L double energy; // joules, units ML^2/T^2 // stored energy = 1/2 CV^2 = 1/2 LI^2 double power; // watts = joules per second, units ML^2/T^3 // I^2R, V^2/R, double cchk; mu0 = pi*4.0E-7; printf("maxwell_eqn.c demonstration running \n"); printf("values of constants in this program \n"); printf("c = %e speed of light in meters per second, units L/T \n", c); printf("pi = %e radians, no units \n", pi); printf("eps0 = %e permittivity vacuum, farads/meter, units T^2Q^2/ML^3 \n", eps0); printf("mu0 = %e permeability vacuum, henry/meter, units ML/Q^2 \n", mu0); cchk = 1.0/sqrt(eps0*mu0); printf("check 1/sqrt(eps0*mu0) = c = %e \n", cchk); printf("\n"); printf("definition and units of variables used in this program \n"); printf("rho = charge density per unit volume, units Q/L^3 \n"); printf("E electric field in volts per meter, units ML/T^2Q \n"); printf(" vector, value in x, y, z direction, may change with time \n"); printf("D electric displacement in coulomb per square meter, units Q/L^2\n"); printf(" D = eps0 E \n"); printf("B magnetic flux in weber per square meter, units M/TQ \n"); printf(" vector, value in x, y, z direction, may change with time \n"); printf("H magnetic intensity in ampere per meter, Q/TL \n"); printf(" H = 1/mu0 B \n"); printf("J current density in amperes per square meter, units Q/TL^2 \n"); printf("Q electric charge in coulombs, units Q, 6.291E+18 electrons \n"); printf("I current in amperes, coulombs per second, units Q/T \n"); printf("R resistance in ohms, units ML^2/TQ^2 \n"); printf("V voltage in volts, units ML^2/T^2Q ( V=IR ) \n"); printf("C capacitance in farads, units T^2Q^2/ML^2 \n"); printf(" C = Q/V, parallel plate C = eps0*area/spacing \n"); printf("L inductance in henrys, units ML^2/Q^2 \n"); printf("lambda wave length in meters, units L \n"); printf("T time in seconds, units T \n"); printf("F frequency in hertz, cycles per second, units 2*pi/T \n"); printf("omega angular frequency in radians per second, units 1/T \n"); printf(" \n"); printf(" equations, d is partial derivative \n"); printf("div E = rho/eps0 \n"); printf("div B = 0 \n"); printf("curl E = - dB/dt \n"); printf("curl B = mu0 * (J + eps0* dE/dt) \n"); printf("div D = rho \n"); printf("curl H = J + dD/dt \n"); printf("V = L dI/dT \n"); printf("I = C dV/dt \n"); printf(" \n"); printf("wave equations \n"); printf("del^2 E = 1/c^2 d^2E/dt^2 \n"); printf("del^2 B = 1/c^2 d^2B/dt^2 \n"); printf(" V = I omega L single frequency alternating current \n"); printf(" I = V omega C complex numbers used to represent phase\n"); printf(" \n"); printf("charge Q = integral over volume of rho \n"); printf("current I = integral over surface of J dot ds \n"); printf(" \n"); printf("math definitions dE/dx partial derivative of E with respect to x \n"); printf("dEz/dy partial derivative of z component of E with respect to y \n"); printf("divergence, del dot E, div E = dE/dx + dE/dy + dE/dz \n"); printf("curl, del cross E, curl E = [dEz/dy - dEy/dz, dEx/dz - dEz/dx, \n"); printf(" dEy/dx - dEx/dy] vector in x,y,z \n"); printf("d^2E/dt^2 second derivative of E with respect to t \n"); printf("del^2 E is Laplacian of E = d^2E/dx^2 + d^2E/dy^2 + d^2E/dz^2 \n"); printf(" \n"); printf("Simulation in three dimensions, x,y,z and time t may use \n"); printf("a four dimensional array with each element containing: \n"); printf(" E, B, J, rho, and possibly mass and velocity, etc \n"); printf(" \n"); printf("maxwell_eqn.c finished \n"); return 0; } // end main