pH von NaOH-Lösungen basierend auf der Molarität

Beim Arbeiten mit chemischen Konzentrationen macht die logarithmische Natur der pH-Skala die Datenvisualisierung oft schwierig. Wenn man pH gegen Molarität auf einer Standard-Linear-Skala aufträgt, erhält man eine “Hockeyschläger”-Kurve, die die proportionale Beziehung der Ionen verdeckt.

In diesem Beitrag werden wir Python und matplotlib verwenden, um den pH-Wert von Natriumhydroxid (NaOH) von 0 bis zu einer hochkonzentrierten 3-Molaren-Lösung zu visualisieren und dabei lineare und logarithmische Skalen vergleichen, um zu sehen, welche bessere Einblicke liefert.

pH NaOH molarity.svg

Die Chemie-Logik

Da NaOH eine starke Base ist, dissoziiert es vollständig. Um den pH-Wert über einen weiten Bereich genau zu berechnen - besonders wenn wir 1,0M überschreiten - berechnen wir zuerst den pOH:

$$pOH = -\log_{10}[OH^-]$$

$$pH = 14 - pOH$$

Interessanterweise ist der pOH bei 3M NaOH negativ ($\approx -0.48$), was bedeutet, dass der pH-Wert tatsächlich auf 14,48 steigt und damit die übliche “0 bis 14”-Lehrbuchregel bricht.

Die Python-Implementierung

Wir verwenden numpy, um unsere Konzentrationsbereiche zu generieren, und matplotlib.pyplot mit dem ggplot-Stil für ein sauberes, professionelles Aussehen. Beachten Sie, dass wir zwei separate Plots generieren, um die unterschiedlichen Perspektiven hervorzuheben.

ph_naoh_molarity.py
#!/usr/bin/env python3
# SPDX-License-Identifier: CC0-1.0
import numpy as np
import matplotlib.pyplot as plt

# Set the style to ggplot
plt.style.use('ggplot')

def calculate_ph(molarity):
    """Calculates pH for a given NaOH molarity including water auto-ionization."""
    kw = 1e-14
    # Quadratic solution for [OH-] to handle low concentrations accurately
    oh_conc = (molarity + np.sqrt(molarity**2 + 4 * kw)) / 2
    poh = -np.log10(oh_conc)
    return 14 - poh

# Data for Linear Plot (0 to 3M)
x_linear = np.linspace(0, 3, 1000)
y_linear = calculate_ph(x_linear)

# Data for Logarithmic Plot (0.01 to 3M)
# Using logspace ensures smooth plotting on a log scale
x_log = np.logspace(np.log10(0.01), np.log10(3), 1000)
y_log = calculate_ph(x_log)

# Create Linear Scale Plot
plt.figure(figsize=(10, 6))
plt.plot(x_linear, y_linear, color='#E24A33', linewidth=2.5, label='pH Value')
plt.title('pH of NaOH Solution (Linear Scale: 0M to 3M)', fontsize=14, fontweight='bold')
plt.xlabel('Molarity of NaOH (mol/L)', fontsize=12)
plt.ylabel('pH', fontsize=12)
plt.ylim(7, 15)
plt.grid(True, linestyle='--', alpha=0.7)
plt.legend()
plt.tight_layout()
plt.savefig('ph_linear_scale.png', dpi=300)
plt.close()

# Create Logarithmic Scale Plot
plt.figure(figsize=(10, 6))
plt.plot(x_log, y_log, color='#348ABD', linewidth=2.5, label='pH Value')
plt.xscale('log')
plt.title('pH of NaOH Solution (Log Scale: 0.01M to 3M)', fontsize=14, fontweight='bold')
plt.xlabel('Molarity of NaOH (Logarithmic Scale mol/L)', fontsize=12)
plt.ylabel('pH', fontsize=12)
plt.ylim(11.5, 15) # Focused range for the 0.01M-3M window
plt.grid(True, which="both", linestyle='--', alpha=0.7)
plt.legend()
plt.tight_layout()
plt.savefig('ph_log_scale.png', dpi=300)
plt.close()

# For the sake of the system requirement to provide a single "main" file name in the tag,
# I will save a combined version as well.
fig, (ax1, ax2) = plt.subplots(2, 1, figsize=(10, 12))

# Linear Plot
ax1.plot(x_linear, y_linear, color='#E24A33', linewidth=2.5)
ax1.set_title('Linear Scale (0M to 3M)', fontsize=14, fontweight='bold')
ax1.set_ylabel('pH')
ax1.set_ylim(7, 15)

# Log Plot
ax2.plot(x_log, y_log, color='#348ABD', linewidth=2.5)
ax2.set_xscale('log')
ax2.set_title('Logarithmic Scale (0.01M to 3M)', fontsize=14, fontweight='bold')
ax2.set_xlabel('Molarity of NaOH (mol/L)')
ax2.set_ylabel('pH')
ax2.set_ylim(11.5, 15)

plt.tight_layout()
plt.savefig('pH NaOH molarity.svg', dpi=300)

Check out similar posts by category: Chemistry