Q:

Setting an upper limit in the NDSOLVE calculations

I have built a code to solve a system of differential equations in the form: 
$\displaystyle \frac{d(AB)}{dt}=kn(A)n(B)$
Here I present a small version of it:
AU = 1.49597871*10^13;  

To = 2200;   

ΔT = 440;  

Ro = 1.9;    

ΔR = 0.1;  

n = 0.5*10^15 ;    

cg = 6.67384*10^-8;   

kb = 1.3806488*10^-16;     

mh = 1.0078250321*(1.660538921*10^-24);    

mf = 1.98892*10^33;   

Te[ϕ_] = To + ΔT*Cos[ϕ]; 

Ra[ϕ_] = Ro + ΔR*Cos[ϕ + Pi];

t[r_, ϕ] := 
  Te[ϕ]*Power[(1 - Sqrt[1 - (Ra[ϕ]/r)^2]), (4)^-1];

dens[r_, ϕ_] = 
  n*Exp[-((2*cg*mf*mh)/(kb*Te[ϕ]*Ra[ϕ]*AU))*(1 - 
       Power[(Ra[ϕ]/r), (2)^-1])];                                                        

k1[r_, ϕ_] := (6.99*10^-14)*((t[r, ϕ]/300)^2.8)*Exp[-1950/t[r, ϕ]];  

k2[r_, ϕ_] := (1.59*10^-11)*((t[r, ϕ]/300)^1.2)*Exp[-9610/t[r, ϕ]]; 

k17[r_, ϕ_] := (3.14*10^-13)*((t[r, ϕ]/300)^2.7)*Exp[-3150/t[r, ϕ]];

k18[r_, ϕ_] := (2.05*10^-12)*((t[r, ϕ]/300)^1.52)*Exp[-1736/t[r, ϕ]]; 

k62[r_, ϕ_] := (1.77*10^-11)*Exp[178/t[r, ϕ]]; 

k63[r_, ϕ_] := (1.85*10^-11)*((t[r, ϕ]/300)^0.95)*
   Exp[-8571/t[r, ϕ]]; 

k94[r_, ϕ_] := (1.65*10^-12)*((t[r, ϕ]/300)^1.14)*
   Exp[-50/t[r, ϕ]]; 

k138[r_, ϕ_] := (5.94*10^-17)*((t[r, ϕ]/300)^0.17)*
   Exp[65.9/t[r, ϕ]]; 

k141[r_, ϕ_] := (1*10^-11)*Exp[-4800/t[r, ϕ]];

k143[r_, ϕ_] := (1*10^-11)*Exp[-4800/t[r, ϕ]];  

k144[r_, ϕ_] := 1*10^-9;

dldens[r_, ϕ_] := D[dens[r, ϕ], r]/dens[r, ϕ];

r1 = k1[r, ϕ]  nH[r] nOH[r];
r2 = k2[r, ϕ]  nH[r] nH2O[r];
r17 = k17[r, ϕ]  nH2[r] nO[r];
r18 = k18[r, ϕ] nH2[r] nOH[r];
r62 = k62[r, ϕ] nO[r] nOH[r];
r63 = k63[r, ϕ]  nO[r] nH2O[r];
r94 = k94[r, ϕ]  nOH[r] nOH[r];
r138 = k138[r, ϕ]  nTi[r] nO[r];
r141 = k141[r, ϕ]  nTi[r] nOH[r];
r143 = k143[r, ϕ]  nTi[r] nH2O[r];
r144 = k144[r, ϕ]  nTiO[r] nH2O[r];
eqns = {(dldens[r, ϕ] nH[r] + nH'[r])/dens[r, ϕ] == -r1 + 
     r17 + r18 - r2 + r62, (dldens[r, ϕ] nOH[r] + nOH'[r])/
     dens[r, ϕ] == -r1 - r141 + r17 - r18 + r2 - r62 + r63 - 
     r94, (dldens[r, ϕ] nO[r] + nO'[r])/dens[r, ϕ] == 
    r1 - r138 - r62 - r63 + r94, (dldens[r, ϕ] nH2[r] + nH2'[r])/
     dens[r, ϕ] == 
    r1 - r17 - r18 + r2, (dldens[r, ϕ] nH2O[r] + nH2O'[r])/
     dens[r, ϕ] == -r143 - r144 + r18 - r2 + 
     r94, (dldens[r, ϕ] nTi[r] + nTi'[r])/
     dens[r, ϕ] == -r138 - r141 - r143 - 
     r144, (dldens[r, ϕ] nTiO[r] + nTiO'[r])/dens[r, ϕ] == 
    r138 + r141 + r143 - r144};

dH = 5*10^-1;

ic = {nH[2] == 5*10^-1/dH, nOH[2] == 3.9*10^-5/dH, 
   nO[2] == 8.5*10^-4/dH, nH2[2] == 5*10^-8/dH, 
   nH2O[2] == 7.07*10^-5/dH, nTi[2] == 9.8*10^-8/dH, 
   nTiO[2] == 10^-8/dH};                       

sol = Table[
   NDSolveValue[{eqns, ic} /. ϕ -> ϕi, {nH, nOH, nO, nH2, 
     nH2O, nTi, nTiO}, {r, 2, 6}, MaxSteps -> Infinity, 
    MaxStepSize -> 10^-2, AccuracyGoal -> 0, PrecisionGoal -> 0, 
    Method -> "BDF"], {ϕi, 0, 2*Pi, Pi}]; 

And it is working fine (Ok, not that fine because as I pointed out, this one is a small version from the one am actually working on). The code is basically ready and the results were expected but there is one statement that I wish to add to the code, which would end the NDSOLVE calculation when $t[r,ϕ]$ reaches a certain value, for example, when $t[r,ϕ] = 1200$ the NDSOLVE routine would stop and the results would be presented until that point. How can I achieve it? Which statement would be better to use?
Thank you for the help.

A:

The definition for t should be:
t[r_, ϕ_] := Te[ϕ]*Power[(1 - Sqrt[1 - (Ra[ϕ]/r)^2]), (4)^-1]

and then you do:
sol = Table[NDSolveValue[{eqns, ic, WhenEvent[t[r, ϕ] == 1200, 
       "StopIntegration"]} /. ϕ -> ϕi, {nH, nOH, nO, nH2, nH2O, nTi, nTiO}, 
        {r, 2, 6}, MaxSteps -> Infinity, MaxStepSize -> 10^-2, 
        AccuracyGoal -> 0, PrecisionGoal -> 0,  Method -> "BDF"], {ϕi, 0, 2*Pi, Pi}];
Needs["DifferentialEquations`InterpolatingFunctionAnatomy`"]; 
Plot[Through[#[t]], {t, 2, InterpolatingFunctionDomain[#[[1]]][[1, 2]]}] & /@ sol

