sandbox/farsoiya/phase_change/stefan_problem.c
Stefan Problem
We simulate a static planar interface which moving due to diffusion of gas.
The time evolution of the interface is given as Alexiades and Solomon, 1992,
Y(t) = Y_0 + 2\lambda \sqrt{D t} and concentration,
c(t) = \frac{\alpha c_s - c_0}{\operatorname{erfc}(\lambda)}\operatorname{erfc}\left(\frac{y - Y_0}{2\sqrt{Dt}}\right)
where lambda is solution of the equation,
\lambda \operatorname{erfc}({\lambda}) e^{\lambda^2} = -\frac{\alpha c_s - c_0}{\sqrt{\pi}}\frac{M_w}{\rho_g}
![]() |
![]() |
|
|
import numpy as np
import matplotlib.pyplot as plt
'font.size': 15})
plt.rcParams.update({
plt.figure()= np.loadtxt('../ref-stefan',delimiter='\t',unpack=True);
t,rep,cep 'k',label='Analytical')
plt.plot(t, rep,
= np.loadtxt('conc-stefan',delimiter=' ',unpack=True)
ts, rb, cb 'k--',label='Basilisk');
plt.plot(ts,rb,# plt.ylim(0.97,1.007)
;
plt.legend()r'$t$')
plt.xlabel(r'$Y(t)$')
plt.ylabel(
plt.tight_layout()
'p001cbt.png')
plt.savefig(
plt.figure()
'k',label='Analytical')
plt.plot(t, cep,
'k--',label='Basilisk');
plt.plot(ts,cb,# plt.ylim(0.97,1.007)
;
plt.legend()r'$t$')
plt.xlabel(r'$c_l$')
plt.ylabel(
plt.tight_layout()
'p001clt.png')
plt.savefig(
plt.figure()
' ') plt.savefig(
References
[farsoiya2021] |
P. K. Farsoiya, Q. Magdelaine, A. Antkowiak, S. Popinet, and L. Deike. Bubble mediated single component gas transfer in homogeneous isotropic turbulence. Journal of Fluid Mechanics, 2021. submitted. |
[alexiades1992mathematical] |
Solomon Alexiades. Mathematical modeling of melting and freezing processes. CRC Press, 1992. |
#define R0 1.
#define L 10. // size of the box
#define MIN_LEVEL 5
#define LEVEL 10
#define MAX_LEVEL 10
#define dR_refine (2.*L0/(1 << LEVEL))
#define F_ERR 1e-10
#define T_END 600
#define DT_MAX 10.
#define DELTA_T 1. // for measurements and videos
#include "navier-stokes/centered.h"
#include "two-phase.h"
#include "tension.h"
#include "phase-change.h"
#include "reduced.h"
#define D_V 1.e-3
#define cinf 0
scalar c[], *stracers = {c};
[top] = dirichlet(cinf);
c
int main() {
(L);
size (0., 0.);
origin = 1 << LEVEL;
N (N);
init_grid
.sigma = 0;
f= 1.;
rho1 = 1.;
rho2 = 1./10.;
mu1 = mu1/20.;
mu2
.x = 0.;
G.x = 0.;
Z
.inverse = false;
c.alpha = 0.8;
c.tr_eq = 1.;
c.D = D_V;
c.mw = 1.;
c
run();
}
event init (i = 0) {
fraction (f, y - L0*0.5);
foreach() {
.x[] = 0.;
u//~ vapor[] = f[]*cinf + (1. - f[])*vcs;
[] = f[]*cinf + (1. - f[])*c.tr_eq;
c}
foreach_face()
.x[] = 0.;
ufboundary({ u, uf,c});
}
#if TREE
event adapt (i++) {
({f, c,u}, (double[]){1e-3, 1e-3, 1e-1, 1e-1,1e-1,1e-1},
adapt_wavelet = MIN_LEVEL, maxlevel = MAX_LEVEL);
minlevel }
#endif
Post-processings and videos
Animation of the concentration field.
We now just have to write several post-processing events
event outputs (t = 0.; t += DELTA_T; t <= T_END) {
double effective_height;
scalar fc[];
foreach()
[] = 1. - f[];
fc
= statsf(fc).sum/10.;
effective_height
char name[80];
sprintf (name, "conc-stefan");
static FILE * fp = fopen (name, "w");
fprintf (fp, "%.17g %.17g %.17g\n", t, effective_height, interpolate(c, L0*0.5, L0*0.5 + 0.2));
fflush (fp);
output_ppm (c, file = "c.mp4", box = {{0,0},{10,10}},
= true, min = 0, max = c.tr_eq);
linear }