When I expanded the t-value range of the function pwQ[t_] and ran the program, the system prompted "PienewiseExpand cannot convert Floor [4000. \ t] to Pienewise form because the required number of segmented cases to search exceeds the internal limit of $MaxPienewiseCases=100".
Can I try changing the size of the internal limit $MaxPierceCases?
program codeļ¼
\[Tau] = 2.5 10^-4;
pwQ[t_] =
PiecewiseExpand[Boole[0 <= Mod[t, \[Tau]] < (2/3)*\[Tau]],
0 <= t <= 3/100];
pars = {vi -> 24, r -> 22, l -> 2 10^-2, c -> 1 10^-4};
spSystem = {vi pwQ[t] == l iL'[t] + vC[t],
vC'[t] == iL[t]/c - vC[t]/(r c), vC[0] == 0, iL[0] == 0};
pwSol = DSolve[spSystem /. pars, {vC, iL}, {t, 0, 2/100}] //
Simplify;
a = Evaluate[iL[t] /. pwSol];
b = Evaluate[vC[t] /. pwSol];
Plot[a, {t, 0, 0.02}, AxesLabel -> {"s", "il[t]/A"},
PlotLegends -> {"LinearlyImplicitEuler"}, PlotStyle -> {Red},
PlotRange -> All]
Plot[b, {t, 0, 0.02}, AxesLabel -> {"s", "vc[t]/V"},
PlotLegends -> {"LinearlyImplicitEuler"}, PlotStyle -> {Blue},
PlotRange -> All]