numpy - ODE in python with specific time point -
i explain question , reach problem @ end of ezplanation. in order solve function f
ode python @ first must set initial point or initial condition (x0=0.2
). then, according codes have searched on internet , sources, should choose rage(time point) solving , plotting. examplet=np.linspace(0,5,20)
devides range between 0
5
20
sections , have 20 out puts.
sol=odeint(f,x0,t)
... problem is, have 1 out put @ 1 time point, set initial point example x0=0.2
, want have 1 answer @ specific point choose, example @ point of 3.4
. when plot ode have answers first point final point, want have optional choice set specific points instead of using linspace(min, max,n)
i appreciate , thank attention.
the t
argument can contain 2 points, first element being time value of x0
(the initial condition), , second being final time interested in.
t0 = 0 t1 = 123.45 # final time interested in sol = odeint(f, x0, [t0, t1])
then values @ time t1
x1 = sol[-1]
.
if time span between t0
, t1
long enough, solver might make maximum allowed number of internal steps before reaching t1
. limit can changed mxstep
argument.
Comments
Post a Comment