Gianluca,
That was an excellent idea. Thanks for your suggestion. I had to make minor adjustment to the code, but it made it work.
vd = NDSolveValue[{vd[0] == 0, vd'[s] == fd[t = s]}, vd, {s, 0, Tp},
AccuracyGoal -> 8];
However, I am getting some errors associated with computing the min and max value of the function. Any suggestion on what I need to do to avoid these errors?
Clear["Global`*"];
t =.; f = 1; \[Omega] = 2 \[Pi] f; Tp = 1/f;
r = 1.;
L = 6 r;
\[Theta] = \[Omega] t;
Vd =.;
Ncyl = 3;
\[Phi][i_] := (i - 1) 2 \[Pi]/Ncyl;
Q[t_, i_] :=
r Sin[\[Theta] + \[Phi][i]] - (
r^2 Sin[\[Theta] + \[Phi][i]] Cos[\[Theta] + \[Phi][i]])/Sqrt[
L^2 - r^2 (Sin[\[Theta] + \[Phi][i]])^2];
ftot[t_] := Sum[Max[Q[t, i], 0], {i, 1, Ncyl}];
favg = Quiet@NIntegrate[ftot[t], {t, 0, Tp}, AccuracyGoal -> 4]/Tp;
vstroke = favg Tp;
fd[t_] := ftot[t] - favg;
Plot[{ftot[t], favg, fd[t]}, {t, 0, Tp}, Frame -> True, Axes -> True,
PlotRange -> { {0, Tp}, {-1.2, 1.2}},
FrameLabel -> {"Time (sec)", "Flow rate"}, GridLines -> Automatic,
AspectRatio -> .65,
PlotStyle -> {{Red, Thickness[0.005]}, {Green,
Thickness[0.0051]}, {Blue, Thickness[0.005]}},
BaseStyle -> {FontWeight -> "Bold", FontSize -> 15,
FontFamily -> "Arial"}]
vd = NDSolveValue[{vd[0] == 0, vd'[s] == fd[t = s]}, vd, {s, 0, Tp},
AccuracyGoal -> 8];
Plot[{vd[s]/vstroke}, {s, 0, Tp}, Frame -> True, Axes -> True,
FrameLabel -> {"Time (sec)", "Flow"}, GridLines -> Automatic,
AspectRatio -> .65,
PlotStyle -> {{Brown, Thickness[0.005]}, {Cyan,
Thickness[0.0051]}, {Gray, Thickness[0.01]}},
BaseStyle -> {FontWeight -> "Bold", FontSize -> 15,
FontFamily -> "Arial"}]
vmax = NMaxValue[vd, s];
vmin = NMinValue[vd, s];
deltav = (vmax - vmin)/vstroke