0

As part of my project (which is testing parallel programming frameworks - I am a computer scientist), I am developing a basic, 3D $n$-body simulation. I assume that each particle is a sphere (uniform radius all around), has uniform density. Finally, there are no external forces applied to the particles, such that all collisions are perfectly elastic.

Each particle has their own, potential unique, set of the following properties:

  • Mass
  • Radius
  • Position (x, y, z)
  • Velocity (x, y, z)

So far, I have developed a solution to update the velocity & position of the particles by using Newton's Universal Law of Gravitation to determine the new velocity of each particle based on the particles around it. But this is all besides the point, I just wanted to show what I've done so far

The part I have remaining is determining the velocity of particles should they collide (I have determined whether they have collided or not). The problem is that I am have been unable to understand how to use the relevant laws of Physics (which I believe are the conservation of momentum, the conservation of kinetic energy) and solved them to obtain the final velocities of two colliding particles, given the initial velocities, masses, and distance (from either the boundary or centre of masses)

I guess what I'd find helpful is if someone could:

  1. Tell me what laws are relevant in this context
  2. How to solve them to get me the final velocities of both particles

This is not homework but part of a larger project. As a non-physicist or mathematician of any sort, this is out of my depth and I'd appreciate elaborate guidance. I have searched the internet for answers, but most are either for a 1D problem which I struggle to extrapolate for 3D, or are just formulas without enough context for me to understand

Bob D
  • 71,527
  • Conservation of linear momentum and of energy is all you need to pin down the solution. However, if you are saying that you already saw that formulæ for 3D but do not understand how they are supposed to be used, then if we write them down for you, how would it help you? It seems like you should be deriving them yourself, or else you will not understand. – naturallyInconsistent Jul 09 '23 at 16:01
  • @naturallyInconsistent for example, this answer means very little to me, as it's seems to have very little explanation. For lack of better wording, I have very little interest in understanding the physics of this code, as it won't be directly assessed at all, but I do want my implementation to be correct; I don't need to understand the subject 100%, but I would like to see how it's done – user1785414 Jul 09 '23 at 16:38
  • 1
    @naturallyInconsistent: actually it's conservation of energy, conservation of linear momentum, then an assumption that the balls are frictionless and the force is always normal to the surfaces at the point of impact. I think you could assume some sort of 100% friction and a non-normal force, but then you'd have to track the ball's rotational velocity also. – TimWescott Jul 09 '23 at 16:49
  • @TimWescott If we are going that pedantic, then I'd also have to point out that we should be strict with how we name things; viscosity is not friction is not drag and they should all be considered differently because they mean totally different interaction terms in the force balance. Since they are all not applicable to the sudden impulse case as is relevant here, you would have to call it by some other name too. – naturallyInconsistent Jul 09 '23 at 16:53
  • Sifting through all this information to find what I'm looking for is exactly why I posted this question in the first place, to those who are evidently more qualified. Though I'd point out I've made my model extremely simple for this reason also – user1785414 Jul 09 '23 at 17:03
  • Suggested google search term: "sphere sphere collision detection and response" – Amit Jul 09 '23 at 19:20
  • @naturallyInconsistent The point is that your comment is incorrect. Momentum and energy conservation do not give enough information to fix the solution in 3D. You have to model how the collision happens. – knzhou Jul 10 '23 at 04:03
  • @knzhou he had the radius; it would have been sufficient to model the collision as a smooth hard spheres problem, unless, as Tim mentioned, angular momentum also needed to be modelled; as the OP stated, he is not interested in the specifics, so it should not be the case that he would want to model to that level of detail. – naturallyInconsistent Jul 10 '23 at 04:40

1 Answers1

1

If you assume that the surfaces of the balls are frictionless, then you can assume that the force of the collisions will always act normal to the surface of the spheres at the point of contact -- which is, in turn, along the line upon which lies the sphere's centers. So you can use Newton's laws of motion here, with an impulse of known direction and unknown magnitude.

Beyond that, for any collision you have to start with the conservation of energy and the conservation of momentum. Because I'm only doing this for the frictionless case, the momentum that's conserved is just linear momentum, and you can ignore any rotation of the balls.

For each ball, then, you have a position vector $\mathbf x = \begin{bmatrix}x, y, z\end{bmatrix}$* and a velocity vector $\mathbf v = \begin{bmatrix}\dot x, \dot y, \dot z\end{bmatrix}$.

Conservation of momentum says that in the absence of any other collisions, the total momentum of any two ball system remains constant through a collision: $m_1 \mathbf v_1 + m_2 \mathbf v_2 = \mathbf p_{12}$, where $\mathbf p_{12}$ is the momentum of the two balls together, and $p_1$ and $p_2$ are their masses.

Conservation of energy says that in the absence of any other collisions, the total energy of any two ball system remains constant through a collision: $m_1 \| \mathbf v_1 \|^2 + m_2 \| \mathbf v_2 \|^2 = u$, where $\| \mathbf v \|^2 = (\dot x)^2 + (\dot y)^2 + (\dot z)^2$.

The fact that we're assuming a frictionless ball surface means that the direction of the impulse at the moment of is known, but its magnitude is unknown: the impulse on ball 1 is $\Delta \mathbf p = k\left( \mathbf x_2 - \mathbf x_1 \right)$. $\mathbf x_2 - \mathbf x_1$ gives the direction, letting $k$ be an unknown positive number captures the fact that we only know the direction of the impulse and have to let the magnitude be determined by the conservation laws.

If you take $t^-$ to be the time immediately before the collision and $t^+$ to be the time immediately after, then $\mathbf p_1(t^+) = \mathbf p_1(t^-) + \Delta \mathbf p$ and $\mathbf p_2(t^+) = \mathbf p_2(t^-) - \Delta \mathbf p$, where $\mathbf p = m \mathbf v$. Note the $+ \Delta \mathbf p$ and $- \Delta \mathbf p$, respectively.

You should at this point, have exactly enough equations in exactly enough unknowns to calculate you ending velocities from your beginning ones.


* Apologies for the dual use of $\mathbf x$ and $x$. I hope the typeface keeps them clear.

TimWescott
  • 2,781
  • I'm not going to go through the math, because it'll be time consuming, and because it's early summer with pollen and wildfire smoke here, so I'm very likely going to get something wrong, possibly in a way that looks entirely right. I won't feel slighted in the least if someone else were to edit this answer with that math, or supply a "second half" answer. – TimWescott Jul 09 '23 at 17:33
  • I understood most of this answer, except a) what k is (not it's value, but what's it's role? a constant or a differing variable?), b) to calculate the change in momentum, I'd have to calculate the x of particle 1 - x of particle 2, etc. - does this give me the change of momentum in each dimension? – user1785414 Jul 09 '23 at 17:59
  • I've edited the answer. Short story is that you know the direction of the impulse from the geometry of the collision, but the magnitude is determined by the two conservation laws. – TimWescott Jul 09 '23 at 18:36