Basics of Math and Physics
These subjects are usually seen by undergraduate students of sciences and engineering. However, a basic understanding of them is required if you want a deep understanding of any computational physical simulation.
The text below is not intended to be a reference in these subjects. It’s main purpose is just to provide the user of Blender some fundamental insight on what is actually happening inside physical simulations of Blender. If you wish learn more about any of the topics discussed, there are some useful links at the bottom of this page.
The formal description of what vectors are and how to use them (mathematically) is the core of Linear Algebra. However, the definition of vectors in Linear Algebra is somewhat obscure, and not intended for direct geometrical practical use, being defined as an abstract concept.
In this document we will use the analytical geometry approach, which defines vectors as "arrows" in 3d space. Examples of physical vectors are velocity, force, and acceleration. Physical quantities that are not vectorial are said to be Scalar. Examples of scalar quantities are energy, mass, and time.
Some properties that summarize vectors:
- One vector may be broken down into its components on the main axes.
- Two vectors are equal if, and only if, all their components are equal.
- The sum/difference of two vectors is equal to the sum/difference of their components.
- Multiplication/division of vectors is not the same as with "common" numbers.
There are some types of operation called products, but any of them are not equal to the products of the components, as you might think. These will not be discussed here.
Particles are the most basic type of body you can create in Physics. They have no size, and therefore cannot be rotated. The law that governs the movement of particles is Newton's Second Law: f=ma (force equals mass times acceleration). This is not the complete form of Newton's law, but the simplified form is sufficient for calculating particle motion. The vectorial sum of all the forces acting on the particle equals has the same direction and orientation of the acceleration. The branch of Physics that is dedicated to this subject is called Classical Mechanics.
Using vector notation, it is simple to solve particle motion equations using a computer even if there are multiple forces of different types. Examples of these forces include Blender "force fields" and Dampening, a force that is proportional to speed (the higher the speed, the higher the force). As particle motion is so simple to solve, Blender is able to calculate the position of thousands of particles almost in real-time when animating.
Rigid Body simulation
Rigid body means the body is not deformable, i.e. cannot stretch, shrink, etc. The main difference from particle simulation is that now our objects are allowed to rotate, and have a size, and a volume.
The equation that governs rotational motion is Τ = I α. Torque equals moment of inertia times angular acceleration. Now we need a definition of each of these words:
- A force may cause a torque. The torque it causes is the vectorial cross product of the component of the force perpendicular to the axis you are evaluating by the distance from the point of the application of the force to that axis. Also, torques are vectors. A very useful special case, often given as the definition of torque in fields other than physics, is as follows:
The construction of the "moment arm" is shown in the figure below, along with the vectors r and F mentioned above. The problem with this definition is that it does not give the direction of the torque but only the magnitude, and hence it is difficult to use in three-dimensional cases. If the force is perpendicular to the displacement vector r, the moment arm will be equal to the distance to the centre, and torque will be a maximum for the given force. The equation for the magnitude of a torque arising from a perpendicular force:
For instance, it is much easier to close a door by pushing it by the handle than by pushing it in the middle of the door, because, when you do it by the handle, you increase the distance of the force you are apply to the axis of calculation.
- Moment of Inertia is a measure of how difficult is to rotate the body. It is proportional to both the mass and the geometry of the object. Given a fixed volume, a sphere possesses the smallest moment of inertia possible.
- Angular acceleration: Is a measure of the acceleration in the rotational movement.
The programs devoted to deliver fast and accurate simulation of rigid body dynamics are often called physics engines, or game engines. Blender itself has a game engine, called Bullet. All simulations in the Bullet engine, if well designed, are real-time, except for those with a very high number of objects present.
In the near future, it is expected that computers used for gaming will have a Physics Processor Unit (PPU) dedicated to these calculations as a card, like what happened when graphics processing was moved from the CPU to video cards (Graphics Processing Units or GPUs).
Physics of deformable bodies
The method most computers use to simulate deformable 2D or 3D bodies is to subdivide (automatically or manually) a body into cells, and then, assuming any properties inside a single cell to be an interpolation of the properties at its corners, to solve the equations at the boundaries of the cells. If you use a large number of cells (in other words, a highly subdivided mesh), you can get very realistic results.
A common application of this method, plus some more hypotheses, leaves us into a wide field of engineering which nowadays is called Finite Element Analysis.
In Blender, the simulation of deformable bodies is somewhat similar to this, but the equations are simplified for speed. If we enable an object as a soft body, Blender assumes that all faces are cells and all vertices are masses, with the edges as springs. The following images illustrate how a 3x3 grid of vertices (a mesh plane in Blender) becomes a set of Soft Body cells in Blender.
There is a theory (in the scientific use of the word theory, it has been proven), that provides us a set of equations called Navier-Stokes equations, that completely state how a fluid will behave in most of situations being turbulent or not. However, these equations cannot be solved by hand, and today, no exact answer has been found to solve this equation in its complete state, just in some very special states, and none of them include turbulence.
Currently, the method used to solve this equation consists in using iterative solving, thus getting an answer as close to real as we want to. This is called DNS (Direct Numerical Simulation). However, DNS requires enormous computation power, and even for today, mid-2006, only supercomputers or very large clusters of computers can use DNS with some success. If correctly applied, however, DNS returns the best and most trusted results of all methods, from the more micro distance at which the results are meaningful to the simulation, to the more macro distance, the scale of the objects we are simulating.
So, we need to approximate our model more, in order to do less calculation. Instead of considering the fluid a continuum, we will discretize our fluid. By discretizing, you can understand dividing into cells. Inside a cell, the properties like velocity, pressure, density are all considered to be the same, so we only have to solve equations on its borders. We also discretized time, i.e., only some instances are calculated. However, we need another equation that deals with this discrete problem. This equation is called the Lattice-Boltzmann equation, and this equation complies with the Navier-Stokes equation.
There is also one more optimization done in Blender, the use of adaptative grids. In a region far from interfaces, instead of using a tiny cell, we use a larger cell. This greatly decreases calculation time (up to 4 times faster), without loss of quality. This optimization is responsible to find places where you can use a larger cell without disturbing the results, and when to start using smaller cells in these places.
Boundaries: The boundaries (domain, obstacles) counts as a cell in the method.
- No slip: The fluid cells near the surface of the boundaries are not allowed to move at all, having zero velocity.
- Free slip: The fluid cells are allowed to move freely. If the calculation indicates that that cell would move inwards the boundary cell, then its velocity vector is inversed.
- Classical Mechanics
Rigid Body simulation
Finite element analysis
- Finite Element Analysis 
- Finite Element Analysis example