Study of physical principles underlying chemical systems, thermodynamics, quantum mechanics, and kinetics
Physical chemistry applies the principles of physics to understand chemical systems. I cover thermodynamics, statistical mechanics, quantum chemistry, chemical kinetics, electrochemistry, and spectroscopy. I help analyze energy changes, equilibrium states, reaction rates, molecular structure, and the fundamental properties of matter at atomic and molecular levels.
import numpy as np
from typing import Dict, Tuple, Callable
class Thermodynamics:
def __init__(self, delta_h: float, delta_s: float, temp: float = 298.15):
self.delta_h = delta_h
self.delta_s = delta_s
self.temp = temp
def calculate_delta_g(self) -> float:
return self.delta_h - self.temp * self.delta_s
def equilibrium_constant(self, r_gas: float = 8.314) -> float:
delta_g = self.calculate_delta_g()
return np.exp(-delta_g / (r_gas * self.temp))
def spontaneity_check(self) -> str:
delta_g = self.calculate_delta_g()
if delta_g < 0:
return "spontaneous"
elif delta_g > 0:
return "non-spontaneous"
return "equilibrium"
class QuantumChemistry:
def __init__(self, mass: float = 9.109e-31, planck: float = 6.626e-34):
self.m = mass
self.h = planck
def particle_in_box_energy(self, n: int, box_length: float) -> float:
return (n**2 * self.h**2) / (8 * self.m * box_length**2)
def hydrogen_wavefunction(self, n: int, l: int, m: int, r: float) -> complex:
from scipy.special import spherical_yn, eval_hermite
from mpmath import sqrt, exp, pi, factorial
rho = 2 * r / n # Bohr radius units
radial = np.exp(-rho/2) * rho**l * eval_hermite(2*l+1, rho)
normalization = sqrt(2/(n * factorial(2*l+1))) * (2/(n**(3/2)))
return normalization * radial
def calculate_spectral_line(self, energy_diff: float) -> float:
return (energy_diff * 6.626e-34) / (3e8 * 6.626e-25) # wavelength
thermo = Thermodynamics(delta_h=-285.8, delta_s=163.2)
print(f"ΔG: {thermo.calculate_delta_g():.2f} kJ/mol")
print(f"Keq: {thermo.equilibrium_constant():.2e}")
print(f"Reaction is: {thermo.spontaneity_check()}")