Group Abstract Group Abstract

Message Boards Message Boards

DSolve has reached the maximum number of calculations

Posted 1 year ago
POSTED BY: James James
7 Replies

In this case I would try Piecewise instead of WhenEvent:

\[Tau] = 1/9;
pwQ[t_] = PiecewiseExpand[Boole[0 <= Mod[t, \[Tau]] < (2/3)*\[Tau]],
   0 <= t <= 3 \[Tau]];
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[system2, {vC, iL},
    {t, 0, 2/10}] // Simplify;
Simplify[spSystem /. pwSol[[1]] /.
  {{t -> 1/100}, {t -> 1/9 - 1/27 + 1/30}, {t -> 1/9 + 1/27}}]
POSTED BY: Gianluca Gorni
Posted 1 year ago

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]
POSTED BY: James James

I didn't know about $MaxPienewiseCases. You can try increasing it Do you know in advance how many intervals you need? For a full analytical solution I would use exact numbers:

\[Tau] = 25/10 10^-4;
POSTED BY: Gianluca Gorni
Posted 1 year ago

Yes, I found the help document for

$MaxPickewiseCases

and directly set $MaxPickewiseCases=(the range you want). The link to the help document isenter link description here

But my code doesn't produce any results...

\[Tau] = 25/10 10^-4;
pwQ[t_] = 
  PiecewiseExpand[Boole[0 <= Mod[t, \[Tau]] < (2/3)*\[Tau]], 
   0 <= t <= 3/100];
$MaxPiecewiseCases = 200;
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]
POSTED BY: James James

Have you tried NDSolve instead of Solve?

POSTED BY: Gianluca Gorni
Posted 1 year ago

Because I want to obtain an exact solution, I am using DSolve instead of NDSolve.

POSTED BY: James James
Attachments:
POSTED BY: Mariusz Iwaniuk
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard