# Change of internal energy with time-variable mass

I hope there’s a thermodynamic superhero to the rescue…

The problem seems simple. There’s an open control volume (of fixed volume), filled with an incompressible fluid, that changes its density with temperature. Since temperature does change over time, the mass of fluid in the control volume changes.

Now, in textbooks and examples there’s always one of these two statements:

• “Since mass in the control volume is constant, …”
• “Since only differences in internal energy […], reference states can be chosen arbitrarily.”

The latter statement also implies that one can calculate the difference of the internal energy by integrating the specific heat between the two temperatures, so no absolute value for the internal energy is ever needed.

Now, in the scenario at hand, the internal energy in the control volume varies both because of changes of specific internal energy, and of mass in the control volume:

Here, the internal energy pops up explicitly, and its absolute value does have an impact on the dynamics of the system. (On the right-hand side, there’s heat flows and mass flows into / out of the control volume, and one would like to rearrange the equation to have an expression for the change of the temperature as an ordinary differential equation.)

Do I get something wrong? Already made all colleagues here at work scratching their heads…

1 Like

I don’t fully understand the problem definition, but here are some thoughts:

One issue is how to treat the work done as the volume expands. Also µ might not be zero.

Do you really need the internal energy U?
The Gibbs free energy is more natural and takes into account the work done by the material as it expands against the (constant?) external pressure.

In this case, the system to look at is an isothermal-isobaric ensemble.

Equation (1) of
Han, Kyu-Kwang, and Hyeon S. Son. “On the Isothermal-Isobaric Ensemble Partition Function.” The Journal of Chemical Physics 115, no. 16 (October 22, 2001): 7793–94. https://doi.org/10.1063/1.1407295.
has the partition function Z = 1/ν(p,T) ∫_0^∞e^{-βpV} Q dV, from which one can get the Gibbs free energy for the entire system. G is extensive, so you can allocate it to the part of the fluid that is still in the control volume. G = U + pV - TS, so you can also get U this way.

Another way to look just at the control volume would is the heat capacity at constant volume, then the Mayer equations Cp - Cv = R (for an ideal gas) or VT α²/β (otherwise)
α = CTE, β=isothermal compressibility, give a value that has been corrected for thermal expansion. If you have the equation of state of the material you can probably find a more accurate relation than the one above.

Wow, thanks.

What I actually need is an ODE for the temperature of the fluid in the control volume (assumption of homogeneous distribution / perfect mixing). With constant mass, there is only a derivative of the internal energy, which is expressed as the specific heat (cv = cp for incompressible fluids) times the derivative of the temperature – so the internal energy does not occur explicitly anymore.

What would be the correct quantity and corresponding equation/relation, that allows to “map” between this energy-related quantity and the temperature (as a “level variable”)?

1 Like

For the fluid flowing out of the control volume you can probably assume it at the same temperature as the fluid in the volume. But what about the fluid flowing into the volume (sinking temperature)?

Yep, that’s another question I will have to deal with. But first I have to become clear about the left-hand side, i.e. how to handle the explicit occurrence of u(t) as absolute value.

Something is wrong with the assumption of an incompressible fluid.
I assumed that your volume is fixed, and the material escapes and does work against the external constant pressure reservoir (the mass changes).
In that case dH = dU + pdV.
For an incompressible fluid the 2nd term is 0, but that is not the case here. So the assumption that cv=cp is not correct.
If nothing can flow out of the control volume as the material expands, there will be a corresponding (potentially very large) dP.

Disclaimer: I am definitely not a thermodynamics expert, the following is just an attemp of a physical common sense.

Internal energy of the control volume is not the value you can (easily) measure. What you can probably measure is the energy added (+ or -) to the whole system. Part of this energy stays in the control volume and part escapes into the environment with the fluid lost.

My intuition, if you take into account both parts, you would get
dE/dt = m(T) * Cp(T) * dT/dt
where m(T) is the mass of the fluid in the control volume.

Here’s a sketch of a minimum example for the problem:

A vessel with a constant volume is heated (or, more generally, heat is added to or removed from the fluid in it). The fluid is incompressible, but its density (as well its specific heat) change with temperature. There is a second reservoir, an open tank, with a very thin pipe connecting the two. The only flow through this connection is the one driven by the expansion (or contraction) of the fluid in the vessel.

The control volume (dotted line) is the lower vessel only, since only this one is of interest. There, due to fluid circulation in it, the temperature is effectively almost homogeneous. I need to obtain the equation for the temporal change (i.e. derivative w.r.t. time, \dot T(t) = \partial / \partial t (T(t))) of the temperature of the fluid in the control volumle (= the bottom vessel). Known are the constant volume of the vessel (V), relations for the density and specific heat of the fluid as a function of temperature (\rho(T), c(T)), and the heat flow into the fluid (\dot Q(t)). I thought coming up with this equation would be straightforward and a matter of 2 minutes…

The temperature of the fluid in the upper tank is not known. I first want to obtain the equation for the temperature in the bottom vessel, assuming some temperature in the upper tank (T_\text{tank}(t)). With that equation, I could then assess the error in the dynamics of the temperature change in the bottom vessel introduced by errors in the estimated / assumed temperature of the fluid in the upper tank. As @Eben60 correctly mentioned, there is only an error if the fluid contracts (i.e. the density increases, i.e. the temperature decreases, i.e. heat is taken out of the fluid / control volume), since then, fluid from the upper tank is drawn into the lower vessel.

Thanks for the diagram.

For the inner energy U, you have a PdV term (and a term on pressure vs T). You don’t have an incompressible fluid (the density changes), so you can’t assume the specific heats are the same. For example, for water

U can be calculated from the first law of thermodynamics:

dU = TdS - pdV + dU_{mix}

dU_{mix} is the energy you get by mixing in the cold fluid from the reservoir.

dS = (∂S/∂V)_T \cdot dV + (∂S/∂T)_V \cdot dT

dU = T[(∂S/∂V)_T \cdot dV + (∂S/∂T)_V \cdot dT] - pdV + dU_{mix}

(∂S/∂T)_V = C_v / T

dU = T(∂S/∂V)_T \cdot dV + C_v \cdot dT- pdV + dU_{mix} (*)

(∂S/∂V)_T depends on the material and can be either derived from the equation of state for your fluid or is tabulated somewhere, it is the same as (∂P/∂T)_V.

(*) is the equation for U for a system as a function of T and V. You’ll need to correct for only heating part of the fluid. T dS is the heat flow into your system.

What does this equation reduce to if we (nevertheless) assume the fluid to be incompressible (and just accept the error introduced by it)? I do not have access to tabulated data or know the equation of state for all fluids, except for water.

We do stay significantly below the boiling point of the fluids, either by limiting temperature (on systems that are open w.r.t. ambient), or by increasing pressure (closed systems). So the assumption of an incompressible fluid should not introduce too large errors, considering the cp, cv diagram of water at 90°C…

Set (∂S/∂V)_T=0. C_v you can find in a table or calculate using Mayer’s equation given above from the mechanical parameters (for water difference is small around 0C due to its anomaly, this not the case for all fluids). If you need to assume an incompressible fluid, assume both are equal.

If you need data about fluids, i would recommend Clapeyron.jl for obtaining such data:

using Clapeyron
model = IAPWS95() #water reference equation of state
atm_p = 1.0e5
cpw_l(T) = isobaric_heat_capacity(model,atm_p ,T, phase = :liquid) # H = integral(cp dT)
cvw_l(T) = isochoric_heat_capacity(model,atm_p ,T, phase = :liquid)  # U = integral(cv dT)


That is a little slow, (in the sense that you perform a full volume calculation for each call), but you could use the EoS values to create your own tabulated values.

1 Like

Thanks for the hint @longemen3000, will have a look at Clapeyron.jl in the future.

So, for an (assumedly) incompressible fluid, we have:

dU = C \cdot dT - p \cdot dV + dU_{mix}

If I apply this to the control volume of the minimal example, and explicitly indicate all dependencies on temperature, I get:

d(V \cdot \rho(T) \cdot u(T)) = V \cdot \rho(T) \cdot c(T) \cdot dT + u_{mix}(T_{mix}) \cdot dm_{mix}

The p \cdot dV term vanishes, since V = const (or is this not correct in this context?). The flow of fluid from the tank to the vessel is dm_{mix}. If the temperature increases, the flow is form vessel to tank (dm_{mix} < 0) and thus T_{mix} = T.

Then I’d use this as left-hand side and have the heat flows on the right-hand side:

dU(t) = dQ(t)

Relating the differentials to time and rearranging then gives (explicitly indicating the dependencies on time):

\dot T(t) = \frac{\dot Q(t) - u_{mix}(T_{mix}) \cdot \dot m_{mix}}{V \cdot \rho(T(t)) \cdot c(T(t))}

Two things are irritating (for my intuition-driven gut feeling ):

• We again end up with an explicit occurrence of the internal energy (u_{mix}), with no reference level to which a difference is taken. So deliberately choosing any reference level (at which u = 0) would influence the dynamics (i.e. rate of change of the temperature) of the system and thus somehow feels to not be allowable.
• Heat added to the control volume (\dot T) and energy added to the control volume by mass transfer (u_{mix} \cdot \dot m_{mix}) should have the same sign.

Mass Balance:

dm/dt = ṁ_in -  ṁ_out
dm/dt = -∆ṁ


Energy balance:

dE/dt = sum(Ė_in) - sum(Ė_out) +  Q̇ +  Ẇ_tot  #Energy balance
Ė =  ṁ* Ê # Energy flow is just the amount of component multiplied by the specific energy
dE/dt = -∆ṁ(Û+ Ê_k + Ê_p) +  Q̇ +  Ẇ_tot  #Energy balance
Ẇ_tot  = Ẇ_flow + Ẇ_other
Ẇ_flow = - ∆ṁPv̂ #the work exerted on a open system is equivalent at a piston
dE/dt = -∆ṁ(Û+ Ê_k + Ê_p -  Pv̂) +  Q̇ +  Ẇ_other
dE/dt =  -∆ṁ(Û+ Ê_k + Ê_p -  Pv̂) +  Q̇ +  Ẇ_other
#H = U + PV, E= U+ E_k + E_p
d(U+ E_k + E_p)/dt =  -∆ṁ(Ĥ+ Ê_k + Ê_p) +  Q̇ +  Ẇ_other


E_k , E_p, Ẇ_other ≈ 0
then:

dU/dt =  -∆ṁ(Ĥ) +  Q̇


we now mix the two balances:

U = mÛ
dU/dt = Û*dm/dt + m*dÛ/dt
dU/dt = -∆ṁÛ+ m*dÛ/dt


and we order:

m*dÛ/dt =  -∆ṁ(Ĥ)  ∆ṁÛ +  Q̇
m*dÛ/dt = -∆ṁPv̂ + Q̇


if we now write explicitly the dependences:

m(t)*dÛ(p,T)/dt = -∆ṁ(t)*Pv̂(p,T) + Q̇(t)


i suppose you are working with low pressures, so you can assume that your specific internal energy remains constant:

dÛ(p,T)/dt = 0


then the system simplifies to:

Q̇(t) = ∆ṁ(t)*Pv̂(p,T) =  ∆ṁ(t)*Pv̂(T)


does it make any sense?

Up to where you combine the balances it seems to be reasonable. The problem was that I exclusively looked at the left-hand side. When also considering the right-hand side, i.e. the enthalpy addition by the mass flow into the control volume, one again ends up with a difference of internal energies. This was the missing “link”; thanks a lot!

Let’s finish this. You define the direction of the flow to be positive when it leaves the control volume. The equations get nicer when we define it the other way around. The mass in the control volume is

m(T) := m_{cv}(T) = V \cdot \rho(T)

and thus its time derivative is

\dot m(T) = V \cdot \dot \rho(T) = V \cdot \rho'(T) \cdot \dot T.

So, naturally, this is also the mass flow going into the control volume, from the tank (since this is the only flow that can make up this change of mass in the control volume).

We also have to keep in mind that if the flow is from the tank into the vessel, the temperature of this flow is not the same as in the vessel. I indicate this by an index \Delta. Also, I denote specific quantites by lower-case letters, so h_\Delta is the specific enthalpy of the flow between tank and vessel. The one equation resulting from the combination of mass and energy balances thus is:

\dot U(T) = \frac{d}{dt}(m(T) \cdot u(T)) = \dot m(T) \cdot u(T) + m(T) \cdot \dot u(T) = \dot m(T) \cdot h(T_\Delta, p) + \dot Q(t)

Collecting terms:

\dot m(T) \cdot (u(T) - h(T_\Delta, p)) + m(T) \cdot c(T) \cdot \dot T = \dot Q(t)

Expanding m(T) and \dot m(T):

V \cdot \rho'(T) \cdot \dot T \cdot (u(T) - h(T_\Delta, p)) + V \cdot \rho(T) \cdot c(T) \cdot \dot T = \dot Q(t)

And collecting terms again:

V \cdot \dot T \cdot \left( \rho'(T) \cdot (u(T) - h(T_\Delta, p)) + \rho(T) \cdot c(T) \right) = \dot Q(t)

With h(T_\Delta, p) = u(T_\Delta) + p \cdot \rho(T_\Delta)^{-1} and rearranging for \dot T, the ODE for the temperature is:

\dot T = \frac{\dot Q(t)}{V \cdot \left( \rho'(T) \cdot (u(T) - u(T_\Delta) - p \cdot \rho(T_\Delta)^{-1}) + \rho(T) \cdot c(T) \right)}

Where we only have a difference in the internal energies,

u(T) - u(T_\Delta) = \int_{T_\Delta}^T c(\tau) d\tau,

which can be explicitly found by the differenc of the antiderivative of c(T). The temperature of the flow between tank and vessel depends on the flow direction:

T_\Delta = \left\{ \begin{array}{l} T, \text{if } \dot m(T) < 0 \\ T_\text{tank}, \text{otherwise} \end{array} \right.

Does this make any sense? I have to digest it first, then do some plausibility checks… but dont’ have time for it right now.

Let’s have control volume V at initial temperature T and constant pressure P₀ filled with a liquid having density ρ(T) and constant pressure heat capacity Cₚ(P₀, T) = Cₚ(T). The mass of the liquid V*ρ(T) = m(T)

Now we add a small amount of heat ΔQ to the system. Part of the liquid stays in the control volume and gets heated by ΔT. Some small quantity Δm leaves the control volume. At the moment of leaving it is at a temperature between T and T+ΔT, lets designate it as T+ΔT*f where 0 < f < 1 . Some mixing effects could influence the temperature of this part of liquid, but only after it leaves the control volume and thus have no influence back on it, thus to be ignored

The heat quantity needed to heat the liquid left within the control volume by ΔT is ΔQ₁ = (m(T)-Δm)*Cₚ(T)*ΔT by the definition of constant pressure heat capacity. The heat going to the liquid leaving the control volume is ΔQ₂ = Δm*Cₚ(T)*ΔT*f .

Now ΔQ = ΔQ₁ + ΔQ₂ = (m(T)-Δm)*Cₚ(T)*ΔT + Δm*Cₚ(T)*ΔT*f = m(T)*Cₚ(T)*ΔT + Δm*ΔT*f

If m(T) =V/ρ(T) is diffentiable function, which physicaly means we have no phase transitions, then
dQ/dT = limit(ΔQ/ΔT) = m(T)*Cₚ(T) = Cₚ(T)*V*ρ(T)

dQ/dT = Cₚ(T)*V*ρ(T)

Or am I very naive and overlook something important?