Skip to content

yohai/advection-diffusion

Repository files navigation

This set of MATLAB functions simulates diffusion-advection flow in a doubly-periodic domain . The equation for the scalar field c(x,y,t) is

where is independent of time and is divergence free. is calculated by the function generate_v_field and is a sum of terms of the form

where m and n are random integers and are random real numbers.

The equations are solved by explicit finite differences conservative scheme. one_run performs a single realization by generating a velocity field, integrating the equations, and returning the result. run_collect_save is a script (not a function) to perform multiple runs with a given set of parameters and store the result in a handy hdf5 file.

convert_to_single.py contains a useful python function that converts an h5 file created by run_collect_save to a file with identical data but in float16 precision, which makes it more manageable.

Structure of the hdf5 files

The file produced by run_collect_save have this format:

  • The name of the file is the value of
  • /t is the list of times for which the solutions are calculated (uniformly spaced)
  • /x and /y are matrices of shape [n,n] with the x and y coordinates of the finite-differences grid for
  • Each file contains 50 realizations, which are at groups /001, /002, ..., /050:
    • /XXX/c is an ndarray of shape [n,n,len(t)] that contains the concentration field. c[i,j,k] is the value of the concentration field at position x[i,j] and y[i,j] at time t[k]. In other words, c[...,i] is the snapshot of the concentration field at time t[i].
    • The group /XXX also contains /XXX/u,/XXX/v, which are the x and y components of the velocity field. Note that u and v are not evaluated at the same grid points as c since we use a staggered scheme to ensure conservation. The functional form of u and v is given in both MATLAB and Mathematica syntax in the attributes of /XXX.

Data

Here are generated hdf5 files. The data is released under Creative Commons CC-BY license.

Creative Commons License

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published