scipy - Take Values inside of odeint in python -
my question if there's way take values in function not integrated in odeint.
exemple: if have derivative dy(x)/dt = a*x+ln(x)
, before equation computed throught of intermediate equation a = b*d
. take a's value during process.
more detailed (only exemple):
def func(y,t) k = y[0] b = 3 = cos(t**2) + b dy/dt = a*t+ln(t) return [dy/dt]
can take a's values of function?
the answer josh karpel
the code that:
def reaction(state,t): # integrate results p = state[0] t = state[1] # function determine enthalpy of system f1(t,p) = enthalpy # function determine specific volume of system f2(t,p) = specific volume # function determine heat release reactions f3(t,p,t) = heat release reactions
# derivatives
dp/dt = f(t,p,enthalpy,specific volume,heat release reactions) dt/dt = f(t,p,enthalpy,specific volume,heat release reactions)
the real code bigger that. but, know if there way store values of f1 (enthalpy), f2 (specific volume), f3 (heat release) vector or tuple during process of solution of odeint same size of p , t.
it's not entirely clear want, sounds need pass value function you're integrating over. there 2 options can think of:
- scipy.integrate.odeint takes
args
argument contains arguments passed integrand function, have signaturey(t, a)
. - you use functools.partial construct new function has argument
a
integrand functiony(t, a)
set.
Comments
Post a Comment