My Math Forum  

Go Back   My Math Forum > College Math Forum > Differential Equations

Differential Equations Ordinary and Partial Differential Equations Math Forum


Thanks Tree2Thanks
  • 1 Post By Joppy
  • 1 Post By Cristiano
Reply
 
LinkBack Thread Tools Display Modes
June 22nd, 2017, 05:22 AM   #1
Newbie
 
Joined: Jun 2017
From: italia

Posts: 9
Thanks: 1

Basic question about low-order 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 low-order Runge-Kutta method; a second-order 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 second-order RK method for this problem?
Cristiano is offline  
 
June 22nd, 2017, 08:06 PM   #2
Senior Member
 
Joined: Feb 2016
From: Australia

Posts: 1,322
Thanks: 452

Math Focus: Yet to find out.
Quote:
Originally Posted by Cristiano View Post
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 low-order Runge-Kutta method; a second-order 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 second-order RK method for this problem?
Any initial conditions for velocity and acceleration? Or do you just want the general form?

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$
Thanks from Cristiano
Joppy is offline  
June 22nd, 2017, 08:18 PM   #3
Senior Member
 
Joined: Feb 2016
From: Australia

Posts: 1,322
Thanks: 452

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 Runge-Kutta-Fehlberg method. Which is a bit more accurate that the RK4.
Joppy is offline  
June 23rd, 2017, 02: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 8th-order Dormand-Prince integrator (DOPRI 853, with 3rd-order 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 n-body 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.
Cristiano is offline  
June 23rd, 2017, 04:59 AM   #5
Senior Member
 
Joined: Apr 2014
From: Glasgow

Posts: 2,049
Thanks: 680

Math Focus: Physics, mathematical modelling, numerical and computational solutions
Quote:
Originally Posted by Cristiano View Post
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.
If you want to take an in-depth 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.
Benit13 is offline  
June 23rd, 2017, 07: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.
Thanks from Benit13
Cristiano is offline  
Reply

  My Math Forum > College Math Forum > Differential Equations

Tags
basic, loworder, question, runge-kutta



Thread Tools
Display Modes


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





Copyright © 2017 My Math Forum. All rights reserved.