Motion in the ocean… I mean in the atmosphere

Up a level : Thermodynamics
Previous page : Grouping the particles
Next page : All the code together

As time ticks on the particles move. For the motion in the horizontal direction, we don’t have any force acting, so we basically will do

x \leftarrow x + {v_x}\Delta t

If we hit a wall, i.e. if the x-coordinate of the centre is closer to a wall than the radius of the particle, we will change the direction of the motion, and undo the last step. We will only change the direction if the particle is moving towards the wall. The reason for this is that if the particle is hit by another particle at the same time as it hits the wall it might be pushed so far into the wall that the undoing step will not move the particle’s edge out of the wall. If the direction of motion is changed now the particle will be stuck in the wall since the direction of the motion will just flip back and forth.

For the motion in the vertical direction, we need to change the velocity too. We get

{v_y} \to {v_y} + g\Delta t

But the average speed will be

\frac{{{v_{yOld}} + {v_{yNew}}}}{2} = \frac{{{v_y} + {v_y} + g\Delta t}}{2} = {v_y} + \frac{{g\Delta t}}{2}

We will use this to update the position in the vertical direction, and then we will update the velocity. In this way, the combined kinetic and potential energy will remain the same.

As with the vertical motion, the direction of the velocity is changed if the particle collides with a horizontal wall, and the last change of position is undone.

The scaling of the speeds and the accelerations is such that Δt can be set to one. That will simplify the calculations greatly.

Here is a bit of JavaScript using this.


 

Up a level : Thermodynamics
Previous page : Grouping the particles
Next page : All the code togetherLast modified: Dec 28, 2023 @ 18:04