Re: Imposing boundary condition at infinity

*To*: mathgroup at smc.vnet.net*Subject*: [mg102568] Re: Imposing boundary condition at infinity*From*: Mark Fisher <particlefilter at gmail.com>*Date*: Fri, 14 Aug 2009 05:59:47 -0400 (EDT)*References*: <h60es7$pjh$1@smc.vnet.net>

On Aug 13, 3:20 am, YH Tung <b942030... at student.nsysu.edu.tw> wrote: > Dear Mathgroup: > > Hi, I tried this method to solve nonlinear PDEs(12/20/2005), but there ar= e > still some problems, I couldn't find the general solution. My question is > du/dt = -(1+u)*du/dx,u=0 as x-> +-infinity, u=Exp(-x^2) as t=0. > > My code: > NDSolve[{D[u[x,t], t] == -(1 + u[x, t])*D[u[x, t],x], u[-ini, t] == = u[ini, > t] == 0, u[x, 0] == Exp[-x^2]}, u, {x, -.0001, .0001} , {t, -.000= 1, .0001}, > MaxSteps -> Infinity] > > How can I improve? > > Thanks > Tony One approach is to simply leave out the boundary conditions and see if the solution you get is satisfactory. (Just ignore the message about insufficient boundary conditions.) In what follows, I solve for Abs[x] <= 5 (and Abs[t] <= 1), but I only look at the solution for Abs[x] <= 3. With the default settings, I get a message about spatial error. The plot shows that the solutions look bad when Abs[t] is near 1. soln0 = u /. First@NDSolve[{D[u[x, t], t] == -(1 + u[x, t])*D[u[x, t], x], u[x, 0] == Exp[-x^2]}, u, {x, -5, 5}, {t, -1, 1}]; Plot3D[soln0[x, t], {x, -3, 3}, {t, -1, 1}] I can fix this (in part) by using advanced options to specify the maximum step size for x. (You can read about these options in the tutorial on "Advanced Numerical Differential Equation Solving" in the section on "Partial Differential Equations: The Method of Lines" in the subsection called "Controlling the Spatial Grid Selection". It's not easy to find!) soln1 = u /. First@NDSolve[{D[u[x, t], t] == -(1 + u[x, t])*D[u[x, t], x], u[x, 0] == Exp[-x^2]}, u, {x, -5, 5}, {t, -1, 1}, Method -> {MethodOfLines, SpatialDiscretization -> {TensorProductGrid, MaxStepSize -> .005}}] Plot3D[soln1[x, t], {x, -3, 3}, {t, -1, 1}] Even though the plot looks good (and I don't get the spatial error message) the residual indicates some problems where Abs[t] > 1/2. resid = Abs[ Subtract @@ (D[u[x, t], t] == -(1 + u[x, t])*D[u[x, t], x])] /. u -> soln1; Plot3D[resid, {x, -3, 3}, {t, -1, 1}, PlotRange -> All] But maybe this solution is good enough. --Mark