#### Archived

This topic is now archived and is closed to further replies.

# Fluid diffusion in a grid

This topic is 5398 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

I am examining the paper Real-Time Fluid Dynamics for Games, by Jos Stam. http://www.dgp.toronto.edu/people/stam/reality/Research/pdf/GDC03.pdf I am in doubt that one of the formulas in the paper is correct and I would very much like a second opinion. In the paper it is stated that "We assume that the physical length of each side of the grid is one, so that the grid spacing is given by h=1/N." Further down the line (in the sourcecode) it is stated that density travels by diffusion between the cells, at a rate stated to be density*diffusionfactor*timestep*N*N. The diffusion works both ways, so two cells with equal density recieves just as much as it emits. I am confused by the N*N part, because my intuition says that it has something to do with the area the diffusion occurs across. And if I follow the statement from before the area the diffusion would occur over is (1/N)*(1/N). Not N*N Have I totally misunderstood the diffusion physics? Or is there an error in the paper. Im confused. (EDITED by Mod to make URL clickable) [edited by - Timkin on March 1, 2004 1:32:24 AM]

##### Share on other sites
Diffusion is rapid at a small scale and slow at a large, so I guess the paper is correct.

##### Share on other sites
You can revise your intuition by looking at the explicit formula for doing diffusion (here for scalar field a):

La[x,y] = (a[x+1,y] + a[x-1,y] + a[x,y+1] + a[x,y-1] - 4a[x,y])/(h^2)

a[x,y] <-- a + La[x,y]*diffusionStrength*timeStep

Notice that 1/h^2 == N^2, so the diffusion rate is clearly N^2*diffusionStrenth*timeStep.

From this it follows that the diffusion rate is the same in any dimension.

Notice also that decreasing h (increasing N) will lead to instabilities if the more accurate grid has more accurate features.

- Mikko

##### Share on other sites
quote:
Original post by Anonymous Poster
Diffusion is rapid at a small scale and slow at a large, so I guess the paper is correct.

That completely depends on the diffusion kernel used.

quote:
Original post by uutee
La[x,y] = (a[x+1,y] + a[x-1,y] + a[x,y+1] + a[x,y-1] - 4a[x,y])/(h^2)

a[x,y] <-- a + La[x,y]*diffusionStrength*timeStep

It should be noted that this is only a first order approximation to a diffusion model with very rigid constraints (diffusion tensor =scalar constant, zero drift). Thus, its relevance to actual diffusion processes is limited.

Timkin

[edited by - Timkin on March 1, 2004 1:31:38 AM]

##### Share on other sites
So I was right that the area was involved. I just had divide with it instead.

Thanx

##### Share on other sites
>>It should be noted that this is only a first
>>order approximation to a diffusion model with very
>>rigid constraints (diffusion tensor =scalar constant,
>>zero drift). Thus, its relevance to actual diffusion
>>processes is limited.

Correct: it was just a tool to help intuition on the matter.

But all approximations to the Laplacian I have seen include a 1/h^2 multiplication, so I think it''s more "universal" (ie. more than just a special case for the standard 5-point approximation) and rising from the fact that the Laplacian is, after all, based on the second derivative. I could be blatantly wrong, of course.

>>So I was right that the area was involved. I just

Well, you CAN think about it as an area enclosed by a hxh square, but...

>>From this it follows that the diffusion rate is the
>>same in any dimension.

... but in 3D for example, it doesn''t generalize to a volume in the cube hxhxh.

- Mikko

PS. If derived from Taylor series, I think it should always give the 1/h^2 multiplication for Laplacian approximation.

##### Share on other sites
I am rather thinking of the 2D case as a N*N*1 voxelgrid. Where their faces are of side 1/N*1/N.

In 3D I use the same area, because the size of the faces are unchanged.

1. 1
2. 2
3. 3
Rutin
15
4. 4
khawk
13
5. 5
frob
12

• 9
• 9
• 11
• 11
• 23
• ### Forum Statistics

• Total Topics
633669
• Total Posts
3013257
×