1 /* Test suite for ElectroMag.asy.
3 * Copyright (C) 2008-2009 W. Trevor King <wking@drexel.edu>
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License along
16 * with this program; if not, write to the Free Software Foundation, Inc.,
17 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
24 Charge a = pCharge(center=(0.5u,2u));
25 Charge b = aCharge(center=(0,-0.5u), q=1);
26 Charge c = nCharge(center=(-3u,-0.5u), q=-3);
27 Charge cs[] = {a,b,c};
28 Distance dab = Distance(b.center(), a.center(), scale=u, L="$r_1$");
29 Distance dbc = Distance(c.center(), b.center(), scale=u, L="$r_2$");
30 Distance ds[] = {dab};
32 a.center(), b.center(), c.center(), radius=.5u, L="$\theta_T$");
34 b.center(), a.center(), c.center(), radius=-0.4u, L="$\phi_x$");
35 Angle as[] = {abc, bac};
39 for (int i=0; i<cs.length; i+=1)
41 for (int i=0; i<ds.length; i+=1)
43 for (int i=0; i<as.length; i+=1)
46 CoulombEFields((-0.5u, 1.2u), c=cs, scale=2u, unit=u/2);
47 //Vector Fba = CoulombForce(b,a, scale=2u, unit=u);
49 CoulombForces(c=cs, scale=2u, unit=u);
51 Charge a = aCharge(center=(-2u, 2u), q=0);
53 Vector v = EField(a.center(), mag=u/2, dir=0,L="E"); v.draw();
54 Vector v = BField(a.center(), mag=u/2, dir=90,L="B"); v.draw();
55 Vector v = Velocity(a.center(), mag=u/2, dir=180,L="$v$"); v.draw();
57 Vector Ic = Current(center=(-0.7u, 2.2u), phi=90, L="$I$"); Ic.draw();
58 draw(shift(Ic.center)*scale(16pt)*unitcircle, BFieldPen, ArcArrow);
60 a = aCharge(center=(-3u, 2u), q=-1);