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 - Filling between two spheres in SphericalPlot3D

Manipulate[ SphericalPlot3D[{1, 2 - n}, {θ, 0, Pi}, {ϕ, 0, 1.5 Pi}, Mesh -> None, PlotPoints -> 15, PlotRange -> {-2.2, 2.2}], {n, 0, 1}] I cant' seem to be able to make a filling between two spheres. I've already tried the obvious Filling -> {1 -> {2}} but Mathematica doesn't seem to like that option. Is there any easy way around this or ... Answer There is no built-in filling in SphericalPlot3D . One option is to use ParametricPlot3D to draw the surfaces between the two shells: Manipulate[ Show[SphericalPlot3D[{1, 2 - n}, {θ, 0, Pi}, {ϕ, 0, 1.5 Pi}, PlotPoints -> 15, PlotRange -> {-2.2, 2.2}], ParametricPlot3D[{ r {Sin[t] Cos[1.5 Pi], Sin[t] Sin[1.5 Pi], Cos[t]}, r {Sin[t] Cos[0 Pi], Sin[t] Sin[0 Pi], Cos[t]}}, {r, 1, 2 - n}, {t, 0, Pi}, PlotStyle -> Yellow, Mesh -> {2, 15}]], {n, 0, 1}]

plotting - Plot 4D data with color as 4th dimension

I have a list of 4D data (x position, y position, amplitude, wavelength). I want to plot x, y, and amplitude on a 3D plot and have the color of the points correspond to the wavelength. I have seen many examples using functions to define color but my wavelength cannot be expressed by an analytic function. Is there a simple way to do this? Answer Here a another possible way to visualize 4D data: data = Flatten[Table[{x, y, x^2 + y^2, Sin[x - y]}, {x, -Pi, Pi,Pi/10}, {y,-Pi,Pi, Pi/10}], 1]; You can use the function Point along with VertexColors . Now the points are places using the first three elements and the color is determined by the fourth. In this case I used Hue, but you can use whatever you prefer. Graphics3D[ Point[data[[All, 1 ;; 3]], VertexColors -> Hue /@ data[[All, 4]]], Axes -> True, BoxRatios -> {1, 1, 1/GoldenRatio}]

plotting - Mathematica: 3D plot based on combined 2D graphs

I have several sigmoidal fits to 3 different datasets, with mean fit predictions plus the 95% confidence limits (not symmetrical around the mean) and the actual data. I would now like to show these different 2D plots projected in 3D as in but then using proper perspective. In the link here they give some solutions to combine the plots using isometric perspective, but I would like to use proper 3 point perspective. Any thoughts? Also any way to show the mean points per time point for each series plus or minus the standard error on the mean would be cool too, either using points+vertical bars, or using spheres plus tubes. Below are some test data and the fit function I am using. Note that I am working on a logit(proportion) scale and that the final vertical scale is Log10(percentage). (* some test data *) data = Table[Null, {i, 4}]; data[[1]] = {{1, -5.8}, {2, -5.4}, {3, -0.8}, {4, -0.2}, {5, 4.6}, {1, -6.4}, {2, -5.6}, {3, -0.7}, {4, 0.04}, {5, 1.0}, {1, -6.8}, {2, -4.7}, {3, -1.