Single Particle Simulation
Explicit Euler Method
Instability and Improvements
Rigid Body Simulation
Fluid Simulation
For similicity we may write vectors in the same way as scalars.
Assume the motion of a particle is determined by a velocity vector field that is a function of position and time:
Computing the position of that particle over time requires solving a first-order ordinary differential equation (ODE):
Solve the ODE subject to a given initial particle position
Euler's Method, a.k.a. Forward Euler, Explicit Euler, is
a simple iterative method,
commonly used,
very inaccurate, and
most often goes unstable.
The rightside of the equation consists of only values at present.
Errors accmulate as the integration goes, and euler integration is particularly bad.
Inaccuracy increases as step
Instability is a common, serious problem that can cause simulaton to diverge.
Solving by numerical integration with finite differences leads to two problems:
Errors:
Errors at each time step accmulate. Accuracy descrease as simualtion proceeds.
Accuracy may not be critical in graphics applications.
Instability:
Errors can compound, causing the simualtion to diverge even when the underlying system does not.
Lack of stability is a fundamental problem in simulation, and cannot be ignored.
Midpoint Method/Modified Euler
Average velocities at start and endpoint.
Adaptive Step Size
Compare one step and two half-steps recursively until the error is acceptable.
Implicit Methods
Use the velocity at the next time step (hard)
Position-Based/Verlet Integration
Constraint positions and velocities of particles after step
Compute Euler step
Compute derivative at the midpoint of Euler step
Update position using midpoint derivative
Averaging velocity at start and end of step gets better results. (Applying second derivatives)
Technique for choosing step size based on error estimation
Practical
May need very small steps
Repeat until error is below threshold:
Compute
Compute
Compute error
If
Informally called Backward Methods.
Use derviatives in the future for the current step
Solve nonlinear problem for
However, we likely do not know
And we need to compute a numerical solution
Use root-finding algorithm, e.g. Newton's method
Much better stability:
Measured by local truncation error (for each step) and total accumulated error (overall)
Order of error w.r.t. step matters more than the absolute value
Implicit Euler has order 1, which means that
Local truncation error:
Global trucnation error:
A family of advanced methods for solving ODEs.
Especially good at dealing with non-linearity
RK4, or the order-four version, is the most widely used
After modified Euler forward-step, constrain positions of particles to prevent divergent, unstable behavior
Use constrainted positions to calculate velocity
Both of these ideas will dissipate energy, stablize
Pros/Cons
Fast and simple
Not physically based, violates conservation of energy
Simple case:
Since the rigid body has all its components fixed, simulation is similar to that of a particle, but with a bit more properties:
where
Key idea:
Assumptions:
Water is composed of small rigid-body spheres
Water cannot be compressed
As long as the density changes somewhere, it should be corrected via changing the position of particles
Need to know the gradient of the density anywhere w.r.t each particle's position
Do gradient descent.
Lagrangian: explictly compute the position of each particles
Eulerian: Separate the space into a grid, compute the change happened inside the grid
Hybrid, combining Eulerian and Lagrangian views:
Lagrangian: consider particles carrying material properties
Eulerian: use a grid to do numerical integration
Interaction: particles transfer properties to the grid, grid performs update, then interpolate back to particles