Jump to content

Fluid divergence - avoiding race conditions


danw

Recommended Posts

Hi all, wondering if anyone can think of a neat solution to this.

 

I'm attempting to drive the divergence of a smoke sim using various combinations of density and/or temperature... I'm after quite a rapid expansion, but one that starts rapidly and then loses energy.

I something get close using temperature to drive divergence, with a rapid cooling rate for the temperature itself, but the moment I push it too far, it will explode entirely.  Because the divergence will literally create more density/temperature out of nothing when it solves, I end up with a race condition where the faster it expands, the more temperature there is, and it expands even faster next frame.

 

Is there any way to have a rapidly divergent sim, but one where the expansion is normalized, so that the density/temperature channels effectively contain the same total amount, just spread more thinly?  That way I could avoid a feedback look, and just crank the values up until it looked right.

Link to comment
Share on other sites

I'm toying around with dividing the temperature by divergence somehow... but it doesn't seem to be achieving much.  Maybe I should just try a straight subtraction as you suggest... I'd just love to know if there was a mathematically accurate way to do a straight-up preservation-of-mass thing, or better yet, I wish it was just built in to the gas projection microsolvers already, as I tend to just stare in abject horror when attempting to work out mathematical notation myself :-)

 

What would it boil down to I wonder... how much extra volume would a divergence value of 1.0 expand a single voxel to per timestep, or per second...?

 

I just have this feeling that the true answer is going to involve dividing by divergence-values^3 or something.

Link to comment
Share on other sites

Hmm, well I seem to have managed to build something that seems vaguely self-regulating...

 

Pre-advection, I multiply both the density and temperature channels by a volume derived from:

1/((divergence*timestep)+1)

 

I can then set divergence to whatever large multiple of the temperature at the sourcing stage, and it will have a more and more violent effect, while still rapidly disipating the shockwave, rather than exponentially accelerating it and causing a feedback loop.

 

Very likely would have mathematicians facepalming, but it seems it might do the job for now :-)

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...