slow kinetics... #647
Closed
atravert
started this conversation in
Developer discussions
Replies: 4 comments 9 replies
-
ok, but can you rebase your branch onto upstream/master because it is out of sync?. Then I will have a look. |
Beta Was this translation helpful? Give feedback.
4 replies
-
ok here something working: global_env = {}
locals_env = {}
exec(
f"def f_(t, C, cls=None): k = cls.k(t); return{self.production_rates_str()}",
global_env, locals_env
)
import functools
bunch = solve_ivp(
functools.partial(locals_env["f_"], cls=self),
(t[0], t[-1]),
self.init_concentrations,
t_eval=t,
method=method,
) Not sure about globals or locals, but the trick is to pass a new parameter using the partial method of functools |
Beta Was this translation helpful? Give feedback.
1 reply
-
ok I did a wrong thing this why it was slow, global_env = {}
locals_env = {}
exec(
f"def f_(self, t, C): k = self.k(t); return{self.production_rates_str()}",
global_env, locals_env
)
import functools
bunch = solve_ivp(
functools.partial(locals_env["f_"], self),
(t[0], t[-1]),
self.init_concentrations,
t_eval=t,
method=method,
) |
Beta Was this translation helpful? Give feedback.
2 replies
-
Many thanks !! . The matrix calculation was much much slower in my case.
I will look at it.
Le 10 mai 2023 20:05:55 GMT+02:00, Christian Fernandez ***@***.***> a écrit :
…but I let you investigate:
very strange:
SpectroChemPy's API - v.0.6.2.dev26
© Copyright 2014-2023 - A.Travert & C.Fernandez @ LCS
Integration time matrix: 0.04888105392456055
Integration time ode explicit: 0.02937769889831543
Integration time ode_str: 0.02445220947265625
Integration time ode_str_2: 0.06603884696960449
I don't see much the differences.
—
Reply to this email directly, view it on GitHub<#647 (reply in thread)>, or unsubscribe<https://github.com/notifications/unsubscribe-auth/ACNBNCRV6CSCHEIMUW2JFULXFPKIHANCNFSM6AAAAAAX46HHVA>.
You are receiving this because you authored the thread.Message ID: ***@***.***>
-- Sent from /e/ Mail.
|
Beta Was this translation helpful? Give feedback.
2 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
In this branch, I am improving the performances of the integration in ActionMassKinetics by generating the expressions of the rates of production instead of using the previous matrix expression which is simple to implement but very inefficient.
I still have a problem in trying to implement an exec() within the function thatr carry out the integration here: https://github.com/atravert/spectrochempy/blob/cf0eee1ff83e34867f57cc8da376d2f236abc82f/spectrochempy/analysis/kinetic_utilities.py#LL489C1-L501C1
... while the equivalent is working fine when used in a script, as in the example below which compare the execution times:
Any suggestion ?
Beta Was this translation helpful? Give feedback.
All reactions