I have the following 1D (in space, that is) system of equations I would like to solve:
\begin{equation} \rho_{fs}\frac{\partial x_{fs}}{\partial t} = h_m\left(W_a - W_{fs}\right) - D_{eff}\left(\frac{\partial \rho_v(T_{fr})}{\partial x} \right) \end{equation} \begin{equation} \rho_{fr}c_{p,fr}\frac{\partial T}{\partial t} = \frac{\partial}{\partial x} \left( k_{fr} \frac{\partial T}{\partial x} \right) + L_{sub} \frac{\partial \rho_{fr}}{\partial x} \end{equation} \begin{equation} \frac{\partial \rho_{fr}}{\partial t} = \frac{\partial}{\partial x}\left( D_{eff} \frac{\partial \rho_v(T_{fr})}{\partial x} \right) \end{equation}
This set of equations describes the time evolution of a frost layer's height, $x_{fs}$, (local) temperature, $T_{fr}$, and (local) density, $\rho_{fr}$.
I have been struggling with trying to solve this system. I have constructed a system of ODEs following the method of lines and attempted to solve it in Matlab using ode45
, but this resulted in matrices filled with NaN
values.
Following this, I am now trying to solve it through a 1st order upwind scheme for the time derivatives, solving one equation at a time and trying to iterate until the differences are small enough:
\begin{equation} \frac{\left(x_{fs}^{n+1} - x_{fs}^n\right)}{\Delta t} = \frac{1}{\rho_{fs}}\left(h_m\left(W_a - W_{fs}\right) - D_{eff}\frac{\rho_v\left(T^n_{i+1}\right) - 2\rho_v\left(T^n_{i}\right) + \rho_v\left(T^n_{i-1}\right)}{(\Delta x)^2} \right) \end{equation} \begin{equation} \frac{\left(T_i^{n+1} - T_i^n\right)}{\Delta t} = \frac{1}{\rho_{fr,i}c_{p,fr}}\left( k_{fr}\frac{T^n_{i+1} - 2T^n_{i} + T^n_{i-1}}{(\Delta x)^2} + L_{sub}D_{eff}\frac{\rho_v\left(T^n_{i+1}\right) - 2\rho_v\left(T^n_{i}\right) + \rho_v\left(T^n_{i-1}\right)}{(\Delta x)^2} \right) \end{equation} \begin{equation} \frac{\left(\rho_i^{n+1} - \rho_i^n\right)}{\Delta t} = D_{eff}\frac{\rho_v\left(T^n_{i+1}\right) - 2\rho_v\left(T^n_{i}\right) + \rho_v\left(T^n_{i-1}\right)}{(\Delta x)^2} \end{equation}
In order to adhere to boundary conditions, the temperature is calculated on the $n_x$ number of nodes, and the density is calculated inbetween, in the $n_x - 1$ number of cells. As for initial and boundary conditions, the temperature at the frost surface and at the bottom of the layer are known, and an initial uniform density profile is assumed due to the very small initial frost height mentioned before.
This approach has not yielded good results yet either, although I am now starting to think it might have to do with my choice of $\Delta t$. The spatial step size $\Delta x$ is set by the layer height $x_{fs}$ and the number of nodes. The starting layer height is very small, in the order of $10^{-4}$. If I understand correctly, this means my $\Delta t$ has to be very small as well in order to satisfy the Courant condition? This would be a bit impractical though, as the simulated time is in the order of tens of minutes or even hours.
I am wondering if there is a better approach to take to solve this system of equations, or if I am making a mistake somewhere. I would appreciate any insights. Apologies if I have made any mistakes in posing my question here.