Step 2: Implementing the forces with Rigidbody

As it was time to implement the mathematics controlling the behaviour of the spheres, we quickly noticed that the pouring technique was not going to cut it. Taking a lot of inspiration for our math from Micky Kelager's paper Lagrangian Fluid Dynamics Using Smoothed Particle Hydrodynamics (2006), we realized that the number of available particles had to be a fixed number from the beginning of the simulation. Hence the obstacles and the pouring was removed and instead 200  - 400 spheres were placed at the scene in Unity. The scene in its current state can be seen in the figure below. Observe that we decided to not render the meshes of the cube to more easily see how the spheres behave, however they are still there.


Following Micky Kelager's paper we implemented external forces in the form of gravity and surface tension and internal forces in the form of the viscosity force and pressure force, as well as all the surrounding math these forces required to work. We decided that we wanted to use Unity's own Rigidbody system to implement the collision. As the rigidbody system allows us to add forces, the behaviour of the spheres were expected to follow the math described in the paper. What we quickly however realized was that the rigidbody system did not recalculate the velocities in a correct manner, which can be seen in the video below (obs! updated videos for a clearer view).




For the water to behave correctly, the kinetic energy of each sphere needs to be conserved and redirected. Hence when a water sphere collides with a wall or another sphere, that energy is not allowed to just disappear as it does when using the rigidbody system. Our next step will because of this be to implement through the functions OnCollisionEnter and OnCollisionExit a conservation of the energies. Hopefully we will manage to create a more correct flow for each sphere.









Kommentarer

Populära inlägg i den här bloggen

Step 4: Implement Kelager's suggested algorithm

Step 6: Implementing the iWave algorithm