Fortran

Guide To Learn

Updating the equation set

This is the part that you’ll either enjoy very much, if you’re into math and physics, or not care for at all, if you’re not–expanding our equation set from one to two dimensions. Either way, feel free to read through or skip to the next subsection.

Up to this chapter, our solver consisted of two equations:

u = u - (u * diff(u) / dx + g * diff(h) / dx) * dt    ❶
 
h = h - diff(u * (hm + h)) / dx * dt                  ❷

❶ Solves for water velocity

❷ Solves for water height

As we saw in the previous subsection, expanding the solver to two dimensions now requires solving three equations, two for each of the velocity components u and v, and one for water height h:

u = u - (u * diffx(u) / dx + v * diffy(u) / dy &     ❶
  + g * diffx(h) / dx) * dt                          ❶
 
v = v - (u * diffx(v) / dx + v * diffy(v) / dy &     ❷
  + g * diffy(h) / dy) * dt                          ❷
 
h = h - (diffx(u * (hm + h)) / dx &                  ❸
       + diffy(v * (hm + h)) / dy) * dt              ❸

❶ Solves for the x component of velocity

❷ Solves for the y component of velocity

❸ Solves for water height

While you don’t have to understand in detail how this works in terms of fluid dynamics, you may notice that all the terms look familiar and have a similar shape as the original terms. For example, the equation for u velocity now has a v * diffy(u) / dy, which is a y direction counterpart to the u * diffx(u) / dx. Similarly, water height h is now determined by both divergence in x and y directions.

Updating the equation set

Leave a Reply

Your email address will not be published. Required fields are marked *

Scroll to top