Allegro.cc - Online Community

Allegro.cc Forums » Game Design & Concepts » Generating a Wind Model

This thread is locked; no one can reply to it. rss feed Print
Generating a Wind Model
Onewing
Member #6,152
August 2005
avatar

I don't know much about how wind currents work and there may not be a plausible way to create them with the small amount of given information I have. I'd sure appreciate any help and/or advice.

Say you have an x by y graph (x amount of nodes in horizontal, y amount in vertical). Each node has a height and a temperature. From this, is it possible to create a wind current model of the entire graph? Any ideas of how one should go about that (algorithms, structure, etc.)?

------------
Solo-Games.org | My Tech Blog: The Digital Helm

Don Freeman
Member #5,110
October 2004
avatar

Bernoulli's Theorem
Look at the gas section. I would think that it would be possible knowing the mass of the particles in the volume and the heat pressures involved. Since everything tends to move from high pressure (high heat) to low pressure (low heat), you can then deduce that particles of higher temp will move towards the lower temp particles. If you want a more accurate simulation, you would have to take into account for thermodynamics in which you account for heat transfer. Looks like an interesting project...I'm just not up to the math...sorry!

--
"Everyone tells me I should forget about you, you don’t deserve me. They’re right, you don’t deserve me, but I deserve you."
"It’s so simple to be wise. Just think of something stupid to say and then don’t say it."

Evert
Member #794
November 2000
avatar

If you assume that the surface as an isobaric surface and that the gas is ideal, then an increase in temperature leads to a decrease in density. This sets up a density distribution, which can drive bulk fluid motion. Alternatively, you can treat the surface as an isodensity surface, in which case the temperature gradient induces a density gradient, which acts as a force.
The relevant equations to solve would be the continuity equation,
<math>\frac{\partial \rho}{\partial t} + \nabla \cdot \rho \vec{v} = 0</math>,
the equation of motion (Euler equation or Navier-Stokes equation).
<math>\rho\frac{\partial \vec v}{\partial t} + \nabla \cdot \left(\rho \vec{v}\vec{v} + p \mathbb{I} \right) = \vec{f}</math>
and the equation of state,
<math>p = \frac{\rho k_B T}{\bar{m}}</math>
Here, <math>\rho</math> is the fluid (mass) density, <math>p</math> is the pressure, <math>\vec v</math> is the fluid velocity and <math>\bar{m}</math> is the mean particle mass in the fluid. A more elaborate model should also include the energy equation and possibly viscosity.

It should be possible to discretise the set of equations and solve them, but I think they're notorious for being sensitive to how you do the discretisation, so it may not be straightforward to get this to work as you want.

EDIT: I forgot to mention: <math>\vec f</math> is the external force per unit mass. You'll probably want to set this to 0, unless you want to simulate a force pushing the matter in one direction (a pressure gradient should build up to counter this force).

ImLeftFooted
Member #3,935
October 2003
avatar

Hmm.. I understood none of that post Evert :P. Can you translate to C/C++ for us non-math experts?

Evert
Member #794
November 2000
avatar

What, you mean write a hydrodynamics code as a part of a forum post? I suppose I could... given at least a couple of weeks to do it properly!
How to discretise the equations really depends on what you're trying to do. If you want to do something like this, you really should know at least enough mathematics to understand the fluid dynamics equations or invest time to learn.

If you want to learn about numerical methods, you cannot easily beat Numerical Recipes (but you can beat their code), so I'd recommend reading up there.

Onewing
Member #6,152
August 2005
avatar

Thanks Evert and Don. I'm going to fiddle with these formulas and see if I can get some currents flowing through my current model. If all goes well, I should be able to accumulate clouds and possibly storms. I'll let you know how it goes.

I'm saving credits in case anybody else wants to pitch in.

********************************* [EDIT] ************************************

Okay, let's put some theory to pratice (mainly because I'm at work and bored). I haven't evaluated all the expressions too closely, see feel free to correct my logic or misunderstandings.

For the purpose of this thread, I'm going to keep it relatively simply. Let's go back to the top-down view, graph-like diagram.

* * * * *
* X * * *
* * * * * 
* * * * *
* * * * *

The *'s above represent the ground at BASE height (for simplicity, let's consider BASE height to be 0). The X represents raised ground. For now, let's assume the temperature is uniform throughout the diagram. I would assume, from what little I know, that the wind, or air particles that make up the wind, fall off the hill and spread out across the flat area:

- ^ - - - 
< X > - -
- V - - - 
- - - - -
- - - - -

The above would be my guess at the where the wind would blow, although the -'s are not necessarily uniform and would have some wind velocity (higher as you got closer to the hill). However, this would mean there's no wind on top of the hill, but that's because I'm looking at this two dimensionally, and technically there'd be many more layers of air. Here's an example of a graph where air rolls up over the X:

* * * * *        - ^ - ^ -
* X * Y *        < < < Y >
* * * * *        - V - V -
* * * * *        - - - - -
* * * * *        - - - - -

Where Y is a spot of ground that is higher than spot X.

Of course, all the above is examining a graph with no temperature differences. Going back to the original graph (with just X), let's pretend the temperature displays like this:

C C C C H
C C C H H
C H H H H
H H H H H
H H H H H

Where C is cold and H is hot. Now, my guess is the following wind model would be used for the graph and temperature pairing:

- ^ ^ ^ <
< X > < < 
^ ^ ^ ^ ^ 
^ ^ ^ ^ ^ 
- - - - -

Kind of messy, but my idea here is looking at the parts of the hill where one side is the same temperature as the top of it would act like the previous wind models. The rest is just kind of a continual flow from hot to cold.

Any comments? I'm going to see what I can accomplish with this much for the time being.

------------
Solo-Games.org | My Tech Blog: The Digital Helm

Arthur Kalliokoski
Second in Command
February 2005
avatar

How big an area are you talking about? If it's only a couple kilometers across (like in a game) I doubt convection currents etc. would affect much except for windless conditions that create tornados, it'd be more to do with high/low pressure systems and the Corealis effect that are hundreds of km across.

They all watch too much MSNBC... they get ideas.

Onewing
Member #6,152
August 2005
avatar

Actually, the area is the size of a planet. Consider each node to be a pixel of a 640X480 screen (or 307,200 nodes). If I know the direction and general velocity of wind at any given spot, I can direct clouds created by water node evaporations. This may seem like overkill, but the conditions of the planet creation are considerably flexible.

------------
Solo-Games.org | My Tech Blog: The Digital Helm

ImLeftFooted
Member #3,935
October 2003
avatar

Evert said:

What, you mean write a hydrodynamics code as a part of a forum post? I suppose I could... given at least a couple of weeks to do it properly!
How to discretise the equations really depends on what you're trying to do. If you want to do something like this, you really should know at least enough mathematics to understand the fluid dynamics equations or invest time to learn.

If you want to learn about numerical methods, you cannot easily beat Numerical Recipes [library.cornell.edu] (but you can beat their code), so I'd recommend reading up there.

Ok, you have 7 days. ready, go!

[serious]
How about a stripped down dummy model in code?

Onewing
Member #6,152
August 2005
avatar

Quote:

How about a stripped down dummy model in code?

For the size of the model, I most likely will have to.

I was also wondering if I need to take water into account. Doesn't water do some weird affects to wind or is it just the temperature of water?

BTW, here's a screen shot of what the model (models are generated randomly at runtime) looks like. No, it doesn't look like realistic terrain, and that's okay with me. I'm not doing any advanced math (or shading), I'm just changing the rgb intensities based on height (which might be how height maps work? I don't know, never worked with one before).

http://comp.uark.edu/~spsilve/terrain.JPG

[EDIT] - typo and forgot some info.

------------
Solo-Games.org | My Tech Blog: The Digital Helm

Evert
Member #794
November 2000
avatar

Quote:

I was also wondering if I need to take water into account. Doesn't water do some weird affects to wind or is it just the temperature of water?

You probably get a shear at the surface. Remember that wind can blow waves onto the water, so you can loose energy from the wind in that way.
However, my advice would be to keep things simple until you know they work well (enough).

Go to: