ode

Why can't I pass a decorated function to scipy.integrate.ode?

Why can't I pass a decorated function to scipy.integrate.ode? Question: When I pass a decorated function to scipy.integrate.ode, the wrapper function gets called, but *args is empty. Why is this happening? This works: y0, t0 = 1, 0 def dydt(t, y): return y*0.5 r = scipy.integrate.ode(dydt) r.set_initial_value(y0) r.integrate(10) assert r.successful() This doesn’t: y0, t0 = …

Total answers: 2

Runge Kutta 4th order Python

Runge Kutta 4th order Python Question: I am trying to solve this equation using Runge Kutta 4th order: applying d2Q/dt2=F(y,x,v) and dQ/dt=u Q=y in my program. I try to run the code but i get this error: Traceback (most recent call last): File "C:UsersEgwDesktopAnalyshAskhsh1asdasda.py", line 28, in <module> k1 = F(y, u, x) #(x, v, …

Total answers: 4

Solving ODEs python with non-independent funcitons python

Solving ODEs python with non-independent funcitons python Question: I’m trying to plot a multi-equation ODE from this paper and I’m having trouble figuring out how to express the dependencies between the functions. I.e, in 3.1, it uses both z1 and z2. Aswell as using its own precious state x. I’ve checked the Scipy documentation but …

Total answers: 2

float() argument must be a string or a number, not 'function' – solve_ivp

float() argument must be a string or a number, not 'function' – solve_ivp Question: I have the following code: def fun(t, s, rho_0, rho_1): return lambda t, s:np.dot(np.array([0.775416, 0,0, 0.308968]).reshape(2,2), s) + np.array([rho_0,rho_1]).reshape(2,1) def fun2(t, rho_0, rho_1): t_eval = np.arange(0,5) res = solve_ivp(fun, [0, 5], y0 = [0, 0], t_eval=t_eval, args = (rho_0, rho_1), vectorized …

Total answers: 1

I am trying to define the following vector function, but keep getting an error

I am trying to define the following vector function, but keep getting an error Question: Where am I going wrong? The function: The code I have written is as follows! Note the second def function is an attempt to integrate it using solve_ivp! please let me know if there are any issues there as well: …

Total answers: 1

stackoverflow error in 2d fipy PDE solver in python

stackoverflow error in 2d fipy PDE solver in python Question: I am trying to solve a system of three coupled PDEs and two ODEs (coupled) in 2D. The problem tries to solve for a case of a particle moving in a medium. The medium is given by the fields- velocity components vx, vy, and density …

Total answers: 1

Implement ball bouncing in free fall using scipy.ivp()

Implement ball bouncing in free fall using scipy.ivp() Question: I want to solve ordinary differential equations using scipy_ivp() of a ball falling with an inital velocity of 1 in the x-direction, and 0 in the y-direction. The gravitational acceleration is g = 9.82, and when the ball hits the ground, its velocity is suppossed to …

Total answers: 2

Why does Python RK23 Solver blow up and give unrealistic results?

Why does Python RK23 Solver blow up and give unrealistic results? Question: I am experimenting with RK45/RK23 solver from python scipy module. Using it to solve simple ODEs and it is not giving me the correct results. When I manually code for Runge Kutta 4th order it works perfectly so does the odeint solver in …

Total answers: 1

Integrating a set of second order differential equations with Scipy

Integrating a set of second order differential equations with Scipy Question: I have a set of second order differential equations: and I would like to solve for using odeint in python. Is this possible? I have attempted to do it, but my code does not give me the expected result. import numpy as np, matplotlib.pyplot …

Total answers: 1

Update initial condition in ODE solver each time step

Update initial condition in ODE solver each time step Question: 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 …

Total answers: 2