Skip to article frontmatterSkip to article content
Site not loading correctly?

This may be due to an incorrect BASE_URL configuration. See the MyST Documentation for reference.

Two-state system

import matplotlib.pyplot as plt
import numpy as np

Calculate fraction of excited states

  • You have a two state system. Consider difference between energy levels Δϵ\Delta \epsilon between units of 0,50, 5 kj/mol

  • Calculate how N1/N2N_1/N_2 changes as a function of Δϵ\Delta \epsilon at temperature kT=1kT= 1 kj/mol

  • Repeat calculation for a few temperatures kT=1,10,100kT=1, 10, 100

delta_Es = np.arange(0, 5, 0.1) 

Compute average energy and heat capacity as a function of temperature

# Define the energy levels and set kB=1 to simplfy units
E0, E1 = 0, 1

# Define a range of temperatures (avoiding zero) 
T = np.linspace(0.1, 5, 100)

# Calculate the internal energy U

# Calculate the heat capacity C
C = np.diff(U) / np.diff(T)
---------------------------------------------------------------------------
NameError                                 Traceback (most recent call last)
Cell In[3], line 10
      5 T = np.linspace(0.1, 5, 100)
      7 # Calculate the internal energy U
      8 
      9 # Calculate the heat capacity C
---> 10 C = np.diff(U) / np.diff(T)

NameError: name 'U' is not defined
# Plotting
#fig, (ax1, ax2) = plt.subplots(1, 2, figsize=(12, 5))

# Internal energy plot
#ax1.plot(kbT, U, label='Internal Energy (U)')
ax1.set_xlabel('Temperature (T)')
ax1.set_ylabel('Internal Energy (U)')
ax1.set_title('Internal Energy vs Temperature')
ax1.legend()

# Heat capacity plot
# Skip the first temperature value since we used np.diff
#ax2.plot(kbT[1:], C, label='Heat Capacity (C)', color='r')
ax2.set_xlabel('Temperature (T)')
ax2.set_ylabel('Heat Capacity (C)')
ax2.set_title('Heat Capacity vs Temperature')
ax2.legend()

plt.tight_layout()