Thermodynamics is the study of the relationship between heat (or energy) and work. In other words, thermodynamics looks at how we can put our energy into a system (whether it is a machine or molecule) and make it do work. Alternatively, we might be able to do some work on system and make it produce energy (like spinning the turbines in a power station to produce electricity).
In chemistry, we sometimes speak more broadly about "energetics" of reactions (rather than thermodynamics), because energy given off during a reaction may simply be lost to the surroundings without doing useful work. Nevertheless, the ideas are the same: energy can be added to a set of molecules in order to produce a reaction, or a reaction can occur between a set of molecules in order to release energy.
Thermodynamics, on the other hand, is really concerned with the overall energy change from the beginning of a reaction to the end. It compares the energies of two sets of molecules to each other: the nergies of the reactants and the energies of the products.
A thermodynamic cycle consists of a linked sequence of thermodynamic processes that involve transfer of heat and work into and out of the system, while varying pressure, temperature, and other state variables within the system, and eventually return the system to its initial state.
Thermodynamics is concerned with the change in
The internal energy,
An adiabatic process is one in which no heat is gained or lost by the system. The first law of thermodynamics with Q=0 shows that all the change in internal energy is in the form of work done.
An important alternative way the gas can expand is through an adiabatic process: if the cylinder is insulated so it is thermally isolated from its surroundings,
which can be integrated for a reversible expansion between the state ($V_{1}, T_{1})$) and ($V_{2}, T_{2})$) to give
This expression is usually presented in the quivalent form
Another important thermodynamic cycle, the Carnot cycle, is based on a sequence of reversible isothermal and adiabatic processes between four states, A, B, C, and D.
I.
II.
III.
IV.
This Python script to illustrate the Carnot Cycle with labelled plot for states A, B, C, and D with following parameters:
$V_{1}=0.2 m^{3}$ $T_{hot}=800 K$ - Isothermal compression ratio,
$r_{i}=V_{B}/V_{A}=2$ - Adiabatic compression ratio,$r_{a}=V_{C}/V_{B}=2$
Demonstrate that the efficiency, defined as
Step 1: Set up and use function
import numpy as np
import matplotlib.pyplot as plt
from scipy.constants import R
# number of molecule gas
n = 1def get_p(V, T):
"""
Return the pressure of 1 mol of an ideal gas at (V, T).
"""
return n * R * T / V
def plot_isotherm(Vmin, Vmax, T, c='k'):
"""
plot a single isoterm for temperature T between Vmin and Vmax.
Returns the arrays of V, p values defining the isoterm.
"""
V = np.linspace(Vmin, Vmax, 1000)
p = get_p(V, T)
plt.plot(V, p, c=c, label=f'{T:.1f} K', lw=1)
return V, p
def plot_adiabatic(Vmin, Vmax, p0, V0, c='k', gamma=5/3):
"""
plot a single adiabatic for between Vmin and Vmax.
p0, V0, is a fixed point on the adiabatic, the function returns the arrays of V, p values defining the adiabatic.
"""
V = np.linspace(Vmin, Vmax, 1000)
p = p0 * (V/V0)**(-gamma)
plt.plot(V, p, c=c, lw=1)
return V, p
def carnot_cycle(V1, T_high, r_i, r_a):
"""
Plot a p-V diagram for a Carnot Cycle for an ideal gas starting at a compressed state (V1, T_high)
defined by isothermal compression ratio
r_i = V2/V1 and adiabatic compression ratio,
r_a = V3/V2.
"""
# Constant-volume heat capacity, "gamma" parameter (Cp/Cv)
C_V, gamma = 3/2 * R, 5/3Step 2: Volumes at each state
# Calculate the state variables at each stage of the cycle.
V2 = V1 * r_i
V3 = V2 * r_a
V4 = V3 * V1/V2-
$V_{1}$ : initial compressed volume. -
$V_{2}$ : after isothermal expansion (ratio,$r_{i}$ . -
$V_{3}$ : after adiabatic expansion (ratio$r_{a}$ . -
$V_{4}$ : after isothermal compression, derived so the cycle closes.
Step 3: Pressures and Temperature
# State Pressure
p1, p2 = get_p(V1, T_high), get_p(V2, T_high)
T_low = T_high * (V2/V3) ** (gamma - 1)
p3, p4 = get_p(V3, T_low), get_p(V4, T_low)- Compute pressures at each state using ideal gas law.
-
$T_{low}$ is found from adiabatic relation,$TV^{\gamma-1}$ .
Step 4: Plot the cycle
# Plot the isotherms and adiabatic for the cycle.
plot_isotherm(V1, V2, T_high, c='r')
plot_adiabatic(V2, V3, p2, V2, c='g', gamma=gamma)
plot_isotherm(V4, V3, T_low, c='b')
plot_adiabatic(V1, V4, p1, V1, c='m', gamma=gamma)- Red = isothermal expansion (high temperature).
- Green = adiabatic expansion.
- Blue = isothermal compression(low temperature).
- Magenta = adiabatic compression.
Step 5: Work and Heat calculation
# Step 1: isothermal expansion, V1 => v2 AT T_high
w1 = - n * R * T_high * np.log(V2 / V1)
q1 = -w1
# Step 2: adiabatic expansion, (V2, T_high) => (V3, T_low)
w2 = n * C_V * (T_low - T_high)
q2 = 0
# Step 3: Isothermal compression, V3 => V4, at T_low
w3 = -n * R * T_low * np.log(V4 / V3)
q3 = -w3
# Step 4: adiabatic compression, (V4, T_low => V1, T_high).
w4 = n * C_V * (T_high - T_low)
q4 = 0- Work and heat are calculated for each step.
- isothermal
$w = -nRT(V_{final}-V_{initial})$ . - Adiabatic,
$w = nC_{V}(T_{final}-T_{initial})$ . - Heat
$q$ is zero for adiabatic steps.
Step 6: Efficiency
# Total energy input through heating:
q_in = q1
# Total work done *on* the gas:
w_total = w1 + w2 + w3 + w4
# Efficiency
eta = -w_total /q_in
print('Efficiency = {:.1f} %'.format(eta * 100))- Efficiency = work output/heat input
- Prints Carnot efficiency.
Step 7: Plot Labels
# Label the states
states = [(p1, V1), (p2, V2), (p3, V3), (p4, V4)]
for i, (p, V) in enumerate(states):
plt.text(V, p, "ABCD" [i])Step 8: Running the code
# Run
plt.figure(figsize=(6, 5))
carnot_cycle(V1=0.01, T_high=800, r_i=2, r_a=2)
plt.savefig('Carnot Cycle p-V Diagram (Ideal Gas).svg', bbox_inches='tight')
plt.show()- Creates a figure
- Runs the Carnot Cycle with chosen parameters.
- Saves the plot as an SVG.
- Displays the diagram.
Efficiency = 37.0%