From 86e62575937c8a501009b52a70e37b486a1fea0d Mon Sep 17 00:00:00 2001 From: "W. Trevor King" Date: Tue, 30 Jun 2009 21:12:13 -0400 Subject: [PATCH] Added tests for my asymptote libraries. Also a few tweaks to get Serway_and_Jewett_4/problem19.07.tex and Young_and_Freedman_12/problem21.74.tex to compile. --- asymptote/Circ-test.asy | 49 +++++++++++++++++++ asymptote/ElectroMag-test.asy | 33 +++++++++++++ asymptote/ElectroMag.asy | 5 +- asymptote/Makefile | 14 ++++++ asymptote/Mechanics-test.asy | 39 +++++++++++++++ .../Serway_and_Jewett_4/problem19.07.tex | 25 +++++----- .../Young_and_Freedman_12/problem21.74.tex | 2 +- 7 files changed, 151 insertions(+), 16 deletions(-) create mode 100644 asymptote/Circ-test.asy create mode 100644 asymptote/ElectroMag-test.asy create mode 100644 asymptote/Makefile create mode 100644 asymptote/Mechanics-test.asy diff --git a/asymptote/Circ-test.asy b/asymptote/Circ-test.asy new file mode 100644 index 0000000..3bb523b --- /dev/null +++ b/asymptote/Circ-test.asy @@ -0,0 +1,49 @@ +import Circ; + +real u = 2cm, v=0; + +write("resistor"); +TwoTerminal Rn = resistor((0,v), normal, 0, "$R_{normal}$", "30\ohm"); +dot("beg", Rn.beg, NW); +dot("end", Rn.end, NE); +dot("mid", Rn.mid, S); +TwoTerminal Rvb = resistor((u,v), variable, 0, "$R_{variable}$", "30\kohm"); +v -= u; + +write("capacitor"); +TwoTerminal Cn = capacitor((0,v), normal, 0, "$C_{normal}$", "30 $\mu$F"); +TwoTerminal Ce = capacitor((u,v), electrolytic, 0, "$C_{electrolytic}$", "30 $\mu$F"); +TwoTerminal Cvb = capacitor((2u,v), variable, 0, "$C_{variable}$", "30 $\mu$F"); +TwoTerminal Cvt = capacitor((3u,v), variant, 0, "$C_{variant}$", "30 $\mu$F"); +v -= u; + +write("inductor"); +TwoTerminal Lup = inductor((0,v), Up, 0, "$L_{Up}$", "30 H"); +TwoTerminal Ldown = inductor((u,v), Down, 0, "$L_{Down}$", "30 H"); +v -= u; + +write("diode"); +TwoTerminal Dn = diode((0,v), normal, 0, "$D_{normal}$", "1.3 V"); +TwoTerminal Dz = diode((u,v), zener, 0, "$D_{zener}$", "1.3 V"); +TwoTerminal Dled = diode((2u,v), LED, 0, "$D_{LED}$", "1.7 V"); +v -= u; + +write("battery"); +TwoTerminal B = battery((0,v), 0, "Battery", "1.5 V"); +v -= u; + +write("switch"); +TwoTerminal B = switchSPST((0,v), NO, 0, "$S_{NO}$", "Open"); +TwoTerminal B = switchSPST((u,v), NC, 0, "$S_{NC}$", "Closed"); +v -= u; + +write("current"); +TwoTerminal Icurr = current((0,v), 0, "I", "10 A"); +v -= u; + +write("source"); +TwoTerminal Sdc = source((0,v), DC, 0, "DC", "5 V"); +TwoTerminal Sac = source((u,v), AC, 0, "AC", "5 V$_{pp}$"); +TwoTerminal Si = source((2u,v), I, 0, "I", "5 A"); +TwoTerminal Sv = source((3u,v), V, 0, "V", "5 V"); +v -= u; diff --git a/asymptote/ElectroMag-test.asy b/asymptote/ElectroMag-test.asy new file mode 100644 index 0000000..a4d1be6 --- /dev/null +++ b/asymptote/ElectroMag-test.asy @@ -0,0 +1,33 @@ +import ElectroMag; + +real u = 1cm; + +Charge a = pCharge(center=(0.5u,2u)); +Charge b = pCharge(center=(0,0)); +Charge c = nCharge(center=(-3u,0), q=-3); +Charge cs[] = {a,b,c}; +Distance dab = Distance(b.center, a.center, scale=u, L="$r_1$"); +Distance dbc = Distance(c.center, b.center, scale=u, L="$r_2$"); +Distance ds[] = {dab}; +Angle abc = Angle(a.center, b.center, c.center, radius=.5u, L="$\theta_T$"); +Angle bac = Angle(b.center, a.center, c.center, radius=-0.4u, L="$\phi_x$"); +Angle as[] = {abc, bac}; + +//write(a.center.x); +//write(a.center.y); +for (int i=0; i 0) { - Charge c = pCharge(center, q, radius, outline, L); + c = pCharge(center, q, radius, outline, L); } else { - Charge c = nCharge(center, q, radius, outline, L); + c = nCharge(center, q, radius, outline, L); } return c; } diff --git a/asymptote/Makefile b/asymptote/Makefile new file mode 100644 index 0000000..fe5bf0b --- /dev/null +++ b/asymptote/Makefile @@ -0,0 +1,14 @@ +MODULES = Circ ElectroMag Mechanics + +all : $(MODULES:%=%-test.pdf) + +view : $(MODULES:%=%-view) + +clean : + rm -f $(MODULES:%=%-test.pdf) + +%-view : %-test.pdf + xpdf $< & + +%-test.pdf : %-test.asy $(MODULES:%=%.asy) + asy -f pdf $< diff --git a/asymptote/Mechanics-test.asy b/asymptote/Mechanics-test.asy new file mode 100644 index 0000000..3cc5e40 --- /dev/null +++ b/asymptote/Mechanics-test.asy @@ -0,0 +1,39 @@ +import Mechanics; + +real u = 1cm; + +Mass a = Mass(center=(0,0)); +Mass b = Mass(center=(2u,1u)); +Mass c = Mass(center=(1u,-2u)); +Mass ms[] = {a,b, c}; +Distance dab = Distance(a.center, b.center, scale=u, L="$r_{ab}$"); +Distance dac = Distance(a.center, c.center, scale=u, L="$r_{ac}$"); +Distance ds[] = {dab, dac}; +Angle bac = Angle(b.center, a.center, c.center, radius=-.5u, L="$\theta_T$"); +Angle as[] = {bac}; + +Vector vs[]; + +vs.push(ihat(center=(0,u))); +vs.push(jhat(center=(0,u))); + +for (int i=0; i