Skip to main content

Yet another elements package

Project description

elementable

Yet another elements package

GitHub Actions Build Status codecov PyPI version Documentation Status

Elementable is another elements package defined in Python. It is written to be usable with a number of different unit systems and classes. At its most minimal, it has no dependencies outside the main Python library. However, the real point of the package is to automagically work with a number of units, base classes, custom data, and be generally flexible.

Usage

Standard

You can use Elementable immediately by importing the standard Elements class. Please see the documentation for information about customization. Each element is defined uniquely to allow for is comparisons.

In [1]: import elementable as elm

In [2]: h = elm.Elements(atomic_number=1)

In [3]: h is elm.Elements(name="hydrogen")
Out[3]: True

In [4]: h is elm.Elements.H
Out[4]: True

In [5]: h.mass
Out[5]: 1.00782503223

Supported attributes include:

  • atomic_number
  • symbol
  • name
  • mass (in atomic mass units)
  • period
  • group
  • covalent_radius (in angstrom)

Each attribute can be used to obtain an Element or list of Elements. Floats are rounded to the nearest 4 decimals when using Elements().

In [5]: elm.Elements(mass=1.0078)
Out[5]: Element(name='hydrogen', symbol='H', atomic_number=1, mass=1.00782503223, period=1, group=1, covalent_radius=0.31)

Using Elements() to retrieve an element can be quite slow, as a number of different cases are checked. If your search is more defined, you can access registries for each attribute directly at Elements.registry. Keys for all floats are rounded to 4 decimal places.

In [6]: elm.Elements.registry.mass[1.0078]
Out[6]: Element(name='hydrogen', symbol='H', atomic_number=1, mass=1.00782503223, period=1, group=1, covalent_radius=0.31)

For attributes where multiple elements have the same value, a sorted tuple of elements is returned.

In [8]: elm.Elements(period=5)
Out[8]:
(Element(name='rubidium', symbol='Rb', atomic_number=37, mass=84.9117897379, period=5, group=1, covalent_radius=2.2),
 Element(name='strontium', symbol='Sr', atomic_number=38, mass=87.9056125, period=5, group=2, covalent_radius=1.95),
 Element(name='yttrium', symbol='Y', atomic_number=39, mass=88.9058403, period=5, group=3, covalent_radius=1.9),
 Element(name='zirconium', symbol='Zr', atomic_number=40, mass=89.9046977, period=5, group=4, covalent_radius=1.75),
 Element(name='niobium', symbol='Nb', atomic_number=41, mass=92.906373, period=5, group=5, covalent_radius=1.64),
 Element(name='molybdenum', symbol='Mo', atomic_number=42, mass=97.90540482, period=5, group=6, covalent_radius=1.54),
 Element(name='technetium', symbol='Tc', atomic_number=43, mass=97.9072124, period=5, group=7, covalent_radius=1.47),
 Element(name='ruthenium', symbol='Ru', atomic_number=44, mass=101.9043441, period=5, group=8, covalent_radius=1.46),
 Element(name='rhodium', symbol='Rh', atomic_number=45, mass=102.905498, period=5, group=9, covalent_radius=1.42),
 Element(name='palladium', symbol='Pd', atomic_number=46, mass=105.9034804, period=5, group=10, covalent_radius=1.39),
 Element(name='silver', symbol='Ag', atomic_number=47, mass=106.9050916, period=5, group=11, covalent_radius=1.45),
 Element(name='cadmium', symbol='Cd', atomic_number=48, mass=113.90336509, period=5, group=12, covalent_radius=1.44),
 Element(name='indium', symbol='In', atomic_number=49, mass=114.903878776, period=5, group=13, covalent_radius=1.42),
 Element(name='tin', symbol='Sn', atomic_number=50, mass=119.90220163, period=5, group=14, covalent_radius=1.39),
 Element(name='antimony', symbol='Sb', atomic_number=51, mass=120.903812, period=5, group=15, covalent_radius=1.39),
 Element(name='tellurium', symbol='Te', atomic_number=52, mass=129.906222748, period=5, group=16, covalent_radius=1.38),
 Element(name='iodine', symbol='I', atomic_number=53, mass=126.9044719, period=5, group=17, covalent_radius=1.39),
 Element(name='xenon', symbol='Xe', atomic_number=54, mass=131.9041550856, period=5, group=18, covalent_radius=1.4))

These can be narrowed down with multiple keyword arguments.

In [9]: elm.Elements(period=5, group=17)
Out[9]: (Element(name='iodine', symbol='I', atomic_number=53, mass=126.9044719, period=5, group=17, covalent_radius=1.39),)

Units

The default units in the standard elements library are:

  • mass: atomic mass units
  • length: angstrom

Sources

The data in the standard package are sourced, with much gratitude, from qcelemental version 0.23.0. Please see the documentation for qcelemental for full details. The covalent radii are obtained from Alvarez 2008.

Copyright

Copyright (c) 2022, Lily Wang

Acknowledgements

Project based on the Computational Molecular Science Python Cookiecutter version 1.6.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

elementable-0.3.0.tar.gz (57.5 kB view details)

Uploaded Source

File details

Details for the file elementable-0.3.0.tar.gz.

File metadata

  • Download URL: elementable-0.3.0.tar.gz
  • Upload date:
  • Size: 57.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.7.1 importlib_metadata/4.10.1 pkginfo/1.8.2 requests/2.27.1 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.9.10

File hashes

Hashes for elementable-0.3.0.tar.gz
Algorithm Hash digest
SHA256 eb7b64dbb8b5f56f07072abf3e4418e52e5a983c59a56282bab1bb1b2fc84fd3
MD5 955f00339b876f9d0aa97c8a091b67b4
BLAKE2b-256 edb72b8f5fbf3e839e27d3fd9e1404180d6ce84123143a868c41a766ecf482fc

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page