Skip to content

Commit

Permalink
Release v2024.5.24
Browse files Browse the repository at this point in the history
  • Loading branch information
cgohlke committed May 23, 2024
1 parent 86504b9 commit 405fe3a
Showing 1 changed file with 87 additions and 76 deletions.
163 changes: 87 additions & 76 deletions README.rst
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
..
This file is generated by setup.py
Molecular mass calculations
===========================

Expand All @@ -14,7 +17,7 @@ of the chemical elements.

:Author: `Christoph Gohlke <https://www.cgohlke.com>`_
:License: BSD 3-Clause
:Version: 2024.5.10
:Version: 2024.5.24
:DOI: `10.5281/zenodo.7135495 <https://doi.org/10.5281/zenodo.7135495>`_

Quickstart
Expand All @@ -23,7 +26,7 @@ Quickstart
Install the molmass package and all dependencies from the
`Python Package Index <https://pypi.org/project/molmass/>`_::

python -m pip install -U molmass[all]
python -m pip install -U "molmass[all]"

Print the console script usage::

Expand Down Expand Up @@ -54,6 +57,10 @@ This revision was tested with the following requirements and dependencies
Revisions
---------

2024.5.24

- Fix GitHub not correctly rendering docstring examples.

2024.5.10

- Add options to disable parsing groups, oligos, fractions, arithmetic (#14).
Expand Down Expand Up @@ -138,80 +145,84 @@ Examples
Calculate the molecular mass, elemental composition, and mass distribution of
a molecule from its chemical formula:

>>> from molmass import Formula
>>> f = Formula('C8H10N4O2') # Caffeine
>>> f
Formula('C8H10N4O2')
>>> f.formula # hill notation
'C8H10N4O2'
>>> f.empirical
'C4H5N2O'
>>> f.mass # average mass
194.1909...
>>> f.nominal_mass # == f.isotope.massnumber
194
>>> f.monoisotopic_mass # == f.isotope.mass
194.0803...
>>> f.atoms
24
>>> f.charge
0
>>> f.composition().dataframe()
Count Relative mass Fraction
Element...
C 8 96.085920 0.494801
H 10 10.079410 0.051905
N 4 56.026812 0.288514
O 2 31.998810 0.164780
>>> f.spectrum(min_intensity=0.01).dataframe()
Relative mass Fraction Intensity % m/z
Mass number...
194 194.080376 0.898828 100.000000 194.080376
195 195.082873 0.092625 10.305100 195.082873
196 196.084968 0.008022 0.892492 196.084968
197 197.087214 0.000500 0.055681 197.087214
.. code-block:: python
>>> from molmass import Formula
>>> f = Formula('C8H10N4O2') # Caffeine
>>> f
Formula('C8H10N4O2')
>>> f.formula # hill notation
'C8H10N4O2'
>>> f.empirical
'C4H5N2O'
>>> f.mass # average mass
194.1909...
>>> f.nominal_mass # == f.isotope.massnumber
194
>>> f.monoisotopic_mass # == f.isotope.mass
194.0803...
>>> f.atoms
24
>>> f.charge
0
>>> f.composition().dataframe()
Count Relative mass Fraction
Element...
C 8 96.085920 0.494801
H 10 10.079410 0.051905
N 4 56.026812 0.288514
O 2 31.998810 0.164780
>>> f.spectrum(min_intensity=0.01).dataframe()
Relative mass Fraction Intensity % m/z
Mass number...
194 194.080376 0.898828 100.000000 194.080376
195 195.082873 0.092625 10.305100 195.082873
196 196.084968 0.008022 0.892492 196.084968
197 197.087214 0.000500 0.055681 197.087214
Access physicochemical and descriptive properties of the chemical elements:

>>> from molmass import ELEMENTS, Element
>>> e = ELEMENTS['C']
>>> e
Element(
6, 'C', 'Carbon',
group=14, period=2, block='p', series=1,
mass=12.01074, eleneg=2.55, eleaffin=1.262118,
covrad=0.77, atmrad=0.91, vdwrad=1.7,
tboil=5100.0, tmelt=3825.0, density=3.51,
eleconfig='[He] 2s2 2p2',
oxistates='4*, 2, -4*',
ionenergy=(
11.2603, 24.383, 47.877, 64.492, 392.077,
489.981,
),
isotopes={
12: Isotope(12.0, 0.9893, 12),
13: Isotope(13.00335483507, 0.0107, 13),
},
)
>>> e.number
6
>>> e.symbol
'C'
>>> e.name
'Carbon'
>>> e.description
'Carbon is a member of group 14 of the periodic table...'
>>> e.eleconfig
'[He] 2s2 2p2'
>>> e.eleconfig_dict
{(1, 's'): 2, (2, 's'): 2, (2, 'p'): 2}
>>> str(ELEMENTS[6])
'Carbon'
>>> len(ELEMENTS)
109
>>> sum(e.mass for e in ELEMENTS)
14693.181589001...
>>> for e in ELEMENTS:
... e.validate()
... e = eval(repr(e))
...
.. code-block:: python
>>> from molmass import ELEMENTS, Element
>>> e = ELEMENTS['C']
>>> e
Element(
6, 'C', 'Carbon',
group=14, period=2, block='p', series=1,
mass=12.01074, eleneg=2.55, eleaffin=1.262118,
covrad=0.77, atmrad=0.91, vdwrad=1.7,
tboil=5100.0, tmelt=3825.0, density=3.51,
eleconfig='[He] 2s2 2p2',
oxistates='4*, 2, -4*',
ionenergy=(
11.2603, 24.383, 47.877, 64.492, 392.077,
489.981,
),
isotopes={
12: Isotope(12.0, 0.9893, 12),
13: Isotope(13.00335483507, 0.0107, 13),
},
)
>>> e.number
6
>>> e.symbol
'C'
>>> e.name
'Carbon'
>>> e.description
'Carbon is a member of group 14 of the periodic table...'
>>> e.eleconfig
'[He] 2s2 2p2'
>>> e.eleconfig_dict
{(1, 's'): 2, (2, 's'): 2, (2, 'p'): 2}
>>> str(ELEMENTS[6])
'Carbon'
>>> len(ELEMENTS)
109
>>> sum(e.mass for e in ELEMENTS)
14693.181589001...
>>> for e in ELEMENTS:
... e.validate()
... e = eval(repr(e))
...

0 comments on commit 405fe3a

Please sign in to comment.