Take the 2-minute tour ×
Mathematica Stack Exchange is a question and answer site for users of Mathematica. It's 100% free, no registration required.

I am having trouble with using NDSolve`Reinitialize when the system consists of a pieceise function.

If we define the ODE system

 simplesys = {r'[t] == 
Piecewise[{{1, 0 <= t <= 10}, {0, 10 <= t <= 20}}, 0], r[0] == 0};

and process the equations with

state = First@NDSolve`ProcessEquations[simplesys, r, t]

this works perfectly fine. However, when I try to reinitilize the ODE system with a new initial condition

newstate = NDSolve`Reinitialize[state, {r[0] == 2}]

this fails with the message

NDSolve`Reinitialize::ntcs: Cannot solve constraint equations for initial conditions.

This is due to the piecewise function in the system, I haven't got this problem for other types of systems, it only occurs when I have piecewise function. How can I solve this issue?

share|improve this question
2  
In this specific case you can replace Piecewise[...] with UnitStep[10 - t]. –  b.gatessucks Aug 14 '13 at 6:51
    
Thanks for the quick response @b.gatessucks. Works absolutely fine now :) –  jaclea Aug 14 '13 at 6:55
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.