Sign in to follow this  

Weather simulation

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

If you intended to correct an error in the post then please contact us.

Recommended Posts

I have tried creating a system for large scale weather based on physical factors many times without success.

 

Whatever I come up with fails due to two issues.

 

1) Initial conditions

2) Calculation complexity

 

So I have come up with yet another approach that is working pretty well so far.

 

I allow the designers to specify a bunch of high and low pressure zones( with values and velocities) and connect them with weather fronts.

 

This is by no means realistic, but the results work well enough.

 

new_clouds2.jpg

 

My problem is now I want to add more realism. At the moment I just create a bunch of clouds based on distance from the weather front and the local air pressure.

 

Now I want to add clouds based on terrain effects.

 

The problem with this is I really need to work out an ambient temperature value for each location on the map.

 

This runs me back into the initial value problem.

 

I have calculated the ETR* value of the sun for each location, but that only gives me a heating effect so I need a start temperature.

 

Has anyone come across a way of calculating an ambient temperature for a location based on date/time/location data?

 

 

 

 

* ETR == extraterrestrial radiation value, the intensity of the sun light in a location.

 

Share this post


Link to post
Share on other sites
I don't think the initial conditions are a big deal: If you know how to run your simulation forward, you should achieve plausible states quickly, even if you started with quite implausible ones (there is probably some formal statement of this using the notion of "thermal equilibrium", but I am not even going to try to go there).

That said, I don't really have any good suggestions for how to model the computation of the state from previous states. This is probably a large field of study. Perhaps this is a good starting point? http://ocw.mit.edu/courses/earth-atmospheric-and-planetary-sciences/12-810-dynamics-of-the-atmosphere-spring-2008/

Share this post


Link to post
Share on other sites

Am i right in assuming your game is historical in nature?

 

Why not just get hold of the weather readings (if there were any) from various locations, and then simulate the weather at each location and interpolate between them?

 

You would know exactly when your game took place and where, weather reports from various stations would have been public knowledge? This is probably how i'd handle it... You won't have to worry about procedural generation, or having artists drawing weather fronts into your maps.

 

What do you think?

Share this post


Link to post
Share on other sites
First off, simulating weather for a game sounds awesome. I really like that idea.

Second, I wouldn't worry too much about being super precise and super realistic. As long as the weather patterns look reasonable and aren't doing anything crazy you should be fine. Your goal should be a weather simulation that makes the game more fun. If the weather patterns make sense to the player and can be used strategically then your simulation is good.

IMHO I wouldn't start with air temperature, pressure zones, and velocities in a tight grid and try to model it like the simulations used to predict weather. I would start by identifying what you want the weather to do and write a simulation that mimics that behavior. Edited by HappyCoder

Share this post


Link to post
Share on other sites


I don't think the initial conditions are a big deal: If you know how to run your simulation forward, you should achieve plausible states quickly, even if you started with quite implausible ones (there is probably some formal statement of this using the notion of "thermal equilibrium", but I am not even going to try to go there).

There is a lot of balance in weather on earth without time trace up, as encapsulated weather subject, without those as established, I guess really the simulation would become some sort of a furnace, like moon and earth spawned in space would just go collapse towards each other. Like, that New York is more south than Madrid, yet the weather and temperatures and ecosystem are incomparable becouse of some water stream.

Share this post


Link to post
Share on other sites

I don't think the initial conditions are a big deal: If you know how to run your simulation forward, you should achieve plausible states quickly, even if you started with quite implausible ones (there is probably some formal statement of this using the notion of "thermal equilibrium", but I am not even going to try to go there).

There is a lot of balance in weather on earth without time trace up, as encapsulated weather subject, without those as established, I guess really the simulation would become some sort of a furnace, like moon and earth spawned in space would just go collapse towards each other. Like, that New York is more south than Madrid, yet the weather and temperatures and ecosystem are incomparable becouse of some water stream.


I don't know if it's the grammar or just the punctuation, but I don't understand what you wrote.

Share this post


Link to post
Share on other sites


I don't know if it's the grammar or just the punctuation, but I don't understand what you wrote.

I wanted to stress that I think that initial conditions of a weather system are as vital as its corect behaviorals. If second is perfect, the system will not be simulated without first. Weather is a cycling system, just as orbits, without parameters of it, they cannot behave as you would expect, even if you would establish newton force of attraction, and base system on some reduced observation set up (position).

Share this post


Link to post
Share on other sites

I wanted to stress that I think that initial conditions of a weather system are as vital as its corect behaviorals. If second is perfect, the system will not be simulated without first. Weather is a cycling system, just as orbits, without parameters of it, they cannot behave as you would expect, even if you would establish newton force of attraction, and base system on some reduced observation set up (position).


I disagree. The atmosphere is a chaotic system that has little in common with orbiting masses. The atmosphere is a system that takes energy from the Sun and from the inside of the Earth and radiates it to space. If you start with initial conditions that are too cold or too hot, you'll see it gaining or losing heat. When it comes to humidity levels, if the air is really dry it will more easily grab moisture from the sea and other bodies of water; if it's too humid, rain will fix that. If the pressure difference between some parts of the atmosphere and others are too large, winds will take care of that.

I've studied dynamical systems enough to be pretty certain about this. Chaotic systems like this one tend to forget their initial state. There is a large portion of the state space that forms the basin of a chaotic attractor that is what corresponds to actual observed weather. If you start too far away from typical conditions, you may be in the basin of a different attractor (e.g., snowball Earth). But it shouldn't be too hard to get the initial conditions in the right ballpark.

Share this post


Link to post
Share on other sites


There is a large portion of the state space that forms the basin of a chaotic attractor that is what corresponds to actual observed weather. If you start too far away from typical conditions, you may be in the basin of a different attractor (e.g., snowball Earth). But it shouldn't be too hard to get the initial conditions in the right ballpark.

So then the weather is is an entropy system of chaos well defined over the rest of condition?(heat, energy, matter, chemical reorganization) And when the outside entropy is well defined, the weather will unfold in its exact form as consequnce? but to bottom-catch weather like this, is, like to simulate universe from big bang after a (few) pictures of the bang. Quite hard to manage, or not?

Share this post


Link to post
Share on other sites

The reason I took the "designed" approach is to give the designers chance to add complexity to the game play.

 

If you watched any films about the US bombing campaign in WWII, you will always see times when the weather has a massive effect on the mission. Cloud obscuring the target, do I go around and fly through the flak again or do I drop and hope?

 

The initial pressure regions defined by the designers have attached velocities. So over the course of the mission the weather fronts move (the weather fronts are calculated not drawn).

 

This means winds change direction, clouds move, all the things that you would expect to happen happen.

 

It also means I can do some very simple maths to detect updrafts and downdrafts, simply look at the wind direction and terrain normal and I can generate nice effects.

 

My problem is the rest of the simulation, the bit that makes it feel real rather than designed.

 

Clouds forming down wind of mountain peaks. Sleet mixed in with the rain where cold air meets warm air. Precipitation. Snow. Fog.  all these things that make it real.

 

What I don't want to do is make the whole system designed. I want a designer to spend 30 minutes setting up weather not two days.

 

To do this I have to bring temperature into the simulation.

 

I may be able to take existing real world data from many sources and create a sort of global ambient temperature map I suppose, but that feels wrong.

 

What I am thinking of doing is just do the sun energy calculation for a full day. Calculate the total energy added to the system at any point over 24 hours, then use some formula to relate that to ambient temperature.

 

Then do a pass with the starting cloud formations to modify that temperature map.

 

Do we think that would work?

 

Any other terms I should add?

Share this post


Link to post
Share on other sites

Had a think about it and I think what I should do is ...

 

1) Calculate the total energy input from the sun for a 24 hour period.

2) Use this to calculate a base ambient temperature. (Use a SHC from some web resource for the terrain type, multiply the two, half it.)

3) Calculate a total energy supplied by the sun up until the simulation start time and add this as a heating effect.

 

This will give me a finger in the air starting point for the ambient temperature.

 

I also think when I get this working I should open source it to see if anyone can improve it.

Share this post


Link to post
Share on other sites

code is irrevelant

 

look at the title and read that pdf



/*
*  A Method for Modeling Clouds based on Atmospheric Fluid Dynamics
*	Ryo Miyazaki Satoru Yoshida Yoshinori Dobashi† Tomoyuki Nishita
*	University of Tokyo †Hokkaido University
*	7-3-1, Hongo, Bunkyo-ku Kita 13, Nishi 8, Kita-ku,
*	Tokyo, 113-0033, Japan Sapporo, 060-8628, Japan
* 	{ryomiya, yoshida, nis}@nis-lab.is.s.u-tokyo.ac.jp doba@nis-ei.eng.hokudai.ac.jp
*
*
*  Coded by me ;]
*
*
*/


//deltaV / deltaT = -(grad(pressure) / density) + visc_coeff*grad(V)   ---- velocity

// grad(div) is the flow caused by the gradient of the mass flow around lattices
// Let vx be the x component of the velocity v for the current time step and vx* be the x component of v for the next time step.

/*
Velocity field update / Viscosity and Pressure Effect

vx is of course the x part of velocity vector

//vx*[x][y][z] = vx[x][y][z] + kv * grad(vx)[x][y][z] + kp * grad(diw)x  //for the same cell

//kv is the viscosity ratio
//kp is the coefficient of the pressure effect

grad(vx)[x][y][z] = divBy6 * ( cell[x+1][y][z].v.x + cell[x-1][y][z].v.x + cell[x][y+1][z].v.x +
cell[x][y-1][z].v.x + cell[x][y][z+1].v.x + cell[x][y][z-1].v.x - 6.0f * cell[x][y][x].v.x );

grad(diw)x = divBy2 * ( cell[x+1][y][z].v.x + cell[x-1][y][z].v.x - 2.0f * cell[x][y][z].v.x   ) +
divBy4 * (  cell[x+1][y+1][z].v.y + cell[x-1][y-1][z] - cell[x-1][y+1][z].v.y - cell[x+1][y-1][z].v.y +
cell[x+1][y][z+1].v.z + cell[x-1][y][z-1].v.z - cell[x-1][y][z+1].v.z - cell[x+1][y][z-1].v.z );



*/



/*
  WATER VAPOR DIFFUSION

  Wv*[x][y][z] = Wv[x][y][z] + temperature_coeff * grad(Wv)[x][y][z];


  grad(Wv) = divBy6 * ( cell[x+1][y][z].w + cell[x-1][y][z].w + cell[x][y+1][z].w +
cell[x][y-1][z].w + cell[x][y][z+1].w + cell[x][y][z-1].w - 6.0f * cell[x][y][x].w );


*/



/*
  Thermal Diffusion

   E*[x][y][z] = E[x][y][z] + temp_diff_coeff * grad(E)[x][y][z];


  grad(E) = divBy6 * ( cell[x+1][y][z].temp + cell[x-1][y][z].temp + cell[x][y+1][z].temp +
cell[x][y-1][z].temp + cell[x][y][z+1].temp + cell[x][y][z-1].temp - 6.0f * cell[x][y][x].temp );



*/



/*
  Buoyancy      AD NOTE 2.: since in paper we have z versor pointing upward we need to convert it to y component since we have lefthanded(or righthanded ;p) system  

kb is the coefficient affecting the strength of the
buoyancy force.


Vz*(x,y,z) = Vz(x,y,z) + kb * divBy4 * (  4.0f * E[x][y][z] - E[x+1][y][z] - E[x-1][y][z] - E[x][y+1][z] - E[x][y-1][z]  );

so the code seems to be like this: (rewritten to y as up vector)


cell[x][y][z].v.y* = cell[x][y][z].y + kb * divBy4 * ( 4.0f * cell[x][y][z].temp - cell[x+1][y][z].temp - cell[x-1][y][z].temp -
cell[x][y][z+1] - cell [x][y][z-1] );
*/



/*
			  PHASE TRANSMISSION


 (6) Phase Transition
The amount of water droplets generated by the phase
transition is determined in proportion to the difference
between the maximum amount of water vapor and the
amount of water vapor in each lattice. The maximum
amount of water vapor for a unit volume of air is a
function of its temperature (see appendix for details ).


APPENDIX

The amount of water droplets is proportional to the
difference between the maximum amount, 'wmax', of water
vapor 'wv' and the amount of water droplets 'wl' of each
lattice. That is, the amount of water droplets created at
each time step is computed by the following equation.



(A.1)
where alpha is the phase transition rate. Q is the latent heat.
wmax is a function of the temperature T[K] and is given by
the following equation:
( ) 217.0 exp[19.482 4303.4 /( 29.5)] / . max w T = - T - T (A.2)


*/
const long double viscosity_coeff = 0.9670;
const long double waterVapor_coeff = 0.9670;
const long double temperature_coeff = 0.9670;
const long double divBy6 = 0.16670; //1.(6)
const long double divBy4 = 0.250;
const long double divBy2 = 0.50;
		 /* Deleted bullcrap not even worth watching */
#endif

 

The problem with this is I really need to work out an ambient temperature value for each location on the map.

 

 

There are many topogrpahic temperature maps, by studying them you could create your own initial value map

 

Has anyone come across a way of calculating an ambient temperature for a location based on date/time/location data?

 

Thats almost impossible to achieve, unless your run fullscale simulation, and learn your program, how things change. (still it will be far from ideal due to external forces)

 

And the wind that causes temperature to move (cool down heat up).

I believe there are heat maps on nasa page, so you could make some kind of one year peroid temperature map (with maybe data from each month, or only for winter, spring, summer, autsomething tongue.png, you wont be able to get acutal day, time, hour weather without running some simple simulation. or lerping <- which is bad as f

 

 

still code is wrong there, (didint have time to fix it) but the pdf is really good.

 

vital is to add third dimension. gravity, coriolis force or whatever its called

 

i am a bit to late with that post but was searchign for that code and pdf name.

 

 

but now i dont know if this is answered or what, still i could write an essay about weather

Edited by WiredCat

Share this post


Link to post
Share on other sites

Yes I tried that sort of system before. The results were encouraging, but used far too much CPU time to make it worthwhile.

 

I moved the equations into shaders and it still took about a minute to generate a full cloud map. That's why I ended up trying this pseudo-scientific approach.

Share this post


Link to post
Share on other sites

I think you have to be very careful about a realistic way to simulate this. May be too difficult and take too much calculation power.

As for how much starting conditions matter, that's completely dependent on what math functions you put in and how they interact. If the range of parameters that lead to equilibrium are narrow, the system may diverge rather than converge and you may get stupid results. A system may converge too narrowly. One parameter may dominate all others. Such an artificial system will only behave like sensible like a real system when you set it up so that it does. And that may actually be a sweet spot. Your world may get hotter and hotter and approach infinite hotness in infinite time. If you make energy, and temperature, a finite quantity, then it will not. But then all heat may end up in one place and stop moving around the map. Then you constrain it even more and it may stay too constant. Then you crank up how fast it changes and all you get a bunch of quickly osculating noise.

 

There's no way to know how your complex system behaves until you run simulations. And if you have a lot of degrees of freedom, you cannot find what constants you need to put into your function to get the behavior you want.

You may need to evolve your parameters or use some fancy numerical approach to your multivariate problem. All a headache.

 

 

So having tried actual simulations which seems to have failed, can you not take a bunch of datasets and mix them up randomly while keeping it continuous somehow?

 

Try to look at just temperature and try to figure out what it has to do, at the bare minimum. Then find the simplest way to implement it. You can have a sine oscillate between a minimum and maximum during the day and during the year. Then you can vary those minima and maxima.

 

Problem is that if you want everything to be smooth and continuous throughout all your game tiles, you just need a smooth 3d function with interesting topography. To generate one randomly is not so hard. Just sum a bunch of functions in 2 variables and see what kind of heat landscape that gives you in a graphing program.

To generate one that makes sense for your topography, that's a lot harder.

 

Sometimes, you can make up a bunch equations with a bunch of parameters. Then you can kind of paint how a solutions would look like by making up a bunch of numbers. Then use a numerical method that tries to converge for the parameters that make the function fit the made-up dataset you created.

 

To generate something that behaves like a real weather system, for that you need a real weather simulation.

Edited by Almeisan

Share this post


Link to post
Share on other sites

I used a table of SHC values I found on the internet and converted the suns incident radiation (in watts per square meter) to an energy value and applied this to the terrain over a 24 hour period. Using this I was able to get an initial value for ambient temperature that looks ok.

 

The results look like this though it's hard to tell anything from an image.

 

temperature.jpg

Share this post


Link to post
Share on other sites

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

If you intended to correct an error in the post then please contact us.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this