mendeleev

repository·master·Indexed 43 days ago

https://github.com/lmmentel/mendeleev

A Pythonic periodic table of elements providing a convenient API for accessing properties of elements, ions, and isotopes. Version v1.3.0 integrates with pint for unit-aware physical properties, pandas for data analysis, and bokeh, plotly, or seaborn for periodic table visualizations.

Tokens
46.3K
Snippets
159
Records
219
Agent score
54%

What's inside mendeleev

  1. Overview of mendeleev capabilities

    master

    mendeleev is a Pythonic periodic table of elements. It provides a convenient API for accessing properties of elements, ions, and isotopes.

    Key features include:

    • Data Access: Comprehensive properties including basic, physical, computed, and isotope-specific data.
    • Data Science Integration: Easy interface to pandas for data manipulation.
    • Visualization: Integration with bokeh to create customized periodic tables and visualize periodic trends.
    • Units Support: Since v1.3.0, it integrates with pint to provide unit-aware physical properties.
  2. Key features of mendeleev

    master

    mendeleev provides a comprehensive toolkit for chemical data:

    • Rich Dataset: Over 100 properties per element (atomic, physical, thermodynamic, electronic).
    • Isotope Information: Data on abundances, masses, half-lives, decay modes, and nuclear properties.
    • Units Support: Integration with pint for unit-aware calculations (available since v1.1.0).
    • Visualization: Compatible with bokeh, plotly, and seaborn for creating periodic tables and trends.
    • Data Access: Support for direct SQLite queries, pandas DataFrame exports, and SQLAlchemy ORM.
    • Electronegativity: Access to 14+ different scales (e.g., Pauling, Allred-Rochow, Mulliken).
  3. Explore the mendeleev API structure

    master

    The mendeleev library is organized into several functional layers. Most users should interact with the Core Modules for high-level data access. Advanced users can leverage Data Models (SQLAlchemy-based), Specialized Modules for calculations, or Visualization tools for rendering periodic tables.

    API Layers

    • Core Modules: High-level functions and classes for accessing element data. Includes mendeleev.mendeleev, mendeleev.fetch, and mendeleev.ion.
    • Data Models: SQLAlchemy models representing chemical entities and properties (mendeleev.models).
    • Specialized Modules: Modules for specific calculations and data processing, such as mendeleev.electronegativity and mendeleev.econf.
    • Utility Modules: Database access and utility functions (mendeleev.db, mendeleev.utils, mendeleev.cli).
    • Visualization: Tools for visualizing periodic tables. The primary entry point is the mendeleev.vis.periodictable.periodic_table function, with support for bokeh, plotly, and seaborn backends.
  4. Available data models in mendeleev

    master

    The mendeleev library provides several specialized classes to access different types of chemical and physical data. The primary models include:

    • Element: Core elemental data.
    • Isotope: Data related to specific isotopes.
    • IsotopeDecayMode: Information on how isotopes decay.
    • ScatteringFactor: Atomic scattering factors.
    • IonizationEnergy: Ionization energy data.
    • IonicRadius: Ionic radii information.
    • OxidationState: Data on oxidation states.
    • PhaseTransition: Information on phase transitions.
    • ScreeningConstant: Screening constant data.
  5. Understand data origins and conventions for Mendeleev properties

    master

    The mendeleev package aggregates chemical data from various scientific sources. When using the library, be aware of the following data conventions:

    Density

    • Solids and Liquids: Reported in $g/cm^3$ at temperatures near room temperature.
    • Gases: Calculated ideal gas densities at 25°C and 101.325 kPa (converted from $g/L$ to $g/cm^3$).
    • Allotropes: For elements with multiple allotropes, the most abundant form is reported (e.g., Carbon as graphite, Sulfur as rhombic).

    Atomic Weight

    • Primarily sourced from IUPAC. For radioactive elements, the weight is taken as the mass number of the most stable isotope.

    Electronegativity

    • Allen Scale: Values are reported in eV (not converted to Pauling units).
    • Mullay Scale: For elements with multiple values, specific hybrid values are chosen (e.g., C sp3, N p, O p).

    Radii

    • Covalent Radius (Cordero): For elements like C, values for different valences are averaged. For Mn, Fe, and Co, low and high spin values are averaged.
    • Van der Waals Radius (Alvarez): Bulk data from Alvarez (2013), with noble gas updates from Vogt (2014).
  6. Access raw mendeleev data in multiple formats

    master

    If you require the raw data instead of using the Python API, you can find the data assets in the mendeleev-data repository. The data is available in the following formats:

    • csv
    • html
    • json
    • sql
    • markdown

    All data assets are tagged with the same version numbers as the mendeleev package.

  7. Use Element, Isotope, and Ion data models

    master

    mendeleev provides object-oriented representations of chemical entities.

    Core Models

    • Element: The main class with 80+ properties (e.g., atomic_number, atomic_weight, melting_point). Accessed via element().
    • Isotope: Contains mass, abundance, half-life, and decay modes. Accessed via isotope() or element.isotopes.
    • Ion: Represents ionic species with charge-dependent properties. Created via Ion('Symbol', charge=N).

    Property Models

    • IonicRadius: Radii for different oxidation states and coordination numbers.
    • IonizationEnergy: Successive ionization energies.
    • OxidationState: Possible oxidation states for elements.
    • PropertyMetadata: Metadata about properties including units, sources, and citations.
  8. Set up mendeleev for development

    master

    For contributors needing to run tests, build documentation, or modify the codebase, follow these steps using poetry:

    1. Clone the repository and enter the directory.
    2. Install core dependencies.
    3. (Optional) Install visualization extras.
    4. (Optional) Install pre-commit hooks for ruff linting and formatting.
    5. Run the test suite using pytest.
    6. (Optional) Build documentation by installing docs dependencies and running make html.
    git clone https://github.com/lmmentel/mendeleev.git
    cd mendeleev
    
    # Install core dependencies
    poetry install
    
    # With visualization extras
    poetry install --with vis
    
    # Install pre-commit hooks (ruff lint + format)
    pre-commit install
    
    # Run tests
    poetry run pytest
    
    # Build docs (one-time: install docs deps, then build)
    poetry install --with docs
    cd docs
    poetry run make html
  9. Verify data sources for property values

    master

    If you suspect a property value is incorrect, you can check the citation keys associated with that attribute by querying the propertymetadata table.

    from mendeleev import fetch_table
    
    metadata = fetch_table('propertymetadata')
    prop_info = metadata[metadata['attribute_name'] == 'atomic_radius']
    print(prop_info['citation_keys'])