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.
290
questions
-1
votes
0answers
23 views
Solve system of complex equations using runge-kutta in python
in a beginner in python and I have a problem that has been giving me headaches from two months. I have to solve a set of nine complex equations using Runge-Kutta. These equations describe the time ...
0
votes
0answers
21 views
Implementation of Runge Kutta 4 on embedded system
I try actually to implement a Runge Kutta 4th Order but in practical aspect how can I approximate the Gyro Rate without knowing its internal function f which is given by w(t)
Function w(t) of ...
2
votes
2answers
60 views
(MATLAB/C++) Is it possible to pass functions as arguments to C++ MEX functions?
I have only been working with mex functions for a couple of weeks, and am now working on writing a Runge-Kutta, 4th order solver as a C++ mex function.
I am wondering whether it is possible to take a ...
0
votes
1answer
36 views
Plot orbit of three bodies using rk4
I have been trying to plot the trajectories of three particles using the RK4 method. I haven't been able to produce an array of results over the time period as it brings up the following error message:...
0
votes
0answers
20 views
How to use a go.Scattergeo object (Earth) as a plot in order to plot a trajectory in the same plot?
I have a code which computes the trajectory of a body considering only the gravitational force acting on it using the runge kutah integrator. I've done it using Matplotlib, and couple days ago I found ...
0
votes
0answers
18 views
-1.IND00 While computing numerical solution to Lokta Volterra DE using RK4 method
The title is selfdescribing, I can´t menage to troubleshoot why this skript:
#include <stdio.h>
#define POINTS 200
void print_csv(double *x, double *y, int size/*size_t size, const char *...
0
votes
1answer
43 views
How do I update my integrated function array correctly?
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 ...
1
vote
1answer
33 views
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 ...
-1
votes
1answer
22 views
Index out of bounds in Runge-Kutta algorithm for parabolic shot
Hi I am trying to get this program to run. The z structure is assumed to be size 4, however it gives the error. I also notice that if I print z in 1 it gives me a value, so I do not know what is the ...
0
votes
1answer
35 views
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()
...
0
votes
0answers
44 views
Ode-system output gives null values in Matlab
I am trying to compute the numerical solution (over the interval [0,2]) for this system of differential equations using the Runga Katta (4th Order) Method and a step of my choice.
% This is not just ...
0
votes
1answer
17 views
TypeError: 'module' object is not callable using rungekutte
i have a homework and I used my code here to solve symmetrical equation using Runge-Kutta method
import numpy as np
import matplotlib.pyplot as plt
import scipy.integrate as integrate
from matplotlib....
0
votes
1answer
57 views
Runge Kutta 4 Implementation
I am trying to implement the Runge-Kutta Method of order 4.
I get a Type Error: 'can't multiply sequence by non-int of type 'numpy.float64' in the calculations of k1,k2,k3,k4. Does anyone know a ...
0
votes
1answer
93 views
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 ...
1
vote
1answer
62 views
How to solve Lorenz 96 model using Runge–Kutta method?
I have written the below code to solve Lorenz 96 model using Runge–Kutta method, but the results are not reliable as can be seen in the below figure:
The correct relationship between three variables ...
1
vote
1answer
44 views
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 ...
2
votes
2answers
74 views
Runge-Kutta : error while solving a second order differential equation
I am trying to solve a third order non linear differential equation. I have tried to transform it and I've obtained this problem which is a second order problem:
I am trying to implement a fourth ...
1
vote
1answer
24 views
Implementing the 3/8 Runge Kutta in Python with a 2nd order ODE
I want to solve the equation y'' + 5y' + 6y = cos(t). Since this is 2nd order, I first created a system of first order ODEs where dy/dt = z = f(t,y,z) and dz/dt = cos(t) - 5z - 6y = g(t,y,z).
I'm a ...
0
votes
0answers
32 views
I am doing a python project about orbits using geometric integrators. I have gotten stuck on the runge-kutta 4th order method [duplicate]
def RK4step(r0,v0,h):
r = math.sqrt((r0[0]**2)+(r0[1]**2))
w0 = [r0[0],r0[1],v0[0],v0[1]]
k1 = [w0[2],w0[3],((-1)*(w0[0])/r**3),((-1)*(w0[1])/r**3)]
k2 = [w0[2]+k1[2]*(h/2),w0[3]+k1[3]...
1
vote
1answer
56 views
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) ...
0
votes
1answer
75 views
Runge-Kutta method to numerically solve a second order non-linear differential equation - Octave
So I have this analytically unsolvable non-linear second order differential equation:
x''=(-1/x)((x')²+gx-gh+ax')
to which I've been trying to apply the Runge-Kutta method in Octave for a while ...
0
votes
0answers
38 views
Using 4th order Runge-Kutta to approximate a damped harmonic oscillator. Not sure of which function to use. Mathematica
The module I have below has worked for multi order differentials up to this point I believe. However, whenever I try to use some variant of an equation used to approximate the motion of a damped ...
0
votes
2answers
33 views
Runge–Kutta of 4th order with the problem of f=alpha*y-beta*(y*y) with Python
so I've been working lately in a project that requires to write a python program that gives as an output a graph for Runge–Kutta of 4th order with the problem of f=alpha*y-beta*(y*y).
So can anyone ...
1
vote
1answer
102 views
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 ...
0
votes
0answers
100 views
Having problem when I try to simulate a double pendulum in python. Running code gives me error messages
I want to simulate a double pendulum in python and I wrote the code below but now I am completely stuck. I get errors every time I run the code and I have looked at it for hours now but I don't ...
0
votes
1answer
56 views
What is the R equivalent of the solve_ivp() function in Python?
I am translating some code from Python to R, and am finding it hard to find the corresponding functions in each. In this particular case, the code I'm having trouble with is:
x_sol_best = solve_ivp(
...
0
votes
1answer
43 views
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. ...
1
vote
1answer
57 views
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 ...
2
votes
1answer
173 views
Julia:Calculation time of Runge Kutta method
I'm trying to calculate a matrix-form ODE,
i.e., (∂/∂t)ψ = -iHψ ,where ψ is a vector and H is a (time-independent) matrix.
I have two problems.
1. Difference of calculation time between ...
0
votes
0answers
22 views
How to solve s system of coupled nonlinear ODES already given the state vector
I have a nonlinear dynamical system. I have found the equations of motion, which results in the following state vector:
The variables I used are
I keep getting all kinds of errors. What am I doing ...
0
votes
0answers
23 views
Runge-Kutta method overflow encountered in double_scalars
I'm no programming expert, but I'm trying to model a runge-kutta method basically by trial an error of a boundary condition. And that's fine by me except that if a try to expand the time domain (i.e ...
0
votes
0answers
15 views
How to update equations for an ODE in a while loop
Having trouble outputting the correct values for the 3rd order Runge function. It needs to return the solution at time = t0 + h = 300. I don't think my function is iterating correctly.
1
vote
2answers
51 views
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 ...
0
votes
1answer
35 views
How to Change into Vector Form
I previously posted the question How to create a Single Vector having 2 Dimensions? , and with some helpful answers I was able to change up my code.
In that previous question I was asked not to ...
2
votes
2answers
178 views
How to calculate movement of pendulum?
I am trying to make a simple simulation of pendulum using Runge–Kutta fourth-order method. I am using p5.js. Usually it calculates the angles properly but sometimes it just starts spinning randomly ...
1
vote
2answers
53 views
How to create a Single Vector having 2 Dimensions?
I have used the Equation of Motion (Newtons Law) for a simple spring and mass scenario incorporating it into the given 2nd ODE equation y" + (k/m)x = 0; y(0) = 3; y'(0) = 0.
I have then been able ...
0
votes
1answer
86 views
Solving Numerical four coupled differential equations using Runge-Kutta
How can I solve the following four coupled equations numerically in Python?
I need a source code !!!!!
y'(1) = (-wa+wp)*y(2)+g*y(4)
y'(2) = (-wa+2wp)*y(1)-g*y(3)
y'(3) = (wa-wp)*y(4)+g*y(2)
y'(4) =-(...
0
votes
1answer
27 views
Runge Kutta terminate when condition reached
The bouncing ball example shown in the Matlab ODE Solver has a way to terminate integration when an even triggers (https://www.mathworks.com/help/matlab/math/ode-event-location.html). In this example ...
0
votes
1answer
166 views
Issue understanding scipy.integrate.RK45 requirements
I am attempting to solve a system of first order differential equations with scipy.integrate.RK45(). I have scripted out the model function that I am hoping to plot (displacement vs time), but RK45() ...
0
votes
1answer
605 views
Solving system of coupled differential equations using Runge-Kutta in python
This python code can solve one non- coupled differential equation:
import numpy as np
import matplotlib.pyplot as plt
import numba
import time
start_time = time.clock()
@numba.jit()
# A sample ...
0
votes
1answer
107 views
N body simulation in C
I'm trying to write a code to solve the n-body problem using Runge Kutta 4 integration algorithm.
I'm testing the code using two bodies with masses uniformly distributed between 0 and 1, position ...
0
votes
0answers
169 views
4th Order Adams-Moulton Method C++
I am trying to solve an ODE using 4th Order Runge Kutta and the 4th Order Adams-Moulton Method. I iterate over a couple of thousand timesteps and it seems to hold fine when the values are constant(...
0
votes
1answer
50 views
Adaptive explicit 2nd order Runge Kutta Method on GSL
Is there a built-in second order explicit Runge Kutta scheme in GSL? I am aware that the gsl_odeiv2_step_rk2 function is an explicit embedded Runge-Kutta (2, 3) method, which converges to a 3rd order ...
0
votes
0answers
30 views
Why is the Runge Kutta solver excluding the damping coefficient?
Good day. I wrote a code to use Runge-Kutta solver to analyse the vibration movement of 3 DOF suspension setup only in the vertical direction. I don't know why but the solver doesn't include the ...
0
votes
0answers
56 views
Correct implementation of a step-size controller for embedded Runge-Kutta methods
I have been trying to write a code in C++ for embedded Runge-Kutta methods (explicit and Rosenbrock for the moment). The idea is to keep the code simple and general so that one can pass their Butcher ...
0
votes
0answers
47 views
Forced vibration second order differential equation using python
I want to make a modification to the example shown here link by adding a force to the right-hand side of the equation such as u(t), where u(t) is read from a text file. The original equation is θ′′(t)+...
0
votes
2answers
68 views
How to get less compile time for Runge Kutta Method [closed]
I want to simulate 8 differential equations by Runge Kutta fourth-order method, the number of iterations is around 60,000,000(the time step is 0.001 ms and the total time is 60s), in which way I will ...
0
votes
1answer
25 views
How can I vectorize a coupled ODE system in a Python function?
So basically I've been trying to implement this coupled ODE system into a function so that it can be solved with Runge-Kutta's method, with parameters q (electrical charge) and t (time), where q is a ...
1
vote
2answers
131 views
Runge–Kutta methods for ODE integration in Python with additional constraints
I have a question on solving second order differential equations using RK4, considering additional constraints on the first derivative. I am doing the example shown here with some modifications
θ′′(t)...
0
votes
3answers
687 views
Lorenz attractor with Runge-Kutta python
Hello I have to program a python function to solve Lorenz differential equations using Runge-Kutta 2cond grade
sigma=10, r=28 and b=8/3
with initial conditions (x,y,z)=(0,1,0)
this is the code i ...