I'm handling with a large DAE system with some events (around 400 equations and 20 events) and lots of them are nonlinear. Let's take the equations from this post as an example.
(* effective heat capacity of building *)
Cwirk = 50 25 3;
(* import outdoor temperature *)
li = Import[
"http://rredc.nrel.gov/solar/old_data/nsrdb/1991-2005/data/tmy3/\
725958TYA.CSV"];
(* interpolate outdoor temperature *)
tae = Interpolation[
Transpose[{Range[8760], Drop[Drop[li, 1][[All, 32]], 1]}]]
eq = {
(* equation for building *)
Q[tau] - 200 (tt[tau] - tae[tau]) == Cwirk tt'[tau],
(* heating capacity of floor heating system *)
Q[tau] - 100 (28 - tr[tau]) vF[tau] 7/6 == 0,
(* the water outlet temperature of floor heating *)
tr[tau] - tt[tau] - (28 - tt[tau]) Exp[-0.9/(7/6 vF[tau] 0.22)] == 0,
(* a simple P-controller for the flow rate *)
vF[tau] - Clip[(20 + 20 (20 - tt[tau])), {10^(-10), 100}] == 0}
ic = FindRoot[eq[[All, 1]] == 0 /. tau -> 1,
Transpose[{{Q[1], tt[1], tr[1], vF[1]}, {3000, 20, 20, 20}}]] /.
Rule -> Equal
workingPrecision = 8;
AbsoluteTiming[
sol = NDSolve[
SetPrecision[Join[eq, ic], workingPrecision], {Q, tt, tr,
vF}, {tau, 1, 24 365}, WorkingPrecision -> workingPrecision,
MaxSteps -> Infinity];]
(*{31.2564,Null}*)
Question 1:
Solving these 4 equations already takes around 30 seconds for me. For the full 400 equations, my poor laptop needs about 3 hours, which is little bit too long. Is there any way to accelerate the NDSolve
for DAE or at least this example?
Question 2:
I've found some posts in this forum state that vectorize the equations will speed up the NDSolve
. Can DAEs also be written in vector form and will it help for the speed?
NDSolve
mainly because it speeds up the pre-processing stage ofNDSolve
, AFAIK. (Related: mathematica.stackexchange.com/a/158519/1871) So personally I don't think that'll help for your problem. $\endgroup$StateSpace
method, the pre-processing of DAE solver seems to heavily depend on… Er… structure analysis of DAE system. But I confess I never tried compiling DAE system, perhaps it's worth exploring. $\endgroup$