Group Abstract Group Abstract

Message Boards Message Boards

Which parameters of NDSolve to change to get a more accurate PDE solution?

Posted 1 year ago

Hello, I have been trying to solve PDEs using NDSolve, in particular the following one:

xmax=10;
wmax=10;
xmin=10^-20;
psiinit[w_,x_]:=(Exp[-w^2]/Sqrt[π]-w*Erfc[w])*x;
sol=NDSolve[{2*x*D[psi[w,x],x]==D[psi[w,x],{w,2}]+2*w*D[psi[w,x],w]-(x*psi[w,x])^2,psi[w,xmin]==psiinit[w,xmin],Derivative[1,0][psi][0,x]==-x,psi[wmax,x]==0},psi,{w,0,wmax},{x,xmin,xmax},PrecisionGoal->20,AccuracyGoal->10,Method->{"MethodOfLines","SpatialDiscretization"->{"TensorProductGrid","MaxStepSize"->1/5000,"DifferenceOrder"->4}}]
N[psi[0,7]/.sol,20]
{1.14428}

However, as can be seen at the end of the above code, the solution obtained is provided with only 6 significant digits, whereas I would be happy to obtain more accurate solutions. Changing parameters such as PrecisionGoal and AccuracyGoal does not seem to help, but cause some error messages. I managed to obtain some improvement only by increasing MaxStepSize. It is less clear whether changing DifferenceOrder brings any improvement. Which other parameters one can change to get a better accuracy of the solution, without causing error messages? Manuals do not seem to provide any discussion of this essential issue. Manuals are also incomplete, as they do not explain which are default settings for various parameters, so that one cannnot even know which particular method or available option is used. Ideally, I would like to make use of the multiprecision available in MATHEMATICA, in order to obtain solutions with as many as 19 accurate significant digits. Is this possible at all? If yes, I would also be happy to learn how to split the PDE solving calculations into several runs, as they are likely to be time-consuming. Or, perhaps there are more accurate and efficient alternatives to NDSolve?
Leslaw

POSTED BY: Leslaw Bieniasz
9 Replies
Posted 1 year ago

There are lists and descriptions of methods, including implicit one-step methods:

LSODA is the default solver for ODE's. IDA for DAEs. Not sure about other forms of DEs.

According to the Overview, "FixedStep" is restricted to one-step methods, so you can't use BDF or LSODA with it. A list of such submethods is in the docs. for NDSolve. Strangely, the FixedStep section gives an example that claims to show how to use Method -> "BDF" using fixed steps, but the steps are in fact of different sizes. You can use BDF for time integration in a PDE, but I do not know how to fix the step size or to restrict the minimum step size.

I do not know of any implementation of Rosebrock methods in Mathematica/WL. How to implement your own methods is described in the Plugin Framework.

POSTED BY: Updating Name
POSTED BY: Michael Rogers
Posted 1 year ago
POSTED BY: Updating Name

Responding to the person "Updating Name": I tried your version of the code, but I get a message: "The initial conditions did not evaluate to an array of numbers of depth 1 on the spatial grid. Initial conditions for partial differential equations should be specified as scalar functions of the spatial variables". To make your code work I had to remove WorkingPrecision -> 40, but then I get an accuracy of no more than 4-11 digits, depending on the choice of MaxPoints and MinPoints, while increasing AccuracyGoal or PrecisionGoal resulted in an enormous slowing down. My feeling is that NDSolve does not tolerate multiprecision, at least not in adaptive calculations.

Concerning the pseudospectral discretization: isn't it practical for periodic boundary conditions only?

Responding to Michael Rogers: I'll try your suggestions, but I am not happy about "ExplicitRungeKutta". Is there any possibility to employ implicit methods, say BDF? Or, other robust implicit schemes, like for example Rosenbrock methods? Some of these are very handy for nonlinear problems, as they do not require Newton iterations. I noticed in some examples on the internet that LSODA was used in NDSolve, and LSODA is based on BDF, if I remember. Explicit methods are likely to cause stability problems. Unfortunately, I cannot find anywhere a complete list of available integrators and other options for NDSolve. Leslaw

POSTED BY: Leslaw Bieniasz
POSTED BY: Leslaw Bieniasz
POSTED BY: Leslaw Bieniasz

Have you tried WorkingPrecision -> 40 or some such setting for it?

POSTED BY: Michael Rogers

Well, thanks, this should be useful for output purpose, but my main concern and question is how to force NDSolve to produce results that have a precision of number representation higher than the standard 16 digits, and how to activate an effective use of higher order accurate discretizations (hopefully) built-into the procedure. My goal is to obtain the solution having many accurate digits, ideally 19-20 digits. This cannot be normally achieved by using standard floating point numbers and discretizations that are only 2nd or even 4th order accurate. Leslaw

POSTED BY: Leslaw Bieniasz

Sorry, the computer ate my post. I don't have time to rewrite it. :/

Here is the full precision (53-bits, 15.95 digits):

Style[psi[0, 7] /. sol, PrintPrecision -> 20]
(*  {1.1442768817404132}  *)

Read http://reference.wolfram.com/language/tutorial/Numbers.html for more about kinds of numbers.

POSTED BY: Michael Rogers
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard