Hi there.
I have been experimenting with Dan Stanger's Maple to Maxima translator,
managing to get it to the point where it translates this:
----------------------------------------------------------------------------
-
R:=0.00008314;
PropMatrix:=[[304.2,73.76,.225],[425.2,38.00,.193]];
k:=[[0,0.130],[0.130, 0]];
PRparamsPure:=proc()
local q; global Tc,Pc,omega,kap,b,ac,a;
for q from 1 to 2 do
Tc[q]:=PropMatrix[q,1];
Pc[q]:=PropMatrix[q,2];
omega[q]:=PropMatrix[q,3];
kap[q]:=0.37464+1.54226*omega[q]-0.26992*(omega[q])^2;
b[q]:=0.07780*R*Tc[q]/Pc[q];
ac[q]:=0.45724*R^2*Tc[q]^2/Pc[q];
a[q] := ac[q]*(1+kap[q]*(1-sqrt(T/Tc[q])))^2;
od:
end:
----------------------------------------------------------------------------
-
into this:
----------------------------------------------------------------------------
-
R : 0.8314;
PropMatrix : matrix ( [ 304.2, 73.76, 0.225 ] , [ 425.2, 38.0, 0.193 ] )
;
k : matrix ( [ 0, 0.130 ] , [ 0.130, 0 ] ) ;
PRparamsPure : lambda ([], block (
[q],
for q : 1 thru 2 do
Tc[q] : PropMatrix[q, 1],
Pc[q] : PropMatrix[q, 2],
omega[q] : PropMatrix[q, 3],
kap[q] : 0.37464 + 1.54226 * omega[q] - 0.26992 * ( ( omega[q] ) )
^ 2,
b[q] : 0.7780 * R * Tc[q] / Pc[q],
ac[q] : 0.45724 * R ^ 2 * Tc[q] ^ 2 / Pc[q],
a[q] : ac[q] * ( ( 1 + kap[q] * ( ( 1 - sqrt ( T / Tc[q] ) ) ) ) )
^ 2 ) )$
----------------------------------------------------------------------------
-
Unfortunately, executing "PRparamsPure()" gives me the output listed at the
end of this email, complaining about the subscript "q" not being an integer.
I am a total beginner at both Maple and Maxima and this one eludes me - "q"
is assigned to the integers 1 and 2 in turn by the for loop and, by way of
further testing, the following sequence works at the toplevel prompt (that
is the for loop index works as expected) and the end result is that a new
subscripted variable is initialised:
-----------------------------------------------
(C6) q:1;
(D6) 1
(C7) PropMatrix[q,1];
(D7) 304.2
(C8) Tc1[q]: PropMatrix[q,1];
(D8) 304.2
(C9) Tc1[q];
(D9) 304.2
(C10) Tc1[1];
(D10) 304.2
(C13) for q1 : 1 thru 2 do
Tc2[q1] : PropMatrix[q1,1];
(D13) DONE
(C14) Tc2[1];
(D14) 304.2
(C15) Tc2[2];
(D15) 425.2
-----------------------------------------------
Any advice would be appreciated.
Cheers
Mike Thomas.
----------------------------------------------------------------------------
-
(C1) R : 0.8314;
(D1) 0.8314
(C2) PropMatrix : matrix ( [ 304.2, 73.76, 0.225 ] , [ 425.2, 38.0,
0.193 ] ) ;
[ 304.2 73.76000000000001 0.225 ]
(D2) [ ]
[ 425.2 38.0 0.193 ]
(C3) k : matrix ( [ 0, 0.130 ] , [ 0.130, 0 ] ) ;
[ 0 0.13 ]
(D3) [ ]
[ 0.13 0 ]
(C4) PRparamsPure : lambda ([], block (
[q],
for q : 1 thru 2 do
Tc[q] : PropMatrix[q, 1],
Pc[q] : PropMatrix[q, 2],
omega[q] : PropMatrix[q, 3],
kap[q] : 0.37464 + 1.54226 * omega[q] - 0.26992 * ( ( omega[q] ) )
^ 2,
b[q] : 0.7780 * R * Tc[q] / Pc[q],
ac[q] : 0.45724 * R ^ 2 * Tc[q] ^ 2 / Pc[q],
a[q] : ac[q] * ( ( 1 + kap[q] * ( ( 1 - sqrt ( T / Tc[q] ) ) ) ) )
^ 2 ) );
(D4) LAMBDA([], BLOCK([q], FOR q THRU 2 DO Tc : PropMatrix ,
q q, 1
Pc : PropMatrix , OMEGA : PropMatrix ,
q q, 2 q q, 3
0.778 R Tc
2 q
kap : 0.37464 + 1.54226 OMEGA + (- 0.26992) OMEGA , b : -----------,
q q q q Pc
q
2 2
0.45724 R Tc
q T 2
ac : --------------, a : ac (1 + kap (1 - SQRT(---))) ))
q Pc q q q Tc
q q
(C5) PRparamsPure();
Subscript must be an integer:
q
#0: PRparamsPure()
-- an error. Quitting. To debug this try DEBUGMODE(TRUE);)
(C6)
----------------------------------------------------------------------------
-