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 string subscripts[] = {"a"};
29 Distance dab = Distance(b.center(), a.center(), scale=u, L="$r_1$");
30 Distance dbc = Distance(c.center(), b.center(), scale=u, L="$r_2$");
31 Distance ds[] = {dab};
33 a.center(), b.center(), c.center(), radius=.5u, L="$\theta_T$");
35 b.center(), a.center(), c.center(), radius=-0.4u, L="$\phi_x$");
36 Angle as[] = {abc, bac};
40 for (int i=0; i<cs.length; i+=1)
42 for (int i=0; i<ds.length; i+=1)
44 for (int i=0; i<as.length; i+=1)
47 CoulombEFields((-0.5u, 1.2u), c=cs, subscripts=subscripts, scale=2u, unit=u/2);
48 //Vector Fba = CoulombForce(b,a, scale=2u, unit=u);
50 CoulombForces(c=cs, subscripts=subscripts, scale=2u, unit=u);
52 Charge a = aCharge(center=(-2u, 2u), q=0);
54 Vector v = EField(a.center(), mag=u/2, dir=0,L="E"); v.draw();
55 Vector v = BField(a.center(), mag=u/2, dir=90,L="B"); v.draw();
56 Vector v = Velocity(a.center(), mag=u/2, dir=180,L="$v$"); v.draw();
58 Vector Ic = Current(center=(-0.7u, 2.2u), phi=90, L="$I$"); Ic.draw();
59 draw(shift(Ic.center)*scale(16pt)*unitcircle, BFieldPen, ArcArrow);
61 a = aCharge(center=(-3u, 2u), q=-1);