Questions tagged [runge-kutta]

Runge–Kutta methods are an important family of implicit and explicit iterative methods, which are used in temporal discretization for the approximation of solutions of ordinary differential equations.

In numerical analysis, the Runge–Kutta methods (German pronunciation: [ˌʁʊŋəˈkʊta]) are an important family of implicit and explicit iterative methods, which are used in temporal discretization for the approximation of solutions of ordinary differential equations. These techniques were developed around 1900 by the German mathematicians C. Runge and M. W. Kutta.

Wikipedia definition about Runge-Kutta

379 questions
1
vote
2 answers

I'm seeing "TypeError: 'tuple' object does not support item assignment" on spyder

What exactly does this mean? Should I not use a for loop? Do I need another tuple? For context: I'm trying to use Huen's method to solve dydt=y/((t+1)**2) with step size h=0.2 at t=0,0.2,0.4,0.6 #import libraries import numpy as np import…
1
vote
1 answer

Is there a better way to simulate PID control in Python with Scipy's solve_ivp()?

I am working on a homework problem. I'm trying to simulate a PID control in Python with Scipy's integrate.solve_ivp() function. My method is to run the PID code within the right-hand-side of the function, using global variables and appending them to…
squeegene
  • 467
  • 1
  • 5
  • 18
1
vote
0 answers

Calculations in for & while loops produce a list of the same number

I am computing the path of a particle near a black hole by performing Runge Kutta on an ODE (details unnecessary, proven to work correctly). The function has parameters h which I input as a function of b and v. I run the path through all v =…
user11339690
1
vote
3 answers

Runge Kutta constants diverging for Lorenz system?

I'm trying to solve the Lorenz system using the 4th order Runge Kutta method, where dx/dt=a*(y-x) dy/dt=x(b-z)-y dx/dt=x*y-c*z Since this system doesn't depend explicity on time, it's possibly to ignore that part in the iteration, so I just…
1
vote
2 answers

Cannot get RK4 to solve for position of orbiting body in Python

I am trying to solve for the position of a body orbiting a much more massive body, using the idealization that the much more massive body doesn't move. I am trying to solve for the position in cartesian coordinates using 4th order Runge-Kutta in…
corgiworld
  • 37
  • 1
  • 7
1
vote
1 answer

Newton method implementation for finding initial values, with Dormand Prince to solve differential equations in C

The following code works like a charm to solve a system of differential equations in it(fcn function in the code), with correct initial values. However, the point of the task is to replace initial values y_1(0) and y_2(0) with some random values,…
Moriarty
  • 11
  • 1
1
vote
1 answer

Using Runge-Kutta-4 method to simulate an orbit in Python (Physics)

I'm trying to implement an RK4 method to solve for the orbit of a rocket around the Earth. Eventually this code will be used for more complex solar system simulations, but I'm just trying to get it working in this simple system first. My code is…
Tom C
  • 13
  • 1
  • 4
1
vote
1 answer

Can Euler be better than Runge-Kutta for some functions?

I'm trying to solve exercises from Steven Strogatz's Non-Linear Dynamics and Chaos. In exercise 2.8.3, 2.8.4, and 2.8.5, one is expected to implement the Euler method, improved Euler method, and Runge-Kutta (4th order) method respectively for the…
1
vote
2 answers

Runge Kutta 4 and pendulum simulation in python

I am trying to make a python program which plot pendulum swings using runge kutta 4. The equation I have is angular accelartion = -(m*g*r/I) * np.sin(y). Please find my code. I am quite new to python. import numpy as np import matplotlib.pyplot as…
damu_d
  • 53
  • 1
  • 8
1
vote
1 answer

The output is list of numbers instead of one number

I ran into the problem, I am new with this kind of usage of Python, I hope some one helps me in this issue. I have a code using RungeKutta algorithm. As I do print(vH), it prints: [70, 98.72259439054349, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,…
Ehsan
  • 73
  • 11
1
vote
0 answers

Runge-Kutta 4th order with 2th order ODE error

I recently made a code to solve a RLC circuit problem, with a 2th order ODE with Runge-Kutta method, but the code I made doens't match the result with standart result ODE for example, with a 5ohm resistor (R), 10mF capacitor (C), 1H inductor (L), 5v…
Crimeiaman
  • 51
  • 7
1
vote
0 answers

Runge-Kutta 2nd order, wave transformation, solve an equation of retention*

I have a problem with solving equation of retention with method Runge-Kutta (2nd order) in Scilab. I must to solve equation: dh/dt=(InF(t)-OutF(t))/F(h), or this equation in picture (link) where: h - height [m]; t - time [sec]; InF- inflow to…
Rafal
  • 11
  • 1
1
vote
0 answers

4th order Runge-Kutta function with controller in Matlab

I'm trying to solve a system of equations defined in a function ('f') using a 4th order Runge-Kutta method, taking into account a PD controller on a variable ('c'). Here is how my code looks like so far: t_f = 100; % simulation end time h = 0.1; …
etienne
  • 13
  • 4
1
vote
0 answers

2nd order DE Runge Kutta 4 on C

I am trying to solve a simple 2nd order DE using 4th order Runge-Kutta on C. My code compiles but the results are kinda awkward and I can't find the mistake. I have repeated the calculations multiple times but I always get the same result. The…
Suyama87
  • 85
  • 10
1
vote
2 answers

Two_body_problem: scipy.integrate.RK45 gives broadcasting error and scipy.integrate.LSODA never enters the twoBody function

I'm working on a trajectory calculator for the Two Body Problem, and I'm attempting to use Scipy's RK45 or LSODA to solve the ODE and return the trajectory. (Please suggest another method if you think there's a better/easier way to do this) I'm…
natemcintosh
  • 730
  • 6
  • 16