Wolfram ResearchPRODUCTSPURCHASEFOR USERSCOMPANYOUR SITES
THIS IS DOCUMENTATION FOR AN OBSOLETE PRODUCT.
SEE THE DOCUMENTATION CENTER FOR THE LATEST INFORMATION.

Getting Solution Functions

Once you have integrated a system up to a certain time, typically you want to be able to look at the current solution values and to generate an approximate function representing the solution computed so far. The command NDSolve`ProcessSolutions allows you to do both.

Getting solutions as InterpolatingFunction objects.

This extracts the solution computed in the previous section as an InterpolatingFunction object.

In[10]:= 

Out[10]=

This plots the solution.

In[11]:= 

Just as when using NDSolve directly, there will be a rule for each function you specified in the second argument to NDSolve`ProcessEquations. Only the specified components of the solutions are saved in such a way that an InterpolatingFunction object can be created.

Obtaining the current solution values.

This gives the current solution values and derivatives in the forward direction.

In[12]:= 

Out[12]=

The choices you can give for the direction dir are "Forward" and "Backward", which refer to the integration forward and backward from the initial condition.

Integration direction specifications.

The output given by NDSolve`ProcessSolution is always given in terms of the dependent variables, either at a specific value of the independent variable, or interpolated over all of the saved values. This means that when a partial differential equation is being integrated, you will get results representing the dependent variables over the spatial variables.

This computes the solution to the heat equation from time t = -1/4 to t = 2.

In[13]:= 

This gives the solution at t = 2.

In[15]:= 

Out[15]=

The solution is given as an InterpolatingFunction object that interpolates over the spatial variable x.

This gives the solution at t = -1/4.

In[16]:= 

Out[16]=

When you process the current solution for partial differential equations, the spatial error estimate is checked. (It is not generally checked except when solutions are produced because doing so would be quite time consuming.) Since it is excessive, the NDSolve::eerr message is issued. The typical association of the word "backward" with the heat equation as implying instability should gives a clue to what is wrong in this example.

Here is a plot of the solution at t = 1/4

In[17]:= 

The plot of the solution shows that instability is indeed the problem.

Even though the heat equation example is simple enough to know that the solution backward in time is problematic, using NDSolve`Iterate and NDSolve`ProcessSolutions to monitor the solution of a PDE can be used to save computing a solution which turns out not to be as accurate as desired. Another simple form of monitoring follows.

Entering the following commands generates a sequence of plots showing the solution of a generalization of the sine-Gordon equation as it is being computed.

In[18]:= 

When you monitor a solution in this way, it is usually possible to interrupt the computation if you see that the solution found is sufficient. You can still use the NDSolve`StateData object to get the solutions that have been computed.


Any questions about topics on this page? Click here to get an individual response.Buy NowFree TrialMore Information



 © 2009 Wolfram Research, Inc.  Terms of Use  Privacy Policy |
Sign up for our newsletter: