sandbox/MCVacher/slosh_dissipation.c
Sloshing as a damped oscillator
We analyse the dissipation of stationnary waves in a tank. This simulation only takes into account the bulk dissipation. To take into account the dissipation generated at the wall, go there.
The code has dimensions as it is right now.
Bulk dissipation
#include "grid/multigrid.h"
#include "navier-stokes/centered.h"
#include "two-phase.h"
#include "navier-stokes/conserving.h"
#include "navier-stokes/perfs.h"
double h;
double h_1;
double R;
double mu_b;
double rho_b;
double grav;
FILE * fpmax; //
int main() {
L0=0.4; //size of the box
rho2 = 1.3;
rho1=1000;
mu1 = 0.1;
mu2 = 0.001*mu1;
h=0.15; //water height at rest
grav=9.81;
h_1=0.015; //size of the perturbation
TOLERANCE = 1e-3 [*];
u.n[bottom] = dirichlet (0.);
u.t[bottom] = neumann(0.);
u.n[top] = neumann(0.);
p[top] = dirichlet(0.);
u.n[left] = dirichlet(0.);
u.n[right] = dirichlet(0.);
u.t[left] = dirichlet(0.);
u.t[right] = dirichlet(0.);
N=128;
origin (-L0/2, 0);//set the origin
init_grid(N);
char param_dim[80];
sprintf (param_dim, "param_dim.txt");
FILE * fparam = fopen(param_dim, "w");
fprintf (fparam, "%g %g %g %g %g %g %g %d\n",L0,h,R,rho1,rho2,mu1,mu2,N);
fclose (fparam);
fpmax = fopen("log.dat", "w");
run();
}The initial state is a sloshing mode m=3, of amplitude h_1.
event init (t = 0) {
mu_b=mu2/mu1;
rho_b=rho2/rho1;
R=h/L0;
char dim_adim[80];
sprintf (dim_adim, "dim_adim.txt"); //to compute the non-dim. parameters
FILE * fparam = fopen(dim_adim, "w");
fprintf (fparam, "%g %g %g\n",mu_b,rho_b,R);
fclose (fparam);
fraction (f, h_1*sin(3*M_PI*x/L0)+h-y);
const face vector G[] = {0,-9.81};
a=G;
}
event logfile (i++) {
fprintf (stderr, "%d %g \n", i, t);
fprintf (fpmax, "%d %g \n", i, t);
}
event profile (t = end) {
printf ("-----END-----\n");
}We track the interface to compute the logarithmic decrease linked to the viscous dissipation.
int isave1 = 1;
event res_save (t += 0.01; t <= 10){
char name[80];
sprintf (name, "interface-%d.txt", isave1);
FILE * fpfacet = fopen(name, "w");
output_facets (f, fpfacet);
fclose(fpfacet);
isave1++;
}We generate a video of the fraction to visualize the decreasing sloshing.
event ppm_output (t = 0; t += 0.05; t <= 30) {
char name[80];
sprintf (name, "f.mp4");
output_ppm (f, file = name, n = 512, min = 0, max = 1, linear = true);
char name2[80];
sprintf (name2, "uX.mp4");
output_ppm (u.x, file = name2, n = 512, min = -0.5, max = 0.5, linear = true);
}Waves
Horizontal velocity
Comparison with theory
soon
