Let's consider a piston pushing on a gas in a tube with a force F causing a change in height Δy. Then the work done by the piston is given as W = FΔy. The force F can be expresses in terms of the pressure P exerted by the piston and the cross-sectional area of the tube as F = PA. Therefore W = PAΔy. And AΔy is equal to the change in volume ΔV of the gas.
W = PΔV
SI units Pa for pressuree and m³ for volume should be used to give Joules. If liter is used for volume then kpa should be used for pressure to get Joules.
A state function is a function whose change depends only on the initial and final states of the system irrespective of the process that brought about the change. Thus, a change in a state function can be expressed as the difference between the values of the function at the final state and the initial state of the system. If Z is an arbitrary state function, then ΔZ = Zf - Zi. The variables that determine the state of a gas are its temperature, volume and pressure. This means, a state function is a function that depends on these variables only. The total internal energy ( U ) of a system is a state function. Its change is equal to the difference between its values at the final and initial states.
ΔU = Uf - Ui
Work and heat are not state functions. They depend on the process that brought about the change and not on the initial and final state. But the difference between heat and work depends on the initial and final states of the system only. The first law of thermodynamics states that the difference between heat ( Q ) and work ( W ) is a state function and is equal to the change in the total internal energy of the system. The following is a mathematical statement of the first law of thermodynamics.
ΔU = Q - W
Using the expression for work in terms of pressure and volume, the following alternative equation for the first law of thermodynamics can be obtained.
ΔU = Q - PΔV
A cyclic process is a process where a system returns to its initial state. In other words, a cyclic process is a process where the initial and final states are identical. For a cyclic process Uf = Ui and ΔU = 0. Therefore for a cyclic process Q = W.

W = QH - QC
W stands for the work done by the heat engine per cycle. QH and QC stand for the heat taken from the hot reservior per cycle and heat given off to the cold reservior per cycle respectively . The efficiency ( E ) of the engine is equal to the ratio between the output energy and input energy. The input energy is equal to the heat taken off from the hot reservior and the output energy is equal to the work done by the engine. That is E = ( QH - QC ) ⁄ QH
E = 1 - QC ⁄ QH
EC = 1 - TC ⁄ TH
If the efficiency of a Carnot engine is to be 100%, the temperature of the cold reservior ( TC ) has to be zero °K which is virtually impossible. This is essentially a statement of the second law of thermodynamics. The second law of thermodynamics states that it is impossible to have a heat engine with a 100% efficiency. In other words, it is impossible to have a heat engine that converts all of the heat energy obtained from the hot reservior to mechanical energy.
ΔS = Sf - Si
Entropy of a system is related with the freedom of movement of the particles comprising the system. For example the liquid state of a system has more entropy than the solid state of a system because the particles of a liquid have more freedom of movement than molecules of a solid do. Similarly, the gas state of a system has more entropy than the liquid state of a system because gas particles have more freedom of movement than particles of liquid.
Since freedom of movement of particles depends on the heat supplied to the system, entropy is related with the amount of heat supplied to a system. Change in entropy is equal to the amount of heat supplied (lost) per a unit temperature ( in °K).
ΔS = Q ⁄ T
Q is amount of heat supplied or lost at a temperature T ( in °K ). The unit of measurement for entropy is J ⁄ °K. In most cases the temperature would change during the process of the supply or loss of heat. In those cases methods of calculas are used to calculate the change in entropy. But during phase changes the temperature remains constant. As a result change in entropy for phase changes can be calculated easily.
The second law of thermodynamics can be stated in terms of the natural tendency of the entropy of a system. The second law of thermodynamics states that the entropy of an isolated system can only increase. In other words the entropy of an isolated system can go only from order to disorder. Since the universe as a whole can be treated as an isolated system, the entropy of the universe can only increase. Or, the universe can go only from order disorder.
Heat flows from high temperature system to a low temperature system because of the second law of thermodynamics. The heats ganed or lost by each system are numerically equal. But the change in entropy which is heat divided by temperature is numerically smaller for the hotter object because of the division by a higher temperature. If the sum of the changes of both entropies is to be positive as called for by the second law of thermodynamics, the change in entropy of the colder system (with bigger change in entropy) should be positive. That is the colder system should gain heat and the hot system should loss heat. In other words, to be consistent with the second law of thermodynamics, heat must flow from a high temperature system to a low temperature system.
The entropy of non-isolated systems may not necessarily increase, because entropy is not the only function that determines the tendency of nature. Two state functions determine the tendency of natural systems. These are entropy and enthalpy ( H ). Enthalpy is essentially the energy of a system ( energy at constant pressure to be exact ). The natural tendency of nature is to decrease its enthalpy and to increase its entropy. An absolute tendency of nature may be obtained by combining these functions into a single function that is called Gibb's function ( G ) or free energy. Free energy of a system is defined to be the difference between enthalpy and the product of temperature and enthropy.
G = H - TS
Nature tends to go in a direction that decreases its free energy. For example if the the free energy of the reactants of a reaction is greater than the free energy of the products, the reaction will take place spontaneously. But if the free energy of the reactants is less than the free energy of the products, the reaction can not take place without the supply of external energy.