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

  • A
  • Thread starter Thread starter member 428835
  • Start date Start date
  • Tags Tags
    Numerical Rk4
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 member 428835
Thread 'Direction Fields and Isoclines'
I sketched the isoclines for $$ m=-1,0,1,2 $$. Since both $$ \frac{dy}{dx} $$ and $$ D_{y} \frac{dy}{dx} $$ are continuous on the square region R defined by $$ -4\leq x \leq 4, -4 \leq y \leq 4 $$ the existence and uniqueness theorem guarantees that if we pick a point in the interior that lies on an isocline there will be a unique differentiable function (solution) passing through that point. I understand that a solution exists but I unsure how to actually sketch it. For example, consider a...
Back
Top