So… what is a simulation? Pt I.

The Simulation Guy
5 min readFeb 7, 2022

One might argue that we live in a simulation. Now, while I love some metaphysics debate, the kind of simulations that I intend to discuss here are on the mathematical and physical side of things.

Since Newton published his Principia Mathematica, we have been introduced to the laws of physics through mathematical lenses, which inevitably yield differential equations. Most if not all physical phenomena are stated through a differential equation.

It turns out, however, that most differential equations are quite hard to solve. Take for instance Navier-Stokes equations, which describe the movement of a fluid particle — they are so hard to solve that we don’t know if solutions to the general equations in 3 dimensions even exist.¹ But that is a mathematical and physics problem. Engineers have been using these equations to model fluid behavior for quite some time. How?

Well, engineering is a kind of art. We are not bound by rigid rules of having to make sense, as long as things simply work. Do we have to make sense of why they work? No such compromise is needed when you’re an engineer. As long as it works. The art that best describes engineering is the art of approximations, and this was how the field of numerical simulation came to be. The general framework of a numerical simulation of a physical phenomenon is:

  1. State the formal problem in the form of a set of differential equations
  2. Use some high-level calculus “tricks” to weaken the mathematical rules regarding the said problem, transforming the differential equations into integral equations.
  3. Approximate the solution to the weak problem as a finite sum of known functions, in such a way that you create a linear/matricial system of equations.
  4. Solve the system of equations and find the approximate solution.

And that’s all. No magic, just a simple set of linear equations. That’s how most commercially available software breaks down complex physical phenomena into easier to compute equations.

Now, when I was learning this in college (and again in my master’s), there was always a convoluted way of explaining these simple steps, through some nefarious interpretation of Hamiltonian mechanics and the principle of virtual work. I’m pretty sure they were right about this, but my monkey brain just couldn’t comprehend what they meant. To me, numerical simulation was calculus magic that was invented to make my grades plummet.

If I could talk to my past self studying for his Solid Mechanics B test, this is how I would explain numerical simulation:

Now, you may have heard about this principle of virtual work that only made you more confused than clear about this subject. Forget about it. Let’s start by writing a simple differential equation that represents a physical phenomenon, like Laplace’s equation with a source term:

Laplace’s equation with a source term

Now, this equation is quite simple to solve depending on where it is happening: a string, a circle, a square, a triangle… these are places where we know the functions that solve this equation. However, we want to solve this for any crazy domain Ω, 1,2 or 3D, like the technical potato:

An oddly-shaped domain

It turns out that we can’t solve the equation for this domain as easily as we could for regular geometries. Well, don’t you worry about that: we have a technique to approximate the solution. Let’s go back to Laplace’s equation and multiply it by a function v. This function must have only two properties: that it is defined inside this domain Ω and that it goes to 0 on the boundary of the domain. So we write:

Now, we integrate this equation over the whole domain of the problem — this is how we get the geometry information for our solution. So we have:

We now integrate by parts, taking advantage of the fact that v is zero over the boundary of Ω. This effectively drops the highest derivative of the problem by 1:

We have now transformed our initial problem from a differential equation into an integral one, just using some clever mathematical tricks. By doing this, we made it possible to include information about the geometry into the problem and we also dropped the order of the highest derivative by one. Effectively, this problem is now weaker than the previous, as it should be easier to solve.

Altough weaker, the problem is still as hard to solve as the other one, as we have absolutely no information on u or v aside from those we’ve made up. That means we have to make some more assumptions.

We must especulate on the nature of u. Since we’re in the realm of approximations, it would be very convenient if the u were some sort of sum of very easy to evaluate functions, like polynomials. That would mean that taking it’s derivative and evaluating its integral would be very easy. So let’s do just that:

P(x) is a polynomial

Still, we haven’t made much progress, as we don’t know exactly what are these polynomials or what are the coefficients d. Neither did we introduce information about out geometry inside the problem.

These, my friends, will be the subject of the next post of this introductory series to numerical analysis. Stay in tune when we demistify the finite-element mesh next week!

¹ The Navier-Stokes existence and smoothness problem is one of the Millenium Prize problems. The statement of the problem is to prove that given a set of initial conditions to the incompressible problem, globally defined solutions that are infinitely smooth exist or if they do not always exist and break down.

--

--

The Simulation Guy

soon to be Dr. Eng. in Mechanical Engineering, specialized in multiphysics, numerical analysis, vibroacoustics and topological optimization.