I worked out the approximate math to figure out how much boiling water to add to a completed mash to for the mashout - to raise the temperature of the mash to 170 F to stop the enzymatic activity.
Using conservation of energy: (heat content of individual components before) = (heat content of combined mixture)
$$ H_{mws} + H_{gs} + H_{aws} = H_{wf} + H_{gf} $$
starting individual terms of heat content are:
mash water at start: $H_{mws} = C_w M_{mw} T_s$
* $C_w$ heat capacity of water
* $M_{mw}$ mass of "mash water"
* $T_s$ starting temperature
grain in mash at start: $H_{gs} = C_g M_g T_s$
* $C_g$ heat capacity of grain
* $M_g$ mass of grain
add water at start: $H_{aws} = C_w M_{aw} T_{aw}$
* $M_{aw}$ mass of add water
* $T_{aw}$ temperature of add water
final individual terms of heat content are:
water, final: $H_{wf} = C_w (M_{mw} + M_{aw}) T_f$
* $T_f$ final temperature
grain, final: $H_{gf} = C_g M_g T_f$
heat before = heat after
$$ H_{mws} + H_{gs} + H_{aws} = H_{wf} + H_{gf} $$
$$ C_w M_{mw} T_s + C_g M_g T_s + C_w M_{aw} T_{aw} = C_w (M_{mw} + M_{aw}) T_f + C_g M_g T_f $$
Solve for $M_{aw}$:
$$ C_w M_{aw} T_{aw} - C_w M_{aw} T_f = C_w M_{mw} T_f + C_g M_g T_f -C_w M_{mw} T_s - C_g M_g T_s $$
$$ M_{aw} C_w (T_{aw} - T_f) = C_w M_{mw} T_f + C_g M_g T_f -C_w M_{mw} T_s - C_g M_g T_s $$
$$ M_{aw} = \frac{C_w M_{mw} T_f + C_g M_g T_f - C_w M_{mw} T_s - C_g M_g T_s}{C_w (T_{aw} - T_f)} $$
$$ M_{aw} = \frac{C_w M_{mw} (T_f - T_s) + C_g M_g (T_f - T_s)}{C_w (T_{aw} - T_f)} $$
$$ M_{aw} = \frac{(T_f - T_s) (C_w M_{mw} + C_g M_g)}{C_w (T_{aw} - T_f)} $$
The numerator is for the materials in the starting mash mixture (water + grain) - their change in temperature times their heat capacity - this is their energy change that will happen as a result of mixing in the add water.
The denominator is for the add water - it is the heat capacity times the change in temperature for the add water, and thus the energy change of the add water.
A lot of terms in here but all on the right side are known!
$T_f = 75.5 \degree C$
* desired final temperature
* this is just an example from one recipe may vary
$T_s = 65.5 \degree C$
* measure this value to use in the calculation
* this is just an example
$C_w = 1 \frac{cal}{g \degree C}$
* specific heat of water
$M_mw = 10 kg$
* mass of the water used to mash
* this is just an example from one recipe may vary
$C_g = 0.4 \frac{cal}{g \degree C}$
* specific heat of grain
* there is wide variation here see below for references
$M_g = 3.4 kg$
* mass of grain
* this is just an example from one recipe may vary
$T_{aw} = 100 \degree C$
* temperature of add water
* typically it is boiling water but can adjust as needed
specific heat of grain references:
https://www.homebrewtalk.com/threads/specific-heat-of-grain.246356/
https://ojs.openagrar.de/index.php/JKA/article/view/375/1207