or run

npx @tessl/cli init
Log in

Version

Tile

Overview

Evals

Files

docs

constants-utilities.mdelements.mdformulas.mdindex.mdneutron-scattering.mdxray-scattering.md
tile.json

tessl/pypi-periodictable

Extensible periodic table of the elements with support for mass, density and X-ray/neutron scattering information

Workspace
tessl
Visibility
Public
Created
Last updated
Describes
pypipkg:pypi/periodictable@2.0.x

To install, run

npx @tessl/cli install tessl/pypi-periodictable@2.0.0

index.mddocs/

Periodictable

An 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.

Package Information

  • Package Name: periodictable
  • Language: Python
  • Installation: pip install periodictable
  • Documentation: https://periodictable.readthedocs.io

Core Imports

import periodictable

Access the main periodic table:

from periodictable import elements

Direct element imports:

from periodictable import H, He, Li, Fe, Ni  # Individual elements by symbol
from periodictable import hydrogen, helium, iron  # Individual elements by name

Basic Usage

import 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⁻⁶ Ų⁻²")

Architecture

The periodictable package uses a modular architecture with lazy loading for performance:

  • PeriodicTable: Central table containing all elements, isotopes, and ions
  • Element/Isotope/Ion Classes: Core data structures with dynamic property loading
  • Formula System: Chemical formula parser with composition and property calculations
  • Scattering Modules: Specialized calculations for neutron (nsf) and X-ray (xsf) scattering
  • Property System: Extensible lazy-loading mechanism for element attributes
  • Data Integration: Authoritative data from NIST, NCNR, and other scientific sources

This design enables efficient memory usage through on-demand loading while providing comprehensive access to elemental data and scientific calculations.

Capabilities

Element and Isotope Access

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] -> Ion

Elements and Isotopes

Chemical Formula Processing

Parse 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) -> Formula

Chemical Formulas

Neutron Scattering Calculations

Comprehensive 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) -> float

Neutron Scattering

X-ray Scattering Calculations

X-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) -> complex

X-ray Scattering

Physical Constants and Utilities

Fundamental 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) -> bool

Constants and Utilities

Types

class 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': ...