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
0 answers

Periodic boundary condition and 4th order Runge Kutta method used for solving partial differential equation(1D wave packet propagation)

# RK4 # disp = u0 # initial condition array flag = True #h = 0 timeee = 0.000 timemax = 5001 #ms while(timeee
Avii
  • 164
  • 12
1
vote
2 answers

how do i create a graph of multiple x,y points inside a loop?

so I saw this code for RK4 on stack and I found it very useful. However, I cannot figure out a way to plot for each y value at each increment(h) of x. def f(x,y): return 2*x**2-4*x+y def RK4(x0,y0): while x0 < b: k1 = h*f(x0,y0) …
1
vote
1 answer

Plotting a Graph for Euler's Method in Sage using Python3

I keep getting an error and I think it is coming from the line yy=function ("yy", x) but I am not sure how to fix it. Or even positive that this is my problem. My coding (along with with the questiion I am trying to answer) is as follows: print("1. …
Kathleen
  • 123
  • 4
1
vote
0 answers

I'm trying visualize the solution to my Predator-Prey model (using Runge-kutta 3) by plotting a graph predator versus prey. But it won't plot

I'm trying to visualize the solution to my code by plotting - in python - a graph of the number of predators versus preys, and using a black circle to mark the current state. My code runs okay except I can't get the plotting portion of the graph to…
Caroline
  • 11
  • 4
1
vote
0 answers

Runge Kutta K values stay at zero when iterating

I'm doing a homework assignment in which I have to model the motion of an aircraft with a 4th order RK approximation. However, for some reason I keep getting results that indicate that all of my K values are zero when I iterate. my main loop is as…
1
vote
1 answer

Not printing out the value of z and theta

I am solving two coupled ordinary differential equations using the 4th-order Runge-Kutta method. I am having trouble in printing the values of z as a result of applying this method. The source code is below for reference. Please, help me fix this…
1
vote
1 answer

How do I assign a a value to a 'Nonetype' function?

I have been trying to use the Runge-Kutta45 integration method to update a set of positions and velocities of particles in space to get the new state at some time step. Initially, I created an array with all these elements and combined them…
1
vote
1 answer

Validation of tolerance in Runge Kutta Fehlberg

I've written a code to solve a system of ODEs using Runge Kutta Fehlberg method: import numpy as np import matplotlib.pyplot as plt import numba import time start_time = time.clock() @numba.jit() def S1(x,u): alpha = 0.01 C1 =…
1
vote
1 answer

Issue on Runge Kutta Fehlberg algorithm

I have wrote a code for Runge-Kutta 4th order, which works perfectly fine for a system of differential equations: import numpy as np import matplotlib.pyplot as plt import numba import time start_time = time.clock() @numba.jit() def V(u,t): …
1
vote
1 answer

Does SciPy RK45 (solve_ivp) count the number of function evaluations accurately?

I want to measure the performance of my own ODE integrator against SciPy RK45. Thus, I need to know exactly the number of right hand side function evaluations that RK45 uses. Does anyone know if the number sol.nfev is accurate, i.e. without…
lueckem
  • 31
  • 4
1
vote
1 answer

Leap frog algorith for solving two body problem

I made a program to solve the two body problem with the leap frog algorithm but the output diagram is wrong. I solved the problem by using an other technique (runge kutta, second order or midpoint) with the same initial conditions, and the result…
1
vote
1 answer

Rk4 Integrator of a nonlinear second order ODE in Python

I'm in a project in my University and I have to implement the Runge-Kutta 4-order integrator using Python. I know I can use for example Sympy, but the goal here is implement the method, the code is ready written in Fortran language, so basically I…
1
vote
1 answer

I tried implementing RK4 to N-body simulation. But the look from the graph the code is not working properly

as I said in the title, even though the code is running without any error messages, the code is not working properly. I'm applying RK4 method to the N-body simulation code, particularly solar system. The graph looks strange like there is no gravity…
1
vote
1 answer

Python evaluating a second order ODE with RK4

Pasted below is my python code. It is a 4th order Runge-Kutta that evaluates the 2nd order ODE: y''+4y'+2y=0 with initial conditions y(0)=1, y'(0)=3.  I need help fixing it. When I run my code, my analytical solution does not match my numerical…
J Wright
  • 21
  • 5
1
vote
2 answers

Solving Differential Equations IN MATLAB For Different Values Of Input

I have written a function plus a script to calculate and plot the response of a 1-degree-of-freedom system using 4th order runge-kutta method in matlab. Here is the thing that I want to plot the response of the system for different values of…
MMd.NrC
  • 91
  • 7