I want to get results of integral of PDE model result. The PDE model is 1D heat diffusion equation with Neumann boundary conditions. The key problem is that integral of PDE model result take too much time to calculate, and I haven't gottten the results yet. I consider the following code:
h = 6000;
a = 200;
Dif = 3.67*10^-14*10^18;
Ni = 1;
deqN = D[u[t, x], t] - Dif*D[u[t, x], {x, 2}] ==
NeumannValue[0, x == 0] + NeumannValue[0, x == h];
ic = u[0, x] == If[0 <= x <= a , Ni, 0]
sol = NDSolveValue[{deqN, ic}, u, {t, 0, 60}, {x, 0, h},
Method -> {"MethodOfLines",
"SpatialDiscretization" -> {"FiniteElement",
"MeshOptions" -> {"MaxCellMeasure" -> {"Length" -> 0.1}}}}];
Plot3D[sol[t, x], {t, 0, 60}, {x, 0, h}, PlotRange -> Full,
PlotStyle -> Automatic, ColorFunction -> "DarkRainbow"]
Plot[NIntegrate[sol[t, x], {x, 0, a}], {t, 0, 60}]
I successfully got a result of the PDE calculation, but the code take lot of time in the integral part. It doesn't finish even I wait for a few hours.
Any suggestions how to speed it up or fix it?

core = u /. sol[[1]]; mid[t_?NumericQ] := NIntegrate[core[t, x], {x, 0, a}, Method -> {Automatic, "SymbolicProcessing" -> 0}]; Plot[mid@t, {t, 0, 60}] // AbsoluteTimingwill resolve your problem. – xzczd Mar 05 '17 at 14:30NDSolveValueso your suggestion doesn't seem to immediately run. – Chris K Mar 05 '17 at 22:10Methodvalues are overkill. I simply usedsol = NDSolve[{deqN, ic}, u, {t, 0, 60}, {x, 0, h}, Method -> {"MethodOfLines", "SpatialDiscretization" -> {"FiniteElement"}}]as @Andre suggested here and it ran very quickly. – Chris K Mar 05 '17 at 22:12mid[t_?NumericQ] := NIntegrate[sol[t, x], {x, 0, a}, Method -> {Automatic, "SymbolicProcessing" -> 0}]; Plot[mid@t, {t, 0, 60}] // AbsoluteTimingis enough :) – xzczd Mar 06 '17 at 03:19