I've been playing around with Method
in NDSolve[...]
and can't quite seem to figure out how to force NDSolve
to use a certain difference order with a certain method.
For instance, I am trying to validate my work against results of solving an ODE with the Backward Euler method which essentially is BDF of order 1.
Now, Mathematica does have the BDF method for solving stiff equations but when I set the following:
Method->{"BDF", "DifferenceOrder"->1}
I get the following error:
NDSolve::moptx: Method option DifferenceOrder in {NDSolve`BDF,{DifferenceOrder->Automatic}} is not one of {ImplicitSolver,MaxDifferenceOrder,VariableStepCoefficients}. >>
NDSolve::initf: The initialization of the method NDSolve`BDF failed. >>
But when I run NDSolve
with just Method->{"BDF"}
, lo and behold, I get my solution.
Just to make sure that BDF
does take DifferenceOrder
options, I checked with
Options[NDSolve`BDF]
as prompted in a previous question.
Is this not how I should set the order for BDF? What am I missing?
EDIT 1:
I realized I should be using the IDA method as that apparently uses the BDF method to solve DAEs. Still trying to figure out how I might go about doing this though.
EDIT 2:
I think I might have figured it out. This is what I changed in Method
Method -> {"IDA", "ImplicitSolver" -> "Newton", "MaxDifferenceOrder" -> 5},
From IDA's documentation provided in Advanced Numerical Differential Equation Solving in Mathematica, I think with IDA
with Newton
Implicit Solver of Order 5, I am actually using a BDF5 method.
EDIT 3:
Per rcollyer's comment, it should be "MaxDifferenceOrder"
and NOT "DifferenceOrder
" in case BDF
is used as the Method
Example: Method->{"BDF", "MaxDifferenceOrder->5"}
executes BDF5.
Any thoughts? Comments? Anything else that I might look for, for say other methods such as the LSODA
etc?
EDIT 4:
As per rcollyer's comment, BDF
with "MaxDifferenceOrder"->5
, NDSolve[..]
changes the order as required UP TO 5 and doesn't just use order 5.
Options[NDSolve`BDF]
gives{"ImplicitSolver" -> NDSolve`Newton, "MaxDifferenceOrder" -> 5, "VariableStepCoefficients" -> Automatic}
for me on v8.0.4 which says that it doesn't take"DifferenceOrder"
as an option. $\endgroup$IDA
withNewtons
method and"MaxDifferenceOrder"->5
the same as runningBDF
with"MaxDifferenceOrder"-> 5
? They both run without errors. $\endgroup$NDSolve
may, however switch between orders up until X to get to a solution. $\endgroup$