import math
# 体心立方格子 (BCC) の充填率、配位数、格子定数、原子半径
def bcc_properties():
a = 1 # 格子定数 (任意の単位)
r = math.sqrt(3) * a / 4 # 原子半径
volume_atom = 2 * (4 / 3) * math.pi * r**3 # 単位胞内の原子の体積
volume_unit_cell = a**3 # 単位胞の体積
packing_fraction = volume_atom / volume_unit_cell # 充填率
coordination_number = 8 # 配位数 (BCC)
return packing_fraction, coordination_number, a, r
# 面心立方格子 (FCC) の充填率、配位数、格子定数、原子半径
def fcc_properties():
a = 1 # 格子定数 (任意の単位)
r = math.sqrt(2) * a / 4 # 原子半径
volume_atom = 4 * (4 / 3) * math.pi * r**3 # 単位胞内の原子の体積
volume_unit_cell = a**3 # 単位胞の体積
packing_fraction = volume_atom / volume_unit_cell # 充填率
coordination_number = 12 # 配位数 (FCC)
return packing_fraction, coordination_number, a, r
# 六方最密構造 (HCP) の充填率、配位数、格子定数、原子半径
def hcp_properties():
a = 1 # 格子定数 (任意の単位)
r = a / 2 # 原子半径
c = 2 * math.sqrt(2 / 3) * a # c 軸の長さ
volume_atom = 6 * (4 / 3) * math.pi * r**3 # 単位胞内の原子の体積
volume_unit_cell = (3 * math.sqrt(3) / 2) * a**2 * c # 単位胞の体積
packing_fraction = volume_atom / volume_unit_cell # 充填率
coordination_number = 12 # 配位数 (HCP)
return packing_fraction, coordination_number, a, r, c
# 各構造のプロパティを計算
bcc_pf, bcc_cn, bcc_a, bcc_r = bcc_properties()
fcc_pf, fcc_cn, fcc_a, fcc_r = fcc_properties()
hcp_pf, hcp_cn, hcp_a, hcp_r, hcp_c = hcp_properties()
print(f"BCCの充填率: {bcc_pf:.2f}")
print(f"BCCの配位数: {bcc_cn}")
print(f"BCCの格子定数: {bcc_a:.2f}")
print(f"BCCの原子半径: {bcc_r:.2f}")
print(f"FCCの充填率: {fcc_pf:.2f}")
print(f"FCCの配位数: {fcc_cn}")
print(f"FCCの格子定数: {fcc_a:.2f}")
print(f"FCCの原子半径: {fcc_r:.2f}")
print(f"HCPの充填率: {hcp_pf:.2f}")
print(f"HCPの配位数: {hcp_cn}")
print(f"HCPの格子定数: {hcp_a:.2f}")
print(f"HCPの原子半径: {hcp_r:.2f}")
print(f"HCPのc軸長: {hcp_c:.2f}")
import numpy as np
import matplotlib.pyplot as plt
def plot_bcc():
fig, ax = plt.subplots(figsize=(6, 6))
# BCCの格子定数と原子半径
a = 1
r = np.sqrt(3) * a / 4
# BCCの格子を描く
# 原子の位置
positions = [
(0, 0), (0, 1), (1, 0), (1, 1), # 4つの角
(0.5, 0.5) # 中心
]
# 断面図の描画
for pos in positions:
circle = plt.Circle(pos, r, color='blue', fill=True, alpha=0.5)
ax.add_artist(circle)
ax.set_xlim(-0.1, 1.1)
ax.set_ylim(-0.1, 1.1)
ax.set_aspect('equal')
ax.set_title('BCC - Body-Centered Cubic')
plt.grid(True)
plt.show()
def plot_fcc():
fig, ax = plt.subplots(figsize=(6, 6))
# FCCの格子定数と原子半径
a = 1
r = np.sqrt(2) * a / 4
# FCCの格子を描く
# 原子の位置
positions = [
(0, 0), (0, 1), (1, 0), (1, 1), # 4つの角
(0.5, 0), (0, 0.5), (0.5, 0.5) # 面心
]
# 断面図の描画
for pos in positions:
circle = plt.Circle(pos, r, color='red', fill=True, alpha=0.5)
ax.add_artist(circle)
ax.set_xlim(-0.1, 1.1)
ax.set_ylim(-0.1, 1.1)
ax.set_aspect('equal')
ax.set_title('FCC - Face-Centered Cubic')
plt.grid(True)
plt.show()
def plot_hcp():
fig, ax = plt.subplots(figsize=(6, 6))
# HCPの格子定数と原子半径
a = 1
r = a / 2
# HCPの格子を描く
# 六角形の原子の位置
angle = np.linspace(0, 2 * np.pi, 7)
x_hex = np.cos(angle)
y_hex = np.sin(angle)
# 六角形の各層の位置
for offset in [(0, 0), (0.5, np.sqrt(3)/2)]:
for i in range(6):
pos = (x_hex[i] + offset[0], y_hex[i] + offset[1])
circle = plt.Circle(pos, r, color='green', fill=True, alpha=0.5)
ax.add_artist(circle)
ax.set_xlim(-1.5, 1.5)
ax.set_ylim(-1.5, 1.5)
ax.set_aspect('equal')
ax.set_title('HCP - Hexagonal Close-Packed')
plt.grid(True)
plt.show()
# 各構造の断面図を描画
plot_bcc()
plot_fcc()
plot_hcp()
import numpy as np
import matplotlib.pyplot as plt
from mpl_toolkits.mplot3d import Axes3D
def plot_bcc():
fig = plt.figure()
ax = fig.add_subplot(111, projection='3d')
# BCCの頂点
vertices = np.array([[0, 0, 0], [1, 0, 0], [0, 1, 0], [0, 0, 1],
[1, 1, 0], [1, 0, 1], [0, 1, 1], [1, 1, 1],
[0.5, 0.5, 0.5]])
# エッジのリスト
edges = [[vertices[i], vertices[j]] for i in range(len(vertices)) for j in range(i + 1, len(vertices))]
for edge in edges:
ax.plot3D(*zip(*edge), color="b")
# BCCの切断面
x = np.linspace(0, 1, 100)
y = np.linspace(0, 1, 100)
X, Y = np.meshgrid(x, y)
Z = 0.5 * np.ones_like(X) # Z = 0.5の平面
ax.plot_surface(X, Y, Z, color='cyan', alpha=0.3, edgecolor='none')
ax.set_title("Body-Centered Cubic (BCC) Lattice with Cutting Plane")
ax.set_xlabel('X')
ax.set_ylabel('Y')
ax.set_zlabel('Z')
plt.show()
def plot_fcc():
fig = plt.figure()
ax = fig.add_subplot(111, projection='3d')
# FCCの頂点
vertices = np.array([[0, 0, 0], [1, 0, 0], [0, 1, 0], [0, 0, 1],
[1, 1, 0], [1, 0, 1], [0, 1, 1], [1, 1, 1],
[0.5, 0.5, 0], [0.5, 0, 0.5], [0, 0.5, 0.5]])
# エッジのリスト
edges = [[vertices[i], vertices[j]] for i in range(len(vertices)) for j in range(i + 1, len(vertices))]
for edge in edges:
ax.plot3D(*zip(*edge), color="r")
# FCCの切断面
x = np.linspace(0, 1, 100)
y = np.linspace(0, 1, 100)
X, Y = np.meshgrid(x, y)
Z = 0.5 * (X + Y) # Z = 0.5*(X+Y)の平面
ax.plot_surface(X, Y, Z, color='orange', alpha=0.3, edgecolor='none')
ax.set_title("Face-Centered Cubic (FCC) Lattice with Cutting Plane")
ax.set_xlabel('X')
ax.set_ylabel('Y')
ax.set_zlabel('Z')
plt.show()
def plot_hcp():
fig = plt.figure()
ax = fig.add_subplot(111, projection='3d')
# HCPの頂点
vertices = np.array([[0, 0, 0], [1, 0, 0], [0.5, np.sqrt(3)/2, 0],
[0.5, np.sqrt(3)/6, np.sqrt(2)/3], [1.5, np.sqrt(3)/6, np.sqrt(2)/3],
[1, np.sqrt(3)/2, np.sqrt(2)/3], [0, np.sqrt(3)/3, 2*np.sqrt(2)/3],
[1, np.sqrt(3)/3, 2*np.sqrt(2)/3], [0.5, np.sqrt(3)/2, 2*np.sqrt(2)/3]])
# エッジのリスト
edges = [[vertices[i], vertices[j]] for i in range(len(vertices)) for j in range(i + 1, len(vertices))]
for edge in edges:
ax.plot3D(*zip(*edge), color="g")
# HCPの切断面
x = np.linspace(0, 1.5, 100)
y = np.linspace(0, np.sqrt(3)/2, 100)
X, Y = np.meshgrid(x, y)
Z = (1/np.sqrt(2)) * (X - 0.5*Y) # Z = (1/sqrt(2))*(X - 0.5*Y)の平面
ax.plot_surface(X, Y, Z, color='magenta', alpha=0.3, edgecolor='none')
ax.set_title("Hexagonal Close-Packed (HCP) Lattice with Cutting Plane")
ax.set_xlabel('X')
ax.set_ylabel('Y')
ax.set_zlabel('Z')
plt.show()
# 各格子構造のプロット
plot_bcc()
plot_fcc()
plot_hcp()
import math
# アボガドロ定数
NA = 6.022e23
# 気体定数
R = 8.314 # J/(mol K)
# モル数の計算
def calculate_moles(mass, molar_mass):
return mass / molar_mass
# 分子の数の計算
def calculate_number_of_molecules(moles):
return moles * NA
# 理想気体の体積の計算
def calculate_gas_volume(pressure, moles, temperature):
return (moles * R * temperature) / pressure
# 入力例
mass = 10.0 # g
molar_mass = 18.015 # g/mol (水のモル質量)
pressure = 101325 # Pa (1気圧)
temperature = 298.15 # K (25°C)
# 計算
moles = calculate_moles(mass, molar_mass)
number_of_molecules = calculate_number_of_molecules(moles)
volume = calculate_gas_volume(pressure, moles, temperature)
print(f"質量: {mass} g")
print(f"モル質量: {molar_mass} g/mol")
print(f"モル数: {moles:.4f} mol")
print(f"分子の数: {number_of_molecules:.2e}")
print(f"気体の体積: {volume:.4f} m³")
# 密度と体積から質量を計算
def calculate_mass_from_density_and_volume(density, volume):
"""
密度と体積から質量を計算する関数
density: 密度 (g/cm³)
volume: 体積 (cm³)
"""
mass = density * volume
return mass
# 質量パーセント濃度から溶質の質量を計算
def calculate_solute_mass(concentration, solution_mass):
"""
質量パーセント濃度から溶質の質量を計算する関数
concentration: 質量パーセント濃度 (%)
solution_mass: 溶液の質量 (g)
"""
solute_mass = (concentration / 100) * solution_mass
return solute_mass
# 入力例
density = 1.0 # g/cm³ (例: 水の密度)
volume = 100.0 # cm³ (例: 水の体積)
concentration = 10.0 # % (例: 溶液の質量パーセント濃度)
solution_mass = 100.0 # g (例: 溶液の質量)
# 計算
mass = calculate_mass_from_density_and_volume(density, volume)
solute_mass = calculate_solute_mass(concentration, solution_mass)
print(f"密度: {density} g/cm³")
print(f"体積: {volume} cm³")
print(f"物質の質量: {mass} g")
print(f"質量パーセント濃度: {concentration} %")
print(f"溶液の質量: {solution_mass} g")
print(f"溶質の質量: {solute_mass} g")
import numpy as np
import matplotlib.pyplot as plt
# pHの計算関数
def calculate_pH(h_concentration):
"""
水素イオン濃度からpHを計算する関数
h_concentration: 水素イオン濃度 (mol/L)
"""
return -np.log10(h_concentration)
# 中和滴定の計算関数
def neutralization_titration(C_acid, V_acid, C_base, V_base):
"""
中和滴定の計算を行う関数
C_acid: 酸の濃度 (mol/L)
V_acid: 酸の体積 (L)
C_base: 塩基の濃度 (mol/L)
V_base: 塩基の体積 (L)
"""
n_acid = C_acid * V_acid
n_base = C_base * V_base
# 中和点では n_acid = n_base
if n_base <= n_acid:
remaining_acid = n_acid - n_base
h_concentration = remaining_acid / (V_acid + V_base)
return calculate_pH(h_concentration)
else:
excess_base = n_base - n_acid
oh_concentration = excess_base / (V_acid + V_base)
return 14 - calculate_pH(oh_concentration)
# 中和滴定曲線のプロット関数
def plot_titration_curve(C_acid, V_acid, C_base, V_base_increment, num_points=100):
"""
中和滴定曲線をプロットする関数
C_acid: 酸の濃度 (mol/L)
V_acid: 酸の体積 (L)
C_base: 塩基の濃度 (mol/L)
V_base_increment: 塩基の体積の増加量 (L)
num_points: プロットする点の数
"""
V_base_values = np.linspace(0, V_base_increment, num_points)
pH_values = []
for V_base in V_base_values:
pH = neutralization_titration(C_acid, V_acid, C_base, V_base)
pH_values.append(pH)
plt.plot(V_base_values, pH_values)
plt.xlabel('Volume of base added (L)')
plt.ylabel('pH')
plt.title('Titration Curve')
plt.grid(True)
plt.show()
# 入力例
C_acid = 0.1 # 酸の濃度 (mol/L)
V_acid = 0.1 # 酸の体積 (L)
C_base = 0.1 # 塩基の濃度 (mol/L)
V_base_increment = 0.2 # 塩基の体積の増加量 (L)
# 中和滴定曲線のプロット
plot_titration_curve(C_acid, V_acid, C_base, V_base_increment)
def calculate_neutralization(na2co3_moles, hcl_moles):
# 第一段階の反応: Na2CO3 + 2HCl → NaHCO3 + NaCl + H2O
na2co3_needed_for_first_step = na2co3_moles
hcl_needed_for_first_step = 2 * na2co3_needed_for_first_step
if hcl_moles >= hcl_needed_for_first_step:
na2co3_remaining_after_first_step = 0
hcl_remaining_after_first_step = hcl_moles - hcl_needed_for_first_step
na_hco3_formed = na2co3_needed_for_first_step
else:
na2co3_remaining_after_first_step = na2co3_moles - hcl_moles / 2
na_hco3_formed = hcl_moles / 2
hcl_remaining_after_first_step = 0
# 第二段階の反応: NaHCO3 + HCl → NaCl + H2O + CO2
na_hco3_needed_for_second_step = na_hco3_formed
hcl_needed_for_second_step = na_hco3_needed_for_second_step
if hcl_remaining_after_first_step >= hcl_needed_for_second_step:
hcl_remaining_after_second_step = hcl_remaining_after_first_step - hcl_needed_for_second_step
co2_formed = na_hco3_needed_for_second_step
na_cl_formed = na_hco3_needed_for_second_step
h2o_formed = na_hco3_needed_for_second_step
else:
na_cl_formed = hcl_remaining_after_first_step
h2o_formed = hcl_remaining_after_first_step
co2_formed = hcl_remaining_after_first_step
hcl_remaining_after_second_step = 0
return {
'Na2CO3_remaining': na2co3_remaining_after_first_step,
'HCl_remaining': hcl_remaining_after_second_step,
'NaHCO3_formed': na_hco3_formed,
'NaCl_formed': na_cl_formed,
'H2O_formed': h2o_formed,
'CO2_formed': co2_formed
}
# 例として、炭酸ナトリウムと塩酸の初期モル数を設定
na2co3_moles = 1.0 # 例えば 1 mol
hcl_moles = 2.5 # 例えば 2.5 mol
results = calculate_neutralization(na2co3_moles, hcl_moles)
for substance, amount in results.items():
print(f"{substance}: {amount} mol")
def calculate_enthalpy_change(na2co3_moles, hcl_moles, delta_h1, delta_h2):
# 第一段階反応に必要なHClの量
hcl_needed_for_first_step = 2 * na2co3_moles
if hcl_moles >= hcl_needed_for_first_step:
na2co3_remaining = 0
hcl_remaining_after_first_step = hcl_moles - hcl_needed_for_first_step
na_hco3_formed = na2co3_moles
else:
na2co3_remaining = na2co3_moles - hcl_moles / 2
na_hco3_formed = hcl_moles / 2
hcl_remaining_after_first_step = 0
# 第二段階反応に必要なHClの量
hcl_needed_for_second_step = na_hco3_formed
if hcl_remaining_after_first_step >= hcl_needed_for_second_step:
hcl_remaining_after_second_step = hcl_remaining_after_first_step - hcl_needed_for_second_step
total_enthalpy_change = delta_h1 * na2co3_moles + delta_h2 * na_hco3_formed
else:
total_enthalpy_change = delta_h1 * na2co3_moles + delta_h2 * hcl_remaining_after_first_step
hcl_remaining_after_second_step = 0
return {
'Na2CO3_remaining': na2co3_remaining,
'HCl_remaining': hcl_remaining_after_second_step,
'Total_enthalpy_change': total_enthalpy_change
}
# 例としてのデータ
na2co3_moles = 1.0 # 1 mol
hcl_moles = 2.5 # 2.5 mol
delta_h1 = -1000 # 第一段階のエンタルピー変化 (例: -1000 kJ/mol)
delta_h2 = -200 # 第二段階のエンタルピー変化 (例: -200 kJ/mol)
results = calculate_enthalpy_change(na2co3_moles, hcl_moles, delta_h1, delta_h2)
for substance, amount in results.items():
print(f"{substance}: {amount} kJ")
#C H : C O O と H O の 反 応 の平 衡式
def calculate_acid_dissociation_constant(concentration_acetic_acid, concentration_acetate_ion, concentration_hydronium_ion):
"""
酢酸と水の反応における酸解離定数 (Ka) を計算する関数
:param concentration_acetic_acid: 酢酸の平衡時濃度 (M)
:param concentration_acetate_ion: 酢酸イオンの平衡時濃度 (M)
:param concentration_hydronium_ion: 水素イオンの平衡時濃度 (M)
:return: 酸解離定数 (Ka)
"""
# 酸解離定数 Ka の計算
ka = (concentration_acetate_ion * concentration_hydronium_ion) / concentration_acetic_acid
return ka
# 例としてのデータ
concentration_acetic_acid = 0.1 # 酢酸の平衡時濃度 (M)
concentration_acetate_ion = 0.01 # 酢酸イオンの平衡時濃度 (M)
concentration_hydronium_ion = 0.01 # 水素イオンの平衡時濃度 (M)
# 酸解離定数を計算
ka = calculate_acid_dissociation_constant(concentration_acetic_acid, concentration_acetate_ion, concentration_hydronium_ion)
print(f"酸解離定数 (Ka): {ka:.2e} M")
import math
def calculate_ka(concentration_acid, concentration_conjugate_base, concentration_hydronium_ion):
"""
酸解離定数 (Ka) を計算する関数
:param concentration_acid: 酸の平衡時濃度 (M)
:param concentration_conjugate_base: 酸の解離生成物の濃度 (M)
:param concentration_hydronium_ion: 水素イオンの平衡時濃度 (M)
:return: 酸解離定数 (Ka)
"""
ka = (concentration_conjugate_base * concentration_hydronium_ion) / concentration_acid
return ka
def calculate_kb(concentration_base, concentration_conjugate_acid, concentration_hydroxide_ion):
"""
塩基解離定数 (Kb) を計算する関数
:param concentration_base: 塩基の平衡時濃度 (M)
:param concentration_conjugate_acid: 塩基の解離生成物の濃度 (M)
:param concentration_hydroxide_ion: 水酸化物イオンの平衡時濃度 (M)
:return: 塩基解離定数 (Kb)
"""
kb = (concentration_conjugate_acid * concentration_hydroxide_ion) / concentration_base
return kb
def calculate_ph(concentration_hydronium_ion):
"""
pH を計算する関数
:param concentration_hydronium_ion: 水素イオンの濃度 (M)
:return: pH
"""
return -math.log10(concentration_hydronium_ion)
def calculate_poh(concentration_hydroxide_ion):
"""
pOH を計算する関数
:param concentration_hydroxide_ion: 水酸化物イオンの濃度 (M)
:return: pOH
"""
return -math.log10(concentration_hydroxide_ion)
def calculate_ph_and_poh(concentration_hydronium_ion, concentration_hydroxide_ion):
"""
pH と pOH を計算する関数
:param concentration_hydronium_ion: 水素イオンの濃度 (M)
:param concentration_hydroxide_ion: 水酸化物イオンの濃度 (M)
:return: pH と pOH のタプル
"""
ph = calculate_ph(concentration_hydronium_ion)
poh = calculate_poh(concentration_hydroxide_ion)
return ph, poh
def calculate_kw(concentration_hydronium_ion, concentration_hydroxide_ion):
"""
水のイオン生成定数 (Kw) を計算する関数
:param concentration_hydronium_ion: 水素イオンの濃度 (M)
:param concentration_hydroxide_ion: 水酸化物イオンの濃度 (M)
:return: 水のイオン生成定数 (Kw)
"""
return concentration_hydronium_ion * concentration_hydroxide_ion
# 使用例
acetic_acid_concentration = 0.1 # 酢酸の濃度 (M)
acetate_ion_concentration = 0.01 # 酢酸イオンの濃度 (M)
hydronium_ion_concentration = 0.01 # 水素イオンの濃度 (M)
base_concentration = 0.1 # 塩基の濃度 (M)
conjugate_acid_concentration = 0.01 # 塩基の解離生成物の濃度 (M)
hydroxide_ion_concentration = 0.01 # 水酸化物イオンの濃度 (M)
ka = calculate_ka(acetic_acid_concentration, acetate_ion_concentration, hydronium_ion_concentration)
print(f"酸解離定数 (Ka): {ka:.2e} M")
kb = calculate_kb(base_concentration, conjugate_acid_concentration, hydroxide_ion_concentration)
print(f"塩基解離定数 (Kb): {kb:.2e} M")
ph, poh = calculate_ph_and_poh(hydronium_ion_concentration, hydroxide_ion_concentration)
print(f"pH: {ph:.2f}")
print(f"pOH: {poh:.2f}")
kw = calculate_kw(hydronium_ion_concentration, hydroxide_ion_concentration)
print(f"水のイオン生成定数 (Kw): {kw:.2e}")
import math
# ヘスの法則
def total_enthalpy_change(*enthalpies):
"""
ヘスの法則に基づくエンタルピー変化の計算
:param enthalpies: 反応のエンタルピー変化
:return: 総エンタルピー変化
"""
return sum(enthalpies)
# ガスの状態方程式
def ideal_gas_law(pressure, volume, moles, temperature):
"""
理想気体の状態方程式を計算する関数
:param pressure: 圧力 (Pa)
:param volume: 体積 (m³)
:param moles: モル数
:param temperature: 温度 (K)
:return: 気体定数 (R) の計算
"""
R = 8.314 # J/(mol·K)
return (pressure * volume) / (moles * temperature)
# 電気分解の法則
def electrolytic_mass(charge, molar_mass, electrons):
"""
電気分解による生成物の質量を計算する関数
:param charge: 電荷量 (C)
:param molar_mass: モル質量 (g/mol)
:param electrons: 電気分解に必要な電子の数
:return: 生成物の質量 (g)
"""
F = 96485 # C/mol
return (charge / F) * (molar_mass / electrons)
# 反応速度方程式
def reaction_rate(k, *concentrations):
"""
反応速度を計算する関数
:param k: 反応速度定数
:param concentrations: 各反応物の濃度
:return: 反応速度
"""
rate = k
for concentration in concentrations:
rate *= concentration
return rate
# ドルトンの法則
def total_pressure(*partial_pressures):
"""
ドルトンの法則に基づく全圧の計算
:param partial_pressures: 各成分気体の部分圧
:return: 全圧
"""
return sum(partial_pressures)
# 使用例
enthalpy_changes = [100, -50, 25] # 例: [反応1, 反応2, 反応3] のエンタルピー変化
print(f"総エンタルピー変化: {total_enthalpy_change(*enthalpy_changes)} kJ")
pressure = 101325 # Pa
volume = 0.1 # m³
moles = 1 # mol
temperature = 298 # K
print(f"理想気体の計算結果: {ideal_gas_law(pressure, volume, moles, temperature):.2f} J/(mol·K)")
charge = 96500 # C
molar_mass = 63.5 # g/mol (例: 銅)
electrons = 2 # 例: 銅の電気分解
print(f"電気分解による生成物の質量: {electrolytic_mass(charge, molar_mass, electrons):.2f} g")
k = 0.1 # 反応速度定数
concentrations = [0.5, 0.2] # 各反応物の濃度
print(f"反応速度: {reaction_rate(k, *concentrations):.2f} mol/(L·s)")
partial_pressures = [200, 300] # 各成分気体の部分圧 (Pa)
print(f"全圧: {total_pressure(*partial_pressures)} Pa")
import math
# 反応熱の計算
def reaction_enthalpy_change(standard_enthalpy_products, standard_enthalpy_reactants):
"""
反応のエンタルピー変化を計算する関数
:param standard_enthalpy_products: 生成物の標準生成エンタルピー (kJ/mol)
:param standard_enthalpy_reactants: 反応物の標準生成エンタルピー (kJ/mol)
:return: 反応のエンタルピー変化 (kJ)
"""
return sum(standard_enthalpy_products) - sum(standard_enthalpy_reactants)
# ボイルの法則
def boyles_law(pressure1, volume1, pressure2):
"""
ボイルの法則に基づく体積の計算
:param pressure1: 初期圧力 (atm)
:param volume1: 初期体積 (L)
:param pressure2: 最終圧力 (atm)
:return: 最終体積 (L)
"""
return (pressure1 * volume1) / pressure2
# シャルルの法則
def charles_law(volume1, temperature1, temperature2):
"""
シャルルの法則に基づく体積の計算
:param volume1: 初期体積 (L)
:param temperature1: 初期温度 (K)
:param temperature2: 最終温度 (K)
:return: 最終体積 (L)
"""
return (volume1 * temperature2) / temperature1
# 理想気体のモル体積
def ideal_gas_molar_volume():
"""
理想気体のモル体積 (標準状態) を返す関数
:return: モル体積 (L/mol)
"""
return 22.4
# 使用例
standard_enthalpy_products = [0] # 例: 生成物の標準生成エンタルピー (kJ/mol)
standard_enthalpy_reactants = [-200] # 例: 反応物の標準生成エンタルピー (kJ/mol)
print(f"反応のエンタルピー変化: {reaction_enthalpy_change(standard_enthalpy_products, standard_enthalpy_reactants):.2f} kJ")
pressure1 = 1.0 # atm
volume1 = 10.0 # L
pressure2 = 2.0 # atm
print(f"最終体積 (ボイルの法則): {boyles_law(pressure1, volume1, pressure2):.2f} L")
volume1 = 10.0 # L
temperature1 = 273 # K
temperature2 = 373 # K
print(f"最終体積 (シャルルの法則): {charles_law(volume1, temperature1, temperature2):.2f} L")
print(f"理想気体のモル体積: {ideal_gas_molar_volume()} L/mol")
import math
# エネルギーと仕事の関係
def work_energy(energy_change):
"""
エネルギー変化に基づく仕事の計算
:param energy_change: エネルギーの変化 (J)
:return: 仕事 (J)
"""
return energy_change
# ギブズ自由エネルギーの計算
def gibbs_free_energy(enthalpy_change, temperature, entropy_change):
"""
ギブズ自由エネルギーの計算
:param enthalpy_change: エンタルピー変化 (J)
:param temperature: 絶対温度 (K)
:param entropy_change: エントロピー変化 (J/K)
:return: ギブズ自由エネルギー変化 (J)
"""
return enthalpy_change - (temperature * entropy_change)
# アボガドロの法則
def volume_from_moles(moles, molar_volume):
"""
アボガドロの法則に基づく体積の計算
:param moles: モル数 (mol)
:param molar_volume: モル体積 (L/mol)
:return: 体積 (L)
"""
return moles * molar_volume
# ヘンリーの法則
def henrys_law(concentration, henry_constant, pressure):
"""
ヘンリーの法則に基づく溶解度の計算
:param concentration: 溶解度 (mol/L)
:param henry_constant: ヘンリー定数 (mol/(L·atm))
:param pressure: 気体の部分圧 (atm)
:return: 溶解度 (mol/L)
"""
return henry_constant * pressure
# オストワルドの希釈法則
def dissociation_degree(acid_dissociation_constant, concentration):
"""
オストワルドの希釈法則に基づく電離度の計算
:param acid_dissociation_constant: 酸解離定数 (mol/L)
:param concentration: 電解質の濃度 (mol/L)
:return: 電離度
"""
return acid_dissociation_constant / concentration
# 使用例
energy_change = 500 # J
print(f"仕事: {work_energy(energy_change)} J")
enthalpy_change = -1000 # J
temperature = 298 # K
entropy_change = 10 # J/K
print(f"ギブズ自由エネルギー変化: {gibbs_free_energy(enthalpy_change, temperature, entropy_change)} J")
moles = 2 # mol
molar_volume = 22.4 # L/mol
print(f"体積: {volume_from_moles(moles, molar_volume)} L")
concentration = 0.1 # mol/L
henry_constant = 3.5e-4 # mol/(L·atm)
pressure = 1.0 # atm
print(f"溶解度: {henrys_law(concentration, henry_constant, pressure)} mol/L")
acid_dissociation_constant = 1e-5 # mol/L
concentration = 0.01 # mol/L
print(f"電離度: {dissociation_degree(acid_dissociation_constant, concentration)}")
import math
# 反応速度の計算
def reaction_rate(k, concentration_A, concentration_B, order_A, order_B):
"""
反応速度を計算する関数
:param k: 反応速度定数
:param concentration_A: 反応物Aの濃度 (mol/L)
:param concentration_B: 反応物Bの濃度 (mol/L)
:param order_A: 反応物Aの反応次数
:param order_B: 反応物Bの反応次数
:return: 反応速度
"""
return k * (concentration_A ** order_A) * (concentration_B ** order_B)
# 半減期の計算
def half_life(order, rate_constant, initial_concentration=None):
"""
半減期を計算する関数
:param order: 反応の次数
:param rate_constant: 反応速度定数 (s^-1)
:param initial_concentration: 初期濃度 (mol/L) (二次反応用)
:return: 半減期 (s)
"""
if order == 1:
return math.log(2) / rate_constant
elif order == 2:
return 1 / (rate_constant * initial_concentration)
else:
raise ValueError("Unsupported reaction order")
# ファラデーの法則
def faradays_law(charge, molar_mass, electrons):
"""
ファラデーの法則に基づく生成物の質量の計算
:param charge: 電荷量 (C)
:param molar_mass: モル質量 (g/mol)
:param electrons: 電子の数
:return: 生成物の質量 (g)
"""
F = 96485 # ファラデー定数 (C/mol)
return (charge / F) * molar_mass / electrons
# ヘスの法則
def hess_law(enthalpy_changes):
"""
ヘスの法則に基づくエンタルピー変化の計算
:param enthalpy_changes: 各ステップのエンタルピー変化 (kJ)
:return: 全体のエンタルピー変化 (kJ)
"""
return sum(enthalpy_changes)
# 使用例
k = 0.1 # 反応速度定数
concentration_A = 0.5 # mol/L
concentration_B = 0.5 # mol/L
order_A = 1
order_B = 1
print(f"反応速度: {reaction_rate(k, concentration_A, concentration_B, order_A, order_B)} mol/L/s")
order = 1
rate_constant = 0.02 # s^-1
print(f"一次反応の半減期: {half_life(order, rate_constant)} s")
charge = 96500 # C
molar_mass = 63.5 # g/mol (Cu)
electrons = 2
print(f"生成物の質量 (ファラデーの法則): {faradays_law(charge, molar_mass, electrons)} g")
enthalpy_changes = [-200, 50, 10] # 各ステップのエンタルピー変化 (kJ)
print(f"全体のエンタルピー変化 (ヘスの法則): {hess_law(enthalpy_changes)} kJ")
import math
# エンタルピー変化の計算
def enthalpy_change(delta_e, pressure, delta_v):
"""
エンタルピー変化を計算する関数
:param delta_e: 内部エネルギー変化 (J)
:param pressure: 圧力 (Pa)
:param delta_v: 体積変化 (m³)
:return: エンタルピー変化 (J)
"""
return delta_e + (pressure * delta_v)
# 平衡定数の計算
def equilibrium_constant(concentrations, coefficients):
"""
平衡定数を計算する関数
:param concentrations: 各成分の濃度の辞書
:param coefficients: 反応物と生成物の係数の辞書
:return: 平衡定数
"""
numerator = 1
denominator = 1
for species, coef in coefficients.items():
if coef > 0: # 生成物
numerator *= concentrations[species] ** coef
else: # 反応物
denominator *= concentrations[species] ** abs(coef)
return numerator / denominator
# Henderson-Hasselbalchの式
def henderson_hasselbalch(pKa, concentration_A_minus, concentration_HA):
"""
Henderson-Hasselbalchの式に基づくpHの計算
:param pKa: 酸のpKa
:param concentration_A_minus: 塩基の濃度 (mol/L)
:param concentration_HA: 酸の濃度 (mol/L)
:return: pH
"""
return pKa + math.log10(concentration_A_minus / concentration_HA)
# 蒸気圧降下の計算
def raoult_law(mole_fraction_solvent, vapor_pressure_pure_solvent):
"""
ラウールの法則に基づく蒸気圧降下の計算
:param mole_fraction_solvent: 溶媒のモル分率
:param vapor_pressure_pure_solvent: 純粋な溶媒の蒸気圧 (Pa)
:return: 蒸気圧降下 (Pa)
"""
return mole_fraction_solvent * vapor_pressure_pure_solvent
# 使用例
delta_e = 500 # J
pressure = 1000 # Pa
delta_v = 0.01 # m³
print(f"エンタルピー変化: {enthalpy_change(delta_e, pressure, delta_v)} J")
concentrations = {'C': 0.1, 'D': 0.2, 'A': 0.3, 'B': 0.4}
coefficients = {'C': 2, 'D': 3, 'A': -1, 'B': -2}
print(f"平衡定数: {equilibrium_constant(concentrations, coefficients)}")
pKa = 4.75
concentration_A_minus = 0.1 # mol/L
concentration_HA = 0.05 # mol/L
print(f"pH: {henderson_hasselbalch(pKa, concentration_A_minus, concentration_HA)}")
mole_fraction_solvent = 0.8
vapor_pressure_pure_solvent = 760 # Pa
print(f"蒸気圧降下: {raoult_law(mole_fraction_solvent, vapor_pressure_pure_solvent)} Pa")
import math
# ミンコフスキーの法則(DNA複製速度)
def dna_replication_speed(L, t):
"""
DNA複製の速度を計算する
:param L: 複製するDNAの長さ (bp)
:param t: 複製にかかる時間 (s)
:return: 複製速度 (bp/s)
"""
return L / t
# ミンコフスキーの法則(生物学的変化率)
def biological_change_rate(delta_N, delta_t):
"""
生物学的変化率を計算する
:param delta_N: 特性の変化量
:param delta_t: 時間の経過 (時間)
:return: 変化率 (個体数/時間)
"""
return delta_N / delta_t
# ポピュレーション増殖のロジスティックモデル
def logistic_growth(N0, K, r, t):
"""
ポピュレーションのロジスティック成長を計算する
:param N0: 初期個体数
:param K: 環境収容力
:param r: 成長率
:param t: 時間
:return: 時間 t における個体数
"""
return K / (1 + ((K - N0) / N0) * math.exp(-r * t))
# 酵素反応のミハエリス・メンテン式
def michaelis_menten(V_max, S, K_m):
"""
ミハエリス・メンテン式を用いて反応速度を計算する
:param V_max: 最大反応速度
:param S: 基質濃度
:param K_m: ミハエリス定数
:return: 反応速度
"""
return (V_max * S) / (K_m + S)
# 呼吸商(RQ)
def respiratory_quotient(CO2_produced, O2_consumed):
"""
呼吸商を計算する
:param CO2_produced: 二酸化炭素の発生量
:param O2_consumed: 酸素の消費量
:return: 呼吸商
"""
return CO2_produced / O2_consumed
# 使用例
L = 1e6 # DNA長さ (bp)
t = 3600 # 時間 (s)
print(f"DNA複製速度: {dna_replication_speed(L, t)} bp/s")
delta_N = 100 # 特性の変化量
delta_t = 10 # 時間 (時間)
print(f"生物学的変化率: {biological_change_rate(delta_N, delta_t)} 個体数/時間")
N0 = 100 # 初期個体数
K = 1000 # 環境収容力
r = 0.1 # 成長率
t = 5 # 時間
print(f"ロジスティック成長に基づく個体数: {logistic_growth(N0, K, r, t)}")
V_max = 10 # 最大反応速度
S = 5 # 基質濃度
K_m = 2 # ミハエリス定数
print(f"ミハエリス・メンテン式に基づく反応速度: {michaelis_menten(V_max, S, K_m)}")
CO2_produced = 50 # 二酸化炭素の発生量
O2_consumed = 60 # 酸素の消費量
print(f"呼吸商: {respiratory_quotient(CO2_produced, O2_consumed)}")
# ミトーシスと減数分裂の計算
def cell_division_mitosis(divisions):
"""
ミトーシスの細胞分裂数を計算する
:param divisions: 分裂回数
:return: 細胞数
"""
return 2 ** divisions
def cell_division_meiosis(divisions):
"""
減数分裂の細胞分裂数を計算する
:param divisions: 分裂回数
:return: 細胞数
"""
return (2 ** divisions) * (2 ** divisions)
# 遺伝の統計
def genetic_probability(prob_Aa):
"""
遺伝形質の確率を計算する
:param prob_Aa: 優性・劣性遺伝子の確率
:return: 確率
"""
return prob_Aa
# 呼吸のカロリメトリー
def calorimetry(C, delta_T):
"""
カロリメトリーを計算する
:param C: 比熱容量 (J/g·K)
:param delta_T: 温度変化 (K)
:return: 発生したエネルギー (J)
"""
return C * delta_T
# 生態系のバイオマスピラミッド
def biomass_efficiency(biomass_upper, biomass_lower):
"""
生態系のバイオマス効率を計算する
:param biomass_upper: 上位トロフのバイオマス
:param biomass_lower: 下位トロフのバイオマス
:return: バイオマス効率 (%)
"""
return (biomass_upper / biomass_lower) * 100
# 酵素の反応速度
def enzyme_reaction_rate(V_max, S, K_m):
"""
酵素の反応速度を計算する
:param V_max: 最大反応速度
:param S: 基質濃度
:param K_m: ミハエリス定数
:return: 反応速度
"""
return (V_max * S) / (K_m + S)
# 使用例
divisions = 3
print(f"ミトーシスの細胞数: {cell_division_mitosis(divisions)}")
divisions = 2
print(f"減数分裂の細胞数: {cell_division_meiosis(divisions)}")
prob_Aa = 0.5
print(f"遺伝形質の確率: {genetic_probability(prob_Aa)}")
C = 4.18 # 比熱容量 (J/g·K)
delta_T = 5 # 温度変化 (K)
print(f"カロリメトリーによるエネルギー: {calorimetry(C, delta_T)} J")
biomass_upper = 50 # 上位トロフのバイオマス
biomass_lower = 200 # 下位トロフのバイオマス
print(f"バイオマス効率: {biomass_efficiency(biomass_upper, biomass_lower)}%")
V_max = 10 # 最大反応速度
S = 5 # 基質濃度
K_m = 2 # ミハエリス定数
print(f"酵素の反応速度: {enzyme_reaction_rate(V_max, S, K_m)}")
import numpy as np
import matplotlib.pyplot as plt
# 定数
k_B = 1.38e-23 # ボルツマン定数 (J/K)
# エネルギーの範囲
E = np.linspace(0, 5e-21, 1000) # エネルギーの範囲 (J)
# 温度設定 (K)
T1 = 300 # 温度 1 (K)
T2 = 600 # 温度 2 (K)
T3 = 1200 # 温度 3 (K)
# Maxwell-Boltzmann分布の計算
def maxwell_boltzmann(E, T):
return np.sqrt(2 / np.pi) * (1 / (k_B * T))**(3 / 2) * E**(1 / 2) * np.exp(-E / (k_B * T))
# 分布の計算
f_E_T1 = maxwell_boltzmann(E, T1)
f_E_T2 = maxwell_boltzmann(E, T2)
f_E_T3 = maxwell_boltzmann(E, T3)
# プロット
plt.figure(figsize=(10, 6))
plt.plot(E * 1e21, f_E_T1, label=f'T = {T1} K', color='blue')
plt.plot(E * 1e21, f_E_T2, label=f'T = {T2} K', color='green')
plt.plot(E * 1e21, f_E_T3, label=f'T = {T3} K', color='red')
# ラベルとタイトル
plt.xlabel('Energy (eV)')
plt.ylabel('Probability Density')
plt.title('Energy Distribution of Liquid Molecules')
plt.legend()
plt.grid(True)
plt.show()
import numpy as np
import matplotlib.pyplot as plt
# 定数
R = 8.314 # 気体定数 (J/(mol·K))
delta_H_vap = 40e3 # 蒸発熱 (J/mol)
# 温度範囲 (K)
T = np.linspace(273, 373, 100) # 0°C ~ 100°C の範囲
# 初期蒸気圧 (常温の蒸気圧を仮定)
T0 = 298 # 初期温度 (K)
P0 = 1e5 # 初期蒸気圧 (Pa)
# 蒸気圧の計算
P = P0 * np.exp((delta_H_vap / R) * (1/T0 - 1/T))
# プロット
plt.figure(figsize=(10, 6))
plt.plot(T, P / 1e5, label='Vapor Pressure Curve')
plt.xlabel('Temperature (K)')
plt.ylabel('Vapor Pressure (bar)')
plt.title('Vapor Pressure Curve')
plt.grid(True)
plt.legend()
plt.show()
import numpy as np
import matplotlib.pyplot as plt
# 冷却データ (サンプルデータ)
time = np.linspace(0, 50, 500) # 時間
temperature = np.piecewise(time,
[time < 20, (time >= 20) & (time < 40), time >= 40],
[lambda t: 100 - 1.5 * t,
lambda t: 70 - 0.5 * (t - 20),
lambda t: 60])
# 定数
Kf = 1.86 # 凝固点降下定数 (°C·kg/mol) for water
i = 1 # ヴァンホッフ因子 (非電解質)
m = np.linspace(0, 1, 100) # 溶質のモル濃度 (mol/kg)
# 凝固点降下の計算
delta_T_f = i * Kf * m
# プロット
plt.figure(figsize=(12, 6))
# 冷却曲線のプロット
plt.subplot(1, 2, 1)
plt.plot(time, temperature, label='Cooling Curve')
plt.axhline(y=60, color='red', linestyle='--', label='Freezing Point')
plt.xlabel('Time (s)')
plt.ylabel('Temperature (°C)')
plt.title('Cooling Curve')
plt.legend()
plt.grid(True)
# 様固点降下のプロット
plt.subplot(1, 2, 2)
plt.plot(m, delta_T_f, label='Freezing Point Depression')
plt.xlabel('Molality (mol/kg)')
plt.ylabel('Freezing Point Depression (°C)')
plt.title('Freezing Point Depression')
plt.legend()
plt.grid(True)
plt.tight_layout()
plt.show()
import numpy as np
import matplotlib.pyplot as plt
# Constants
k = 0.1 # Reaction rate constant
t_max = 50 # Simulation time
# Time array
t = np.linspace(0, t_max, 100)
# Initial concentrations
A0 = 1.0 # Initial concentration of hydrogen (H2)
B0 = 1.0 # Initial concentration of iodine (I2)
# Initial concentration of product
C0 = 0.0 # Initial concentration of hydrogen iodide (HI)
# Calculate concentrations
A = A0 * np.exp(-k * t)
B = B0 * np.exp(-k * t)
C = 2 * (A0 - A)
# Plotting
plt.figure(figsize=(10, 6))
plt.plot(t, A, label='[H2]')
plt.plot(t, B, label='[I2]')
plt.plot(t, C, label='[HI]')
plt.xlabel('Time')
plt.ylabel('Concentration')
plt.title('Concentration Changes in Hydrogen Iodide Formation Reaction')
plt.legend()
plt.grid(True)
plt.show()
import numpy as np
import matplotlib.pyplot as plt
# Constants
A = 1e13 # Pre-exponential factor (s^-1)
Ea = 25000 # Activation energy (J/mol), just an example value
R = 8.314 # Universal gas constant (J/(mol·K))
# Temperature range
T_min = 300 # Minimum temperature in Kelvin (approximately 27°C)
T_max = 600 # Maximum temperature in Kelvin (approximately 327°C)
temperatures = np.linspace(T_min, T_max, 100) # Temperature array
# Calculate reaction rates using the Arrhenius equation
reaction_rates = A * np.exp(-Ea / (R * temperatures))
# Normalize the reaction rates at 356°C (629 K) to 1
T_ref = 356 + 273.15 # Reference temperature in Kelvin
reaction_rates_ref = A * np.exp(-Ea / (R * T_ref))
normalized_rates = reaction_rates / reaction_rates_ref
# Plotting
plt.figure(figsize=(10, 6))
plt.plot(temperatures - 273.15, normalized_rates, label='Normalized Reaction Rate')
plt.xlabel('Temperature (°C)')
plt.ylabel('Normalized Reaction Rate')
plt.title('Temperature Dependence of the Reaction Rate')
plt.legend()
plt.grid(True)
plt.show()
import matplotlib.pyplot as plt
from mpl_toolkits.mplot3d import Axes3D
import numpy as np
def plot_molecule_3d(molecule):
fig = plt.figure()
ax = fig.add_subplot(111, projection='3d')
if molecule == 'H2O':
# H2Oの折れ線形
O = np.array([0, 0, 0])
H1 = np.array([-0.5, 0.5, 0])
H2 = np.array([0.5, 0.5, 0])
ax.plot([O[0], H1[0]], [O[1], H1[1]], [O[2], H1[2]], 'ro-')
ax.plot([O[0], H2[0]], [O[1], H2[1]], [O[2], H2[2]], 'ro-')
ax.text(O[0], O[1], O[2], 'O', fontsize=12, ha='center', va='center', color='black')
ax.text(H1[0], H1[1], H1[2], 'H', fontsize=12, ha='center', va='center', color='black')
ax.text(H2[0], H2[1], H2[2], 'H', fontsize=12, ha='center', va='center', color='black')
ax.set_title('H2O Molecule')
elif molecule == 'NH3':
# NH3の三角錐形
N = np.array([0, 0, 0])
H1 = np.array([-0.6, 0.8, 0])
H2 = np.array([0.6, 0.8, 0])
H3 = np.array([0, -1, 0])
ax.plot([N[0], H1[0]], [N[1], H1[1]], [N[2], H1[2]], 'ro-')
ax.plot([N[0], H2[0]], [N[1], H2[1]], [N[2], H2[2]], 'ro-')
ax.plot([N[0], H3[0]], [N[1], H3[1]], [N[2], H3[2]], 'ro-')
ax.text(N[0], N[1], N[2], 'N', fontsize=12, ha='center', va='center', color='black')
ax.text(H1[0], H1[1], H1[2], 'H', fontsize=12, ha='center', va='center', color='black')
ax.text(H2[0], H2[1], H2[2], 'H', fontsize=12, ha='center', va='center', color='black')
ax.text(H3[0], H3[1], H3[2], 'H', fontsize=12, ha='center', va='center', color='black')
ax.set_title('NH3 Molecule')
elif molecule == 'CH4':
# CH4の正四面体形
C = np.array([0, 0, 0])
H1 = np.array([-1, 1, 1])
H2 = np.array([1, 1, 1])
H3 = np.array([-1, -1, 1])
H4 = np.array([1, -1, 1])
ax.plot([C[0], H1[0]], [C[1], H1[1]], [C[2], H1[2]], 'ro-')
ax.plot([C[0], H2[0]], [C[1], H2[1]], [C[2], H2[2]], 'ro-')
ax.plot([C[0], H3[0]], [C[1], H3[1]], [C[2], H3[2]], 'ro-')
ax.plot([C[0], H4[0]], [C[1], H4[1]], [C[2], H4[2]], 'ro-')
ax.text(C[0], C[1], C[2], 'C', fontsize=12, ha='center', va='center', color='black')
ax.text(H1[0], H1[1], H1[2], 'H', fontsize=12, ha='center', va='center', color='black')
ax.text(H2[0], H2[1], H2[2], 'H', fontsize=12, ha='center', va='center', color='black')
ax.text(H3[0], H3[1], H3[2], 'H', fontsize=12, ha='center', va='center', color='black')
ax.text(H4[0], H4[1], H4[2], 'H', fontsize=12, ha='center', va='center', color='black')
ax.set_title('CH4 Molecule')
elif molecule == 'CO2':
# CO2の直線形
C = np.array([0, 0, 0])
O1 = np.array([-1.2, 0, 0])
O2 = np.array([1.2, 0, 0])
ax.plot([O1[0], C[0]], [O1[1], C[1]], [O1[2], C[2]], 'ro-')
ax.plot([O2[0], C[0]], [O2[1], C[1]], [O2[2], C[2]], 'ro-')
ax.text(C[0], C[1], C[2], 'C', fontsize=12, ha='center', va='center', color='black')
ax.text(O1[0], O1[1], O1[2], 'O', fontsize=12, ha='center', va='center', color='black')
ax.text(O2[0], O2[1], O2[2], 'O', fontsize=12, ha='center', va='center', color='black')
ax.set_title('CO2 Molecule')
ax.set_xlim(-2, 2)
ax.set_ylim(-2, 2)
ax.set_zlim(-2, 2)
ax.set_xlabel('X axis')
ax.set_ylabel('Y axis')
ax.set_zlabel('Z axis')
plt.show()
# 分子の形状を3Dでプロットする例
plot_molecule_3d('H2O')
plot_molecule_3d('NH3')
plot_molecule_3d('CH4')
plot_molecule_3d('CO2')
import matplotlib.pyplot as plt
import numpy as np
# 電気陰性度のデータ(ポーリングの値)
elements = ['F', 'O', 'N', 'Cl', 'C', 'H']
electronegativity = [3.98, 3.44, 3.04, 3.16, 2.55, 2.20]
# データのプロット
plt.figure(figsize=(10, 6))
plt.bar(elements, electronegativity, color=['blue', 'orange', 'green', 'red', 'purple', 'cyan'])
plt.xlabel('Element')
plt.ylabel('Electronegativity')
plt.title('Electronegativity of Elements')
plt.ylim(0, 4.5)
plt.grid(True)
plt.show()
import numpy as np
import matplotlib.pyplot as plt
# 時間の配列を作成
time = np.linspace(0, 10, 100)
# 可逆反応の濃度変化をモデル化
def reversible_reaction(t):
return np.exp(-0.1 * t) # 正反応
def reverse_reaction(t):
return 1 - np.exp(-0.1 * t) # 逆反応
# グラフをプロット
plt.figure(figsize=(10, 6))
plt.plot(time, reversible_reaction(time), label='Reversible Reaction', color='blue')
plt.plot(time, reverse_reaction(time), label='Reverse Reaction', color='red')
plt.xlabel('Time')
plt.ylabel('Concentration')
plt.title('Concentration vs Time for Reversible and Reverse Reactions')
plt.legend()
plt.grid(True)
plt.show()
# 時間の配列を作成
time = np.linspace(0, 10, 100)
# 初期濃度と反応速度を設定
initial_concentration_H2 = 1.0
initial_concentration_I2 = 1.0
initial_concentration_HI = 0.0
def reaction_progress(t):
k1 = 0.1 # 正反応速度定数
k2 = 0.05 # 逆反応速度定数
H2 = initial_concentration_H2 * np.exp(-k1 * t) # H2の濃度
I2 = initial_concentration_I2 * np.exp(-k1 * t) # I2の濃度
HI = initial_concentration_HI + (initial_concentration_H2 - H2) # HIの濃度
return H2, I2, HI
H2_concentration = []
I2_concentration = []
HI_concentration = []
for t in time:
H2, I2, HI = reaction_progress(t)
H2_concentration.append(H2)
I2_concentration.append(I2)
HI_concentration.append(HI)
# グラフをプロット
plt.figure(figsize=(10, 6))
plt.plot(time, H2_concentration, label='[H2]', color='blue')
plt.plot(time, I2_concentration, label='[I2]', color='green')
plt.plot(time, HI_concentration, label='[HI]', color='red')
plt.xlabel('Time')
plt.ylabel('Concentration')
plt.title('Concentration of Reactants and Products Over Time')
plt.legend()
plt.grid(True)
plt.show()
# 平衡定数の計算
def equilibrium_constants(T, R):
K_c = 1.0 # 仮定の平衡定数
K_p = K_c * (R * T) ** (delta_n) # Kpの計算
return K_p
T = np.linspace(300, 1500, 100) # 温度範囲
R = 0.0821 # 気体定数
delta_n = 1 # 反応物と生成物のモル数の差
K_p_values = equilibrium_constants(T, R)
# グラフをプロット
plt.figure(figsize=(10, 6))
plt.plot(T, K_p_values, label='Kp vs Temperature', color='purple')
plt.xlabel('Temperature (K)')
plt.ylabel('Kp')
plt.title('Pressure Equilibrium Constant vs Temperature')
plt.legend()
plt.grid(True)
plt.show()
import numpy as np
import matplotlib.pyplot as plt
from matplotlib.animation import FuncAnimation
# チンダル現象のシミュレーション
def plot_tyndall_effect():
plt.figure(figsize=(8, 6))
plt.title('Tyndall Effect')
plt.xlabel('Distance (arbitrary units)')
plt.ylabel('Intensity (arbitrary units)')
distance = np.linspace(0, 10, 500)
intensity = np.exp(-distance**2) * 100 # 光の強度分布のシミュレーション
plt.plot(distance, intensity, color='blue')
plt.fill_between(distance, intensity, color='blue', alpha=0.2)
plt.grid(True)
plt.show()
# ブラウン運動のシミュレーション
def plot_brownian_motion():
num_particles = 100
num_steps = 500
step_size = 0.1
x = np.zeros((num_particles, num_steps))
y = np.zeros((num_particles, num_steps))
for i in range(1, num_steps):
angle = np.random.uniform(0, 2 * np.pi, num_particles)
x[:, i] = x[:, i-1] + step_size * np.cos(angle)
y[:, i] = y[:, i-1] + step_size * np.sin(angle)
plt.figure(figsize=(8, 8))
plt.title('Brownian Motion')
plt.xlabel('X Position')
plt.ylabel('Y Position')
for i in range(num_particles):
plt.plot(x[i], y[i], alpha=0.5)
plt.grid(True)
plt.show()
# 電気泳動のシミュレーション
def plot_electrophoresis():
num_particles = 50
num_steps = 100
step_size = 0.1
electric_field = 0.2 # 電場の強さ
x = np.zeros((num_particles, num_steps))
y = np.zeros((num_particles, num_steps))
for i in range(1, num_steps):
angle = np.random.uniform(0, 2 * np.pi, num_particles)
x[:, i] = x[:, i-1] + step_size * np.cos(angle) + electric_field
y[:, i] = y[:, i-1] + step_size * np.sin(angle)
plt.figure(figsize=(8, 8))
plt.title('Electrophoresis')
plt.xlabel('X Position')
plt.ylabel('Y Position')
for i in range(num_particles):
plt.plot(x[i], y[i], alpha=0.5)
plt.grid(True)
plt.show()
# チンダル現象のプロット
plot_tyndall_effect()
# ブラウン運動のプロット
plot_brownian_motion()
# 電気泳動のプロット
plot_electrophoresis()
import numpy as np
import matplotlib.pyplot as plt
# 実在気体の定数
a = 1.0 # 単位: (L^2 atm / mol^2)
b = 0.1 # 単位: L / mol
R = 0.0821 # 気体定数: (L atm / K mol)
# 温度のリスト
temperatures = [273, 300, 350] # K
# 体積の範囲
V = np.linspace(1, 10, 400) # L
plt.figure(figsize=(10, 6))
# 各温度での状態方程式をプロット
for T in temperatures:
n = 1 # モル数
P = (n * R * T) / (V - n * b) - a * (n**2) / (V**2) # 状態方程式
plt.plot(V, P, label=f'T={T} K')
plt.title('Real Gas State Equation')
plt.xlabel('Volume (L)')
plt.ylabel('Pressure (atm)')
plt.legend()
plt.grid(True)
plt.show()
import matplotlib.pyplot as plt
# Bond energies (kJ/mol)
H_H_bond_energy = 432 # kJ/mol for H2 -> 2H
Cl_Cl_bond_energy = 239 # kJ/mol for Cl2 -> 2Cl
H_Cl_bond_energy = 428 # kJ/mol for HCl -> H + Cl
# Thermochemical equation energy
Q = None # Unknown value to be calculated
# Energy levels for each step in the reaction
states = ['H2 (gas)', '2H (gas)', 'Cl2 (gas)', '2Cl (gas)', 'HCl (gas)']
energies = [0, -H_H_bond_energy, 0, -Cl_Cl_bond_energy, -H_Cl_bond_energy]
# Calculate Q from the energy balance
# H2 + Cl2 -> 2HCl
# ΔH = (2 × 428) - (432 + 239)
Q = (2 * H_Cl_bond_energy) - (H_H_bond_energy + Cl_Cl_bond_energy)
# Update the final energy state with the calculated Q
energies[-1] = -H_Cl_bond_energy + Q
# Plotting the energy diagram
plt.figure(figsize=(10, 6))
plt.plot(states, energies, marker='o', linestyle='-', color='b')
plt.title('Energy Diagram')
plt.xlabel('State')
plt.ylabel('Energy (kJ/mol)')
plt.grid(True)
plt.xticks(rotation=45)
plt.show()
import matplotlib.pyplot as plt
# Given energies (kJ/mol)
lattice_energy = 772 # kJ/mol for NaCl (solid) = Na+ (gas) + Cl- (gas)
ionization_energy_Na = 496 # kJ/mol for Na (gas) = Na+ (gas) + e-
sublimation_heat_Na = 92 # kJ/mol for Na (solid) = Na (gas)
bond_energy_Cl2 = 244 # kJ/mol for Cl2 (gas) = 2Cl (gas)
electron_affinity_Cl = 349 # kJ/mol for Cl (gas) + e- = Cl- (gas)
# Calculate Q (heat of formation of NaCl)
# Na (solid) + 1/2 Cl2 (gas) = NaCl (solid) + Q (kJ)
Q = ionization_energy_Na + sublimation_heat_Na + (bond_energy_Cl2 / 2) - electron_affinity_Cl - lattice_energy
# Energy levels for each step in the reaction
states = ['Na (solid)', 'Na (gas)', 'Na+ (gas)', 'Cl2 (gas)', '2Cl (gas)', 'NaCl (solid)']
energies = [0, sublimation_heat_Na, sublimation_heat_Na + ionization_energy_Na,
0, bond_energy_Cl2 / 2, sublimation_heat_Na + ionization_energy_Na + bond_energy_Cl2 / 2 - electron_affinity_Cl - lattice_energy]
# Plotting the energy diagram
plt.figure(figsize=(10, 6))
plt.plot(states, energies, marker='o', linestyle='-', color='b')
plt.title('Energy Diagram')
plt.xlabel('State')
plt.ylabel('Energy (kJ/mol)')
plt.grid(True)
plt.xticks(rotation=45)
plt.show()
import numpy as np
import matplotlib.pyplot as plt
# Given solubility data
temp_80 = 80 # in Celsius
solubility_80 = 167 # in g per 100g of water
temp_40 = 40 # in Celsius
solubility_40 = 61.3 # in g per 100g of water
# Calculating the amount recrystallized
recrystallized_amount = solubility_80 - solubility_40 # g
# Generating temperature data points
temperature = np.linspace(40, 80, 400)
# Fitting a parabola (2nd degree polynomial) through the given points
coefficients = np.polyfit([40, 80], [solubility_40, solubility_80], 2)
solubility_curve = np.polyval(coefficients, temperature)
# Plotting the solubility curve
plt.figure(figsize=(10, 6))
plt.plot(temperature, solubility_curve, label='Solubility Curve', color='b')
plt.scatter([40, 80], [solubility_40, solubility_80], color='r')
# Adding horizontal lines for initial and final solubility
plt.axhline(y=solubility_80, color='r', linestyle='--', label='Initial solubility at 80°C (167g)')
plt.axhline(y=solubility_40, color='g', linestyle='--', label='Final solubility at 40°C (61.3g)')
# Annotating the recrystallized amount
plt.annotate(f'Recrystallized: {recrystallized_amount}g',
xy=(60, solubility_40 + recrystallized_amount/2),
xytext=(45, solubility_40 + recrystallized_amount/2 + 20),
arrowprops=dict(facecolor='black', shrink=0.05))
plt.title('Recrystallization Process')
plt.xlabel('Temperature (°C)')
plt.ylabel('Solubility (g per 100g of water)')
plt.legend()
plt.grid(True)
plt.show()
import numpy as np
import matplotlib.pyplot as plt
# Simulated solubility data for different substances
temperature = np.linspace(0, 100, 11) # Temperature range from 0°C to 100°C
# Solubility data in g/100g of water for different substances (hypothetical)
potassium_nitrate = np.array([13, 21, 31, 45, 61, 83, 106, 134, 167, 202, 245])
sodium_nitrate = np.array([73, 77, 82, 88, 94, 101, 108, 116, 125, 135, 146])
potassium_chloride = np.array([28, 31, 34, 38, 42, 46, 50, 55, 60, 66, 72])
sodium_chloride = np.array([35, 35.5, 36, 36.5, 37, 37.5, 38, 38.5, 39, 39.5, 40])
lithium_sulfate = np.array([30, 32, 34, 36, 38, 40, 42, 44, 46, 48, 50])
# Plotting the solubility curves
plt.figure(figsize=(10, 6))
plt.plot(temperature, potassium_nitrate, 'b-', label='Potassium Nitrate')
plt.plot(temperature, sodium_nitrate, 'r--', label='Sodium Nitrate')
plt.plot(temperature, potassium_chloride, 'g-.', label='Potassium Chloride')
plt.plot(temperature, sodium_chloride, 'y:', label='Sodium Chloride')
plt.plot(temperature, lithium_sulfate, 'c-', label='Lithium Sulfate')
# Adding title and labels
plt.title('Solubility Curves')
plt.xlabel('Temperature (°C)')
plt.ylabel('Solubility (g per 100g of water)')
plt.legend()
plt.grid(True)
# Show the plot
plt.show()
import matplotlib.pyplot as plt
# Problem 1
# KCl solubility at 40°C
solubility_40C = 40 # g/100g water
# (1) Amount of KCl that can still be dissolved at 40°C
dissolved_KCl = 25 # g
remaining_KCl = solubility_40C - dissolved_KCl
print(f"1(1): Remaining KCl that can be dissolved: {remaining_KCl} g")
# (2) Maximum amount of KCl that can dissolve in 250g water at 40°C
water_mass = 250 # g
max_dissolved_KCl_250g = solubility_40C * (water_mass / 100)
print(f"1(2): Maximum amount of KCl in 250g water: {max_dissolved_KCl_250g} g")
# (3) Amount of KCl in 100g of saturated solution at 40°C
# Solubility ratio
x = solubility_40C
saturated_solution_mass = 100 # g
dissolved_KCl_saturated = (x / (100 + x)) * saturated_solution_mass
print(f"1(3): Amount of KCl in 100g of saturated solution: {dissolved_KCl_saturated:.1f} g")
# Problem 2
# Solubility of KCl at different temperatures
solubility_20C = 30 # g/100g water
solubility_60C = 50 # g/100g water
# (1) Temperature at which KCl starts to precipitate when cooling from 60°C
initial_dissolved_KCl = 40 # g in 100g water
if initial_dissolved_KCl > solubility_40C:
precipitate_temp = 40 # °C
else:
precipitate_temp = 60 # °C
print(f"2(1): Temperature at which KCl starts to precipitate: {precipitate_temp} °C")
# (2) Amount of KCl precipitated when water evaporates at 40°C
# Remaining KCl after evaporation
evaporated_water_mass = 20 # g
max_dissolved_KCl_evaporated = solubility_40C * (evaporated_water_mass / 100)
print(f"2(2): Amount of KCl precipitated after evaporation: {max_dissolved_KCl_evaporated} g")
# Problem 3
# KNO3 solubility at 40°C and 80°C
KNO3_solubility_40C = 60 # g/100g water
KNO3_solubility_80C = 160 # g/100g water
# Amount of KNO3 precipitated when cooling from 80°C to 40°C
initial_dissolved_KNO3 = 160 # g in 100g water
remaining_KNO3_40C = KNO3_solubility_40C
precipitated_KNO3 = initial_dissolved_KNO3 - remaining_KNO3_40C
print(f"3: Amount of KNO3 precipitated: {precipitated_KNO3} g")
# Problem 4
# CuSO4 solubility at 20°C and 60°C
CuSO4_solubility_20C = 20 # g/100g water
CuSO4_solubility_60C = 40 # g/100g water
# Amount of CuSO4·5H2O precipitated when cooling from 60°C to 20°C
initial_dissolved_CuSO4 = 40 # g in 100g water
remaining_CuSO4_20C = CuSO4_solubility_20C
precipitated_CuSO4 = initial_dissolved_CuSO4 - remaining_CuSO4_20C
# Molecular weights
CuSO4_mw = 160
H2O_mw = 18
CuSO4_5H2O_mw = CuSO4_mw + 5 * H2O_mw
precipitated_CuSO4_5H2O = precipitated_CuSO4 * (CuSO4_5H2O_mw / CuSO4_mw)
print(f"4: Amount of CuSO4·5H2O precipitated: {precipitated_CuSO4_5H2O:.1f} g")
# Plotting the solubility curve
temperatures = [20, 40, 60, 80]
KCl_solubility = [30, 40, 50, 60] # Hypothetical solubility data for KCl
KNO3_solubility = [20, 60, 100, 160] # Hypothetical solubility data for KNO3
plt.figure(figsize=(10, 6))
plt.plot(temperatures, KCl_solubility, 'bo-', label='KCl')
plt.plot(temperatures, KNO3_solubility, 'rs-', label='KNO3')
plt.title('Solubility Curves')
plt.xlabel('Temperature (°C)')
plt.ylabel('Solubility (g per 100g of water)')
plt.legend()
plt.grid(True)
plt.show()
import numpy as np
import matplotlib.pyplot as plt
# Parameters
V0 = 50 # Volume of HCl solution (mL)
C0 = 0.1 # Concentration of HCl (M)
C1 = 0.1 # Concentration of NaOH (M)
# Volume range for NaOH addition
V_NaOH = np.linspace(0, 100, 1000) # mL
# Calculate pH
def calculate_pH(V_NaOH, V0, C0, C1):
# Moles of HCl and NaOH
n_HCl = V0 * C0 / 1000 # moles of HCl
n_NaOH = V_NaOH * C1 / 1000 # moles of NaOH
# Initialize pH array
pH = np.zeros_like(V_NaOH)
# Acidic solution case
acidic = n_NaOH <= n_HCl
pH[acidic] = -np.log10(n_HCl - n_NaOH[acidic])
# Basic solution case
basic = n_NaOH > n_HCl
pOH = -np.log10(n_NaOH[basic] - n_HCl)
pH[basic] = 14 - pOH
return pH
pH_values = calculate_pH(V_NaOH, V0, C0, C1)
# Plotting
plt.figure(figsize=(10, 6))
plt.plot(V_NaOH, pH_values, label='Titration Curve', color='b')
plt.axhline(y=7, color='r', linestyle='--', label='Neutral pH (7)')
plt.title('Titration Curve of Strong Acid with Strong Base')
plt.xlabel('Volume of NaOH added (mL)')
plt.ylabel('pH')
plt.legend()
plt.grid(True)
plt.show()
import numpy as np
import matplotlib.pyplot as plt
# Parameters
V0 = 50 # Volume of NH3 solution (mL)
C0 = 0.1 # Concentration of NH3 (M)
C1 = 0.1 # Concentration of HCl (M)
Kb = 1.8e-5 # Base dissociation constant for NH3
# Volume range for HCl addition
V_HCl = np.linspace(0, 100, 1000) # mL
# Calculate pH
def calculate_pH_weak_base(V_HCl, V0, C0, C1, Kb):
# Moles of NH3 and HCl
n_base = V0 * C0 / 1000 # moles of NH3
n_acid = V_HCl * C1 / 1000 # moles of HCl
# Initialize pH array
pH = np.zeros_like(V_HCl)
# Determine pH based on the amount of base and acid
for i in range(len(V_HCl)):
if n_acid[i] < n_base:
# Before equivalence point
C_base = (n_base - n_acid[i]) / (V0 + V_HCl[i]) # Concentration of NH3
C_conjugate_acid = (n_acid[i] / (V0 + V_HCl[i])) # Concentration of NH4+
pOH = 0.5 * (np.log10(Kb * C_base / C_conjugate_acid))
pH[i] = 14 - pOH
else:
# After equivalence point
excess_acid = n_acid[i] - n_base
pH[i] = -np.log10(excess_acid / (V0 + V_HCl[i]))
return pH
pH_values = calculate_pH_weak_base(V_HCl, V0, C0, C1, Kb)
# Plotting
plt.figure(figsize=(10, 6))
plt.plot(V_HCl, pH_values, label='Titration Curve', color='b')
plt.axhline(y=7, color='r', linestyle='--', label='Neutral pH (7)')
plt.title('Titration Curve of Weak Base with Strong Acid')
plt.xlabel('Volume of HCl added (mL)')
plt.ylabel('pH')
plt.legend()
plt.grid(True)
plt.show()
import numpy as np
import matplotlib.pyplot as plt
# 定数
N2O5_0 = 2.33 # 初期濃度 (mol/L)
k = 0.63 # 反応速度定数 (s^-1)
time = np.linspace(0, 2000, 1000) # 時間 (秒)
# 濃度の計算
N2O5_concentration = N2O5_0 * np.exp(-k * time)
# 濃度の対数計算 (自然対数)
ln_N2O5 = np.log(N2O5_concentration)
# グラフの作成
plt.figure(figsize=(10, 6))
# 濃度のプロット
plt.subplot(2, 1, 1)
plt.plot(time, N2O5_concentration, label='[N2O5]', color='blue')
plt.title('Concentration of N2O5 vs Time')
plt.xlabel('Time (s)')
plt.ylabel('Concentration [N2O5] (mol/L)')
plt.grid(True)
plt.legend()
# 対数プロット (一次プロット)
plt.subplot(2, 1, 2)
plt.plot(time, ln_N2O5, label='ln[N2O5]', color='green')
plt.title('First-Order Plot (ln[N2O5] vs Time)')
plt.xlabel('Time (s)')
plt.ylabel('ln[N2O5]')
plt.grid(True)
plt.legend()
# グラフの表示
plt.tight_layout()
plt.show()
import numpy as np
import matplotlib.pyplot as plt
# 定数
R = 8.3145 # 気体定数 (J/K/mol)
Ea = 1.24e5 # 活性化エネルギー (J/mol)
A = 1e13 # 頻度因子
# 温度範囲 (K)
T = np.linspace(300, 1500, 100) # 温度範囲を300Kから1500Kまで
# アレニウス式に基づく反応速度定数の計算
k = A * np.exp(-Ea / (R * T))
# 自然対数を取る
ln_k = np.log(k)
# プロットの作成
plt.figure(figsize=(10, 6))
# 反応速度定数 k のプロット
plt.subplot(2, 1, 1)
plt.plot(T, k, label='Reaction rate constant k', color='blue')
plt.title('Reaction Rate Constant (k) vs Temperature (T)')
plt.xlabel('Temperature (K)')
plt.ylabel('k')
plt.grid(True)
plt.legend()
# ln(k) と 1/T のプロット (線形化されたアレニウス式)
plt.subplot(2, 1, 2)
plt.plot(1/T, ln_k, label='ln(k)', color='green')
plt.title('Linearized Arrhenius Plot (ln(k) vs 1/T)')
plt.xlabel('1/Temperature (1/K)')
plt.ylabel('ln(k)')
plt.grid(True)
plt.legend()
# グラフの表示
plt.tight_layout()
plt.show()
import numpy as np
# 定数
R = 8.3145 # 気体定数 (J/K/mol)
T1 = 273.15 # 温度 T1 (K), 0 deg C
T2 = 318.15 # 温度 T2 (K), 45 deg C
k1 = 1.06e-5 # 速度定数 k1 (s^-1)
k2 = 2.92e-3 # 速度定数 k2 (s^-1)
# log(k2/k1) の計算
log_k_ratio = np.log(k2 / k1)
# 1/T1 - 1/T2 の計算
temp_diff = (1 / T1) - (1 / T2)
# 活性化エネルギー E_a の計算 (J/mol)
Ea = -log_k_ratio * R / temp_diff
# 結果を kJ/mol で表示
Ea_kJ = Ea / 1000 # J/mol -> kJ/mol
print(f"活性化エネルギー (E_a): {Ea_kJ:.2f} kJ/mol")
# 反応物と生成物の濃度 (mol/L)
A_conc = 1.0 # [A] の濃度 (mol/L)
B_conc = 1.0 # [B] の濃度 (mol/L)
C_conc = 2.0 # [C] の濃度 (mol/L)
D_conc = 2.0 # [D] の濃度 (mol/L)
# 係数 (反応式における化学量論係数)
a = 1 # aA の a
b = 1 # bB の b
c = 1 # cC の c
d = 1 # dD の d
# 平衡定数 K の計算
K = (C_conc ** c * D_conc ** d) / (A_conc ** a * B_conc ** b)
# 結果の表示
print(f"平衡定数 K: {K:.2f}")
import math
from scipy.optimize import fsolve
# (1) Calculation of the equilibrium constant K_c
HI_mol = 3.16 # Moles of hydrogen iodide produced at equilibrium [mol]
H2_mol_remaining = 0.42 # Moles of hydrogen remaining at equilibrium [mol]
I2_mol_remaining = 0.42 # Moles of iodine remaining at equilibrium [mol]
# Calculation of the equilibrium constant K_c
Kc = (HI_mol ** 2) / (H2_mol_remaining * I2_mol_remaining)
print(f"(1) Equilibrium constant K_c: {Kc:.2f}")
# (2) Calculation of the amount of hydrogen iodide produced at equilibrium under different initial conditions
# Initial conditions
H2_initial = 5.00 # Initial moles of hydrogen [mol]
I2_initial = 3.50 # Initial moles of iodine [mol]
# Define the equation to find the equilibrium point
def equilibrium(x):
return (2 * x) ** 2 / ((H2_initial - x) * (I2_initial - x)) - Kc
# Solve for x (half the moles of HI produced) using fsolve
x_solution = fsolve(equilibrium, 1.0)[0]
# Calculate the total moles of hydrogen iodide produced
HI_mol_generated = 2 * x_solution
print(f"(2) Moles of hydrogen iodide produced at equilibrium: {HI_mol_generated:.2f} mol")
import math
# Given constants
Kw = 1.01e-14 # Ion product of water at 25°C in mol^2/L^2
H_plus_concentration = 0.0100 # Concentration of H⁺ ions in mol/L for HCl
# (1) Calculate the concentration of OH⁻ ions using Kw
OH_minus_concentration = Kw / H_plus_concentration
print(f"Concentration of OH⁻ ions: {OH_minus_concentration:.2e} mol/L")
# (2) Calculate the pH
pH = -math.log10(H_plus_concentration)
print(f"pH of the solution: {pH:.2f}")
# (3) Calculate the pOH
pOH = -math.log10(OH_minus_concentration)
print(f"pOH of the solution: {pOH:.2f}")
import math
# Constants
R = 8.314 # Gas constant in J/(mol*K)
F = 96485 # Faraday constant in C/mol
T = 298.15 # Temperature in Kelvin (25°C assumed)
n = 2 # Number of electrons transferred
# Standard EMF of Daniell cell
E_standard = 1.10 # in Volts (for the Zn-Cu system)
# Concentrations of Zn2+ and Cu2+
Zn_concentration = 0.010 # Concentration of Zn2+ in mol/L
Cu_concentration = 1.0 # Concentration of Cu2+ in mol/L
# Nernst equation for the Daniell cell
E = E_standard - (R * T / (n * F)) * math.log(Zn_concentration / Cu_concentration)
print(f"The EMF of the Daniell cell is: {E:.4f} V")