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

solve deflection curve using scipy.solve_ivp error: 'Required step size is less than spacing between numbers.'

I encountered a failure on solving deflection curve using scipy.solve_ivp when I used a big length for the beam(pipe). The following is my script. # -*- coding: utf-8 -*- # # Calculate deflection curve under gravity # import numpy as np from…
Jilong Yin
  • 278
  • 1
  • 3
  • 15
0
votes
0 answers

Adaptive Stepsize Runge Kutta Method

def runge_kutta(f, x0, dt, T): n = int(T / dt) t = np.zeros(n + 1) if isinstance(x0, (int, float)): x = np.zeros(n + 1) else: neqns = len(x0) x = np.zeros((n + 1, neqns)) x[0] = x0 t[0] = 0 for…
0
votes
4 answers

Why is RK4 not updating values for my simulation of the Earth's orbit?

I am trying to use a Runge Kutta method to simulate the motion of the Earth around the Sun in C, I cannot see why but my code does not update the values for position or velocity and just keeps the initial values. The code I have written…
user20774365
0
votes
1 answer

Solving equation of motion due to (Lorentz acceleration) using Forward Euler and Runge-Kutta 4th order using Python 3

I am tring to solve the equation of motion of charged particle in planetary magnetic field to see the path of the particle using Forward Euler's and RK5 method in python (as an excercise in learning Numerical methods) I encounter two problems: The…
0
votes
0 answers

Runge Kutta 4 doesn't give the desired result

I am solving a system of differential equations with the RK4 method but the outcome performs bad towards the end iteration. The problem seems to be with the eq11 of my function l(lna,x,y,m,xi,yi) since the term…
0
votes
0 answers

Warning: Matrix is singular, close to singular or badly scaled. Results may be inaccurate. RCOND = NaN

The following code uses rk4 to simulate the dynamics defined via fe function. However, I encountered the warning Warning: Matrix is singular, close to singular or badly scaled. Results may be inaccurate. RCOND = NaN. . I felt that the function…
chloe
  • 31
  • 7
0
votes
1 answer

How to do finite difference integration in python?

I want to solve a differential equation of a given function S. First, I integrate a function using 4th-order runge kutta: def rk4_step(r, u, h, f, *args): k1 = h * f(r, u, *args) k2 = h * f(r + h/2, u + k1/2, *args) k3 = h * f(r + h/2, u…
User8563
  • 123
  • 1
  • 2
  • 13
0
votes
1 answer

Runge Kutta program outputting incorrect graphs

I'm creating a program to compare two graphs, using the Runge Kutta method to solve an ODE. Ideally the resulting plots would be directly on top of each other, but the Runge Kutta function is outputting an incorrect plot. Am I incorrectly populating…
0
votes
1 answer

RK4 speed up with numba

I want to make RK4 with the numba for speed-up. I'm a beginner using the numba. Why can't the numba understand my code? The simple code is following in swing.py @numba.jit(nopython=True) def RK4(func, t_end, X0, dt): t = np.arange(0,t_end, dt,…
0
votes
0 answers

SIRK schemes and Lokta-Volterra test

I'm aiming at making a 2D compressible Euler equations numerical model, and to do so I need to implement a so-called "semi-implicit fourth order runge-kutta scheme" in order to integrate an equation of the form du/dt = f(u) + g(u); where g is a…
0
votes
0 answers

Convergence rate adaptive Runge Kutta methods

I have a system of ODEs and I solve them with two different algorithms: A normal, constant stepsize, Runge Kutta 4 implementation A modified Runge Kutta 4, with variable stepsize control My professor asked me to make a plot showing convergences…
0
votes
1 answer

Fourth Order Runge Kutta for SIR model

I am implementing a fourth order Runge Kutta method to solve a system of three ODEs that describe the SIR model. Based on other simulations, I would expect a different solution (mine diverges very quickly). Here is my code for the runge kutta…
0
votes
1 answer

How to impose boundary conditions in the Generalized Weighted Residual Method (Chebyshev Galerkin modal form)

I am working on combining a Generalized Weighted Residual Method with an RK4. The GWRM part decomposed the PDEs to the spectral space where the unknowns are Chebyshev coefficients a_k. However, I'm having difficulty seeing how the boundary…
0
votes
0 answers

Regarding incorporating piecewise function in ode using octave code

Differential equation where M_v is a piecewise function Differential equation where M_v is a piecewise function Piecewise function I have coded the differential equation in Octave using the RUnge-Kutta 4 (RK4) method. However, the result is not…
0
votes
0 answers

How to solve two first order ODEs in which one of the variables contains a list of elements?

I need help with solving three first-order ODEs using the scipy.integrate.ode module with the integration method of the Runge Kutta Method. My problem is that I don't know how to solve the ODE with one of the variables as a list of 1000 elements. As…
CYU1
  • 41
  • 5