Stack Exchange
1D diffusion problem: Troublesome NeumannValue
Bug introduced in 13.1 or earlier and fixed in 13.2.0

Mathematica solves the diffusion problem (two Neumann-conditions)
U = NDSolveValue[{Derivative[1, 0][u][t, x] ==Derivative[0, 2][u][t, x] +
NeumannValue[-u[t, x], x == 0]+
Boole[t <= 10] (1 +  $MachineEpsilon)   NeumannValue[1,x == 1], u[0, x] == 0}, u, {x,0, 1}, {t, 0, 20}  ]

Plot3D[U[t, x], {t, 0, 20}, {x, 0, 1}, PlotRange -> All,AxesLabel -> {t, x, u}]

without problems.

But the second Neumann-condition
Boole[t <= 10] (1 +  $MachineEpsilon)   NeumannValue[1,x == 1]

seems to be very sensitive near Boole[t <= 10]  1!
If I change to "undisturbed Neumann condition"
U = NDSolveValue[{Derivative[1, 0][u][t, x] ==Derivative[0, 2][u][t, x] +NeumannValue[- 
u[t, x], x == 0]
+ Boole[t <= 10] 1   NeumannValue[1,x == 1], u[0, x] == 0}, u,{x,0, 1}, {t, 0, 20}  ]

Mathematica gives the wrong(?) solution U[t,x]==0
What's wrong here?
Thanks!

"Thereby the second Neumann-condition" I think by "thereby" you mean "But"?

Actually $MachineEpsilon isn't necessary. Boole[t <= 10] 1. NeumannValue[1, x == 1] is enough. I believe this is a parsing error i.e. when the coefficient of NeumannValue[…] doesn't involve MachinePrecision number, the whole NeumannValue[…] is missing. Let's wait for confirmation from user21 :) .

@xzczd Thanks, I changed the wording.

@xzczd, I started looking into this. It seems the problem is that compiled Bool will return an integer but the compiled code expects a real. Let's see if I can improve on that. This is really a special case as Bool can change domain it returns; a bit like Sqrt.

@user21 Good to know that Boole causes the problem. Thanks!

This is a bug. The problem is that a compiled Boole will return an integer but the compiled FEM code expects a real. This is really a special case as Boole can change domain it returns; a bit like Sqrt. I have committed a fix for this for version 13.2. In the mean time use
1.*Boole[expr]

to force this to be a real value. Sorry for the trouble and thanks for reporting.
