Hello Julian
This is a common issue in hydraulic simulation.
The Sqrt function has a vertical tangent at zero,
this make the system undamped which is not realistic,
and drives to a stiff and oscillant solution when approaching null flow.
The realistic way to solve it, is to use a modified sqrt root function (sqr respectively)
This function must integrates two realistic effects :
- the flow can go both ways, so you will not have complex solutions
- the flow does a transition from turbulent to laminar around zero, preserving damping around null flow
ModifiedSignedSqrt[x_] := If[Abs[x]< 1,x,Sign[x]*Sqrt[Abs[x]]]
Plot[ModifiedSignedSqrt[x], {x, -10, 10}]
You must adjust the treshold (here 1) depending of the Reynolds number.
And obviously keep the function continuous around the transition.
Doing this way ensure that the computation is done in reals, and the system is not stiff around null flow.
This will remove the solver issue (event handling is not required), and give a realistic result
Q1 = Ad1*Cd1*ModifiedSignedSqrt[(2/Rho)*(ps - p1[t])]
...
eqs = {p1'[t] == (beta*Q3)/V1, p2'[t] == (beta*Q4)/V2, p1[0] == p2[0] == 0};
...
PS : If you are interested by realistic modeling, try bond graphs.
I am the author of the
bond graph toolbox for mathematica
Nicolas