9
$\begingroup$

I am trying to solve a system of coupled non-linear partial differential equations, 2D spatially + time. The equations are:

enter image description here

where c, d, and p are constants. I am solving for the functions Az and Bz in polar coordinates, r -> x and theta -> y, and time, t (I am using x and y to visually simplify the code). To do so, I am using NDSolve. The equations in code form are:

azExt[x_, y_, t_] = -bo*(1 - E^(-t*2*Pi/(w*T)))*a*x*Sin[2*Pi*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[$MachineEpsilon, 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]};

Where the constants are defined as:

bo = 0.05; w = 5*10^6; T = 10^-5;
a = 0.05; t0 = 5/312;
c = 312;(*312*)d = 1.3;
p = 250; x0 = 10^-5;

I have left the third boundary condition for x open for Mathematica to find as the authors from whom I have taken the equations from did not clearly specify what it might be.

My current problem is that the solution becomes very stiff. To solve, I have tried using both Explicit Euler and Method of Lines and have played around with options such as MaxStepFraction, AccuracyGoal,PrecisionGoal, Max- and MinPoints. With the ExplicitEuler method, I get an overflow error and the solutions tends to explode. I will use the method of lines in the code below as it seems to be the go to method for many pde problems I've seen on the site. The code for NDSolve is:

sol = NDSolve[eqns, {az[x, y, t], bz[x, y, t]}, {x, $MachineEpsilon, 
   5}, {y, -Pi, Pi}, {t, 0, 5}, "ExtrapolationHandler" -> {Indeterminate &,"WarningMessage" -> False}, Method -> {"MethodOfLines", "TemporalVariable" -> t, "SpatialDiscretization" -> {"TensorProductGrid"}}]

Depending on what method and options I'm messing around with but for this particular case, the error I get is:

NDSolve::mxsst: Using maximum number of grid points 100 allowed by the MaxPoints or MinStepSize options for independent variable y.
NDSolve::bcart: Warning: an insufficient number of boundary conditions have been specified for the direction of independent variable x. Artificial boundary effects may be present in the solution.
NDSolve::ndcf: Repeated convergence test failure at t == 1.2163884257297997`*^-14; unable to continue.
NDSolve::eerr: Warning: scaled local spatial error estimate of 253.1320098824361` at t = 1.2163884257297997`*^-14 in the direction of independent variable y is much greater than the prescribed error tolerance. Grid spacing with 101 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.

And the solution is solved up to 1.22 * 10^-14.

Increasing the maxpoints tends to lead to excessively long computation that lead to nothing. Decreasing my accuracy and precision goals does allow me to calculate solutions further in time but usually not past ~2.5. I would like to be able to calculate up to t = 100 but I understand that that might not be possible.

I am pretty new to using Mathematica and even more green to solving systems of PDE's. I'm not sure if this system is too complicated for Mathematica or if I'm just going at it the wrong way. I've browsed similar questions with no luck. Any help with solving it would be appreciated! If you need more information or think I missed something, please let me know.

$\endgroup$
1

1 Answer 1

4
$\begingroup$

Make a replacement t->t/c, r->x, define constants T, w. Boundary conditions and error messages appear. But the solution of the system of equations converges, which is surprising.

azExt[x_, y_, t_] = -bo*(1 - E^(-t*2*Pi/(w*T)))*a*x*Sin[2*Pi*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[r, 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[az[x, y, t], x] /. x -> 1) == 
    2*azExt[1, y, t]/(bo*a) - az[1, y, t]};

bo = 0.05; w = 1; T = .001;
a = 0.05; t0 = 5/312;
c = 1;(*312*)
d = 1.3;
p = 250; x0 = 10^-5;


sol = NDSolve[eqns, {az, bz}, {x, x0, 1}, {y, -Pi, Pi}, {t, 0, t0}, 
  Method -> {"MethodOfLines", 
    "SpatialDiscretization" -> {"TensorProductGrid", 
      "MinPoints" -> 77, "MaxPoints" -> 77, "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", "t"}, PlotLabel -> "Bz"]}}

fig1

$\endgroup$
4
  • $\begingroup$ Thank you! I've updated the question with the values. I haven't accepted your answer yet because I need to take a better look at it later tonight. However, the values for w and T that I added do work with your updated code. From your perspective does it seem to be a matter of rescaling the the time derivatives in the equations? That would be my hunch but I'm not too familiar with how Mathematica handles numerical calculations. $\endgroup$
    – Woody
    Commented Jan 7, 2019 at 16:18
  • $\begingroup$ @Alex Trounev, very nice example, but how can we know "DifferenceOrder" ? $\endgroup$
    – ABCDEMMM
    Commented Sep 2, 2019 at 18:01
  • $\begingroup$ @ABCDEMMM This parameter can be selected by numerical experiments. $\endgroup$ Commented Sep 3, 2019 at 3:53
  • $\begingroup$ @AlexTrounev thanks very much! $\endgroup$
    – ABCDEMMM
    Commented Sep 3, 2019 at 9:04

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.