2
$\begingroup$

Recently I asked a question on solving a system of 3 nonlinear PDE (To solve a system of 3 nonlinear PDE). Now I transitioned to the next step, that is, a realistic PDE which has been my initial aim:

eq1A = -0.00006 p1[t, x, y] - 0.00067 p1[t, x, y]^3 + 
    0.019 p1[t, x, y]^5 - 0.0026 p1[t, x, y] p2[t, x, y]^2 + 
    0.016 p1[t, x, y]^3 p2[t, x, y]^2 + 
    0.008 p1[t, x, y] p2[t, x, y]^4 + (y p3[t, x, y])/(x^2 + y^2) - 
    0.0026 p1[t, x, y] p3[t, x, y]^2 + 
    0.016 p1[t, x, y]^3 p3[t, x, y]^2 + 
    0.008` p1[t, x, y] p3[t, x, y]^4 + D[p1[t, x, y], x, x] + 
    D[p1[t, x, y], y, y] == D[p1[t, x, y], t];
eq2A = -0.00006 p2[t, x, y] - 0.0026 p1[t, x, y]^2 p2[t, x, y] + 
    0.008 p1[t, x, y]^4 p2[t, x, y] - 0.00068 p2[t, x, y]^3 + 
    0.016 p1[t, x, y]^2 p2[t, x, y]^3 + 0.02` p2[t, x, y]^5 - (
    x p3[t, x, y])/(x^2 + y^2) - 0.0026 p2[t, x, y] p3[t, x, y]^2 - 
    0.2 p1[t, x, y]^2 p2[t, x, y] p3[t, x, y]^2 + 
    0.016 p2[t, x, y]^3 p3[t, x, y]^2 + 
    0.0078 p2[t, x, y] p3[t, x, y]^4 + D[p2[t, x, y], x, x] + 
    D[p2[t, x, y], y, y] == D[p2[t, x, y], t];
eq3A = (y p1[t, x, y])/(x^2 + y^2) - (x p2[t, x, y])/(x^2 + y^2) - 
    0.00006 p3[t, x, y] - 0.0026 p1[t, x, y]^2 p3[t, x, y] + 
    0.008 p1[t, x, y]^4 p3[t, x, y] - 
    0.0026 p2[t, x, y]^2 p3[t, x, y] - 
    0.2 p1[t, x, y]^2 p2[t, x, y]^2 p3[t, x, y] + 
    0.008 p2[t, x, y]^4 p3[t, x, y] - 0.00068 p3[t, x, y]^3 + 
    0.016 p1[t, x, y]^2 p3[t, x, y]^3 + 
    0.016 p2[t, x, y]^2 p3[t, x, y]^3 + 0.02 p3[t, x, y]^5 + 
    D[p3[t, x, y], x, x] + D[p3[t, x, y], y, y] == D[p3[t, x, y], t];

within the disk with the mesh:

    Needs["NDSolve`FEM`"];
R = 40.;
bM = ToBoundaryMesh[Disk[{0, 0}, R]];
hCenter = 0.5;   (* ~0.1\[Ellipsis]1 near r=0*)
hBoundary = 30;   (* ~5\[Ellipsis]10 near r=R*)
 
h[r_] := hCenter + (hBoundary - hCenter) (r/R)^1.5;
Amax[r_] := Sqrt[3]/4 h[r]^2;

c=Sqrt[3]/4;

mrf = Function[{verts, 
    area},(*refine if the current area is above the radius-
   dependent target*)area > Amax[Norm[Mean[verts]]]];
mesh = ToElementMesh[bM, MeshRefinementFunction -> mrf, 
   MaxCellMeasure -> c hBoundary^2, "MeshOrder" -> 1];
mesh["Wireframe"]  

enter image description here

and boundary as well as initial conditions:

dC1 = DirichletCondition[p1[t, x, y] == 0, ElementMarker == 1];
dC2 = DirichletCondition[p2[t, x, y] == 0, ElementMarker == 1];
dC3 = DirichletCondition[p3[t, x, y] == 0, ElementMarker == 1];
iC1A = p1[0, x, y] == 0.01*Exp[-(x^2 + y^2)/4];
iC2A = p2[0, x, y] == 0.02*Exp[-(x^2 + y^2)/4];
iC3A = p3[0, x, y] == 0.03 Exp[-(x^2 + y^2)/4];

All this worked for me in the previous case. The present case differs from the previous one by the considerably more complex polynomials representing the nonlinear parts of the equations. Then I apply the standard NDSolve:

ndsl = NDSolve[{eq1A, eq2A, eq3A, dC1, dC2, dC3, iC1A, iC2A, 
    iC3A}, {p1, p2, p3}, {t, 0, 10}, {x, y} \[Element] mesh];

I get the following response: LinearSolve::mcovl: The computation encountered machine-number overflow. Only machine-number code is available for sparse matrices. If your matrix is not too large, consider trying again after using Normal on the matrix.

Any idea?

$\endgroup$
13
  • 1
    $\begingroup$ There are typos in your code with D[p1[t, x, y] t], D[p2[t, x, y] t], D[p3[t, x, y] t]. It should be with , as D[p1[t, x, y], t] ... $\endgroup$ Commented Oct 27 at 20:10
  • $\begingroup$ Could add the NDSolve call? $\endgroup$ Commented Oct 28 at 5:02
  • $\begingroup$ A bit of a better workflow would be to use something like: nr = ToNumericalRegion[Disk[{0, 0}, R]]; bM = ToBoundaryMesh[nr]; mesh = ToElementMesh[nr, MeshRefinementFunction -> mrf, MaxCellMeasure -> c hBoundary^2, "MeshOrder" -> 1]; This allows the full mesh generation to get access to the symbolic region. I can then generate a better boundary approximation. $\endgroup$ Commented Oct 28 at 5:02
  • $\begingroup$ Also, c is not defined and why have you chosen to restrict the mesh order to 1? $\endgroup$ Commented Oct 28 at 5:05
  • 1
    $\begingroup$ @AlexeiBoulbitch Everything is working perfectly for me, there are no error messages. $\endgroup$ Commented Oct 28 at 19:51

1 Answer 1

2
$\begingroup$

Here I explain the reason for the machine-number overflow and a possible workaround.

The highest nonlinear terms in all the equations are of power 7. Some of them, in addition, have large coefficients. In such cases, when the dependent variables exceed unity or even come close to it, these terms can become very large and lead to a machine-number overflow.

To test this hypothesis and to obtain a remedy, we apply the rescaling:

p[t,x,y]->\Epsilon*u[t,x,y]      (1)

where \Epsilon < 1 is a constant. If, for some value of \Epsilon, we succeed in obtaining a solution for u[t,x,y], the hypothesis is confirmed, and transformation (1) serves as a workaround. Let us proceed. By first applying transformation (1) and then dividing once by \Epsilon, one obtains the system of equations together with the Dirichlet boundary conditions dC and the initial conditions iC:

eq1 = Derivative[1, 0, 0][u1][t, x, y] == 
   Derivative[0, 0, 2][u1][t, x, y] + 
    Derivative[0, 2, 0][u1][t, x, y] - a*u1[t, x, y] + 
    0.0013*\[Epsilon]^2*u1[t, x, y]^3 - 
    31.72*a*\[Epsilon]^2*u1[t, x, y]^3 - 
    0.015*\[Epsilon]^4*u1[t, x, y]^5 + 
         
    544.74*a*\[Epsilon]^4*u1[t, x, y]^5 - \[Epsilon]^6*u1[t, x, y]^7 - 
    0.00096*\[Epsilon]^2*u1[t, x, y]*u2[t, x, y]^2 - 
    26.56*a*\[Epsilon]^2*u1[t, x, y]*u2[t, x, y]^2 + 
    0.016*\[Epsilon]^4*u1[t, x, y]^3*u2[t, x, y]^2 + 
    0.0079*\[Epsilon]^4*u1[t, x, y]*u2[t, x, y]^4 - 
         
    8.1*\[Epsilon]^6*u1[t, x, y]^3*
     u2[t, x, y]^4 + (y*u3[t, x, y])/(0.001 + x^2 + y^2) - 
    0.00096*\[Epsilon]^2*u1[t, x, y]*u3[t, x, y]^2 - 
    26.56*a*\[Epsilon]^2*u1[t, x, y]*u3[t, x, y]^2 + 
    0.016*\[Epsilon]^4*u1[t, x, y]^3*u3[t, x, y]^2 - 
         0.2*\[Epsilon]^4*u1[t, x, y]*u2[t, x, y]^2*u3[t, x, y]^2 - 
    0.97*\[Epsilon]^6*u1[t, x, y]^3*u2[t, x, y]^2*u3[t, x, y]^2 - 
    0.48*\[Epsilon]^6*u1[t, x, y]*u2[t, x, y]^4*u3[t, x, y]^2 + 
    0.0079*\[Epsilon]^4*u1[t, x, y]*u3[t, x, y]^4 - 
         8.12*\[Epsilon]^6*u1[t, x, y]^3*u3[t, x, y]^4 - 
    0.48*\[Epsilon]^6*u1[t, x, y]*u2[t, x, y]^2*u3[t, x, y]^4;


eq2 = Derivative[1, 0, 0][u2][t, x, y] == 
   Derivative[0, 0, 2][u2][t, x, y] + 
    Derivative[0, 2, 0][u2][t, x, y] - a*u2[t, x, y] - 
    0.00096*\[Epsilon]^2*u1[t, x, y]^2*u2[t, x, y] - 
    26.7*a*\[Epsilon]^2*u1[t, x, y]^2*u2[t, x, y] + 
         0.0079*\[Epsilon]^4*u1[t, x, y]^4*u2[t, x, y] + 
    0.0013*\[Epsilon]^2*u2[t, x, y]^3 - 
    31.4*a*\[Epsilon]^2*u2[t, x, y]^3 + 
    0.016*\[Epsilon]^4*u1[t, x, y]^2*u2[t, x, y]^3 - 
    8.1*\[Epsilon]^6*u1[t, x, y]^4*u2[t, x, y]^3 - 
    0.015*\[Epsilon]^4*u2[t, x, y]^5 + 
         
    550.3*a*\[Epsilon]^4*u2[t, x, y]^5 - \[Epsilon]^6*
     u2[t, x, y]^7 - (x*u3[t, x, y])/(0.001 + x^2 + y^2) - 
    0.00096*\[Epsilon]^2*u2[t, x, y]*u3[t, x, y]^2 - 
    26.7*a*\[Epsilon]^2*u2[t, x, y]*u3[t, x, y]^2 - 
    0.2*\[Epsilon]^4*u1[t, x, y]^2*u2[t, x, y]*u3[t, x, y]^2 - 
         0.48*\[Epsilon]^6*u1[t, x, y]^4*u2[t, x, y]*u3[t, x, y]^2 + 
    0.016*\[Epsilon]^4*u2[t, x, y]^3*u3[t, x, y]^2 - 
    0.97*\[Epsilon]^6*u1[t, x, y]^2*u2[t, x, y]^3*u3[t, x, y]^2 + 
    0.0079*\[Epsilon]^4*u2[t, x, y]*u3[t, x, y]^4 - 
         0.48*\[Epsilon]^6*u1[t, x, y]^2*u2[t, x, y]*u3[t, x, y]^4 - 
    8.1*\[Epsilon]^6*u2[t, x, y]^3*u3[t, x, y]^4; 


eq3 = Derivative[1, 0, 0][u3][t, x, y] == 
   Derivative[0, 0, 2][u3][t, x, y] + 
    Derivative[0, 2, 0][u3][t, x, 
     y] + (y*u1[t, x, y])/(0.001 + x^2 + y^2) - (x*
       u2[t, x, y])/(0.001 + x^2 + y^2) - a*u3[t, x, y] - 
         0.00096*\[Epsilon]^2*u1[t, x, y]^2*u3[t, x, y] - 
    26.73*a*\[Epsilon]^2*u1[t, x, y]^2*u3[t, x, y] + 
    0.0079*\[Epsilon]^4*u1[t, x, y]^4*u3[t, x, y] - 
    0.00096*\[Epsilon]^2*u2[t, x, y]^2*u3[t, x, y] - 
    26.73*a*\[Epsilon]^2*u2[t, x, y]^2*u3[t, x, y] - 
         0.2*\[Epsilon]^4*u1[t, x, y]^2*u2[t, x, y]^2*u3[t, x, y] - 
    0.48*\[Epsilon]^6*u1[t, x, y]^4*u2[t, x, y]^2*u3[t, x, y] + 
    0.0079*\[Epsilon]^4*u2[t, x, y]^4*u3[t, x, y] - 
    0.48*\[Epsilon]^6*u1[t, x, y]^2*u2[t, x, y]^4*u3[t, x, y] + 
    0.0013*\[Epsilon]^2*u3[t, x, y]^3 - 
         31.4*a*\[Epsilon]^2*u3[t, x, y]^3 + 
    0.016*\[Epsilon]^4*u1[t, x, y]^2*u3[t, x, y]^3 - 
    8.1*\[Epsilon]^6*u1[t, x, y]^4*u3[t, x, y]^3 + 
    0.016*\[Epsilon]^4*u2[t, x, y]^2*u3[t, x, y]^3 - 
    0.97*\[Epsilon]^6*u1[t, x, y]^2*u2[t, x, y]^2*u3[t, x, y]^3 - 
         8.1*\[Epsilon]^6*u2[t, x, y]^4*u3[t, x, y]^3 - 
    0.015*\[Epsilon]^4*u3[t, x, y]^5 + 
    550.*a*\[Epsilon]^4*u3[t, x, y]^5 - \[Epsilon]^6*u3[t, x, y]^7;

dC1 = DirichletCondition[u1[t, x, y] == 0, ElementMarker == 1]; 
dC2 = DirichletCondition[u2[t, x, y] == 0, ElementMarker == 1]; 
dC3 = DirichletCondition[u3[t, x, y] == 0, ElementMarker == 1];

iC1A = u1[0, x, y] == 
   0.41*(1 - (x^2 + y^2)/R^2)*Exp[-(x^2 + y^2)/100.]; 
iC2A = u2[0, x, y] == 
   0.421*(1 - (x^2 + y^2)/R^2)*Exp[-(x^2 + y^2)/100.]; 
iC3A = u3[0, x, y] == 
   0.42*(1 - (x^2 + y^2)/R^2)*Exp[-(x^2 + y^2)/100.]; 

Let us set \Epsilon = 0.1 and look for the solution at a = 0.22. The mesh is the one from the question above:

a = 0.22;
\[Epsilon] = 0.1;

sol = NDSolveValue[{eq1, eq2, eq3, dC1, dC2, dC3, iC1A, iC2A, 
    iC3A}, {u1, u2, u3}, {t, 0, 100}, {x, y} \[Element] mesh] // 
  AbsoluteTiming

enter image description here

We see that Mma returns a solution in 2.4 s. To verify that the returned InterpolatingFunctions indeed represent solutions, let us plot one of them:

Plot3D[sol[[2, 1]][100, x, y], {x, y} \[Element] mesh, 
 PlotRange -> All]

enter image description here

Thus, the above results show that the overflow indeed originates from the very high polynomial degree and, at the same time, the rescaling (1) provides a practical workaround.

Good to know.

Have fun!

$\endgroup$

Your Answer

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

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.