Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.soft-sys.math.maple > #1148
| Date | 2015-06-25 09:29 -0700 |
|---|---|
| From | "Thomas D. Dean" <tomdean@speakeasy.org> |
| Newsgroups | comp.soft-sys.math.maple |
| Subject | Local Variables in Proc |
| Message-ID | <KaidndA_z5XxsRHInZ2dnUU7-LmdnZ2d@megapath.net> (permalink) |
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):
Back to comp.soft-sys.math.maple | Previous | Next — Next in thread | Find similar
Local Variables in Proc "Thomas D. Dean" <tomdean@speakeasy.org> - 2015-06-25 09:29 -0700
Re: Local Variables in Proc Joe Riel <joer@san.rr.com> - 2015-07-03 13:04 -0700
Re: Local Variables in Proc "Thomas D. Dean" <tomdean@speakeasy.org> - 2015-07-07 02:58 -0700
Re: Local Variables in Proc Joe Riel <joer@san.rr.com> - 2015-07-07 09:54 -0700
csiph-web