Skip to main content

Solving a system of coupled non-linear partial differential equations


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.



Answer



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


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