# solve pde with moving top boundary

I am trying to solve this pde (1D diffusion with source term) with a top boundary that moves over time noted as L0[t]. The NDsolve works when L0=constant, but here the top boundary changes in height with time.

Manipulate[
Module[{d, c, solN, pars, L0, pde, ic, bc, x, u, t, B, phi, phistart,
k, mu, H}, {B = 10^-5, phistart = 0.2, mu = 3.6*10^-5, H = 3.5};
phi[t] = phistart - c*t;
L0[t] = H - ((H*c*t)/(1 - phistart));
k[t] = (((phi[t])^3)*d^2)/(150*(1 - phi[t])^2);
pde = D[u[x, t], t] ==
k[t]/(B*phi[t]*mu)*
D[(1 + B*u[x, t])*D[u[x, t], x],
x] - ((1 + B*u[x, t])/((B*phi[t]*(1 - phi[t]))))*
D[phi[t], t] + NeumannValue[0, x == 0];
bc = u[L0[t], t] == 0;
ic = u[x, 0] == (L0[t] - x)/L0;(*made up IC*)
pars = {d -> d0, c -> c0};
solN = NDSolve[Evaluate[{pde, ic, bc} /. pars],
u, {x, 0, L0[t]}, {t, 0, t0}];
Quiet@Plot[Evaluate[u[0, t] /. solN], {t, 0, t0},
PlotRange -> {Automatic, {0, 2}}, GridLines -> Automatic,
GridLinesStyle -> LightGray, PlotStyle -> Red,
AxesLabel -> {"t", "u(0,t)"}, BaseStyle -> 12]], {{d0, 0.0001,
"Particle diameter [m]"}, 0.0001, 0.1, 0.0001,
Appearance -> "Labeled"}, {{c0, 0, "porosity rate of change c"}, 0,
0.0001, 10^-6, Appearance -> "Labeled"}, {{t0, 1, "time (s)"}, 0.1,
maxTime, 0.1, Appearance -> "Labeled"}, {{maxTime, 3000}, None},
TrackedSymbols :> {d0, c0, t0}]


What would need changing to make this work?

• Strongly related: mathematica.stackexchange.com/q/211080/1871 Don't miss the links there. Nov 19 '21 at 6:41
• A NeumannValue is a spatial boundary condition not a temporal one; besides Neumann 0 is ignored anyways, you can remove that. Nov 19 '21 at 15:07