2 added 96 characters in body
source | link

Update

Just tested on Wolfram cloud, the sample no longer gets stuck in v12.0.


Update

Just tested on Wolfram cloud, the sample no longer gets stuck in v12.0.


1
source | link

OK, I manage to reproduce the issue in v11.3, but not in v11.2 and v9. I guess this is related to the truth that "CatchMachineUnderflow" option is removed in this version, because after adding WorkingPrecision -> 16 to NDSolveValue together with Rationalize[..., 0], the problem is resolved:

h2 = {{0, -(Ω/2)}, {-(Ω/2), δ0 + Δ}};   
ρ2 = {{ρ11[t], ρ12[t]}, {ρ21[t], ρ22[t]}};

ρdecay = {{1/2*γ*ρ22[t], -γ*ρ12[t]}, {-γ*ρ21[t], -(1/2)*γ*ρ22[t]}};

ρtderiv = -I*(h2.ρ2 - ρ2.h2) + ρdecay;

replace3 = {Δ -> -1*10^9, γ -> 1.6*10^9, Ω -> 1, 
   m -> 10^-25, ℏ -> 1*10^-34, k -> (2 π)/(500*10^-9), v -> 10^3};

txvarray = Table[{0, 0, 0}, 200];

t0 = 0; ρ120 = 0; ρ210 = 0; ρ220 = 0; ρ110 = 1; δ0 = (2 π*10^3)/(500*10^-9);

Do[{ρsol11, ρsol12, ρsol21, ρsol22} = 
  NDSolveValue[{ρ11'[t] == ρtderiv[[1, 1]], ρ12'[
        t] == ρtderiv[[1, 2]], ρ21'[t] == ρtderiv[[2, 1]], ρ22'[
        t] == ρtderiv[[2, 2]], ρ11[t0] == ρ110, ρ12[
        t0] == ρ120, ρ21[t0] == ρ210, ρ22[t0] == ρ220} /. 
     replace3 // Rationalize[#, 0] &, {ρ11, ρ12, ρ21, ρ22}, {t, t0, 
    t0 + 0.01}, WorkingPrecision -> 16];
 Δt = 0.01;
 t0 += Δt;
 fscatt = ℏ k^2 γ Re[ρsol22[t0]]/m /. replace3;
 δ0 -= Δt fscatt;
 txvarray[[i, 1]] = t0;
 txvarray[[i, 2]] = fscatt;
 txvarray[[i, 3]] = δ0;
 ρ120 = ρsol12[t0];
 ρ210 = ρsol21[t0];
 ρ220 = ρsol22[t0];
 ρ110 = ρsol11[t0], {i, 1, 200}]

txabs = Table[{txvarray[[i, 1]], Abs[txvarray[[i, 3]]]}, {i, 1, 200}];

ListPlot[txabs, PlotStyle -> Green]

The output is just the same as in v9 and v11.2:

v11.3 result after adding WorkingPrecision -> 16:

enter image description here

v9 result (Definition of txvarray is modified to txvarray = Table[{0, 0, 0}, {200}]):

enter image description here