Thermodynamics

First Law of Thermodynamics

ΔU = Q − W — energy is conserved, just changes form between heat, work, and internal energy

The first law of thermodynamics is energy conservation — the change in internal energy of a system equals heat added minus work done by the system. ΔU = Q − W. Heat and work are different ways energy crosses system boundaries; both can change internal energy. Foundation of all energy accounting in engines, refrigerators, biology, and power generation.

  • StatementΔU = Q − W
  • U (internal energy)Total energy of all microscopic particles
  • Q (heat)Energy transferred due to temperature difference
  • W (work done BY system)Energy transferred via mechanical means
  • Sign conventionQ > 0 (heat in), W > 0 (work out)
  • Universal applicabilityMechanical, electrical, chemical, biological systems

Interactive visualization

Press play, or step through manually. The visualization is yours to drive — try it before reading on.

Open visualization fullscreen ↗

Watch the 60-second explainer

A condensed visual walkthrough — narrated, captioned, under a minute.

The law

The change in internal energy of a system equals the heat added to the system minus the work done by the system:

ΔU = Q − W

where:

  • U — internal energy (total microscopic energy of all particles).
  • Q — heat added TO the system (positive for heat in).
  • W — work done BY the system (positive for work out).

This is energy conservation applied to thermodynamic systems. Energy can change form (heat, work, internal) but is never created or destroyed.

State functions vs process variables

QuantityTypeNotes
Internal energy UState functionDepends only on T, P, V, composition
Temperature TState function
Pressure PState function
Volume VState function
Heat QProcess variableDepends on path taken
Work WProcess variableDepends on path taken
Entropy SState function(But ΔS depends on details — see 2nd law)

Common thermodynamic processes

ProcessConstraintQ, W, ΔU relations
Isothermal (constant T)ΔT = 0For ideal gas, ΔU = 0 → Q = W
Adiabatic (no heat)Q = 0ΔU = −W (work done at expense of internal energy)
Isobaric (constant P)ΔP = 0W = P·ΔV; Q = ΔU + W
Isochoric (constant V)ΔV = 0W = 0; Q = ΔU
CyclicReturns to same stateΔU = 0 → Q_net = W_net

Engines and the first law

An engine takes heat from a hot reservoir (Q_h), uses some to do work (W), and dumps waste heat to a cold reservoir (Q_c).

Q_h = W + Q_c
W = Q_h − Q_c

Efficiency:

η = W / Q_h = (Q_h − Q_c) / Q_h = 1 − Q_c/Q_h
SystemTypical efficiency
Car gasoline engine20-30%
Diesel engine30-40%
Combined-cycle gas turbine~60%
Best Rankine cycle (steam)~50%
Solar PV cell~20-25%
Bicycle (human → mechanical)~95%
Carnot ideal (T_h = 800 K, T_c = 300 K)~63%

Worked examples

Adiabatic compression of gas

A gas is compressed quickly so no heat exchange occurs (Q = 0). Work is done ON the gas (W < 0 by convention). By first law:

ΔU = Q − W = 0 − W = −W (positive since W is negative)

Internal energy increases, so temperature rises. This is why bike pumps get hot — adiabatic compression of air.

Isothermal expansion of ideal gas

Gas expands at constant temperature. For ideal gas, U depends only on T, so ΔU = 0. Therefore Q = W. The gas absorbs heat from the surroundings and does equal work on the piston.

JavaScript — first law calculations

// First law: ΔU = Q - W
function deltaU(Q, W) { return Q - W; }

// Engine efficiency
function engineEfficiency(Q_hot, Q_cold) {
  const W = Q_hot - Q_cold;
  return W / Q_hot;
}

console.log(`Engine: Q_h = 1000 J, Q_c = 700 J → η = ${(engineEfficiency(1000, 700) * 100).toFixed(1)}%`);

// Work in isobaric process
function isobaricWork(P, V_initial, V_final) {
  return P * (V_final - V_initial);
}

// Work in isothermal expansion of ideal gas
function isothermalWork(n, T, V_initial, V_final, R = 8.314) {
  return n * R * T * Math.log(V_final / V_initial);
}

// 1 mole of gas at 300 K, doubles volume
console.log(`Isothermal expansion: ${isothermalWork(1, 300, 1, 2).toFixed(0)} J`); // ~1729 J

// Adiabatic process: T·V^(γ-1) = constant for ideal gas
function adiabaticTemperature(T_initial, V_initial, V_final, gamma = 1.4) {
  // (γ - 1) is heat capacity ratio adjustment
  return T_initial * Math.pow(V_initial / V_final, gamma - 1);
}

// Compress air to half volume adiabatically (e.g., diesel)
console.log(`Adiabatic compression to half: T_initial=300K → T_final=${adiabaticTemperature(300, 2, 1).toFixed(1)}K`);
// 300 × 2^0.4 = 396 K (123°C)

// Cycle work (net)
function cycleWork(Q_in, Q_out) { return Q_in - Q_out; }

// Bicycle pump efficiency: human → mechanical work
function pumpEfficiency(useful_work, calories_burned) {
  // 1 kcal = 4184 J
  const energy_in = calories_burned * 4184;
  return useful_work / energy_in;
}

console.log(pumpEfficiency(50, 0.05).toFixed(3));  // 50 J output, ~50 cal of metabolic energy

Where the first law shows up

  • Engineering thermodynamics. Heat engines (cars, power plants), refrigerators, heat pumps, HVAC.
  • Chemistry. Heats of formation, reaction energies, enthalpy changes.
  • Biology. Metabolic energy balance, food calories, exercise physiology.
  • Astrophysics. Stellar structure (energy balance in stars), gravitational collapse.
  • Atmospheric science. Adiabatic cooling/heating in air masses, weather formation.
  • Materials science. Heat capacity, phase transitions, mechanical work on materials.
  • Industrial process. Distillation, refining, manufacturing efficiency calculations.

Common mistakes

  • Confusing Q and ΔT. Heat Q is energy transferred. Temperature change ΔT depends on Q AND heat capacity. Q = mc·ΔT for sensible heat; phase changes have Q with no ΔT.
  • Sign convention errors. Q > 0 if heat enters system. W > 0 if system does work (expansion). Mistakes here flip the formula.
  • Treating heat as a substance. Heat is energy in transit. It "flows" but isn't a thing stored in a body. (Although caloric theory historically thought so — disproved by Rumford and Joule.)
  • Forgetting it's energy CONSERVATION. The 1st law doesn't say what's possible — it says what's required. Many "possible" processes (e.g., heat flowing from cold to hot spontaneously) violate the 2nd law, not the 1st.
  • Misapplying state vs process variables. ΔU between states is well-defined. Q and W aren't — depend on path. Don't write "U = Q + W" as if Q and W were stored quantities.
  • Confusing internal energy with mechanical energy. Internal U is microscopic energy of constituents (kinetic + potential of atoms). Mechanical energy is bulk motion + position energy. Different things.

Frequently asked questions

Why is internal energy a state function but heat and work are not?

Internal energy U depends only on the state (T, P, V, composition). Two paths between the same states give the same ΔU. But Q and W depend on the PATH taken — same start and end points, different processes give different Q and W. This is why internal energy is "stored" in a system, while heat and work are "in transit." Like elevation (state) vs path-distance (process).

How does the first law relate to energy conservation?

It IS energy conservation, applied to thermodynamic systems. Total energy isn't created or destroyed; it just transfers between forms (heat, work, internal). For a closed system: ΔU = Q − W. For an open system: also include energy carried by mass flow. Same principle in mechanical/electrical/chemical contexts.

What's the difference between heat and temperature?

Temperature is a measure of average kinetic energy of particles (intensive). Heat is energy transferred due to temperature difference (extensive — depends on amount). Two cups of coffee at 70°C have same temperature but different total heat content. You can transfer heat without changing temperature (during phase changes); you can change temperature without transferring heat (compression heats gas).

How is the first law applied to engines?

Engine cycle: take heat Q_h from hot reservoir, output work W, dump waste heat Q_c to cold reservoir. By first law: W = Q_h - Q_c. Efficiency η = W/Q_h = (Q_h - Q_c)/Q_h. Maximum efficiency limited by second law (Carnot: η = 1 - T_c/T_h). Real engines: car ~25-35% efficient; CCGT power plant ~60%; ideal Carnot at typical temps ~70%.

What about chemical reactions?

First law applies. Chemical reactions release/absorb energy as heat (exothermic = heat out, endothermic = heat in). Combustion: chemical PE → heat + light + work. ΔU = Q − W still holds. Heat of formation tables (ΔH_f) used in chemistry are essentially first-law accounting.

How does this work for biological systems?

Biology is an open system — mass flows in (food, oxygen) and out (waste, CO₂). Total energy balance: chemical energy in food → ATP → muscle contractions (work) + body heat (Q). Daily 2000 kcal diet ≈ 9 MJ ≈ 100 W of energy. About 80% becomes heat, 20% becomes mechanical work in active people.

Why is W done BY the system positive?

Convention. If a gas expands and pushes a piston, the gas does positive work on the piston. From the gas's perspective, it loses energy (W is "out"), so ΔU = Q - W. The minus sign reflects the convention. Some textbooks use opposite convention (W done ON system positive); algebra works out the same.