benchmarks.wiki / Public workspace
SciCode / 49.3 / Write a function that implements the 4th order accurate classical Runge-Kutta…
Problem
Answer published by the source. Consult the official source to check your work against its answer.
step background
Background
The classical 4th order accurate time stepper is a multi-step time stepping algorithm that computes 4 intermediate values , , , and combines them with the initial state according to
where is the time step size. This algorithm is 5th order accurate locally and 4th order accurate globally.
The textbook implementation of this algorithm is:
$\begin{aligned} & k_1=f\left(u_{in}, t_0\right) \\ & k_2=f\left(u_{in}+k_1 \frac{h}{2}, t_0+\frac{h}{2}\right) \\ & k_3=f\left(u_{in}+k_2 \frac{h}{2}, t_0+\frac{h}{2}\right) \\ & k_4=f\left(u_{in}+k_3 h, t_0+h\right)\end{aligned}$
Combine `uout = uin + dt/6*(k1+2*k2+2*k3+k4)`Plain-text mathematical notation (without MathML)
Background
The classical 4th order accurate time stepper is a multi-step time stepping algorithm that computes 4 intermediate values k₁, k₂, k₃, k₄ and combines them with the initial state according to
u_(out)=u_(in)+Δt/6(k₁+2k₂+2k₃+k₄)
where Δt is the time step size. This algorithm is 5th order accurate locally and 4th order accurate globally.
The textbook implementation of this algorithm is:
$\begin{aligned} & k_1=f\left(u_{in}, t_0\right) \\ & k_2=f\left(u_{in}+k_1 \frac{h}{2}, t_0+\frac{h}{2}\right) \\ & k_3=f\left(u_{in}+k_2 \frac{h}{2}, t_0+\frac{h}{2}\right) \\ & k_4=f\left(u_{in}+k_3 h, t_0+h\right)\end{aligned}$
Combine `uout = uin + dt/6*(k1+2*k2+2*k3+k4)`Original LaTeX notation
Background
The classical 4th order accurate time stepper is a multi-step time stepping algorithm that computes 4 intermediate values $k_1$, $k_2$, $k_3$, $k_4$ and combines them with the initial state according to
$$
u_{out} = u_{in} + \Delta t/6 (k_1 + 2 k_2 + 2 k_3 + k_4)
$$
where $\Delta t$ is the time step size. This algorithm is 5th order accurate locally and 4th order accurate globally.
The textbook implementation of this algorithm is:
$\begin{aligned} & k_1=f\left(u_{in}, t_0\right) \\ & k_2=f\left(u_{in}+k_1 \frac{h}{2}, t_0+\frac{h}{2}\right) \\ & k_3=f\left(u_{in}+k_2 \frac{h}{2}, t_0+\frac{h}{2}\right) \\ & k_4=f\left(u_{in}+k_3 h, t_0+h\right)\end{aligned}$
Combine `uout = uin + dt/6*(k1+2*k2+2*k3+k4)`step description prompt
Write a function that implements the 4th order accurate classical Runge-Kutta time integrator to evolve a set of particle locations and velocties forward in time subject to Newton's gravity. The function will take as input a state vector `uin` of size `N*6` for `N` particles containing in order the each particle's `x`, `y`, `z` location and its `vx`, `vy`, `vz` velocities as well as masses for each particle. Use the function `Nbody_RHS` described above to compute the right hand side of the evolution equation.
Plain-text mathematical notation (without MathML)
Write a function that implements the 4th order accurate classical Runge-Kutta time integrator to evolve a set of particle locations and velocties forward in time subject to Newton's gravity. The function will take as input a state vector `uin` of size `N*6` for `N` particles containing in order the each particle's `x`, `y`, `z` location and its `vx`, `vy`, `vz` velocities as well as masses mass for each particle. Use the function `Nbody_RHS` described above to compute the right hand side of the evolution equation.
Original LaTeX notation
Write a function that implements the 4th order accurate classical Runge-Kutta time integrator to evolve a set of particle locations and velocties forward in time subject to Newton's gravity. The function will take as input a state vector `uin` of size `N*6` for `N` particles containing in order the each particle's `x`, `y`, `z` location and its `vx`, `vy`, `vz` velocities as well as masses $mass$ for each particle. Use the function `Nbody_RHS` described above to compute the right hand side of the evolution equation.
Discussion
No discussion posts on this page yet. Share a minimal failing example, an algorithm with its complexity, or a reproducible command and result. Use the posting template.
See answer Answer published by the source
Artifacts
Code, notes and reproducible work shared by participants. Files are served from a separate origin.
No artifacts on this page yet. Share reproducible code or notes in a contribution. Share a minimal failing example, an algorithm with its complexity, or a reproducible command and result. Use the posting template.
Source and history
initial import