
Differential Equations Ordinary and Partial Differential Equations Math Forum 
 LinkBack  Thread Tools  Display Modes 
June 22nd, 2017, 06:22 AM  #1 
Newbie Joined: Jun 2017 From: italia Posts: 9 Thanks: 1  Basic question about loworder RK
At a given instant $\displaystyle t_i$, a body is moving in the atmosphere with velocity $\displaystyle \vec v_i$. I need to know the velocity after an arbitrary interval of time. I calculate: $\displaystyle \vec a_i= k \cdot v^2_i \cdot \frac {\vec v_i} {\vec v_i}$ The velocity $\displaystyle \vec v_{i+1}$ at time $\displaystyle t_{i+1} = t_i + \Delta t$ is $\displaystyle \vec v_{i+1}= \vec a_i \cdot \Delta t$. I would speed up my simulation while retaining a good accuracy and I thought to use a loworder RungeKutta method; a secondorder RK would be a good starting point, but unfortunately my math skill is poor (like my English ). Please, would somebody help me in writing a secondorder RK method for this problem? 
June 22nd, 2017, 09:06 PM  #2  
Senior Member Joined: Feb 2016 From: Australia Posts: 1,413 Thanks: 482 Math Focus: Yet to find out.  Quote:
Using RK2 with 2 coupled DE's will result in four function evaluations. You could assign $\dfrac{dv}{dt} \equiv f(t, v)$, and $\dfrac{ds}{dt} \equiv g(t,a)$. The RK2 scheme would look like, $\Delta t = h$ $f_1 = h f(t_i, v_i)$ $g_1 = h g(t_i, a_i)$ $f_2 = h f(t_i + \frac{h}{2}, v_i + \frac{f_1}{2})$ $g_2 = h f(t_i + \frac{h}{2}, a_i + \frac{g_1}{2})$ $a_{i+1} = f_i + f_2$ $v_{i+1} = g_i + g_2$ $t_{i+1} = t_i + h$  
June 22nd, 2017, 09:18 PM  #3 
Senior Member Joined: Feb 2016 From: Australia Posts: 1,413 Thanks: 482 Math Focus: Yet to find out. 
I have to ask, why RK2? For a system like this, i don't see any trouble in using RK4 or some variant. In any case, the software you are using to simulate this will likely have a built in differential equation solver. In matlab, this would be ode45(). From memory, it is the RungeKuttaFehlberg method. Which is a bit more accurate that the RK4. 
June 23rd, 2017, 03:32 AM  #4 
Newbie Joined: Jun 2017 From: italia Posts: 9 Thanks: 1 
Thanks a lot for the clear answer! In the working versions of my simulations, I use the 8thorder DormandPrince integrator (DOPRI 853, with 3rdorder error estimation and continuous output), but I don't understand what I'm doing; I just put the acceleration formula in the derivative function and then I start the simulation (typically an nbody problem or an "atmospheric" problem). I hope that if I start to write a simple RK integrator from scratch, I should understand how it works and I should stop asking for help every time I need to write a simulation. Now I'll try to code what you wrote... Thank you. 
June 23rd, 2017, 05:59 AM  #5 
Senior Member Joined: Apr 2014 From: Glasgow Posts: 2,074 Thanks: 695 Math Focus: Physics, mathematical modelling, numerical and computational solutions  If you want to take an indepth look at numerical methods, try getting hold of a copy of Numerical Recipes (in C or Fortran). It's brilliant and will help you a lot even if you don't code anything in C or Fortran.

June 23rd, 2017, 08:02 AM  #6 
Newbie Joined: Jun 2017 From: italia Posts: 9 Thanks: 1 
I have the 3rd edition of NR in C and it's very useful, but a question & answer thread helps a lot. 

Tags 
basic, loworder, question, rungekutta 
Thread Tools  
Display Modes  

Similar Threads  
Thread  Thread Starter  Forum  Replies  Last Post 
basic question  john beattie  New Users  1  September 17th, 2015 11:42 AM 
Basic question  genieboy  Elementary Math  4  November 15th, 2012 04:28 AM 
Basic question  OriaG  Linear Algebra  1  November 7th, 2012 06:21 PM 
Basic question  Dudewithmathproblems  Algebra  12  February 6th, 2012 01:37 PM 
Basic Question In PDE  WannaBe  Applied Math  0  October 24th, 2010 01:36 PM 