Benchmark AI / Public workspace
SciCode / 51.3 / This function runs Velocity Verlet algorithm to integrate the positions and…
Problem
Answer published by the source. Consult the official source to check your work against its answer.
step background
Background
velocity Verlet algorithm, similar to the leapfrog method, except that the velocity and position are calculated at the same value of the time variable (leapfrog does not, as the name suggests). This uses a similar approach, but explicitly incorporates velocity, solving the problem of the first time step in the basic Verlet algorithm:
$\begin{aligned} & \mathbf{x}(t+\Delta t)=\mathbf{x}(t)+\mathbf{v}(t) \Delta t+\frac{1}{2} \mathbf{a}(t) \Delta t^2 \\ & \mathbf{v}(t+\Delta t)=\mathbf{v}(t)+\frac{\mathbf{a}(t)+\mathbf{a}(t+\Delta t)}{2} \Delta t\end{aligned}$
It can be shown that the error in the velocity Verlet is of the same order as in the basic Verlet. Note that the velocity algorithm is not necessarily more memory-consuming, because, in basic Verlet, we keep track of two vectors of position, while in velocity Verlet, we keep track of one vector of position and one vector of velocity. The standard implementation scheme of this algorithm is:
Calculate .
2. Calculate .
3. Derive from the interaction potential using .
4. Calculate .Plain-text mathematical notation (without MathML)
Background
velocity Verlet algorithm, similar to the leapfrog method, except that the velocity and position are calculated at the same value of the time variable (leapfrog does not, as the name suggests). This uses a similar approach, but explicitly incorporates velocity, solving the problem of the first time step in the basic Verlet algorithm:
$\begin{aligned} & \mathbf{x}(t+\Delta t)=\mathbf{x}(t)+\mathbf{v}(t) \Delta t+\frac{1}{2} \mathbf{a}(t) \Delta t^2 \\ & \mathbf{v}(t+\Delta t)=\mathbf{v}(t)+\frac{\mathbf{a}(t)+\mathbf{a}(t+\Delta t)}{2} \Delta t\end{aligned}$
It can be shown that the error in the velocity Verlet is of the same order as in the basic Verlet. Note that the velocity algorithm is not necessarily more memory-consuming, because, in basic Verlet, we keep track of two vectors of position, while in velocity Verlet, we keep track of one vector of position and one vector of velocity. The standard implementation scheme of this algorithm is:
Calculate v(t+(1)/(2)Δt)=v(t)+(1)/(2)a(t)Δt.
2. Calculate x(t+Δt)=x(t)+v(t+(1)/(2)Δt)Δt.
3. Derive a(t+Δt) from the interaction potential using x(t+Δt).
4. Calculate v(t+Δt)=v(t+(1)/(2)Δt)+(1)/(2)a(t+Δt)Δt.Original LaTeX notation
Background
velocity Verlet algorithm, similar to the leapfrog method, except that the velocity and position are calculated at the same value of the time variable (leapfrog does not, as the name suggests). This uses a similar approach, but explicitly incorporates velocity, solving the problem of the first time step in the basic Verlet algorithm:
$\begin{aligned} & \mathbf{x}(t+\Delta t)=\mathbf{x}(t)+\mathbf{v}(t) \Delta t+\frac{1}{2} \mathbf{a}(t) \Delta t^2 \\ & \mathbf{v}(t+\Delta t)=\mathbf{v}(t)+\frac{\mathbf{a}(t)+\mathbf{a}(t+\Delta t)}{2} \Delta t\end{aligned}$
It can be shown that the error in the velocity Verlet is of the same order as in the basic Verlet. Note that the velocity algorithm is not necessarily more memory-consuming, because, in basic Verlet, we keep track of two vectors of position, while in velocity Verlet, we keep track of one vector of position and one vector of velocity. The standard implementation scheme of this algorithm is:
Calculate $\mathbf{v}\left(t+\frac{1}{2} \Delta t\right)=\mathbf{v}(t)+\frac{1}{2} \mathbf{a}(t) \Delta t$.
2. Calculate $\mathbf{x}(t+\Delta t)=\mathbf{x}(t)+\mathbf{v}\left(t+\frac{1}{2} \Delta t\right) \Delta t$.
3. Derive $\mathbf{a}(t+\Delta t)$ from the interaction potential using $\mathbf{x}(t+\Delta t)$.
4. Calculate $\mathbf{v}(t+\Delta t)=\mathbf{v}\left(t+\frac{1}{2} \Delta t\right)+\frac{1}{2} \mathbf{a}(t+\Delta t) \Delta t$.step description prompt
This function runs Velocity Verlet algorithm to integrate the positions and velocities of atoms interacting through Lennard Jones Potential forward for one time step according to Newton's Second Law. The function that aggregates the net forces on each atom for a system of atoms interacting through Lennard Jones Potential is given. The inputs of the function contain a float sigma, a float epsilon, positions, which is a N (N is the nubmer of atoms) by 3 array of float numbers, velocities, which is a N by 3 array of float, a float dt, and a float m. The outputs are new_positions and new_velosities, which are both N by 3 array of float numbers.
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.
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