softmatter:Euler Algorithm
From NSDL Materials Digital Library Wiki
The Euler algorithm is the simplest of all numerical integration techniques. It uses only the positions and velocities at time t to find those at time t + Δt
General Algorithm
Expand the position and velocity of a particle at time t in a Taylor series, truncating terms of Δt3and higher in
and Δt2in
:
where
,
and
are the position, velocity, and acceleration of the particle and Δt is the time step of integration.
Truncation error in the velocity is
per time step. Over an interval of length l the truncation error is proportional to lΔt2 times
steps. This results in an overall truncation error of
in the velocity. This error compounds in the calculation of the position, making matters worse.
Example Source Code
void Integrate()
{
// Initialize positions and velocities
Initialize();
for (int timestep = _begin; timestep <= _end; timestep++)
{
//compute forces from particle positions
ComputeForce();
for (int i = 0; i < Nparticles; i++)
{
v[i] = v[i] + (f[i] / mass[i]) * delta_t;
x[i] = x[i] + v[i] * delta_t;
}
}
}
Comments:
Because the Euler algorithm has such terrible error accumulation it should not ever be used for molecular simulation.


