SPL-ethz / CAT

Open Source Population Balance Equation Solver
http://www.spl.ethz.ch/scientificeducationaltools/cat
GNU General Public License v3.0
16 stars 8 forks source link

Anonymous functions fail when dependent on variables #77

Closed miggland closed 10 years ago

miggland commented 10 years ago

Example:

rhoW = @(T) -2e-07(T).^4; P.solubility = @(T) (3.e-06(T).^4 )./rhoW(T);

Running this will fail with the error that rhoW is not defined - this is because the function is redefined in a context in which rhoW is not defined, to add xm. The definition below will work:

P.solubility = @(T,xm) (3.e-06*(T).^4 )./rhoW(T);

miggland commented 10 years ago

This is fixed with the introduction of the function evalanonfunc - the definition of functions is now more flexible to the user, but in the solver, functions need to be evaluated using evalanonfunc. Example:

G = evalanonfunc(O.growthrate, S,T,y,t);