Home » Chemistry and python – the mendeleev package

Chemistry and python – the mendeleev package

by chemdude71

In this article, we will look at a package that provides a Python API for accessing various properties of elements from the periodic table of elements. It is called Mendeelev

In the case of python development, I use a mixture of development environments – thonny, PyCharm, and using Anaconda – VSCode

I recommend looking at basic Python tutorials online if you are just getting started – this is designed for people with a working knowledge. You have installed Python and/or a development environment and done some basic programming.

Installation

pip install mendeleev

Basic Examples

We will start with silicon

from mendeleev import Si
print("Si's name is ", Si.name)

When you run this you will see something like this in the REPL window

Si’s name is Silicon

Now let us go further and also get the atomic number and weight of silicon

from mendeleev import Si
print("Si's name is ", Si.name)
print("Si's atomic number is ", Si.atomic_number)
print("Si's atomic weight is ", Si.atomic_weight)

You will see this

Si’s name is Silicon
Si’s atomic number is 14
Si’s atomic weight is 28.085

You can also use the element function, let us do that now

from mendeleev import element
si = element('Si')
print (si.atomic_number)
print (si.atomic_weight)
print (si.description)
print (si.group)
print (si.symbol)

Run this and you will see the following in the Python REPL window

14
28.085
Metalloid element belonging to group 14 of the periodic table. It is the second most abundant element in the Earth’s crust, making up 25.7% of it by weight. Chemically less reactive than carbon. First identified by Lavoisier in 1787 and first isolated in 1823 by Berzelius.
<Group(symbol=IVA, name=Carbon group)>
Si

One advantage of VSCode and having autocomplete in the example above as soon as I typed in print (si. a list of properties that I could use was displayed and could be scrolled through. Other IDEs may have the same functionality.

The Python library has a huge amount of properties available such as

atomic number
atomic volume
atomic weight
block
cas
electrons
electronic configuration
group
name
neutrons
mass number
period
protons
series
symbol

There are many, many more that are available – the documentation link at the bottom of the article will show you them

Isotopes

Lets now display a list of isotopes of Silicon, here is how you do that

from mendeleev import element
si = element('Si')
for iso in si.isotopes:
print(iso)

Run this and in the reply, you will see something like this, I have reduced the output as you may know there are over 20 isotopes of Silicon

atomic_number= 14, mass_number= 26, mass=25.9923338(1), abundance=None
atomic_number= 14, mass_number= 27, mass=26.9867047(1), abundance=None
atomic_number= 14, mass_number= 28, mass=27.9769265344(6), abundance=92.254(4)
atomic_number= 14, mass_number= 29, mass=28.9764946643(6), abundance=4.67(2)
atomic_number= 14, mass_number= 30, mass=29.97377014(2), abundance=3.074(2)

Thats just scratching the surface of the library, we will return with some more fun and games in a future article

Links

https://mendeleev.readthedocs.io/en/stable/index.html

http://maxpython.com/

 

This website uses cookies to improve your experience. We'll assume you're ok with this, but you can opt-out if you wish. Accept Read More

Adblock Detected

Please support us by disabling your AdBlocker extension from your browsers for our website.