ode

need to understand better how rtol, atol work in scipy.integrate.odeint

半腔热情 提交于 2019-12-06 06:37:54
问题 Here scipy.integrate.odeint is called with six different standard ode problems with rtol = atol from 1E-06 to 1E-13 . I've looked at the max difference between the results at all larger tolerances minus those of the smallest, to get some kind of representation of "error". I'm curious why, for a given tolerance, one problem (D5) gives errors a million times worse than another problem (C1), even though the range in number of steps is fairly tight (within a factor of 10). The citation for the

Can I integrate with scipy's odeint until a local max is found?

不羁的心 提交于 2019-12-06 05:51:21
问题 This is my first question on here, so please go easy on me. I'm wondering if there is a way to integrate an ODE system only until a local max of a specified variable is found. Here is some more detail: Let's call our ODE system dX/dt = F(X) where X(t) = [x1(t), x2(t), ... , xn(t)] . Assume the solution to this system is attracted to a stable limit cycle C everywhere but at one unstable fixed point p. Choose some initial conditions X0 not p, and not in C. We wish to follow the trajectory of

How to solve DAE with a varying input / a time-dependent input function in Matlab?

人盡茶涼 提交于 2019-12-05 22:51:58
I'm solving a DAE problem with ode15i solver. I have 8 variables and 8 equations, and the system is complex that the only working solver so far is ode15i. I've used the guide: http://se.mathworks.com/help/symbolic/set-up-your-dae-problem.html . However, this guide doesn't help me to solve the problem with a varying input. My system has a time-dependent input, a function. The function itself is quite simple, but the problem is that the time t in DAE system is in symbolic form, and my input function can't solve the corresponding input value, because it can't compute symbolic time value t. here

Internal working of scipy.integrate.ode

非 Y 不嫁゛ 提交于 2019-12-05 19:32:08
I'm using scipy.integrate.ode and would like to know, what happens internally when I get the message UserWarning: zvode: Excess work done on this call. (Perhaps wrong MF.) 'Unexpected istate=%s' % istate)) This appears when I call ode.integrate(t1) for too big t1 , so I'm forced to use a for -loop and incrementally integrate my equation, what lowers the speed since the solver can not use adaptive step size very effectively. I already tried different methods and setting for the integrator. The maximal number of steps nsteps=100000 is very big already but with this setting I still can't

ODE integration with discretized values

折月煮酒 提交于 2019-12-05 19:11:28
I want to use scipy.integrate.ode solver. I can define the callable function f only as an array of discrete points (because it depends on results of integration from previous iterations). But from the documentation it seems that the integrator expects the callable to be a continuous function. I suppose some sort of interpolation needs to be done. Can the solver deal with this on its own, or do I need to write some interpolation routine? Is there some scipy documentation/tutorial that explains it? Yes, the callable needs to be a function which returns the derivative for any value that is

Differential Equations in Java

一个人想着一个人 提交于 2019-12-05 18:01:53
问题 I am trying to create a simple simulation program of SIR-epidemics model in java. Basically, SIR is defined by a system of three differential equations: S'(t) = - l(t) * S(t) I'(t) = l(t) * S(t) - g(t) * I(t) R'(t) = g(t) * I(t) S - susceptible people, I - infected people, R - recovered people. l(t) = [c * x * I(t)] / N(T) c - number of contacts, x - infectiveness (probability to get sick after contact with sick person), N(t) - total population (which is constant). How can I solve such

solving two dimension-differential equations in python with scipy

℡╲_俬逩灬. 提交于 2019-12-05 07:46:53
问题 i am a newbie to python. I have a simple differential systems, which consists of two variables and two differential equations and initial conditions x0=1, y0=2 : dx/dt=6*y dy/dt=(2t-3x)/4y now i am trying to solve these two differential equations and i choose odeint . Here is my code: import matplotlib.pyplot as pl import numpy as np from scipy.integrate import odeint def func(z,b): x, y=z return [6*y, (b-3*x)/(4*y)] z0=[1,2] t = np.linspace(0,10,11) b=2*t xx=odeint(func, z0, b) pl.figure(1)

complex ODE systems in scipy

旧城冷巷雨未停 提交于 2019-12-05 03:12:47
问题 I am having trouble sovling the optical bloch equation, which is a first order ODE system with complex values. I have found scipy may solve such system, but their webpage offers too little information and I can hardly understand it. I have 8 coupled first order ODEs, and I should generate a function like: def derv(y): compute the time dervative of elements in y return answers as an array then do complex_ode(derv) My questions are: my y is not a list but a matrix, how can i give a corrent

Update initial condition in ODE solver each time step

北城以北 提交于 2019-12-04 17:07:43
I am wanting to solve a system of ODEs where for the first 30,000 seconds, I want one of my state variables to start from the same initial value. After those 30,000 seconds, I want to change the initial value of that state variable to something different and simulate the system for the rest of time. Here is my code: def ode_rhs(y, t): ydot[0] = -p[7]*y[0]*y[1] + p[8]*y[8] + p[9]*y[8] ydot[1] = -p[7]*y[0]*y[1] + p[8]*y[8] ydot[2] = -p[10]*y[2]*y[3] + p[11]*y[9] + p[12]*y[9] ydot[3] = -p[13]*y[3]*y[6] + p[14]*y[10] + p[15]*y[10] - p[10]*y[2]*y[3] + p[11]*y[9] + p[9]*y[8] - p[21]*y[3] ydot[4] =

ODEs with infinite initlal condition in python

南楼画角 提交于 2019-12-04 13:22:52
问题 I have a second order differential equation that I want to solve it in python. The problem is that for one of the variables I don't have the initial condition in 0 but only the value at infinity. Can one tell me what parameters I should provide for scipy.integrate.odeint ? Can it be solved? Equation: Theta needs to be found in terms of time. Its first derivative is equal to zero at t=0 . theta is not known at t=0 but it goes to zero at sufficiently large time. all the rest is known. As an