ANASEN_analysis/ELoss/material_definitions.py
James Szalkie 8240310039 sanitized
2026-08-25 11:14:10 -04:00

74 lines
1.7 KiB
Python

"""Shared material definitions for ELoss analysis scripts."""
import pycatima as catima
R_GAS_CONSTANT = 8.3144 # J/mol/K
def _gas_molar_density(p_torr, temp_k):
"""Return molar density in mol/m^3 from pressure (Torr) and temperature (K)."""
p_pa = p_torr * 133.322
return p_pa / (R_GAS_CONSTANT * temp_k)
def build_material(medium, p_torr, temp_k):
"""
Build a CATIMA material and return (material, density_g_cm3).
Supported media names:
- He
- PureHe
- Si
- kapton
"""
medium_key = medium.strip().lower()
if medium_key == "he":
m_he = 4.0026
m_c = 12.0000
m_o = 15.9949
material_def = [
(m_he, 2, 0.96),
(m_c, 6, 0.04),
(m_o, 8, 0.08),
]
molar_density = _gas_molar_density(p_torr, temp_k)
m_mix_avg = 0.96 * m_he + 0.04 * (m_c + 2 * m_o)
rho_g_cm3 = (molar_density * m_mix_avg) / 1e6
elif medium_key == "purehe":
m_he = 4.0026
material_def = [(m_he, 2, 1.0)]
molar_density = _gas_molar_density(p_torr, temp_k)
m_mix_avg = m_he
rho_g_cm3 = (molar_density * m_mix_avg) / 1e6
elif medium_key == "si":
m_si = 28.084
material_def = [(m_si, 14, 1.0)]
rho_g_cm3 = 2.33
elif medium_key == "kapton":
m_h = 1.008
m_c = 12.011
m_n = 14.007
m_o = 15.999
material_def = [
(m_h, 1, 0.026),
(m_c, 6, 0.691),
(m_n, 7, 0.073),
(m_o, 8, 0.209),
]
rho_g_cm3 = 1.42
else:
raise ValueError(f"Unsupported medium: {medium}")
material = catima.Material(material_def)
material.density(rho_g_cm3)
return material, rho_g_cm3