I came across the paper Solidification dynamics of an impacted drop regarding a heat equations by Thiévenaz et.al and was interested in knowing how they obtained the graphs presented. From what I understand, they solved the PDE presented below, with a moving boundary using the finite differences method. I did solve them in matlab but was wondering how one would do this in mathematica given that the flexibility of matlab with matrices is much greater. The code in matlab may be found here. The relevant equations are: The two heat equations for the temperature field $T(z,t)$ $$\frac{\partial T}{\partial t}=D_s\frac{\partial^2 T}{\partial z^2}, \,\,z\leq0;\qquad \frac{\partial T}{\partial t}=D_i\frac{\partial^2 T}{\partial z^2}, \,\,0\leq z\leq h(t)$$ and the four boundary conditions:
$$T(0^-,t)=T(0^+,t);\quad \lambda_s\frac{\partial T(0^-,t)}{\partial t}=\lambda_i\frac{\partial T(0^+,t)}{\partial t};\quad T(h(t)^-,t)=T_m;$$ $$\lambda_i\frac{\partial T(h(t)^-,t)}{\partial t}=\rho_i L\frac{dh}{dt}$$ where $L$ denotes the latent heat of solidification, $\rho_k$ the thermal density, $\lambda_n$ the thermal conductivity, $D_k=\lambda_k/(\rho_kC_k)$ the diffusion coefficient. Here $k$ denotes $l$ in the liquid phase, $i$ in the solid phase and $s$ for the substrate (they are all constant parameters). It is also imposed a constant temperature $T_s$ deep in the substrate, i.e., $$\lim_{z\to-\infty}T(z,t)=T_s,\quad T(z,0)=T_s\quad z\leq0, h(0)=0$$ which means that at time $0$ the liquid is put into contact with the substrate.
A pictorial description of the model is showed below:
Note: The constants mentioned above in my code are chosen arbitrarily (i.e. I chose the values assigned to them)
I did not post the code because it was somewhat long.
As requested in the comments, the scheme I used was:
$$\vec{T^{\,n+1}}=A^{-1}\left(\vec{T^{\,n}}+\vec{B}\right)\implies c\rho\frac{T_i^{n+1}-T_i^n}{\Delta t}=k\frac{T_{i-1}^{n+1}-2T_i^{n+1}+T_{i+1}^n}{\Delta x^2}$$ which is the implicit version. The explicit is similar, and looks like $$c\rho\frac{T_i^{n+1}-T_i^n}{\Delta t}=k\frac{T_{i-1}^{n}-2T_i^{n}+T_{i+1}^n}{\Delta x^2}$$ In my code you will see how I found $A$ and $B$. ($A$ is a matrix and $B$ a vector)
DChange
,pdetoode
andNDSolve
is a better choice for solving the problem, and again, we don't need to know how the MATLAB code looks like. $\endgroup$