First law of thermodynamics applied to mechanical and gravitational systems The first law says that the change in internal energy is equal to the work done on the system (W) minus the work done by the system (Q). However, can $Q$ be any kind of work, such as mechanical work? For example, does a string heat up if it is attached to a block and a tension is applied to move the block? And what about the work done on the system by gravity when an object falls? Is there any internal energy change when that happens?
 A: The work in the first law is exactly the usual work $W=\int Fdx\rightarrow\int PdV$. For point particles, this is enough to completely specify the behavior of the system using Newton's first law, or energy methods. However, for macroscopic objects, the motion of the internal components (in thermodynamics these would be particles) have some additional degrees of freedom. Statistically, we can use the temperature to tell us things about "how much" energy the system has on its own, so changes in temperature can tell us how much its energy changes.
So the first law $\Delta U=Q-W$ tells us that we have to take care of heat transfer ($Q$) as well as the work ($W$) that is done on the system. Of course, these two quantities are not completely decoupled as I have described, but this is my intuition for how this works.
A: $Q$ is heat and $W$ is work. $Q$ is considered positive when it is added to the system and work is considered positive when work is done by the system. Also remember that $Q$ and $W$ are energies in transit I.e energies associated when system moves from one state of equilibrium to another state of equilibrium. One cannot say that $Q$ amount of heat is present in the system or $W$ amount of work is present in the system for certain conditions. We can say that the body gained $Q$ amount of heat during the process and did $W$ amount of work during the process.
A: Consider a piston cylinder arrangement.
Pressure * Area equals force and this force moves by a distance ds (consider piston moving upward by a distance ds) then work done = Fdx = PAreads =Pdv.
Volume of cylinder equals Area *height
A: 
The Question 1:  The first law says that the change in internal energy is equal to the work done on the system ($W$) minus work by the system ($Q$). However, can $Q$ be any kind of work, such as mechanical work? 



*

*Answer 1: This question reveals a misunderstanding of the meaning of the terms composing the first law  $\Delta U = Q - W$. The question erroneously asserts that $W$ refers to work into the system, and $Q$ refers to work out of the system. 

*Correctly defined, Heat ($Q$) refers to the amount of Thermal Energy that flows in or out of a system. Heat flowing into a system is assigned a positive sign, and Heat flowing out reduces the internal energy of the system and is assigned a minus sign. 

*Correctly defined, Work ($W$) refers to the amount of work done to a system by the environment or the amount of work done by the system on the environment. 

*Example, Work energy leaves system a cylinder with higher pressure gas expanding and pushing a piston against atmospheric pressure. Work done by the system decreases the internal energy. Work done by the system is given a positive sign so that the first law equation $\Delta U=Q-W$ makes sense. 

*The original question poses an interesting final consideration, whether "any kind of mechanical work will increase the internal energy". Examples are always good to illustrate a principle:  
1) Compression or expansion of a gas is mechanical work, $W=P\Delta V$,  
2) Hitting a car with a hammer deforms the metal: $W= F\Delta x$. The kinetic energy of the hammer converts into other kinetic and potential energy reservoirs: a) slippage of borders between crystals, then stopping when the reduced interatomic distance (resulting in an increased repulsive field force due  the reduced proximity to the adjacent atomic cloud) exerts an equal and opposite force to equalize convert the momentum of the metallic crystal into the strain of the molecular deformation, c) Some of the energy of the impulse is converted to sound - cyclic/periodic acceleration of air molecules due to the gross mass vibration of the air adjacent to the surface of the impacted mass, as the kinetic energy of the blow transmits through the mass, periodically reflecting off its internal surfaces and in the process transmitting some of that kinetic energy to the oscillations of air molecules, and d) Some of the energy of the blow is converted to thermal energy; the blow giving momentum to a wave of atomic motion, propagating radially from the point of impact. The moving atoms will not strike all their neighbors squarely, resulting in rotation and dispersion of the impact energy, which results in a homogenization of the direction of the mass energy of kinetic energy vectors of the originally uni-directional kinetic energy of the impulse.  Such uniform/complete dispersion of kinetic energy throughout a body of mass is the de facto definition of an increased temperature.  The original energy of the blow was converted from coherent kinetic energy to the randomized kinetic energy of we recognize as thermal energy.



Question 2: Does a string heat up if it is attached to a block and a tension is applied to move the block? 



*

*Answer 2: Yes, a string is composed of physical matter with inelastic intermolecular bonds. (If the bonds were perfectly elastic, or the string perfectly rigid, it would not have heated, since no non-conservative forces would have been involved.) Pulling on the string and stretching it causes deformation (lengthening) of the intermolecular bonds. The kinetic energy supplied to the constituent atoms collide and result in atomic & molecular motion in the various available molecular degrees of freedom. Such motion is randomly oriented kinetic energy of small particles composing the system, which means the force producing Work, gives kinetic energy to the atoms, which is opposed and stopped by the increasing force of the bond lenthening, and a portion of that displacement kinetic energy results in increased thermal energy in the string.  In other words, stretch the string and it heats up.

*Thus, a portion of the stretch-displacement of the molecular bonds is converted into Work, and a portion is converted into increased temperature (increased kinetic energy of the inter-atomic/molecular bonds). This thermal energy may then dissipate into the environment, but regardless, the energy converted into thermal energy is sufficiently dispersed/disoriented from coherent energy, that the probability of it converting back into a single direction to un-stretch the string is so small that we declare that heat lost, and unrecoverable/unusable for doing future work. In this analysis, the system is the set of all atoms displaced axially; the environment is the atoms in the string which are moving thermally perpedicular or in the direction opposing to the axial force.  In other words, entropy increased by the amount of heat lost to the environment. $dS=\delta Q/T$ (Note: $\delta Q$ refers to an infinitesimal amount of heat flow/thermal energy transfer. Q itise)



Question 3: If I drop a cylinder of compressed gas from an airplane, its gravitational potential energy is converted into kinetic energy. Does this change the internal energy of the gas in the cylinder?



*

*Answer 3: No, the internal energy of the gas in the cylinder does not change when the gravitational potential energy of the whole system is converted into kinetic energy. There is no differential acceleration applied to the gas and cylinder. But, when the cylinder lands on the desert floor, the rigidity of the cylinder stops and dissipates the momentum of its mass quicker than the momentum of the gas molecules. In effect, the gas molecules slosh around, and the momentum held by the molecules is randomized. See discussion of this question.
Summary of some first law of thermodynamics principles.


*

*The first law is $\Delta U = Q - W$. 

*The first law is a statement that both heat and work are types of energy, and when added together their sum equals the change in internal energy. Heat $Q$ is the amount of thermal energy transferred into the system, and Work $W$ is the amount of mechanical work done to or by the system.

*(Note: The first law can also be written as $\Delta U = Q+W$. This form of the equation is more intuitive, since adding positive heat and positive work energy into the system increase the internal energy of the system. This form of the first law equation is used in physical chemistry.)

*Heat ($Q$) is a process term, an amount of thermal energy that has flown across a system boundary. Heat $Q$ should more properly be written as $\Delta Q$, as $Q$ always represents a differential of thermal energy transfer. But, the use of $Q$ has become common, and the incremental transfer of thermal energy is now implied by/implicit within the notation of Heat as $Q$.

*Work ($W$) is likewise a process term, the delivery of a differential of energy, an amount of mechanical energy imparted to or removed from a system by displacement against a force. That work may be converted into potential energy by displacement in a force field, or by conversion into thermal energy by various mechanisms of kinetic energy loss.  All Work requires movement, hence acceleration, which implies at least a momentary conversion into Kinetic Energy. After that displacement, the kinetic energy may convert into the potential energy of a field (e.g. electrostatic repulsion of molecular bond compression), or thermal energy (conversion of coherent kinetic energy into incoherent kinetic energy).



Question 4: Can mechanical work produce heat? And can heat produce work? 



*

*Answer 4: Yes, but this requires elaboration.

*Heat is a term used to denote the movement of thermal energy across a system border.  So, the first question that must be resolved is whether work can produce thermal energy.  And, the answer is yes.  Compression of a gas is a common example. 

*Next, the question is can that thermal energy be transmitted across a system border; and again the answer is yes.  So, clearly, work can be converted into thermal energy, which moves based upon the temperature differential between two partitions.

*Next is the question about reversible and irreversible heat flow.  If heat moves rapidly (e.g. over a finite period of time), then the transfer of heat is irreversible.  That transfer of heat is reversible if done over an infinite amount of time. 

*To illustrate the interconversion of Heat and Work, first define the boundary conditions; choose the elements included within the system (i.e. the space containing the designated mass and electromagnetic fields of concern). All other mass and radiation shall be considered "the environment". For simplification purposes, consider the system at two times $t_{initial}$ and $t_{final}$, when the system has attained equilibrium; no further net energy flows across the system boundary, and there is no further change in system state over time.

*Example of conversion of heat to work: allow Thermal Energy $Q$ to pass into the system (e.g. from a hotter liquid surrounding a cylinder-piston-gas system). The increase of the gas temperature is proportional to the increase in Internal Energy of the system. The added Thermal Energy now within the system may cause the gas to expand (i.e. the higher velocity molecules impacting on the piston face, resulting in a pressure differential across the freely moving/low friction piston, resulting in movement, and the system settling at a new position and pressure equilibrium between the inside surface and outside surface of the piston).  This is an example of Heat converting into Work. The hotter/more thermally energetic molecules of the liquid transferred their thermal energy to the cylinder wall; the wall transmitted that thermal energy to the gas; the gas molecules with more kinetic energy imparted their momentum to the piston inner surface; the atmospheric molecules imparted their momentum to the outer piston surface; the net differential in momentum moved the piston out; the piston movement accelerated atmospheric molecules giving them more kinetic energy; Work was done on the environment. 

*Example of Work conversion to Heat: Mechanical work $W$ transfers energy into or out of a system by compressing or expanding the system volume. This change of system volume $\Delta V$ is produced by a differential force $F=\Delta P*Area\ between the system and environment.  For example, a difference in force on either side of a piston separating a near-vacuum gas in a cylinder on one side, and the relatively high pressure of the atmosphere on the other, the atmospheric pressure will compress the low pressure cylinder gas, resulting in an increase of pressure to the point of equalization of pressure on both sides of the piston. The change in pressure in the cylinder inside will increase the temperature of the gas. Thus, Work energy has converted into thermal energy. Thermal energy is not called heat, but by changing the system boundaries, we can see that in fact, heat does flow internally within the cylinder as the thermal equilibrium establishes inside the system. The thermal energy is initially created by the collision of the moving piston with the gas; thus, the thermal energy is in a small volume next to the piston.  Once the thermal energy has been created from the piston kinetic energy, it may not migrate throughout the cylinder; by choosing imaginary surfaces across the cylinder, successively deeper into the cylinder from the piston, we see thermal energy/heat migrating across these boundaries.  Thus, Work converts into heat.



As stated by @levitopher, "these two quantities are not completely decoupled".



*

*Work and Heat are both kinetic energies. Heat can be converted into work, and work can be converted into heat. Heat and Work are the two types of energy that can increase Internal Energy by adding or subtracting energy from the system. Both Heat and Work are fundamentally based upon Kinetic Energy. In the Internal Energy equation, we see Heat and Work are added to quantify the change in Internal Energy. In analyzing the Internal Energy of a system, Heat and Energy must be considered separately as they cross the system boundary in different ways; both Heat and Energy have their own nature/laws/heuristic which we must apply to predict the behavior of that energy type within the system in response to the addition of that energy. 

*There is a distinction between Heat and Work, but the distinction is somewhat shallow. Work is not Heat, and Heat is not Work, but both are Kinetic Energy transmitted across boundaries. Therefore, under the appropriate conditions, the two can interconvert. 

*Thermal Energy has randomly directed Kinetic Energy. Thermal Energy is distributed over many particles, with its velocity vectors pointed in random directions. Work is produced by a coherent directed force acting against an equal and opposite force over a finite distance.

*If heat enters a system, and the system expands, it does work on the environment. Thus, heat can convert to work. 

*Example of Heat converting to work under constant pressure: Isobaric expansion (constant pressure with heat transfer into system): Gas in a cylinder with a massless and frictionless movable piston; heat is transmitted through the walls of the cylinder from the environment (and is retained); the thermal kinetic energy of the gas increases, the gas expands, the piston moves out, work is done on the environment. The process completes with the piston at rest, and $P_{internal}=P_{external}$.

*Example of frictionless isobaric expansion: Heat is converted completely into Work.  The work done on the environment is $W=P\Delta V$; the amount of work done on the environment is equal to the Heat transferred into the system, thus $W=Q$. Thus, there is no change in internal energy. The energy went in as heat and went out as work, thus the lack of change of Internal Energy.  

*Example of isobaric expansion with friction: In a real system, with friction, the movement of the movement of the piston (in response to the inflow of Thermal Energy) would have created Heat, which would have raised the temperature of the gas, and moved the piston.  If all the energy was lost as expansion, then the amount of work done by the expansion of the gas would still equal the amount of heat put into the system.  But, in actuality, some Thermal Energy will be lost through the cylinder walls, resulting in less work/displacement of the piston than the full Thermal Energy transfer. The loss of heat energy to environmental dissipation is a loss of useful energy. Thermal Energy lost to the environment translates to energy going into a reservoir where useful work cannot be extracted.

*The system boundary conditions limit the degrees of freedom of the system. The system's boundary conditions establish the possible ways that Heat and Work may interconvert. Eventually, the processes of $W\rightarrow Q$ and $Q\rightarrow W$ come equilibrium within and between the system and environment.

*The interconversion of Work and heat is the basis of refrigeration/heating and generators/engines.

*Work can be done on a system by adiabatic, isothermal, isobaric, and isentropic processes. Heat may be transferred into a system with constant Temperature, Constant volume, Constant Pressure, or Constant Entropy processes. 





*

*The same process may be done reversibly or irreversibly. A reversible process stays in equilibrium at every moment of the transfer of heat and work. In other words, it's still possible, given the probabilities of the situation for the movement or heat transfer to reverse without requiring a force or temperature differential.  An irreversible process moves too quickly for the system to maintain equilibrium at each moment. The result is an increase in the disorder/randomness of the system, making the energy lost to thermal energy irretrievable/non-useful.

*Returning to our example of irreversible work: a piston compresses a gas quickly (i.e. in a finite time period), the gas heats near to the piston; over time that temperature gradient dissipates into uniformity throughout the cylinder and with the environment, and the piston moves to its new equilibrium position.

