Solutions

Video

Alternative link

Code

1. Define your own functions (with docstrings) to calculate the following quantities.

a. The de Broglie wavelength

\[\lambda = \frac{h}{p},\]

where \(h\) is Planck’s constant and \(p\) is the momentum.

Test your function for \(p = 1.01 \times 10^{-31}\,\mathrm{kg\ m\ s}^{-1}\).

from scipy import constants

def de_broglie_wavelength(p):
    '''
    Calculates de Broglie wavelength for a given momentum.

    Arguments
    ---------
    p: float
        Momentum in kg m s^-1

    Returns
    -------
    float
        de Broglie wavelength in m
    '''
    return constants.h / p

momentum = 1.01E-31 # kg m s^-1
wavelength = de_broglie_wavelength(momentum)
print(f'For a particle with momentum {momentum} kg m s⁻¹')
print(f'The de Broglie wavelength is {wavelength:.3g} m')
For a particle with momentum 1.01e-31 kg m s⁻¹
The de Broglie wavelength is 0.00656 m

b. The change in the Gibbs free energy

\[\Delta G = -RT\ln K,\]

where \(R\) is the gas constant, \(T\) is the temperature and \(K\) is the equilibrium constant.

Test your function for \(T = 500\, \mathrm{K}\) and \(K = 1.15\).

import scipy.constants as constants
import math

def eq_to_gibbs(T, K):
    '''
    Calculates the change in Gibbs free energy associated
    with a given equilibrium constant at a given temperature.
    DG = -RTln(K)

    Arguments
    ---------
    T: float
        Temperature in K
    K: float
        Equilibrium constant (dimensionless)

    Returns
    -------
    float
        Change in Gibbs free energy in kJ mol^-1
    '''

    # Delta G in J mol^-1
    delta_G = - constants.R * T * math.log(K)

    # Convert to kJ mol^-1
    delta_G *= 1E-3
    
    return delta_G

T = 500 # K
K = 1.15

delta_G = eq_to_gibbs(T, K)

print(f'At T={T:.3g} K, an equilibrium constant of {K:.3g} corresponds to')
print(f'a change in Gibbs free energy of {delta_G:.3g} kJ mol⁻¹')
At T=500 K, an equilibrium constant of 1.15 corresponds to
a change in Gibbs free energy of -0.581 kJ mol⁻¹

c. The mean activity according to the Debye-Huckel limiting law

\[\gamma_{\pm} = \exp\left[-|z_{+}z_{-}|A\sqrt{I}\right],\]

where \(z_{+}\) and \(z_{-}\) are the charges on the cations and anions respectively, \(I\) is the ionic strength and \(A\) is a constant that depends upon the solvent and the temperature.

Test your function with values of

\[ z_{+} = 1\ \ \ \ \ z_{-} = 2 \]

\[ A = 1.179\, \mathrm{M}^{\frac{1}{2}} \ \ \ \ \ I = 0.018\, \mathrm{M} \]

import math

def dh_mean_activity(zp, zm, A, I):
    '''
    Calculates the mean activity γ_± of a solution
    using the Debye-Huckel limiting law.

    Arguments
    ---------
    zp: int
        Charge of positive ion (dimensionless)
    zm: int
        Charge of negative ion (dimensionless)
    A: float
        Debye-Huckel constant for given solution
        (solvent and temperature dependent) in M^{-1/2}
    I: float
        Ionic strength of solution in M

    Returns
    -------
    float
        Mean activity of solution (dimensionless)
    '''

    gamma_pm = math.exp(-abs(zp*zm) * A * math.sqrt(I))
    return gamma_pm

# Charge on each ion - integers i.e. NOT in units
# of e
z_plus = 1
z_minus = 2

# Ionic strength in M
I = 0.018

# DH constant in M^{-1/2}
A = 1.179

gamma_pm = dh_mean_activity(z_plus, z_minus, A, I)

print(f'The mean activity is {gamma_pm:.2g}')
The mean activity is 0.73

2a. The thermal de Broglie wavelength \(\Lambda\) describes the average de Broglie wavelength of particles in an idealgas at a given temperature:

\[\Lambda = \frac{h}{\sqrt{2\pi mk_{\mathrm{B}}T}},\]

where \(h\) is Planck’s constant, \(m\) is the mass of each particle, \(k_\mathrm{B}\) is Boltzmann’s constant and \(T\) is the temperature.

Write a function to calculate \(\Lambda\).

2b. The total entropy of an ideal gas can be calculated with the Sackur-Tetrode equation:

\[\frac{S}{k_{\mathrm{B}}N} = \ln\left(\frac{V}{N\Lambda^{3}}\right) + \frac{5}{2},\]

where \(S\) is the entropy, \(N\) is the number of particles, \(V\) is the volume, \(k_{\mathrm{B}}\) is Boltzmann’s constant and \(\Lambda\) is the thermal de Broglie wavelength.

  1. Write a function to calculate the entropy of an ideal gas with the Sackur-Tetrode equation.

  2. Using your two functions, calculate the entropy of an ideal gas with

import math
import scipy.constants as constants

def thermal_de_broglie_wavelength(m, T):
    '''
    Calculates the thermal de Broglie wavelength
    of an ideal gas of given mass
    at given temperature.

    Arguments
    ---------
    m: float
        Mass of particle in kg
    T: float
        Temperature of system in K

    Returns
    -------
    float
        Thermal de Broglie wavelength in m
    '''

    denom = math.sqrt(2 * math.pi * m * constants.Boltzmann * T)
    
    thermal_db = constants.h / denom

    return thermal_db

def sackur_tetrode_entropy(V, thermal_db, N):
    '''
    Calculates the total entropy of an ideal gas
    using the Sackur-Tetrode equation for a given
    volume, number of particles, and thermal 
    de Broglie wavelength.

    Arguments
    ---------
    V: float
        Volume of system in m^3
    thermal_db: float
        Thermal de Broglie wavelength in m
    N: float | int
        Number of particles

    Returns
    -------
    float
        Total entropy in J K^{-1}
    '''

    entropy = math.log(V / (N * thermal_db**3)) + 2.5

    entropy *= constants.Boltzmann * N

    return entropy

# System configuration
mass = 6.63E-26 # kg
T = 500 # K
N = 1.92E23
V = 5E-3

# Thermal de Broglie wavelength of gas
thermal_db = thermal_de_broglie_wavelength(mass, T)

# Entropy according to ST equation
entropy = sackur_tetrode_entropy(V, thermal_db, N)

print('For an ideal gas with the following attributes')

print(f' - Mass = {mass:.3g} kg')
print(f' - Temperature = {T:.3g} K')
print(f' - Number of Particles = {N:.3g}')
print(f' - Volume of container = {V:.3g} m³')

print(f'\nThe thermal de Broglie wavelength is {thermal_db:.3g} m')
print(f'and the Total (Sackur-Tetrode) Entropy is {entropy:.3g} J K⁻¹')
For an ideal gas with the following attributes
 - Mass = 6.63e-26 kg
 - Temperature = 500 K
 - Number of Particles = 1.92e+23
 - Volume of container = 0.005 m³

The thermal de Broglie wavelength is 1.24e-11 m
and the Total (Sackur-Tetrode) Entropy is 50.2 J K⁻¹