Skip to main content

differential equations - Singularities forming on boundary while solving system of pde's


This is a follow up of a previous question I asked regarding solving a system of coupled, non-linear partial differential equations, 2D spatially + time. The equations (shown below) model a magnetic field diffusing into a plasma column.



enter image description here


Note: the equation is actually in polar coordinates. I made the changes r -> x and theta -> y for simplicity in the code I post below.


Before my previous question, I was having problems solving the system for any measure of time. Thanks to a recommendation, I rescaled the time derivative which helped me solve a solution well past, in time, what I was capable of previously.


Now, however, I'm running into apparent singularities appearing along the boundary x = 0. Frankly, this was probably my problem the whole time and I'm only just now realizing it. I'll illustrate what I mean by discussing two cases.


The equations in code form are:


azExt[x_, y_, t_] = -bo*a*(1 - E^(-f*t*2*Pi/(w*T)))*x*Sin[2*Pi*f*t - y];
eqns = {c*D[az[x, y, t], t] == (Laplacian[az[x, y, t], {x, y}, "Polar"] + 1/x*d*p*(D[az[x, y, t], x]*D[bz[x, y, t], y] - D[az[x, y, t], y]*D[bz[x, y, t], x])),
c*D[bz[x, y, t], t] == (Laplacian[bz[x, y, t], {x, y}, "Polar"] + 1/x*1/d*p* (D[az[x, y, t], y]* D[Laplacian[az[x, y, t], {x, y}, "Polar"], x] - D[az[x, y, t], x]* D[Laplacian[az[x, y, t], {x, y}, "Polar"], y])),
(*Initial Conditions*)
az[x, y, 0] == 0,

bz[x, y, 0] == 1,
(*Boundary Conditions*)
bz[x, Pi, t] == bz[x, -Pi, t],
az[x, Pi, t] == az[x, -Pi, t],
bz[1, y, t] == 1,
az[1, y, t] == 0,
(D[bz[x, y, t], x] /. x -> x0) == 0,
(D[az[x, y, t], x] /. x -> 1) == 2*azExt[1, y, t]/(bo*a) - az[1, y, t],
(D[D[az[x, y, t], x], x] /. x -> 1) == (D[az[x, y, t], x] /. x -> 1)};


Where the constants are:


bo = 0.005;
w = 5*10^6;
T = 0.4*10^-6;
a = 0.02;
f = 4.*10^-2;
t0 = 3.8595/(f)
c = 40/f;
d = 10;
p = 31;

x0 = 10^-6;

Here, f is a scaling factor for the time derivatives, so it can change from solution to solution without affecting the physics of the system.


The equations are solved using NDSolve and plotted using the following code:


sol = NDSolve[eqns, {az, bz}, {x, x0, 1}, {y, -Pi, Pi}, {t, 0, t0}, "ExtrapolationHandler" -> {Indeterminate &, "WarningMessage" -> False}, Method -> {"MethodOfLines", "SpatialDiscretization" -> {"TensorProductGrid", "MinPoints" -> 20, "MaxPoints" -> 20, "DifferenceOrder" -> 2}}]


{{ContourPlot[Evaluate[az[x, 0, t] /. sol], {x, x0, 1}, {t, 0, t0}, Contours -> 20, ColorFunction -> Hue, PlotLegends -> Automatic, PlotRange -> All, FrameLabel -> {"x", "t"}, PlotLabel -> "Az"],
ContourPlot[Evaluate[bz[x, 0, t] /. sol], {x, x0, 1}, {t, 0, t0}, Contours -> 20, ColorFunction -> Hue, PlotLegends -> Automatic, PlotRange -> All, FrameLabel -> {"x", "t"}, PlotLabel -> "Bz"]},
{ContourPlot[Evaluate[az[x, y, t0] /. sol], {x, x0, 1}, {y, -Pi, Pi}, Contours -> 20, ColorFunction -> Hue, PlotLegends -> Automatic, PlotRange -> All, FrameLabel -> {"x", "y"}, PlotLabel -> "Az"],

ContourPlot[Evaluate[bz[x, y, t0] /. sol], {x, x0, 1}, {y, -Pi, Pi}, Contours -> 20, ColorFunction -> Hue, PlotLegends -> Automatic, PlotRange -> All, FrameLabel -> {"x", "y"}, PlotLabel -> "Bz"]}}

Now, here's the odd thing. If I specify t0 = 3.8594/f (or 96.485) , the solution converges with pretty much no problem, just a warning about spatial errors. I get something that looks like this, which makes physical sense:


enter image description here


Great! Now, if I increase t0 to 3.8595/f, a few things happen. For one, the solution is not able to converge. In fact, it stops at t = 73.18 (as opposed to 96.4875). This is odd as in the previous example, the solution was able to solve well past this time stamp. Further more, a singularity forms at t = 73.18 as shown below:


enter image description here


As you can see, the singularity begins forming along the boundary near x = 0 and I get the following errors:


NDSolve::ndsz: At t == 73.18237747079812`, step size is effectively zero; singularity or stiff system suspected.
NDSolve::eerr: Warning: scaled local spatial error estimate of 29.87465573060914` at t = 73.18237747079812` in the direction of independent variable x is much greater than the prescribed error tolerance. Grid spacing with 20 points may be too large to achieve the desired accuracy or precision. A singularity may have formed or a smaller grid spacing can be specified using the MaxStepSize or MinPoints method options.


My question is, how can I either avoid or rectify this singularity? I was thinking that perhaps I could specify a constant region for Az and Bz near the boundary. I've tried increasing the max points but I either get the singularity at a different time and/or I get large (>10^3) spatial errors, which also seems odd to me since I would think refining the grid would decrease the spatial errors while also helping to tackle the singularity problem. I'm at a loss here as to what to do. I'm still fairly new at Mathematica and solving PDE's numerically so any help would be greatly appreciated. Please let me know if I missed anything in my code or if something doesn't make sense to you. Thank you!



Answer



The problem is version related. I manage to reproduce the warning in v11.2, but not in v9.0.1. So the ndsz warning may be related to improper time step choosing in v11. Following this guess, I find MaxStepSize -> {Automatic, Automatic, 0.1} helps:


sol = NDSolve[eqns, {az, bz}, {x, x0, 1}, {y, -Pi, Pi}, {t, 0, t0}, 
Method -> {"MethodOfLines",
"SpatialDiscretization" -> {"TensorProductGrid", "MinPoints" -> 20,
"MaxPoints" -> 20, "DifferenceOrder" -> 2}},
MaxStepSize -> {Automatic, Automatic, 0.1}]; // AbsoluteTiming

The first 2 Automatic is the grid size specification for x and y. This isn't the only solution. The fix function also helps:



(* Definition of fix isn't included in this post,
please find it in the link above. *)
soltest = fix[t0, 2]@
NDSolve[eqns, {az, bz}, {x, x0, 1}, {y, -Pi, Pi}, {t, 0, t0},
Method -> {"MethodOfLines",
"SpatialDiscretization" -> {"TensorProductGrid", "MinPoints" -> 20,
"MaxPoints" -> 20, "DifferenceOrder" -> 2}}]

Comments

Popular posts from this blog

front end - keyboard shortcut to invoke Insert new matrix

I frequently need to type in some matrices, and the menu command Insert > Table/Matrix > New... allows matrices with lines drawn between columns and rows, which is very helpful. I would like to make a keyboard shortcut for it, but cannot find the relevant frontend token command (4209405) for it. Since the FullForm[] and InputForm[] of matrices with lines drawn between rows and columns is the same as those without lines, it's hard to do this via 3rd party system-wide text expanders (e.g. autohotkey or atext on mac). How does one assign a keyboard shortcut for the menu item Insert > Table/Matrix > New... , preferably using only mathematica? Thanks! Answer In the MenuSetup.tr (for linux located in the $InstallationDirectory/SystemFiles/FrontEnd/TextResources/X/ directory), I changed the line MenuItem["&New...", "CreateGridBoxDialog"] to read MenuItem["&New...", "CreateGridBoxDialog", MenuKey["m", Modifiers-...

How to thread a list

I have data in format data = {{a1, a2}, {b1, b2}, {c1, c2}, {d1, d2}} Tableform: I want to thread it to : tdata = {{{a1, b1}, {a2, b2}}, {{a1, c1}, {a2, c2}}, {{a1, d1}, {a2, d2}}} Tableform: And I would like to do better then pseudofunction[n_] := Transpose[{data2[[1]], data2[[n]]}]; SetAttributes[pseudofunction, Listable]; Range[2, 4] // pseudofunction Here is my benchmark data, where data3 is normal sample of real data. data3 = Drop[ExcelWorkBook[[Column1 ;; Column4]], None, 1]; data2 = {a #, b #, c #, d #} & /@ Range[1, 10^5]; data = RandomReal[{0, 1}, {10^6, 4}]; Here is my benchmark code kptnw[list_] := Transpose[{Table[First@#, {Length@# - 1}], Rest@#}, {3, 1, 2}] &@list kptnw2[list_] := Transpose[{ConstantArray[First@#, Length@# - 1], Rest@#}, {3, 1, 2}] &@list OleksandrR[list_] := Flatten[Outer[List, List@First[list], Rest[list], 1], {{2}, {1, 4}}] paradox2[list_] := Partition[Riffle[list[[1]], #], 2] & /@ Drop[list, 1] RM[list_] := FoldList[Transpose[{First@li...

plotting - How to draw lines between specified dots on ListPlot?

I would like to create a plot where I have unconnected dots and some connected. So far, I have figured out how to draw the dots. My code is the following: ListPlot[{{1, 1}, {2, 2}, {3, 3}, {4, 4}, {1, 4}, {2, 5}, {3, 6}, {4, 7}, {1, 7}, {2, 8}, {3, 9}, {4, 10}, {1, 10}, {2, 11}, {3, 12}, {4,13}, {2.5, 7}}, Ticks -> {{1, 2, 3, 4}, None}, AxesStyle -> Thin, TicksStyle -> Directive[Black, Bold, 12], Mesh -> Full] I have thought using ListLinePlot command, but I don't know how to specify to the command to draw only selected lines between the dots. Do have any suggestions/hints on how to do that? Thank you. Answer One possibility would be to use Epilog with Line : ListPlot[ {{1, 1}, {2, 2}, {3, 3}, {4, 4}, {1, 4}, {2, 5}, {3, 6}, {4, 7}, {1, 7}, {2, 8}, {3, 9}, {4, 10}, {1, 10}, {2, 11}, {3, 12}, {4, 13}, {2.5, 7}}, Ticks -> {{1, 2, 3, 4}, None}, AxesStyle -> Thin, TicksStyle -> Directive[Black, Bold, 12], Mesh -> Full, Epilog -> { Line[ ...