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

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[ ...

equation solving - Invert and fit implicitly defined curve

I need to fit an implicitly defined curve. I thought I could get some data out of Solve , and then using FindFit . Therefore, I would like to find the relation the parametric curve defined by $F(x,y)=0$: Solve[-(1/2) + 1/2 (0.41202 BesselK[0, 0.1 Sqrt[x^2 + y^2]] + (0.101483 x BesselK[1, 0.1 Sqrt[x^2 + y^2]])/Sqrt[x^2 + y^2]) == 0, y] But I can't get an output: Solve was unable to solve the system with inexact coefficients or the system obtained by direct rationalization of inexact numbers present in the system. Since many of the methods used by Solve require exact input, providing Solve with an exact version of the system may help. >> Edit: In particular, I would like to fit the data coming from the curve with the expression of another curve, and not with a function $f(x)$. In particular, since this clearly looks like a cardioid , I would like it to fit to something like it. What other strategies could I try?

dynamic - How can I make a clickable ArrayPlot that returns input?

I would like to create a dynamic ArrayPlot so that the rectangles, when clicked, provide the input. Can I use ArrayPlot for this? Or is there something else I should have to use? Answer ArrayPlot is much more than just a simple array like Grid : it represents a ranged 2D dataset, and its visualization can be finetuned by options like DataReversed and DataRange . These features make it quite complicated to reproduce the same layout and order with Grid . Here I offer AnnotatedArrayPlot which comes in handy when your dataset is more than just a flat 2D array. The dynamic interface allows highlighting individual cells and possibly interacting with them. AnnotatedArrayPlot works the same way as ArrayPlot and accepts the same options plus Enabled , HighlightCoordinates , HighlightStyle and HighlightElementFunction . data = {{Missing["HasSomeMoreData"], GrayLevel[ 1], {RGBColor[0, 1, 1], RGBColor[0, 0, 1], GrayLevel[1]}, RGBColor[0, 1, 0]}, {GrayLevel[0], GrayLevel...