Open bas-rustenburg opened 9 years ago
Plans:
experiment
and extract the necessary data earlier.expected_injection_heats
similar to TwoComponentBindingModel expected_injection_heats
a static method (no ref to self
)equilibrium_concentrations
. The ODE solver is probably slow.I haven't verified in detail, but perhaps the ode
function can be written to use numexpr to speed it up?
workdir/bitc.profile% stats \bode\b
Wed Feb 18 21:55:14 2015 workdir/bitc.profile
158007904 function calls (156067107 primitive calls) in 209.440 seconds
Ordered by: cumulative time
List reduced from 5159 to 2 due to restriction <'\\bode\\b'>
ncalls tottime percall cumtime percall filename:lineno(function)
131803 2.548 0.000 139.944 0.001 bitc/models.py:601(ode)
1 0.000 0.000 0.000 0.000 /home/bas/anaconda/lib/python2.7/site-packages/scipy/integrate/_ode.py:103(ode)
Will give that a shot.
I think dc_n = - c_n[:] + Ka_n[:] * (x_Ln[:]/V - c_n[:]) * (x_R/V - c_n[:].sum())
can become something like
import numexpr as ne
dc_n = ne.evaluate('-c_n + Ka_n*(x_Ln/V - c_n) * (x_R/V - sum(c_n))')
File "/home/bas/anaconda/lib/python2.7/site-packages/numexpr/necompiler.py", line 726, in evaluate
a = global_dict[name]
KeyError: 'V'
AFAICT numexpr takes its variables from the surrounding context, perhaps V is not accessible?
editing to avoid spamming the thread: maybe it would be easier to rewrite the equilibrium_concentration
function to not have nested functions?
Will have to remodel the way the function receives the arguments. I think V is a var defined one level above the function. Will let you know if I try something else.
Removed references to experiment. Now at 4.5 steps /min instead of 2.5 steps per min. Will open a work-in-progress pull request in a minute.
Closed #49, in favor of #50.
I'm playing around with cython a little. I took the expected_injection_heats and equilibrium_concentrations methods out of CompetitiveBindingModel and compiled the plain python code as cython. This sped it up from ~140 steps to ~ 160 steps per minute.
Bigger improvement would be expected once I define my types statically, will open a PR once I have time to figure out how to do this. Cython is still unfamiliar to me.
That improvement probably isn't worth the hassle, but a speedup of 10x would be notable and worthwhile if it could ve achieved!
Did a little profiling.. here is by total internal time spent working. Pint units are a big thing. I was running verbose, so arrayprint is also a top hit.
And here is cumulatively, the lambda, expected heats and equilibrium concentrations functions are taking a long time.