"Bad MatrixOPs token" error
Jakub
Dear Colleagues,
When I'm trying to execute the following code:
Function Kohler()
Variable T = 320, k = 1.38E-23, o = 72.64E-3, n = 6.348E28, Ms = .092, Mw = .018, p = 2600, i = 1, ro=0, Vol=0, mass=0, m=0
make /O/N=1000 r0
SetScale/P x, 1e-7, 1e-6, r0
r0=x+9e-7
ro=0.5e-6; //initial radius of a dry droplet
Vol=(4/3)*pi*ro^3;
mass=Vol*p;
m=mass/Ms;
MatrixOP/O/FREE E=(exp((2*o)/(n*k*T*r0)))*(1/(1+((i*m*Mw)/(Ms*(((4/3)*pi*(powR(r0,3))*p)-m)))));
end
Variable T = 320, k = 1.38E-23, o = 72.64E-3, n = 6.348E28, Ms = .092, Mw = .018, p = 2600, i = 1, ro=0, Vol=0, mass=0, m=0
make /O/N=1000 r0
SetScale/P x, 1e-7, 1e-6, r0
r0=x+9e-7
ro=0.5e-6; //initial radius of a dry droplet
Vol=(4/3)*pi*ro^3;
mass=Vol*p;
m=mass/Ms;
MatrixOP/O/FREE E=(exp((2*o)/(n*k*T*r0)))*(1/(1+((i*m*Mw)/(Ms*(((4/3)*pi*(powR(r0,3))*p)-m)))));
end
I'm getting the bad matrixOPs token error. Is it because I'm trying to use variables in the MatrixOP call? There is one wave in there, which is the r0 1D Wave. Should I make waves instead of variables for it to work? I'm using Igor 8.04.
Kind regards,
Jakub
Your wave isn't a matrix, and there is no real reason to use MatrixOp for that expression.
Here is your code rewritten as a regular wave assignment statement:
Variable T = 320, k = 1.38E-23, o = 72.64E-3, n = 6.348E28, Ms = .092, Mw = .018, p_var = 2600, i_var = 1, ro=0, Vol=0, mass=0, m=0
make /O/N=1000 r0
SetScale/P x, 1e-7, 1e-6, r0
r0=x+9e-7
ro=0.5e-6; //initial radius of a dry droplet
Vol=(4/3)*pi*ro^3;
mass=Vol*p_var;
m=mass/Ms;
Make/O/FREE/N=(numpnts(r0)) Ewave
// TODO: Do you want Ewave to be single precison float (the default)
// or double precision? If double, add the /D flag to the Make command above
MultiThread Ewave =(exp((2*o)/(n*k*T*r0[p])))*(1/(1+((i_var*m*Mw)/(Ms*(((4/3)*pi*(r0[p]^3)*p_var)-m)))));
end
Note the TODO item about the number type of the output wave.
I also changed two of your variable names, p->p_var and i->i_var. p and i are Igor function names. If you create a variable with the same name then the variable is used instead of the Igor function with the same name, which is confusing (and can lead to an incorrect result).
November 2, 2020 at 04:55 am - Permalink
Hello Jakub,
The expression you wrote may have the advantage that it is very readable but it is computationally very inefficient. MatrixOP does not care about the efficiency but you ran into problems with the divisions where you need to use the rec() function. Here is a quick attempt at modifying your code:
Variable T = 320, k = 1.38E-23, o = 72.64E-3, n = 6.348E28, Ms = .092
Variable Mw = .018, p = 2600, i = 1, ro=0, Vol=0, mass=0, m=0
make /O/N=1000 r0
SetScale/P x, 1e-7, 1e-6, r0
r0=x+9e-7
ro=0.5e-6; //initial radius of a dry droplet
Vol=(4/3)*pi*ro^3;
mass=Vol*p;
m=mass/Ms;
Variable Sp1=2*o
Variable Sp2=n*k*T
Variable Sp3=i*m*Mw
Variable Sp4=(4/3)*pi
MatrixOP/O Ew=exp(rec(r0)*sp1/sp2)*rec(1+(Sp3*rec(Ms*(Sp4*powR(r0,3)*IndexRows(r0)-m))))
end
I hope it helps,
AG
November 2, 2020 at 03:06 pm - Permalink
Static Constant o = 72.64E-3
Static Constant n = 6.348E28
Static Constant Ms = 0.092
Static Constant Mw = 0.018
Static Constant rho = 2600
Static Constant ro = 0.5e-6
Function Kohler(variable TK)
variable mass, m
variable sp1, sp2, sp3, sp4
// initialize values
make/O/N=1000/D r0
SetScale/P x, 1e-7, 1e-6, r0
r0=x+9e-7
// mass and moles?
mass=((4/3)*pi*ro^3)*rho
m=mass/Ms
// factors
sp1=2*o
sp2=n*k*TK
sp3=m*Mw
sp4=(4/3)*pi
// expression
MatrixOP/O Ew=exp(rec(r0)*sp1/sp2)*rec(1+(sp3*rec(Ms*(sp4*powR(r0,3)*IndexRows(r0)-m))))
return 0
end
In case you are interested in the evolution with temperature.
November 2, 2020 at 06:12 pm - Permalink
To add detail to AG's comment, for the "/" operator the MatrixOP help states:
November 3, 2020 at 05:38 am - Permalink