1

This is a follow-up question to this previous post by @FLP, in which an interesting system of equations was solved with the useful pdetoode developed by @xzczd. I have tried to solve this problem with a different initial condition (IC). And I appreciated the help and effort from @xzczd and @FLP. The following code is a combination of the original post and the answer. Due to the symmetry, the differential equation for h[r,t] is to be solved from $r=0$ to a sufficiently large value $r>>1$. Here, the left bound of $r$ is taken as a small non-zero value due to some numerical reason, and the right bound is taken as $50$.

My question:

In the original post, a system about $h[r,t]$ was solved with an IC of the exponential function IC = {h[r, t] == 20 E^-(r/20)^2 + hf} /. t -> 0;. For some weird reason if you change the amplitude of the IC, say, IC = {h[r, t] == 10 E^-(r/10)^2 + hf} /. t -> 0;, it would stuck at a small time (relative to a given Tend) and return an error: step size is effectively zero; singularity or stiff system suspected.

I also tried a parabolic IC defined by If:

IC = {h[r, t] == unitStepExpand@If[r >= lb && r < 1, 3/5*(1 - r^2) + hf, hf]} /. t -> 0

but the error of a singularity remained. Noted that in this case PiecewiseExpand transforms If[...] to an equivalent Piecewise[...]; then SimplifyPWToUnitStep transforms Piecewise[...] to an equivalent combination of UnitStep[...]. This is a necessary transformation since pdetoode assumes the functions in the equations, ICs, and BCs are all Listable.

For the piecewise IC, I guess the issue may be caused by the discontinuous derivative at $r=1$. But I cannot understand why the code fails with the IC only changed in its amplitude: h[r, t] == 10 E^-(r/10)^2 + hf.

An even more strange issue is that if I change the side of the domain with, say rb=100, a singularity occurs again.

The code:

The code for pdetoode neglected here, please find in the abovementioned link. Here, Int[r,t] is an integral function, defined as $$Int(r,t)=\int_0^\infty K(r, r^\prime)\frac{\partial}{\partial r^\prime }\left(\frac{h_f}{h} \right)^3 \mathrm{d}r^\prime, $$ where $K(r,r^\prime)=\frac{2}{\pi}r[\mathbf{K}(r^\prime/r)-\mathbf{E}(r^\prime/r)]$ for $r^\prime<r$

or $K(r,r^\prime)=\frac{2}{\pi}r^\prime[\mathbf{K}(r/r^\prime)-\mathbf{E}(r/r^\prime)]$ for $r^\prime>r$, in which $\mathbf{K}$ and $\mathbf{E}$ are the complete elliptic integrals.

In order to avoid the singularity of $K(r,r^\prime)$ at $r=r^\prime$, $r$ takes the values at the grid point lb+i*step and $r^\prime$ takes the values at the staggered grid lb+(i+0.5)*step.

(*constants*)
a = 0.001; hf = 0.01; \[Mu] = 1; \[Beta] = 1;
(*Equations*)
With[{h = h[r, t], P = P[r, t], Q = Q[r, t], J = J[r, t]},
EqnP = P == D[h, r, r] + D[h, r]/r + a^2/h^3;
EqnQ = Q == 1/3*h^3*r*D[P, r];
EqnC = D[h, t] + (\[Mu] D[Q, r])/r == -J;
EqnJ = J == (\[Beta] D[Int[r, t], r])/r;]

(Computation Domain) lb = 1/100; rb = 50;

(unitStepExpand is a function that transforms If[[Ellipsis]] to mathematically equivalent combination of UnitStep[[Ellipsis]], useful in the computation of the following integral) unitStepExpand = Simplify`PWToUnitStep[PiecewiseExpand[#]] &;

(initial and boundary conditions) IC = {h[r, t] == 20 E^-(r/20)^2 + hf} /. t -> 0; (IC = {h[r, t] == 10 E^-(r/10)^2 + hf} /. t -> 0;) (IC = {h[r, t] == unitStepExpand@If[r >= lb && r < 1, 3/5(1 - r^2) + hf, hf]} /. t -> 0;*) BC = {{D[h[r, t], r] == 0, D[h[r, t], r, r, r] == 0, D[h[x, t], x] == 0, D[h[x, t], x, x, x] == 0} /. {r -> lb, x -> rb}};

(Discretization setting) difforder = 2; points = 200; grid = Array[# &, points, {lb, rb}];

hgrid = Map[h[#][t] &, grid]; hdgrid = fdd[Derivative[1], grid, hgrid];

(the Integral Function) Kernel[r_, i_] := (2r)/[Pi]unitStepExpand@If[r > i, r (EllipticK[i/r] - EllipticE[i/r]), i (EllipticK[r/i] - EllipticE[r/i])];

Integrand = D[(hf/h[r, t])^3, r] /.Thread[{D[h[r, t], r], h[r, t]} -> {hdgrid, hgrid}]; step = (rb - lb)/points; Int[r_][t_] := Total@Table[stepKernel[r, lb + (i + 0.5)step]*0.5 (Integrand[[i]] + Integrand[[i + 1]]), {i, 1, points - 1}];

(Discretising the rest of the system) ptoofunc = pdetoode[{h[r, t], P[r, t], Q[r, t], J[r, t], Int[r, t]}, t, grid, difforder]; removeredundant = #[[3 ;; -3]] &;

odeadd = Map[ptoofunc, {EqnP, EqnQ, EqnJ}, {2}]; ode = Block[{P, Q, J}, Set @@@ odeadd; ptoofunc@EqnC] // removeredundant; odIC = ptoofunc@IC;

With[{sf = 1}, odBC = diffbc[t, sf]@BC // ptoofunc];

(Solving the System) var = Map[h, grid];

showStatus[status_] := LinkWrite[$ParentLink,SetNotebookStatusLine[FrontEnd`EvaluationNotebook[],ToString[status]]]; clearStatus[] := showStatus[""]; clearStatus[] monitor[t_] := EvaluationMonitor :> showStatus["t = " <> ToString[CForm[t]]]

Tend = 200;

sollst = NDSolveValue[{ode, odIC, odBC}, var, {t, 0, Tend}, monitor[t], Method -> {EquationSimplification -> MassMatrix}]; // AbsoluteTiming

(postprocess) solfunc = rebuild[sollst, grid];

Manipulate[Plot[solfunc[t, r], {r, lb, rb}, PlotRange ->All], {t, 0, Tend}]

Some notes:

  1. This code works well with the original IC, but when you change the amplitude of the IC, say, from $20$ to $10$, a singularity will be encountered. Increasing the point number and order of FD has little improvement.

  2. I am wondering if a nonuniform mesh (or adaptive mesh) could be implemented in the framework of pdetoode such that a refined resolution is bunched towards the region where the change of slope of h[r,t] is large based on physical reason?

  3. As mentioned by @FLP, the original code has some additional problems as well. I'm not sure if the treatment of IC will be one of the potential issues. So I post this question here to draw attention.

Please give me some suggestions. Thank you in advance!

Update:

  1. With the suggestion of xzczd, the code can run with IC = {h[r, t] == 10 E^-(r/20)^2 + hf} /. t -> 0;, which only changes in its amplitude, up to T=502 approximately, and then singularity occurs at the radius position of the blob, where the slope changes most rapidly.

  2. By changing the width of the initial blob, I found smaller the initial width earlier the singularity occurs. For example, using IC = {h[r, t] == unitStepExpand@If[r >= lb && r < 1, 3/5*(1 - r^2) + hf, hf]} /. t -> 0, the singularity occurs at t=0.000024 approximately. Increasing points improves things a little.

lxy
  • 165
  • 5
  • 19
  • Is this model taken from the paper "Nonlocal description of evaporating drops"? – Alex Trounev May 17 '23 at 14:29
  • @AlexTrounev, yes exactly, but the current method is not exactly the same. – lxy May 18 '23 at 02:12
  • This problem can be solved with using Navier-Stocks and FEM as mentioned in my answer on https://physics.stackexchange.com/questions/509623/how-to-determine-adhesive-forces-between-fluid-and-a-surface/512014#512014 – Alex Trounev May 18 '23 at 03:45
  • @Alex Troune, it is a promising approach but may require more computation cost than the model. Please elaborate. Thank you in advance! – lxy May 18 '23 at 05:03
  • Actually it could be much faster to solve linear equation $\nabla^2 c=0$ with appropriate boundary conditions on the moving border and at infinity then nonlinear integrodifferential equation. – Alex Trounev May 18 '23 at 09:52
  • @AlexTrounev yes, I could be faster to solve the original two-phase system of Laplace and NS equations. Well, using the simplified model and the current code, we can also obtain a decent solution in a short time. Could you just test the current code? – lxy May 18 '23 at 11:37
  • I have solution up to 17.1 s for IC = {h[r, t] == 10 E^-(r/10)^2 + hf} /. t -> 0;. Is it small time what are you talking about? The message step size is effectively zero; singularity or stiff system suspected means that there is singularity formed around r=R, where R is the radius of droplet. It looks like model should be updated for this case. – Alex Trounev May 18 '23 at 13:53
  • Yes, this singularity occurs at about 17 near the radius position for that i.c. However, no b.c. is imposed at the radius of the drop. The singularity may arise from the integral, which accounts for evaporating flux. The flux is highest at the radius position. We could apply a Dirichlet b.c. h[x, t] == hf at the right end of the domain according to the physics instead. The model has been scaled properly, see eq (31) and (32) of that article. I guess the domain size and the initial profile might be related in the current code since changing the domain size gives rise to a similar error. – lxy May 18 '23 at 14:19

1 Answers1

1

If "the IC only changed in its amplitude", changing sf = 1 to sf = 10 resolves the problem.

xzczd
  • 65,995
  • 9
  • 163
  • 468
  • Is it answer or comment? – Alex Trounev May 20 '23 at 03:10
  • @xzczd, good to see you. I tried sf=10 with i.c. IC = {h[r, t] == 10*E^-(r/10)^2 + hf} /. t -> 0 or IC = {h[r, t] == unitStepExpand@If[r >= lb && r < 1, 3/5*(1 - r^2) + hf, hf]} /. t -> 0. The singularity issue remains in each case. With a larger sf, are you trying to resolve a problem of inconsistent i.c. and b.c.s? – lxy May 20 '23 at 03:52
  • @xzczd, what did you mean by period in the answer? – lxy May 20 '23 at 03:53
  • @Alex An answer of course, if "the IC only changed in its amplitude". – xzczd May 20 '23 at 04:28
  • @lxy Again, you've made careless mistake when writing the question, 10*E^-(r/10)^2 + hf is not an "IC only changed in its amplitude", period. – xzczd May 20 '23 at 04:33
  • @xzczd, sorry..., in my mind, I used amplitude to refer to the width and height of the drop together. Actually, I do want to change the width of the initial profile. This is exactly why I also tried the parabolic IC for a drop radius of r=1. Sorry for any confusion caused. – lxy May 20 '23 at 05:16
  • @xzczd, please have a look at my update when you have time. Thank you very much! – lxy May 20 '23 at 05:40
  • @xzczd, I use Plot[Evaluate[1/r*D[Total@Table[step*Kernel[r, lb + (i + 1/2)*step]*1/2*(Integrand[[i]] + Integrand[[i + 1]]), {i, 1, points - 1}], r]/. h -> solfunc[10, r]], {r, lb, rb}, PlotRange -> {{0, rb}, All}] to plot J at t=10, it gives just an empty figure. Could help the plotting for function J? – lxy May 23 '23 at 03:43
  • @lxy No. Think about the following: why does Plot[h[lb][t] /. h -> solfunc[10, r] // Evaluate, {r, lb, rb}] give just an empty figure? – xzczd May 23 '23 at 03:56
  • @xzczd, for your example, I think it is because 1. the spatial position in the plotting function h[lb][t] was fixed; 2. the time variable in h[lb][t] should be assigned. But the presence of lb in my plotting function arises from the integral Int[r_][t_] and r-position is not fixed. I tried Plot[Evaluate[1/r*D[Total@Table[step*Kernel[r, lb + (i + 1/2)*step]*1/2*(Integrand[[i]] +Integrand[[i + 1]]), {i, 1, points - 1}], r] /. h -> solfunc[t, r] /. t -> 10], {r, lb, rb}]... – lxy May 23 '23 at 06:19
  • @lxy Suppose I want to calculate $\sin(\pi/2)$, what's wrong with the following code?: f[Pi/2] /. f -> Sin[x] – xzczd May 23 '23 at 06:29
  • @xzczd we should use f[Pi/2]/. f -> Sin, changing the function only – lxy May 23 '23 at 06:59
  • @lxy Then what's wrong with h[lb][t] /. h -> solfunc[10, r]? – xzczd May 23 '23 at 07:37
  • @xzczd, for this example, using Plot[h[r, t] /. h -> solfunc /. t -> 10 // Evaluate, {r, lb, rb}] should be correct? But I cannot figure out how to plot J at a time – lxy May 23 '23 at 08:25
  • @lxy How can h[lb][t] + h[2 lb][t] be transformed to solfunc[t, lb] + solfunc[t, 2 lb]? – xzczd May 23 '23 at 08:32
  • @xzczd, honestly, I cannot figure it out and this might be the heart of the question. I noticed that the orders of the independent variables in h and solfunc are different. Clearly, h[lb][t] + h[2 lb][t] /. h -> solfunc does not work. – lxy May 23 '23 at 08:47
  • @lxy Then please re-visit the document related to pattern matching carefully. – xzczd May 23 '23 at 09:02
  • @xzczd, I still have difficulty in plotting some defined functions. May I consult the function P = P[r, t]? I'm trying solp[r_, h_] = D[h, r, r] + D[h, r]/r + a^2/h^3; Plot[Evaluate[solp[r, h] /. h[r_][t] -> solfunc[t, r] /. t -> 10], {r, lb, rb}], which gives an empty figure again. Sorry if it is a low-level problem. – lxy May 24 '23 at 12:13