Friday, February 25, 2011

Alpha Review

Since I went over most of the stuff during the Alpha Review I'll keep this post brief. This week in addition to getting some sweet custom SPH kernels integrated which work really well for the viscosity stuff, I got the thermal diffusion working (temperature diffuses through the fluid until an equilibrium is reached in some distant timestep depending on a thermal diffusion constant) as well as a "real" viscosity term working using deformation and stress tensors. It works pretty well for a "melting" effect currently, although there are a lot of artifacts which I need to work out through playing with good ranges for the constants as well as maybe look at some other possible solutions.

One idea I had, was in addition to having just a "viscous fluid" state, would be a rigid body or solid state, in which pressure forces do not affect the particle itself and instead use rigid body dynamics (intertial tensors, center of mass, torque and the whole shebang) which will interact with the fluid. As adding something like this will really complicate the fluid dynamics and the entire fluid dynamics enginer, I want to stable the current viscosity structure and emulate results from the paper I am implementing before taking the dive, although I believe coupling these two approaches will lead to some really fantastic effects.

Sunday, February 20, 2011

Basic SPH Simulation


This week I finished stripping down and integrating the SPH simulation into my renderer/framework, and found some good initial constants to play with as well as added some fun debugging stuff like hot/cold color ramping for different particle attributes like pressure, current velocity, temperature, etc. This will be useful for future debugging.

The simulation I am using is pretty basic and uses the standard kernels from "Particle-Based Fluid Simulation for Interactive Applications" with viscous error correction (not technically the same thing we want to use, as the viscous error correction value is constant throughout the simulation and only meant to counter numerical instability, without this term the simulation quickly blows up within its own containment box). However it does not take into account particle forces at the fluid boundaries such as surface tension, which would be something interesting to implement.


The next steps in the next couple following days will be to add the "real" viscoscity stress tensor which will have a large effect on the viscoelastic nature of this fluid, and then couple it to the temperature (eventually I want to have the temperature time-variate according to the heat equation ). I will be starting off by implementing it as described in "Particle-based non-Newtonian fluid animation for melting objects" which describes the formulation of not only the stress tensor, but the viscocity function and the heat equation.

Sunday, February 13, 2011

Simple Framework

So, I retracted stomach flu this week, which meant that a weekend of unproductivity turned into about half of a week of unproductivity... I also probably gave it to Joe but from the looks of things it could have been any DMD senior undergrad flu victim who was not properly quarantined.

However, after battling with several CUDA implementations (I do not believe my knowledge of the inner workings of CUDA at this point to properly be able to extend an SPH or particle simulation first) I decided it would be best to integrate and modify an existing and more object oriented CPU implementation. 

In the meantime,  I have set up my simulation framework and UI complete with a camera, FPS tracker, image recorder, and sliders to control simple simulation parameters in the near future. In addition, I set up a particle renderer to allow for multiple modes of rendering the particles (I anticipate having several debug "modes" for rendering particles from viewing pressures, velocities, etc in particles, as well as a framework to be able to use different shaders for particle rendering). 

Although SPH is not fully integrated so the renderer isn't full connected to the proposed particle system, I tapped into my novice shader GPU skillz to make some sample VBO's to hold color and the particle positions, and attached them to the renderer to see how it would work. I stole a lot of the shading code from both the Nvidia particles sample, and Jon's shader loader from CIS565, mostly because I liked the idea of having direct control of the different shaders and because as I have learned in GPU, immediate mode is deprecated and awful so I might as well start learning how to do it correctly now before I solidify some bad habits. 

Here is a video of the simple framework:




More to come soon as I finish modifying and integrating the SPH framework and renderer.

Friday, February 4, 2011

Some Models...

Here are a couple of models I've been sketching for how the simulation should work for different materials.

There are a few things: 1) I realized that with a physically accurate phase changing simulation (thank you Ian for pointing this out) the density and volume will be changing. For water this could potentially be a trivial case, as its fairly incompressible and has a pretty uniform density in its liquid state, and a uniform density which is higher in its solid state due to the way water crystallizes. Other materials such as metal do not act this way, and usually contract as they solidify, and their non-uniform structure (something like granite where the rock is made up of a bunch of different grains of different minerals, each with different properties) means that they might become increasingly more goopy (think like lava, or a slurpee) as the temperature changes. If a weakly compressible flow SPH implementation is controllable as far as these density parameters, it might be good to look into that. Otherwise I will have to figure out a way to fake the density change due to phase change.

2) I am unsure about fracturing in the material as the temperature increases. I believe that in the materials which I have discussed, this bond-breaking is occurring at a microscopic level, and that a lot of the fracturing which occurs in materials is actually a product of physical forces and deformations in combination with material properties at  varying temperatures (forging weakening the metallic bonds in order to more easily deform metal, etc.). I will focus on first simulating multi-phase flow...

3) Do I want to create a multi-phase flow simulation using air and material particles, or just material particles?That is do I want the heat transfer to occur automatically through the particle interactions in the sim through the air, or do I just use material particles and use another method of heat transfer. The system dynamics could be extremely different if I guess or estimate heat transfer through air by using the estimation methods in a lot of papers I've read, although it will definitely speed up simulation times.

In other news, I am trying to get some other SPH implementations I've found to work, but I am not having any luck with FLUIDS v.2, because of some changes made to CUDA 3.x from 2.3. I'm not sure if using this implementation is worth rolling my CUDA installation back to this version, or if it will even help but I am continuing to look for the best SPH implementation which would suit my needs. Although I can definitely say that looking at the source for these particle systems and SPH implementations is really helping me get a hold of what will be difficult to implement as far as the phenomena I've listed below. 

Once I decide on an implementation and get to creating the proper particle dynamics I will post some videos of preliminary results next week.

Wednesday, February 2, 2011

Particle Attributes

As I continue to read about current implementations of multi-phase flow and phase changing materials using SPH, there are a few things which I need to iron out with the approach I am going to take in tackling SPH.

The first are what kinds of things I am planning on simulating in materials, in order to make the simulation as applicable as possible to different types of materials, as there are a lot of different phenomena I need to consider. I do not plan on implementing or utilizing all of these, but there are a few which are extremely important.


Phenomena
  • Particles
    • SPH!
  • Heat Transfer
    • How heat is transferred from particle to particle
  • Phase Changes 
    • Particles of Different Types: Solids, Liquids, Gases
  • Viscosity 
    • Closely Associated with Heat/Deformation
  • Multi-Phase Flow 
    • Interaction Between Particles of Different Types
  • Buoyancy 
    • As you get particles of varying densities or different materials, the less dense material rises according to the buoyancy equation, bubbles IE
  • Surface-Tension
    • Cohesion of particles near the surface interface.
    • Fluid-Air Interface
  • Inter-Facial Tension
    • Cohesion/Repulsion interactions of particles between different phases or different materials
    • Fluid-Fluid,Fluid-Solid Interface
  • Spatial Hashing / Uniform Grid
    • Speed Up search for Neighbors/Collisions between Particles, optimized for/on GPU)
  • SPH Simulation for Deformable Solids
    • Elasticity and Rotation of Deformable Solids during Simulation
    • Based on "Corrated SPH for deformable solids", to allow for better rigid body dynamics using SPH
  • Adaptive Sampling 
    • Larger Particles for Less Detailed Areas, Smaller Particles for More Detailed Areas during Sim
  • Surface Extraction
    • Creating a mesh from particle data.
  • Marching Cubes, Blobbies, Screen Space Meshes, etc.
Keyword: SPH is a particle based method for fluid simulation (has other applications), in which each particle is 
updated by a neighborhood of other particles based on a kernel function which is usually applies a Gaussian 
weight by distance from other particles surrounding it. Most if not all particle attributes discussed would be 
updated this method, including velocity/acceleration, heat transfer, etc.


Particle Structure
  • Basic Particle Attributes
    • Position
    • Velocity
    • Acceleration
    • Area
    • Mass
    • Radius (Uniform or Adaptive Size?)
  • Advanced Particle Attributes
    • Temperature
    • Viscosity
    • Density
    • Pressure
    • Stress Tensor
    • Phase (Solid/Liquid/Gas/Oobleck?)
Additional Forces
  • Temperature of the Air
  • Gravity
  • Immovable (SOLID) Particles
    • Containers for more Interesting Fluid Flow
I have found a lot of methods for simulating these different phenomena in various related papers, some which seem more physically correct than others, but most of them produced extremely interesting and believable results.

There are two interesting points which I have found through reading and observation. The first is that there have been few attempts to apply SPH to rigid body dynamics apart from a paper called "Corrated SPH for deformable solids", which uses additional attributes to account for dynamics such as rotation and shear, which I think will be extremely useful.

The other is that surface tension (and perhaps other cohesive forces) play an extremely large part in determining the shape and structure of flow in things such as lava and highly viscous materials. There is only one method I could find for defining surface tension for SPH which is described here: http://portal.acm.org/citation.cfm?id=846298 but the original paper describing the method is here: http://onlinelibrary.wiley.com/doi/10.1002/1097-0363(20000615)33:3%3C333::AID-FLD11%3E3.0.CO;2-7/abstract

However I can't access the latter paper...do we have access to this library? Either way I am unsure if this surface tension force will work well for what I am trying to accomplish, given that it is for extremely small scale surface tension effects for low viscosity flows.