Extensible periodic table of the elements with support for mass, density and X-ray/neutron scattering information
npx @tessl/cli install tessl/pypi-periodictable@2.0.0An extensible periodic table of the elements with comprehensive support for mass, density, X-ray and neutron scattering information. This package enables scientific calculations including neutron activation analysis, X-ray scattering factor computations, and chemical formula processing with composite material property calculations.
pip install periodictableimport periodictableAccess the main periodic table:
from periodictable import elementsDirect element imports:
from periodictable import H, He, Li, Fe, Ni # Individual elements by symbol
from periodictable import hydrogen, helium, iron # Individual elements by nameimport periodictable as pt
# Access elements by symbol, name, or atomic number
iron = pt.Fe # or pt.iron or pt.elements[26]
nickel = pt.elements.Ni
# Access isotopes and ions
iron56 = pt.Fe[56] # Iron-56 isotope
iron2plus = pt.Fe.ion[2] # Fe2+ ion
deuterium = pt.D # Special symbol for deuterium
# Element properties (lazy-loaded)
print(f"Iron mass: {iron.mass} {iron.mass_units}")
print(f"Iron density: {iron.density} {iron.density_units}")
# Chemical formulas and calculations
water = pt.formula("H2O")
print(f"Water molecular mass: {water.mass} u")
# Neutron scattering length density
sld_real, sld_imag, sld_inc = pt.neutron_sld(water, density=1.0)
print(f"Water neutron SLD: {sld_real:.4f} × 10⁻⁶ Ų⁻²")The periodictable package uses a modular architecture with lazy loading for performance:
This design enables efficient memory usage through on-demand loading while providing comprehensive access to elemental data and scientific calculations.
Core functionality for accessing elements, isotopes, and ions from the periodic table with comprehensive property data including mass, density, and atomic structure information.
# PeriodicTable access methods
elements[atomic_number: int] -> Element
elements.symbol(symbol: str) -> Element
elements.name(name: str) -> Element
elements.isotope(isotope_str: str) -> Isotope
# Element properties and methods
Element.symbol: str
Element.name: str
Element.number: int
Element.mass: float
Element.density: float
Element[mass_number: int] -> Isotope
Element.ion[charge: int] -> IonParse chemical formulas, calculate molecular properties, create mixtures by weight or volume, and perform isotope substitutions with full support for composite material calculations.
def formula(compound: str = None, density: float = None,
natural_density: float = None, name: str = None) -> Formula
def mix_by_weight(*args, **kwargs) -> Formula
def mix_by_volume(*args, **kwargs) -> Formula
# Formula class properties and methods
Formula.atoms: dict
Formula.mass: float
Formula.density: float
Formula.charge: int
Formula.replace(source, target, portion: float = 1) -> FormulaComprehensive neutron scattering calculations including scattering length densities, cross sections, and penetration depths for elements, isotopes, and compounds with energy-dependent and activation analysis support.
def neutron_sld(compound, density: float = None, wavelength: float = None) -> tuple
def neutron_scattering(compound, density: float = None, wavelength: float = None) -> dict
def neutron_wavelength(energy: float) -> float
def neutron_energy(wavelength: float) -> floatX-ray scattering factor calculations, scattering length densities, form factors, and optical properties including refractive indices and mirror reflectivity for crystallographic and materials science applications.
def xray_sld(compound, density: float = None, energy: float = None,
wavelength: float = None) -> tuple
def xray_wavelength(energy: float) -> float
def xray_energy(wavelength: float) -> float
def index_of_refraction(compound, density: float = None, energy: float = None,
wavelength: float = None) -> complexFundamental physical constants, crystallographic calculations, uncertainty parsing, and periodic table data visualization tools for scientific applications.
# Constants module
avogadro_number: float = 6.02214076e23
planck_constant: float = 6.62607015e-34
electron_volt: float = 1.602176634e-19
speed_of_light: float = 299792458
# Utility functions
def parse_uncertainty(s: str) -> tuple
def cell_volume(a: float = None, b: float = None, c: float = None,
alpha: float = None, beta: float = None,
gamma: float = None) -> float
# Core utility functions
def default_table(table=None) -> PeriodicTable
def change_table(atom, table) -> Union[Element, Isotope, Ion]
def isatom(val) -> bool
def iselement(val) -> bool
def isisotope(val) -> bool
def ision(val) -> boolclass PeriodicTable:
"""Periodic table containing all elements, isotopes, and ions."""
def __getitem__(self, key: int) -> Element: ...
def __iter__(self) -> Iterator[Element]: ...
def symbol(self, symbol: str) -> Element: ...
def name(self, name: str) -> Element: ...
def isotope(self, isotope_str: str) -> Isotope: ...
class Element:
"""Individual element with properties and access to isotopes/ions."""
symbol: str
name: str
number: int
mass: float
mass_units: str
density: float
density_units: str
def __getitem__(self, mass_number: int) -> Isotope: ...
def add_isotope(self, mass_number: int) -> Isotope: ...
@property
def ion(self) -> dict: ...
class Isotope(Element):
"""Element isotope with specific mass number."""
isotope: int
@property
def ion(self) -> dict: ...
class Ion(Element):
"""Charged element or isotope."""
charge: int
class Formula:
"""Parsed chemical formula with calculation capabilities."""
atoms: dict
mass: float
molecular_mass: float
density: float
charge: int
hill: str
mass_fraction: dict
def replace(self, source, target, portion: float = 1) -> 'Formula': ...
def neutron_sld(self, wavelength: float = None, energy: float = None) -> tuple: ...
def xray_sld(self, energy: float = None, wavelength: float = None) -> tuple: ...
def change_table(self, table) -> 'Formula': ...
def __add__(self, other: 'Formula') -> 'Formula': ...
def __iadd__(self, other: 'Formula') -> 'Formula': ...
def __rmul__(self, multiplier: float) -> 'Formula': ...