Edited to add: New information at bottom.
Consider the following system of differential equations:
eqlist = {a'[t] == 6600 b[t] + 15000.`30. a[t] b[t] + 5.5`30.*^6 b[t]^2 +
kcq b[t] c[t] + k67 b[t] c[t] - k76 a[t] d[t] +
5.5`30.*^6 b[t] d[t],
b'[t] == -6600 b[t] - 15000.`30. a[t] b[t] - 5.5`30.*^6 b[t]^2 -
kcq b[t] c[t] - k67 b[t] c[t] + k76 a[t] d[t] -
5.5`30.*^6 b[t] d[t],
c'[t] == -k67 b[t] c[t] + 85 d[t] + kcq a[t] d[t] +
k76 a[t] d[t] + 5.5`30.*^6 b[t] d[t] + 30000 c[t] d[t] +
5.5`30.*^6 d[t]^2,
d'[t] == k67 b[t] c[t] - 85 d[t] - kcq a[t] d[t] - k76 a[t] d[t] -
5.5`30.*^6 b[t] d[t] - 30000 c[t] d[t] -
5.5`30.*^6 d[t]^2,
A60[t] == (19879 b[t])/200,
A70[t] == (1073 d[t])/200,
Atot[t] == A60[t] + A70[t],
a[0] == 1/125,
b[0] == 0,
c[0] == 11/500,
d[0] == 0,
A60[0] == (19879 b[0])/200,
A70[0] == (1073 d[0])/200,
Atot[0] == A60[0] + A70[0]};
impulse1 = WhenEvent[t == 10^-4, {a[t] -> -((893 Ilaser)/(1000 125)) + a[t],
b[t] -> (893 Ilaser)/(1000 125) + b[t],
c[t] -> -((2021 Ilaser 11)/(250 500)) + c[t],
d[t] -> (2021 Ilaser 11)/(250 500) + d[t]}];
result1 = ParametricNDSolve[Append[eqlist, impulse1], {a, b, c, d, A60, A70, Atot},
{t, 0, 0.002}, {kcq, k67, k76, Ilaser},
WorkingPrecision -> 30];
Plot[Evaluate[((# /. result1)[30000, 5 10^6, 5 10^6, 5 10^-3][t]) & /@ {A60, A70, Atot}],
{t, 0, 0.002}, PlotRange -> Full, Frame -> True, ImageSize -> Large]
Which works as it should. But if I try to parameterize the time offset, it fails:
impulse2 = WhenEvent[t == t0, {a[t] -> -((893 Ilaser)/(1000 125)) + a[t],
b[t] -> (893 Ilaser)/(1000 125) + b[t],
c[t] -> -((2021 Ilaser 11)/(250 500)) + c[t],
d[t] -> (2021 Ilaser 11)/(250 500) + d[t]}];
result2 = ParametricNDSolve[Append[eqlist, impulse2], {a, b, c, d, A60, A70, Atot},
{t, 0, 0.002}, {kcq, k67, k76, Ilaser, t0},
WorkingPrecision -> 30];
Plot[Evaluate[((# /. result2)[30000, 5 10^6, 5 10^6, 5 10^-6, 0.1 10^-3][t]) & /@
{A60, A70, Atot}], {t, 0, 0.002}, PlotRange -> Full, Frame -> True,
ImageSize -> Large]
Is this behavior expected? Is there a workaround?
New information: If we evaluate the functions to plot, we get an interesting clue:
Evaluate[((# /. result1)[30000, 5 10^6, 5 10^6, 5 10^-3][t]) & /@
{A60, A70, Atot}]
Evaluate[((# /. result2)[30000, 5 10^6, 5 10^6, 5 10^-6, 10^-4][
t]) & /@ {A60, A70, Atot}]
Why are the domains so small in the second case?








t0=10^-4and look – Alex Trounev Sep 28 '19 at 10:31