Andras,
Your problem is with the Friction function. You have a discontinuity at 0 flow and using Return[] is not correct. I would change it to
friction[ q_ ] := Module[ { rey = 0. , fl = 0. , ft = 0. } ,
If[q >= 0.001,
rey = ( 4. * q * \[Rho] ) / ( N[ \[Pi] ] * dia * \[Mu] ) ;
fl = 64. / rey ;
ft = 1. /((
1.8 * Log10[ 6.9/rey + (ee /(3.7 * dia))^1.11 ] )^2) ;
Piecewise[
{{ (fl), ( 0. < rey && rey < 2000. ) } ,
{ (
fl + ( ft - fl ) * ( rey - 2000.) / 2000. ), (
2000. <= rey && rey < 4000. ) } ,
{ ( ft), ( 4000. <= rey ) }}
] , friction[0.001]]
]
or if you want to use Which:
friction[ q_ ] := Module[ { rey = 0. , fl = 0. , ft = 0. } ,
If[q>=0.001, rey = ( 4. * q * \[Rho] ) / ( N[ \[Pi] ] * dia * \[Mu] ) ;
fl = 64. / rey ;
ft = 1. /(( 1.8 * Log10[ 6.9/rey + (ee /(3.7 * dia))^1.11 ] )^2) ;
Which[
( 0. < rey && rey < 2000. ) , ( fl ) ,
( 2000. <= rey && rey < 4000. ) , ( fl + ( ft - fl ) * ( rey - 2000.) / 2000. ) ,
( 4000. <= rey ) , ( ft )
] (* Which[ *), friction[0.001]]
]
Either of these works. Your plot is still not matching the goal plots you included, however, you can now debug from here. Note your initial conditions are not correct. For example, Tank 2 seems to start at 2.5
Regards,
Neil