Path: csiph.com!usenet.pasdenom.info!weretis.net!feeder4.news.weretis.net!eternal-september.org!feeder.eternal-september.org!mx02.eternal-september.org!.POSTED!not-for-mail From: Joe Riel Newsgroups: comp.soft-sys.math.maple Subject: Re: Local Variables in Proc Date: Fri, 03 Jul 2015 13:04:56 -0700 Organization: A noiseless patient Spider Lines: 111 Message-ID: <876161c8if.fsf@san.rr.com> References: Mime-Version: 1.0 Content-Type: text/plain Injection-Info: mx02.eternal-september.org; posting-host="15591ad2607da309a0d1a78a1d632bc7"; logging-data="20293"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18aIupfze3Nrpy6uIMu7N67" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.4 (gnu/linux) Cancel-Lock: sha1:i1MK4+NRRkl57KDDhbQZhjbkc5k= sha1:h9f6JsHDtvwAVskc/yfE6qFwroc= Xref: csiph.com comp.soft-sys.math.maple:1151 "Thomas D. Dean" writes: > See below. > > I want to make a group of variables in a proc local. > > But, I call Syrup[Solve] and the variables are not resolved. > > How do I do this? > > Tom Dean > > ## simulate the source for the ideal loop, > ## http://www.vlf.it/feletti2/idealloop.html > ## > ## restart; > with(Syrup): with(ScientificConstants): > loop := proc(wire_sel) > description "Calculations on a loop antenna designed for VLF applications." > " The argument wire_sel is the index into the wire constants vectors." > " The return value, vout, contains a variable f, the frequency." > " "; > local A, R, gauge, Dia, len_kg, dia, N, L, Cl; > local Cs, Rin, Cin, Rlk, mu, Z, Clight, lambda, h; > local rho, B, omega, Vsource, ckt, volts, others, vout; > local resist; > # loop dimensions > A :=(475/10*Unit('cm'))^2; > R :=60; > gauge := < 26, 24, 22, 20, 18>; > Dia := < 410, 510, 640, 800, 1000>; > len_kg := <8875, 5485, 3464, 2167, 1366> / 10; > resist := 348/10*len_kg/1000; ## ohms/km * m / (m/km) > ##wire_sel := 4; > dia := Dia[wire_sel]*Unit('um'); > N := floor(simplify(len_kg[wire_sel]*Unit('m') / 4 / sqrt(A))); > L := 80*Unit('mH'); > Cl :='Cl'; ## prevent errors > Cl := 235*Unit('pF'); > Cs :='Cs'; ## prevent errors > Cs := 510*Unit('pF'); > Rin := 75/10*Unit('kOmega'); ## ad797 differential input stage > Cin := 20*Unit('pF'); ## ad797 differential input stage > Rlk := 100*Unit('MOmega'); ## ad797 differential input stage > ## > ## derived values from physical constants > mu[0] := GetValue(Constant('mu[0]'))*GetUnit(Constant('mu[0]')); > mu[r] := 1; > Z[0] := GetValue(Constant('Z[0]'))*GetUnit(Constant('Z[0]')); > Clight := GetValue(Constant('c'))*GetUnit(Constant('c')); > lambda := Clight/(f*Unit('Hz')); > h[e] := simplify(2*Pi*N*A*mu[r]/lambda); > rho := 17240*10^(-12)*Unit('Omega*m'); > ## radiation resistance > R[rad] := simplify(Z[0] * 2/3 * Pi * (h[e]/lambda)^2); > ## AC resistance > R[ac] := simplify(4 * N * sqrt(A) / (Pi * dia) * > sqrt(Pi*mu[0]*f*Unit('Hz') > *rho)); > ## dc resistance > R[dc] := resist[wire_sel]; ## > simplify(4*N*sqrt(A)/((Pi*dia^2)/4)*rho); > ## source controlled source > ## Z[0] :=GetValue(Constant('Z[0]')); > ## mu[0]:=GetValue(Constant('mu[0]')); > ## B is in tesla (or Wb, H is A/m, B = mu[0] * mu[r] * H > ## use 1pT as source field strength > ## B:=convert(1,'units','pT','kg/(A*s^2)'); > ## H:=solve(B=mu[0]*GetUnit(Constant('mu[0]'))*mu[r]*'H','H'); > ## H:=1e-12*Unit('T')/mu[0]/GetUnit(Constant('mu[0]')); > ## > ## Volts = meter^2 * kg / (s^3 * A) > ## to get from tesla to volts: simplify(Unit('Hz')*Unit('m^2')*Unit('pT')); > B :=1*Unit('pT'); > ## or, freq * area * tesla > omega :=2*Pi*f*Unit('Hz'); > > ## loop voltage source > Vsource := simplify(omega*A*N*B); > > ckt := "* Ideal Loop Source\n" > "Vloop 1 2 map(convert,Vsource,unit_free)\n" > "Lloop 2 3 map(convert,L,unit_free)\n" > "Rac 3 4 map(convert,R[ac],unit_free)\n" > "Rdc 4 5 map(convert,R[dc],unit_free)\n" > "Rrad 5 6 map(convert,R[rad],unit_free)\n" > "Cloop 6 1 map(convert,Cl,unit_free)\n" > "Cshield1 1 0 map(convert,Cs/2,unit_free)\n" > "Cshield2 6 0 map(convert,Cs/2,unit_free)\n" > "Rload 6 1 map(convert,Rin,unit_free)\n" > "Cload 6 1 map(convert,Cin,unit_free)\n" > "Rleak 1 0 map(convert,Rlk,unit_free)\n" > ".end"; > # > volts,others:=Solve(ckt,returnall); > assign(volts); > vout:=eval(v[6]-v[1],s=I*map(convert,omega,unit_free)); > vout:=simplify(vout); > print(Rlk); > evala(vout); > end proc: > > vout := loop(4): What problem are you seeing? The procedure runs here, but I'm using a developmental version of Syrup. It returns 100 [MΩ] -- Joe Riel