How to numerically solve a system of differential equation with boundary conditions and piece wise affine functions ?
Consider the following system of differential equations from some optimal control problem:
δ = Piecewise[{{0.0105, 0 <= t <= 10}, {0.0413,10 <= t <= 80}, {0.001, 80 <= t}}] ; p=Exp[-δ*0.05*t];
equadiff = {m'[t] == 0.5 m[t] - (v[t]/(p * δ)^(-1/2)), v'[t] == -0.5v[t]}
Running
solution = NDSolve[Join[equadiff, {m[0] == 100}, {m[100]==0}], {m[t], v[t]}, {t, 0, 100}]
I get the following error:
I also get the same error when using the shooting method with initial value on variable v
I tried suggestions in this post on discontinuous data
When running
solution = NDSolve[Join[equadiff, {m[0] == 100}, {m[100]==0}], {m[t], v[t]}, {t, 0, 100},Method ->{"PDEDiscretization" -> "FiniteElement"}]
I get the following error
When running
solution = NDSolve[Join[equadiff, {m[0] == 100}, {m[100]==0}], {m[t], v[t]}, {t, 0, 100},Method -> {"DiscontinuityProcessing" -> False}]
I get the following errors:
Using finite elements tries to solve the system but the errors suggest that it encounters problem from divided by 0 or negative roots. I suspect that variable v
somehow is numerically negative or 0 at some time points (which should be theoretically strictly positive in my problem).
How to solve this system with boundary conditions and piecewise data? I want to solve numerically, not analytically because it is particular case of a more general problem with no analytical solution. What other methods could I try?
)
is missing somewhere inequadiff
, 2. What'srt
? Please double check your code. Also, it's better to show us a complete sample reproducing the issue, rather than embed it in the text. $\endgroup$