Friday, September 15, 2017

newtonian mechanics - Physics simulator based on conservation laws?


Reading the article:


http://en.wikipedia.org/wiki/Newton%27s_laws_of_motion#Relationship_to_the_conservation_laws


there's a section stating that:


In modern physics, the laws of conservation of momentum, energy, and angular momentum are of more general validity than Newton's laws


I've also seen lectures by Richard Feynman where he talked about how the law of angular momentum can be derived if one assumes Newton's laws. But it turns out the law of angular momentum is much more general than Newton's laws. Which is also in agreement with that is stated above.


However, one thing I can't wrap my head around is that the conservation laws doesn't seem to be as "directly implementable" as for instance Newton's laws. It is rather trivial to write a simulator based on Newton's laws, or at least some approximating of them. Such a simulator could operate by solving the differential equations or it could numerically solve/simulate such equations using small time steps etc.. The conservation laws, on the other hand, seem more indirect. How would one base a simulator on the conservation laws? Would the simulator have to constantly examine all possible outcomes and then select those that conserve all the quantities that have to be conserved etc. These laws by themselves don't seem to lend themselves as well to implementation.


The same is true for other fundamental laws like the second law of thermodynamics. This too seems to be a very fundamental law even though it can be derived from other laws in various contexts, and would automatically be at least statistically true in a simulator implementing Newtonian mechanics. But again it seems to be more generally valid than these derivations suggest and is in that sense more fundamental. But again, it seems difficult to write a simulator that uses this as the fundamental principle.



Of course, there's no guarentee that the fundamental laws of nature would lend themselves well to implementation. But "intuitively" it feels like the fundamental laws of nature should be something that could be put into a simulation program where each time step could be executed in some constant time - and not, i.e. a program based on brute-forcing all possible outcomes and then selecting those that satisfies various constraints. Of course there's no guraentee this is so, but it seems it would require an improportionate "computational power" by the universe to simulate even the simplest of situations. Maybe this is already so considering how every mass in the universe is in some sense in constant gravitational interaction with all other mass in the universe etc.



Answer



Let's dive right into an example -- let's say you are simulating a fluid. First, you need to pick your reference frame. Are you going to simulate a fixed domain in space and have your fluid move through it, meaning you have a grid and at each point on the grid you store and solve for the fluid properties (Eulerian frame)? Or will you track each discrete packet of fluid as it moves around and interacts with the things around it (Lagrangian frame)? Both are useful in various cases and which one you choose tends to give more or less complexity. And you can easily go between the two in some cases as we'll see below.


Okay, so let's say for now that you are going to be in a Lagrangian frame. You can now use Newton's Law:


$$ a_i = \frac{F_i}{m} = \frac{D u_i}{D t} $$


which says that the change in velocity in the i-direction of a fluid packet is due to the net force on the packet in the i-direction divided by the mass. Or, you can use the Navier-Stokes equations:


$$ \frac{D u_i}{D t} = -\frac{1}{\rho}\frac{\partial P}{\partial x_i} + \nu \frac{\partial^2 u_i}{\partial x_i x_j}$$


which are just an expression of conservation of momentum. It turns out, however, that these two equations are really just expressions of the exact same thing. So Newton's Law is the conservation of momentum and vice versa. The total force on my fluid packet is due to the differences in pressure on each side of my packet and also due to the collision of my packet with other packets (which is modeled by the viscous term).


I said it is easy to go between Lagrangian and Eulerian frames. The time derivative, $D/Dt$ is called the substantial derivative and is defined as:


$$\frac{D}{Dt} = \frac{\partial}{\partial t} + u_i\frac{\partial}{\partial x_i}$$



which will transform the equations into an Eulerian reference frame.




When it comes to simulation, the conservation laws are directly implementable. It's easier sometimes to understand the conservation laws when they are written in an integral form:


$$\frac{\partial }{\partial t} \iiint\limits_V \vec{W} dV + \iint\limits_{S(V)} \left[\vec{F}-\vec{G}\right] \cdot dS = \vec{S}$$


where:


$$ \begin{aligned} \vec{W} &= \begin{bmatrix} \rho \\ \rho u_i \\ \rho E \end{bmatrix}\qquad \vec{F} = \begin{bmatrix} \rho u_i \hat{n}_i \\ \rho u_i u_j \hat{n}_j + p \hat{n}_i \\ \rho u_i \left(E+p\right)\hat{n}_i \end{bmatrix}\qquad \vec{G} = \begin{bmatrix} 0 \\ \tau_{ij}\hat{n}_j \\ u_j \tau_{ij} \hat{n}_i + \kappa \frac{\partial T}{\partial x_i}\hat{n}_i \end{bmatrix}\\ \vec{S} &= \begin{bmatrix} 0 \\ 0 \\ 0 \end{bmatrix} \end{aligned} $$


In this case, these are the conservation equations (mass, momentum and energy) for a compressible fluid in an Eulerian reference frame. $\vec{F}$ is the inviscid flux vector (so how the properties change due to inviscid motion) and $\vec{G}$ is the viscous flux vector (how the properties change to the viscous effects) and $\vec{S}$ is the source vector.


I said this is easier to see the conservation law form but then it looks all nasty. But here is why it is easier: $\iiint \vec{W} dV$ is the total amount of a property within your control volume; $\iint \vec{F}-\vec{G} dS$ is the amount moved into and out of your control volume through the edges/faces of it; $\vec{S}$ is the amount created or destroyed within your control volume. In words, what is inside is equal to what comes in minus what leaves plus whatever is made inside.


Notice that since mass, momentum and energy are neither created nor destroyed, the source vector for all of those terms is 0.


These equations are "directly implementable" in a simulation and do not require summing up things everywhere and trying to find an answer that will conserve everything. If you are solving those equations, you are conserving everything and no extra effort needs to be made*.





*. Okay, so that's a bit of a lie. In a simulation, considerable effort needs to be made to make sure your numerical method conserves things properly. It turns out, they only will do so if they are consistent and convergent, and if you use an infinite number of points and an infinitely small time step. Otherwise, numerical errors will manifest essentially as source terms in each of those equations and you will get mass/energy/momentum production or destruction. But it's not the equations' fault, it just turns out solving them is pretty darn hard.


No comments:

Post a Comment

classical mechanics - Moment of a force about a given axis (Torque) - Scalar or vectorial?

I am studying Statics and saw that: The moment of a force about a given axis (or Torque) is defined by the equation: $M_X = (\vec r \times \...