Lesson 2 of 15

The First Law of Thermodynamics

The First Law of Thermodynamics

The First Law of Thermodynamics is a statement of conservation of energy applied to thermodynamic systems. It relates the change in internal energy of a system to the heat exchanged with its surroundings and the work done.

The Equation

ΔU=QW\Delta U = Q - W

Where:

  • ΔU\Delta U is the change in internal energy of the system (J)
  • QQ is the heat added to the system (J) — positive when heat flows in, negative when it flows out
  • WW is the work done by the system (J) — positive when the system expands, negative when compressed

Sign Conventions

QuantityPositiveNegative
QQHeat absorbed by systemHeat released by system
WWWork done by systemWork done on system
ΔU\Delta UInternal energy increasesInternal energy decreases

Work by Expansion

When a gas expands against a constant external pressure PP, it does work on the surroundings:

W=PΔVW = P \Delta V

Where ΔV=VfinalVinitial\Delta V = V_{\text{final}} - V_{\text{initial}} is the change in volume. If the gas is compressed, ΔV<0\Delta V < 0 and the work is negative (work done on the system).

Examples

Isothermal process (constant temperature): If a gas absorbs 1000 J of heat and does 1000 J of work expanding, then ΔU=10001000=0\Delta U = 1000 - 1000 = 0. The internal energy does not change — consistent with constant temperature for an ideal gas.

Adiabatic compression: If no heat is exchanged (Q=0Q = 0) but 500 J of work is done on the gas (W=500W = -500), then ΔU=0(500)=500J\Delta U = 0 - (-500) = 500\,\text{J}. The gas heats up.

Your Task

Implement the two functions below using the First Law equations.

Python runtime loading...
Loading...
Click "Run" to execute your code.