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
1 answer

Values Within range of if statement not printing (Runge-Kutta Fourth Order in Python)

I am writing a code to perform a Fourth Order Runge-Kutta numerical approximation with adaptive step size. def f(x, t): #integrating function return -x def exact(t): #exact solution return np.exp(-t) def Rk4(x0, t0, dt): …
infinitylord
  • 175
  • 7
1
vote
1 answer

How to plot a defined function against one of its arguments in Python

from __future__ import division import numpy as np import matplotlib.pyplot as plt def f(x, t): #function for x'(t) = f(x,t) return -x def exact(t): #exact solution return np.exp(-t) def Rk4(x0, t0, dt): #Runge-Kutta…
infinitylord
  • 175
  • 7
1
vote
1 answer

Julia challenge - FitzHugh–Nagumo model PDE Runge-Kutta solver

I am newbie in Julia programming language, so I don't know much of how to optimize a code. I have heard that Julia should be faster in comparison to Python, but I've written a simple Julia code for solving the FitzHugh–Nagumo model , and it doesn't…
Ohm
  • 2,312
  • 4
  • 36
  • 75
1
vote
1 answer

How to Solve Simple ODEs Using Thrust and odeint in C++

I'm trying to create a simple program to become familiar with Thrusts's GPU computational ability and odeint's ODE solving capability. I would like to be able to solve simple ODEs (i.e. dy/dx = 3x^2y) using the Runge-Kutta method on the GPU in the…
Gibs
  • 27
  • 3
1
vote
1 answer

how to implement newton-raphson to calculate the k(i) coefficients of a implicit runge kutta?

I'm trying to implement a RK implicit 2-order to convection-diffusion equation (1D) with fdm_2nd and gauss butcher coefficients: 'u_t = -uu_x + nu .u_xx' . My goal is to compare the explit versus implcit scheme. The explicit rk which works well with…
1
vote
1 answer

Plot python is showing empty value

I'm trying to plot a runge kutta equation, but it shows an empty value. Where did I go wrong in the logic? for n in xrange(0,10): k1 = R*T[n] + g*h[n] l1 = -1*r*h[n] - a*b*T[n] k2 = R*(T[n]+k1*not_dt/2) + g*(h[n]+l1*not_dt/2) l2 =…
F L
  • 183
  • 1
  • 10
1
vote
1 answer

what will be python code for runge kutta second method?

Is this code is ok? def rKN(x, fx, n, hs): k1 = [] k2 = [] k3 = [] k4 = [] xk = [] for i in range(n): k1.append(fx[i](x)*hs) for i in range(n): xk.append(x[i] + k1[i]*0.5) for i in range(n): …
Amin Mithun
  • 25
  • 1
  • 5
1
vote
1 answer

Runge Kutta's Method circular motion

I've been asked to solve this differential equation: (x,y,vx,vy)'=(vx,vy,vy,-vx) which should return a circular motion with a 2*pi period. I implemented the function: class FunzioneBase { public: virtual VettoreLineare Eval(double t, const…
Tana
  • 31
  • 4
1
vote
1 answer

Why is my Runge-Kutta Python script defining elements of an array in this abnormal way?

I am a newcomer to Python, my knowledge of the programming language is still in its infancy, so I copied the Runge-Kutta Python script shown here and modified it for my purposes. Here is my current script: import numpy as np from matplotlib import…
Josh Pinto
  • 1,453
  • 4
  • 20
  • 37
1
vote
1 answer

Adapt Runge-Kutta ODE solver from first order to second order

I have a Matlab function for doing Runge-Kutta4k approximation for first-order ODE's, and I want to adapt it to work for second-order ODE's. Would anyone be able to help me get started? This is what I have for first order RK4K: function [y,t,h] =…
kathystehl
  • 831
  • 1
  • 9
  • 26
1
vote
1 answer

MATLAB - converting Euler method to Heun's method

I saw this Euler method that calculates errors: function [t,le,ge] = euler_errors(h) f=@(u) u*(2-u); % this is the function for the IVP t0=0; tn=1; t=t0:h:tn;%we want to find the errors along this solutions %here is the exact solution of the…
1
vote
1 answer

Integrating wave equation with Runge-Kutta (2nd order)

I try to solve numerically simple equation - linear wave equation with no sources: utt = v2 uxx where v - velocity of wave. I use initial conditions: u(x, 0) = sin(x) ux(x, 0) = -v * sin(x) which correspond to initial wave sin(x) propagating…
newt
  • 215
  • 1
  • 2
  • 10
1
vote
1 answer

RK4 giving wrong result

I'm trying to numerically solve a simple second order DE x'' = -x. I used a new variable x'=v, so I have two equations. While it seems simple, it somehow produces a result that's really far of the correct result. def f(x): return -x def…
1
vote
1 answer

Implement pseudo-spectral method with RK4 in Python

I am using pseudo-spectral method to solve for KdV equation u_t + u*u_x + u_xxx = 0. After simplification by Fourier Transform, I got two equations with two variables: uhat = vhat * exp(-i*k^3*t) d(vhat)/dt =-0.5i * k *…
Jundong
  • 261
  • 4
  • 20
1
vote
1 answer

Solving ODEs in NetLogo, Eulers vs R-K vs R solver

In my model each agent solves a system of ODEs at each tick. I have employed Eulers method (similar to the systems dynamics modeler in NetLogo) to solve these first order ODEs. However, for a stable solution, I am forced to use a very small time…
user3887089
  • 307
  • 1
  • 8