I'm trying to solve differential equations but encountered singularity problem as usual. My idea is to solve is by using higher WorkingPrecision
, but somehow it always gives me errors
For example,
eqs = {51.7 ti'[tau] == qH[tau] + qS - 0.7343549132947976 (-tae + ti[tau]),
0 == -ti[tau] + tr[tau] - Exp[-2.655/Max[1.*10^(-9), vF[tau]]] (-ti[tau] + tv),
0 == qH[tau] - 1.1021142600089968` (-tr[tau] + tv) vF[tau],
0 == vF[tau] - Max[0, 20 + 20 (20 - ti[tau])]}
vars = {ti[tau], qH[tau], tr[tau], vF[tau]}
The solution of the steady-state equation can be used as initial condition. Without manually setting the working precision, it runs smoothly.
ic = (FindRoot[eqs[[All, 2]] //. {tv -> 28, qS -> 0, tae -> -2.5 Cos[2 Pi/24 tau], tau -> 0}, Transpose[{vars /. tau -> 0, ConstantArray[RandomReal[], Length[vars]]}]] /. Rule -> Equal)
NDSolve[{eqs /. {tv -> 28, qS -> 0, tae -> -2.5 Cos[2 Pi/24 tau]}, ic}, vars, {tau, 0, 24 30}]
When I try to set WorkingPrecision->10
, it gives me the error.
With[{eqNew =
SetPrecision[{eqs /. {tv -> 28, qS -> 0,
tae -> -2.5 Cos[2 Pi/24 tau]}, ic}, 10]},
NDSolve[eqNew, vars, {tau, 0, 24 30}, WorkingPrecision -> 10]]
NDSolve::mconly: For the method NDSolve`IDA, only machine real code is available. Unable to continue with complex values or beyond floating-point exceptions.
Any ideas?
WorkingPrecision -> MachinePrecision
for the IDA method, which is the only way to solve a DAE. Try differentiating your algebraic equations ineqs
. -- Side remark: Machine precision is almost 16, but without precision tracking and extra guard digits. I'd recommend settingWorkingPrecision
to 16 or higher, if you want higher precision. $\endgroup$Max
gives some trouble when differentiated. I didn't solve it. $\endgroup$èqs=Rationalize[ ....,0]
I don't have any problems with NDSolve, working with MMA 8.0. $\endgroup$