For our balance, we will choose an **arbitrary** fixed (in
space) control volume. Thus, it is an *open* system (i.e.,
one through which mass may flow). Accounting for energy within that
volume (and transfer with surroundings) we get:

rate of accumulation of energy in CV | = | net rate of energy transport
into CV (by flow) |
+ | net rate of energy
transferred to material in CV |

We denote *e* as the total energy per unit mass, and note
that energy can be transferred to the material in the CV through
both heat (thermal energy) flow and work. Therefore, we can write
this in equation form as:

$\displaystyle{\frac{d}{dt}\int\int\int_{CV} e \rho dV = -\int\int_{CS} e \rho \left(\mathbf{v}\cdot\mathbf{n}\right ) dA +q +W}$

- *e*, the total energy per unit mass, is comprised of
mechanical (kinetic and potential) as well as internal (thermal)
energy

- q represents the heat that is transferred to the material within the volume

- W represents *any* work done on or by the system (the
chosen sign convention is that work done *on* the system is
positive).

We note that the energy per unit mass may have an internal energy component as well as a kinetic and potential energy component, so that we can write it as:

$\displaystyle{e = \hat U + \frac{1}{2}v^2 + gz}$

We further note that the work can have several components:

$\displaystyle{W = W_s + W_\sigma + W_\tau}$

where W_{s} is the shaft work and the other two
components ($\displaystyle{ W_\sigma}$ and
$\displaystyle{W_\tau}$) correspond to stresses at the boundaries
(both normal and shear). If we extract the pressure from the normal
stresses we can write our work in the form:

$\displaystyle{W = W_s - \int\int_{CS}P\left(\mathbf{v}\cdot \mathbf{n}\right ) dA + W_\mu}$

where the pressure stresses now make up what is typically called the "flow work" term, and remaining viscous stresses are lumped into the term $\displaystyle{W_\mu}$, which is only non-zero if we have a non-zero shearing velocity on the control surfaces.

Combining these observations into a final form of the macroscopic energy balance equation, we get

$\displaystyle{\frac{d}{dt}\int\int\int_{CV} \rho\left(\hat U +\frac{1}{2}v^2 + gz\right ) dV = -\int\int_{CS} \rho\left(\hat U +\frac{1}{2}v^2 + gz + \frac{P}{\rho}\right ) \left(\mathbf{v}\cdot\mathbf{n}\right ) dA +q +W_s + W_\mu}$

Derive and use a macroscopic energy balance