sandbox/Antoonvh/vhm16.c

At sunrise thermal plumes start to grow. Alternatively, they reside during sunset. Image via smule.com

At sunrise thermal plumes start to grow. Alternatively, they reside during sunset. Image via smule.com

The Growth and Decay of Atmospherc Convective Turbulence.

Here we follow Van Heerwaarden and Mellado (2016) and model the growth and subsequent decay of convective turbulence in the atmosphere. This is very similar as was done in Van Hooft et al. (2018). However, there have been some advancements in the set-up methodology.

//#include "grid/octree.h" // <- Uncomment for 3D
#include "navier-stokes/centered.h"
#include "tracer.h"
#include "diffusion.h"
#include "profile5b.h" // A grid-adaptive profiling function

#define damp(s) (-(s)*(exp((y-2))-1)*(y>2)/2.)

scalar b[];
scalar * tracers = {b};
face vector av[];

double ue = 0.02; //U / ?
double be = 0.02; //b_0 / 50
int maxlevel = 9;

We use normalized values for the initital stratification strength (db/dy=N2) and the bottom buoyancy (b0). As such the CBL-height lengthscale =1. The Prandtl number (Pr) also has a value of unity and the Reynolds number (Re) is defined below as Re=3000.

double Re = 3000;

double ν, T = 1, Tend = 1, dT = 1;

u.t[bottom] = dirichlet(0.);
b[bottom] = dirichlet(1.);
b[top] = neumann(1.);
int main(){
  periodic(left);
  ν = pow(1./Re, 9./8.);
#if (dimension == 2)
  const face vector muc[] = {ν, ν};
#elif (dimension > 2)
  periodic(front);
  u.r[bottom] = dirichlet(0.);
  const face vector muc[] = {ν, ν, ν};
#endif
  T = pow(ν, -1./3.);
  dT = T;
  Tend = 30 * T;
  L0 = 3.;
  μ = muc;
  a = av;

The most important updates are related to using non-default attributes for the prognostic variable fields.

  foreach_dimension()
    u.x.refine = refine_linear; // Momentum conservative refinement
  p.refine = p.prolongation = refine_linear; // Third order accurate for vertical variations
  b.gradient = minmod2; // A flux limiter
  init_grid (1<<5);
  run();
}

event init (t = 0){
  TOLERANCE = 10E-5;
  DT = 0.01; 
  refine(y< 0.1 && level < (maxlevel - 1));
  refine(y< 0.05 && level < maxlevel);
  foreach()
    b[] = y + 0.001*noise();
}

event acceleration(i++){ //Gavity and damping for u.y
  foreach_face(y)
    av.y[] = (b[] + b[0,-1])/2. + damp((u.y[] + u.y[-1])/2.);
}

event tracer_diffusion(i++){ // and damping for b.
  diffusion(b, dt, μ);
  foreach()
    b[] += damp(b[] - y)*dt;
}

event adapt(i++){
  DT = min(DT * 1.05, 0.1); // DT_max = N/10
  TOLERANCE = min(TOLERANCE * 1.05, 10E-3);
  adapt_wavelet((scalar *){b,u},(double[]){be, ue, ue, ue}, maxlevel);
}

The keep the required computational resources within limited bounds, the simulation is stopped at t=Tend.

event stop(t = Tend){
  return 1;
}

Output

The output consists of vertical profiles,

event profiler(t += dT){
  char fname[99];
  sprintf (fname, "proft=%dT", (int)(t/T));
  profile ((scalar*){b, u}, fname);
}

time series data for some domain-integrated quantities and solver characteristics,

event time_series (i += 25){
  double e = 0, diss = 0, sbflx = 0;
  foreach(reduction(+:diss) reduction(+:e) reduction(+:sbflx)){
    foreach_dimension() {
      e += sq(u.x[])*dv();
      diss += dv()*(sq(u.x[1] - u.x[-1]) +
		    sq(u.x[0,1] - u.x[0,-1]) +
		    sq(u.x[0,0,1] - u.x[0,0,-1]))/sq(2.*Δ);
    }
    if (Δ > y)
      sbflx += (b[0,-1] - b[])*dv()/sq(Δ);
  }
  diss *= -ν;
  sbflx *= ν;
  e /= 2.;
  static FILE * fp = fopen("timeseries", "w");
  if (i==0)
    fprintf(fp, "t\ti\tn\twct\tspeed\te\tdiss\tsbflx\n");
  fprintf(fp, "%g\t%d\t%ld\t%g\t%g\t%g\t%g\t%g\t%g\n",
	  t/T, i, grid->tn, perf.t, perf.speed, e, diss, sbflx);
  fflush(fp);
}

and simulation dumps for run restoration and/or post processing.

event dumping (t += T){
  char fname[99];
  sprintf(fname, "dump_t=%dT",(int)((t/T)+0.5));
  dump(fname);
}

Furthermore, two movies are rendered that display the evolution of the buoyancy structures (using the field m =ln(b+1)), and the numerical mesh.

event movies(t += 0.25){
  char fname[99];
  vector db[];
  scalar m[];
  boundary({b});
  gradients ({b}, {db});
  foreach(){
    m[] = 0;
    foreach_dimension()
      m[] += sq(db.x[]);
    if (m[] > 0)
      m[] = log(sqrt(m[])+1.);
  }
  boundary({m});
  sprintf(fname , "ppm2mp4 db.mp4");
  static FILE * fpm = popen(fname, "w");
  output_ppm (m, fpm, n = (1<<maxlevel), min = 0, max = 2, linear = true);
  scalar lev[];
  foreach()
    lev[] = level;
  sprintf(fname, "ppm2mp4 lev.mp4");
  static FILE * fpl = popen(fname, "w");
  output_ppm (lev, fpl, n = (1<<maxlevel), min = 1, max = maxlevel);
}

Results

Here, the simulation in run in 2D and these are the two movies,

The evolution of the aforementioned m field

The evolution of the grid structure

Some profiles of the buoyancy field.

Here is the time evolution of the total kinetic energy.

It appears that the decay of 2D turbulence differs quite a bit from it’s 3D counterpart, see also this example.

References

Van Heerwaarden, C. C., & Mellado, J. P. (2016). Growth and decay of a convective boundary layer over a surface with a constant temperature. Journal of the Atmospheric Sciences, 73(5), 2165-2177.

van Hooft, J. A., Popinet, S., van Heerwaarden, C. C., van der Linden, S. J., de Roode, S. R., & van de Wiel, B. J. (2018). Towards Adaptive Grids for Atmospheric Boundary-Layer Simulations. Boundary-Layer Meteorology, 167(3), 421-443.