Efficient Computation of k2 in RK4 for Numerical RHS | PF Discussion

  • Context: Graduate 
  • Thread starter Thread starter member 428835
  • Start date Start date
  • Tags Tags
    Numerical Rk4
Click For Summary

Discussion Overview

The discussion revolves around the computation of the term ##k_2## in the Runge-Kutta 4th order (RK4) method for numerically solving the equation ##d_t y = d_x u^2##. Participants explore the implications of using finite differencing for the right-hand side (RHS) and clarify the integration process involved in the RK4 method, particularly in the context of fluid dynamics and the Navier-Stokes equations.

Discussion Character

  • Technical explanation
  • Mathematical reasoning
  • Debate/contested

Main Points Raised

  • One participant seeks clarification on how to compute ##k_2## when the RHS is finite differenced, specifically using the expression ##(u_{i+1}^2-u_{i-1}^2)/\Delta x##.
  • Another participant questions the notation and the role of ##t## in the equation, asking for clarity on whether the integration is over time or space.
  • A participant explains that finite differencing ##2ud_xu## is equivalent to finite differencing ##d_xu^2##, suggesting that the form used is for ease of understanding.
  • One participant describes their numerical approach to solving the Navier-Stokes x-momentum equation, indicating they are using a finite-volume method and expressing confusion about time integration via RK4.
  • Another participant interprets the equation as shorthand for the advection equation and confirms the initial conditions provided by the original poster.
  • There is a discussion about performing an Euler step to compute ##k_2##, with one participant seeking further explanation on what is meant by "one Euler step."
  • A participant provides a detailed breakdown of how to compute ##k_1## and subsequently ##k_2##, emphasizing the need to determine the time derivative of the vector ##\vec u##.
  • One participant expresses confusion regarding the term ##\vec u^2## in the context of the derivative ##d_x \vec u^2## and requests clarification.

Areas of Agreement / Disagreement

Participants express varying levels of understanding and clarity regarding the RK4 method and the specific computations involved. There is no consensus on the best approach to compute ##k_2##, and multiple interpretations of the problem statement exist.

Contextual Notes

Participants highlight potential ambiguities in the problem statement, particularly regarding the integration variables and the interpretation of the terms involved. The discussion reflects a reliance on specific mathematical formulations and assumptions that may not be universally agreed upon.

member 428835
Hi PF!

I am trying to compute ##d_t y = d_x u^2##. Following standard RK4 procedure outlined by wikipedia as https://en.wikipedia.org/wiki/Runge–Kutta_methods
I am forced to compute ##k_2##. If the RHS is analytic, the fractional stepping is direct. However, the RHS gradient is finite differenced: ##(u_{i+1}^2-u_{i-1}^2)/\Delta x##. Then how would you compute ##k_2##?

Thanks!
 
Last edited by a moderator:
Physics news on Phys.org
Hi,

Is a bit cryptic to me. I always thought ##d_xu^2 = 2u\;d_xu##
But what is ##t## doing on the LHS ? Could you be a bit clearer in the problem statement ? Are you integrating over ##t## or over ##x## ?
 
BvU said:
Hi,

Is a bit cryptic to me. I always thought ##d_xu^2 = 2u\;d_xu##
You're right, but finite differencing ##2ud_xu## is equivalent to finite differencing ##d_xu^2##, so I left it in this form for ease.
BvU said:
But what is ##t## doing on the LHS ? Could you be a bit clearer in the problem statement ? Are you integrating over ##t## or over ##x## ?
So I'm numerically solving Navier-Stokes x-momentum using a finite-volume approach. The unsteady term is ##d_tu## and then the RHS is the advective terms. So I have ##u## for all spatial nodes along ##x## at a current time step ##n##, and I'm time-integrating to get ##u## at time ##n+1##. I can use explicit Euler no problem, but I'm confused how to time-integrate via RK4. Any ideas?
 
Ok, so your $$d_t y = d_x u^2$$ is shorthand for $${\partial u\over\partial t} + {\partial u^2\over\partial x} = 0$$ with
$$u(x,0) = g(x) $$ in tandem with $$u(0,t)= \phi_0(t)$$ where ##g(0) = \phi_0(0)##.
(this is what I remember from the advection equation for crystal size distributions).

Right so far ?

So with RK4 you take one Euler step over ##1\over 2## the interval and recalculate ##\partial \vec u\over \partial t## there. Gives you ##k_2##
 
BvU said:
Ok, so your $$d_t y = d_x u^2$$ is shorthand for $${\partial u\over\partial t} + {\partial u^2\over\partial x} = 0$$ with
$$u(x,0) = g(x) $$ in tandem with $$u(0,t)= \phi_0(t)$$ where ##g(0) = \phi_0(0)##.
(this is what I remember from the advection equation for crystal size distributions).

Right so far ?
Yep, that sounds right!

BvU said:
So with RK4 you take one Euler step over ##1\over 2## the interval and recalculate ##\partial \vec u\over \partial t## there. Gives you ##k_2##
Can you explain what you mean by "one Euler step"? I think this is what's getting me stuck.
 
From the link $$ k_1 = h f(t_n,y_n) = h f(y_n)$$ since your ##f## is ##d_xu^2##, so not directly dependent on ##t##.
His ##y## is your ##\vec u## : $$ \vec k_1 = h\,{\;\vec {\partial u^2}\over \partial x} $$
In other words: determine the time derivative ##\partial \vec u\over\partial t## -- a vector -- and add ##h\over 2 ## times this vector to ##\vec u##. That way you do an Euler step ##h\over 2## to give you a new ##\vec u_n + {\vec k_1\over 2}## from which you establish ##\vec k_2 ##.

I must admit that I don't grok what is ##\vec u^2## in ##d_x \vec u^2## but I hope you can explain how to establish the time derivative :rolleyes: ?
 
Last edited:
  • Like
Likes   Reactions: member 428835

Similar threads

  • · Replies 2 ·
Replies
2
Views
2K
  • · Replies 1 ·
Replies
1
Views
3K
  • · Replies 8 ·
Replies
8
Views
4K
  • · Replies 0 ·
Replies
0
Views
2K
  • · Replies 13 ·
Replies
13
Views
4K
  • · Replies 1 ·
Replies
1
Views
3K
  • · Replies 1 ·
Replies
1
Views
1K
Replies
6
Views
5K