- #1
tqbrowne
- 1
- 0
I'm modeling a physical system described by a second-order ODE with LOTS of parameters.
Using SciLab, I sucessfully implimented the model using a while loop with time. Because of the loop structure, every time I called the DE solver (ode), I updated the intial conditions for the current solution with the output from the previous iteration of ode. For example, my original initial conditions, theta[0] = 0 and theta'[0] = 0, would be updated with the solution after the first step.
Now, due to the usefulness (and downright awesomeness) of the Manipulate function, I would like to achieve the same setup in Mathematica. In the process of checking the continuity between Mathematica and SciLab, I ran the ode solver in SciLab without the loop and simply using the original initial conditions. The problem I'm having in both Mathematica and SciLab is that, without updating the intial conditions after each iteration, both solvers fail to return the values that I achieved in Scilab with the loop.
Normally, I would be inclined to trust the solution found without updating the intial conditions. However, I have verified the correctness of the SciLab-looped solution with an analytic solution. The SciLab-looped numerical solution does exactly what I would expect, it converges on the analytic steady-state solution in a predictable fashion.
Should I write a loop in mathematica that updates the initial conditions for NDSolve or is it as simple as changing the solution method?
Using SciLab, I sucessfully implimented the model using a while loop with time. Because of the loop structure, every time I called the DE solver (ode), I updated the intial conditions for the current solution with the output from the previous iteration of ode. For example, my original initial conditions, theta[0] = 0 and theta'[0] = 0, would be updated with the solution after the first step.
Now, due to the usefulness (and downright awesomeness) of the Manipulate function, I would like to achieve the same setup in Mathematica. In the process of checking the continuity between Mathematica and SciLab, I ran the ode solver in SciLab without the loop and simply using the original initial conditions. The problem I'm having in both Mathematica and SciLab is that, without updating the intial conditions after each iteration, both solvers fail to return the values that I achieved in Scilab with the loop.
Normally, I would be inclined to trust the solution found without updating the intial conditions. However, I have verified the correctness of the SciLab-looped solution with an analytic solution. The SciLab-looped numerical solution does exactly what I would expect, it converges on the analytic steady-state solution in a predictable fashion.
Should I write a loop in mathematica that updates the initial conditions for NDSolve or is it as simple as changing the solution method?