Prediction of temperature changes caused by water or gas entry into a horizontal well