My book says that for current flowing in a wire
$Ri^2dt = mcdT + hS(T-T_0)dt $
and when equilibrium is reached
$Ri^2dt = hS(T-T_0)dt $
where R is the resistance of the conductor, i is the current, dt is a time differential, m is the mass of the conductor, c is the specific heat, dT is the differential of temperature, h is the thermal conductivity, S the section of the wire, and external environment temperature. The books says the electrical work done by the generator provoques an increase in temperature of the wire and heat is given to the external environment
I am trying to make sense of this equation by using the first law of thermodynamics,$W=Q-\Delta U $ but signs are not coming out well and I am not sure of how should I do the energy balance or if I should make the external environment part of my system or not.
If the system is composed of just the wire The work done by the generator should be - because it enters the system, so $W=- Ri^2dt $ I am not sure if the increase of temperature of the wire should be $\Delta U$ or $Q$, because internal energy is due to temperature but this is also heat being given to the environment, right? Considering it corrisponds to $\Delta U$ we have $\Delta U =mcdT $
and so the heat should be given by Newton's conduction law, and since it leaves the system it is negative, so, $Q= - hS(T-T_0)dt $, then
$W=Q-\Delta U $ yields
$-Ri^2dt=- hS(T-T_0)dt-mcdT $ which would give the right answer, but Why can't I consider $Ri^2dt$ to be instead the heat produced by the circuit and released to the environment, how would the energy balance be in that case?
One more thing, why does $ mcdT $ has temperature expressed with a differential, while $ hS(T-T_0)dt $ does not?