Re: NDSolve: large relative error without error message
- To: mathgroup at smc.vnet.net
- Subject: [mg127794] Re: NDSolve: large relative error without error message
- From: Mara Grahl <grahl at th.physik.uni-frankfurt.de>
- Date: Thu, 23 Aug 2012 02:52:23 -0400 (EDT)
- Delivered-to: l-mathgroup@mail-archive0.wolfram.com
- Delivered-to: l-mathgroup@wolfram.com
- Delivered-to: mathgroup-newout@smc.vnet.net
- Delivered-to: mathgroup-newsend@smc.vnet.net
- References: <5022A87E.50606@th.physik.uni-frankfurt.de>
Dear mathgroup, since there was no reply to my question so far, I just wanted to ask if I described my problem in an understandable form. To point out the main question: For AccuracyGoal -> 5, PrecisionGoal -> 5, MaxStepSize -> {0.9, 140} there's no error message. However, calculating the relative error err := 1/( k*D[U[k, \[CurlyPhi]], k]) (-k*D[U[k, \[CurlyPhi]], k] + k^5/(12*\[Pi]^2)*(3/Sqrt[ k^2 + 2*D[U[k, \[CurlyPhi]], \[CurlyPhi]]]* Coth[Sqrt[k^2 + 2*D[U[k, \[CurlyPhi]], \[CurlyPhi]]]/(2*T)] + 1/Sqrt[k^2 + 2*D[U[k, \[CurlyPhi]], \[CurlyPhi]] + 4*\[CurlyPhi]*D[U[k, \[CurlyPhi]], {\[CurlyPhi], 2}]]* Coth[Sqrt[ k^2 + 2*D[U[k, \[CurlyPhi]], \[CurlyPhi]] + 4*\[CurlyPhi]*D[U[k, \[CurlyPhi]], {\[CurlyPhi], 2}]]/( 2*T)] - (2*3*2)/Sqrt[ k^2 + g^2*\[CurlyPhi]]*(Tanh[( Sqrt[k^2 + g^2*\[CurlyPhi]] - mu)/(2*T)] + Tanh[(Sqrt[k^2 + g^2*\[CurlyPhi]] + mu)/(2*T)]))) for different points, shows that the solution computed by Mathematia is wrong. Is this a bug? If not, why is there no error message? Best regards Mara On 08/08/12 19:57, Mara Grahl wrote: > Dear mathgroup, > > I'm trying to solve a partial differential equation for quite a while > now and have several questions regarding the options for NDSolve. > > Here's the PDE: > > T = 100 > mu = 0 > g = 3.2 > > \[CurlyPhi]rb = 120^2 > > rb = D[10/4*\[CurlyPhi]^2, \[CurlyPhi]] /. \[CurlyPhi] -> \[CurlyPhi]rb > > sol = NDSolve[{k*D[U[k, \[CurlyPhi]], k] == > k^5/(12*\[Pi]^2)*(3/Sqrt[ > k^2 + 2*D[U[k, \[CurlyPhi]], \[CurlyPhi]]]* > Coth[Sqrt[k^2 + 2*D[U[k, \[CurlyPhi]], \[CurlyPhi]]]/(2*T)] + > 1/Sqrt[k^2 + 2*D[U[k, \[CurlyPhi]], \[CurlyPhi]] + > 4*\[CurlyPhi]*D[U[k, \[CurlyPhi]], {\[CurlyPhi], 2}]]* > Coth[Sqrt[ > k^2 + 2*D[U[k, \[CurlyPhi]], \[CurlyPhi]] + > 4*\[CurlyPhi]*D[U[k, \[CurlyPhi]], {\[CurlyPhi], 2}]]/( > 2*T)] - (2*3*2)/Sqrt[ > k^2 + g^2*\[CurlyPhi]]*(Tanh[( > Sqrt[k^2 + g^2*\[CurlyPhi]] - mu)/(2*T)] + > Tanh[(Sqrt[k^2 + g^2*\[CurlyPhi]] + mu)/(2*T)])), > U[500, \[CurlyPhi]] == 10/4*\[CurlyPhi]^2, > U^(0,1)[k,\[CurlyPhi]rb]==rb}, > U, {k, 2, 500}, {\[CurlyPhi], 0, \[CurlyPhi]rb}, AccuracyGoal -> 6, > PrecisionGoal -> 6, MaxStepSize -> {0.05, 120}, MaxSteps -> 10000] > > Please note that I did copy & paste from the notebook, except for the > boundary condition on the first derivative U^(0,1)[k,\[CurlyPhi]rb]==rb . > > To summarize: it's a partial differential equation, first order in k and > second order in \[CurlyPhi]. My initial condition is U[500, \[CurlyPhi]] > == 10/4*\[CurlyPhi]^2. I state only one boundary condition, since I > only know that the derivative should not change far away from the origin > (I chose 120^2 for the boundary). > > I read tutorial/NDSolvePDE and related. > > My coordinate intervals are {k, 2, 500} and {\[CurlyPhi], 0, 120^2}. > As far as I understand, without stating another method, Mathematica uses > the method LSODA (a particular method of lines). The intervals for the > coordinates are discretized on a grid with > > Stepsize in k-direction = (500-2)/ N > Stepsize in \[CurlyPhi]-direction = 120^2 / M > > where N and M are the number of grid points in each direction. That is, > for MaxStepSize -> {0.05, 120}, Mathematica can use 498/0.05= 9960 grid > points at maximum in k-direction, and 120 in \[CurlyPhi]-direction. > > I experimented with different Accuracy- and PrecisionGoals, MaxStepSizes > and MaxSteps. It seems that the higher the Accuracy and Precision > settings, the earlier the integration gets unstable, that is the higher > the value for k in the error message > > NDSolve::mxst: Maximum number of 10000 steps reached at the point k == > 4.053046219166641` . > > This error message also appears for too small MaxStepSize, and > increasing MaxSteps is often not an effective help then. For larger > MaxStepSize there's no error message at all, but the solution given by > Mathematica is wrong for small k anyway. For example, using the settings > > AccuracyGoal -> 5, PrecisionGoal -> 5, MaxStepSize -> {0.9, 140} > > there's no error message. However, calculating the relative error > > err := 1/( > k*D[U[k, \[CurlyPhi]], k]) (-k*D[U[k, \[CurlyPhi]], k] + > k^5/(12*\[Pi]^2)*(3/Sqrt[ > k^2 + 2*D[U[k, \[CurlyPhi]], \[CurlyPhi]]]* > Coth[Sqrt[k^2 + 2*D[U[k, \[CurlyPhi]], \[CurlyPhi]]]/(2*T)] + > 1/Sqrt[k^2 + 2*D[U[k, \[CurlyPhi]], \[CurlyPhi]] + > 4*\[CurlyPhi]*D[U[k, \[CurlyPhi]], {\[CurlyPhi], 2}]]* > Coth[Sqrt[ > k^2 + 2*D[U[k, \[CurlyPhi]], \[CurlyPhi]] + > 4*\[CurlyPhi]*D[U[k, \[CurlyPhi]], {\[CurlyPhi], 2}]]/( > 2*T)] - (2*3*2)/Sqrt[ > k^2 + g^2*\[CurlyPhi]]*(Tanh[( > Sqrt[k^2 + g^2*\[CurlyPhi]] - mu)/(2*T)] + > Tanh[(Sqrt[k^2 + g^2*\[CurlyPhi]] + mu)/(2*T)]))) > > for different points, shows that - with the above settings roughly for k > < 50 - the solutions acquire a complex part (whereas for k >50 , the > relative error is of the order 10^-6), e.g.: > > err /. k -> 30 /. \[CurlyPhi] -> 30^2 /. sol > -0.522023 - 0.000456848 I > > I face the same problem for all other settings I've tried so far. One of > the longest calculations I have run was for > AccuracyGoal -> 4, PrecisionGoal -> 4, MaxStepSize -> {0.005, 40}, > MaxSteps -> 140000 > > I would appreciate very much any suggestions how to obtain a solution > with small relative error also for small k. > > Thank you, best regards, > Mara > > > > > > > > >