### Install Dependencies with Poetry Source: https://github.com/lmmentel/mendeleev/blob/master/docs/source/CONTRIBUTING.md Install project dependencies using Poetry for development. ```bash poetry install ``` -------------------------------- ### Install mendeleev using pip Source: https://github.com/lmmentel/mendeleev/blob/master/docs/source/install.rst Install the package using pip. ```bash pip install mendeleev ``` -------------------------------- ### Install mendeleev from GitHub repository Source: https://github.com/lmmentel/mendeleev/blob/master/docs/source/install.rst Install the most recent version from the repository using pip. ```bash pip install git+https://github.com/lmmentel/mendeleev.git ``` -------------------------------- ### Install Mendeleev with Pipenv Source: https://github.com/lmmentel/mendeleev/blob/master/README.md Use this command to install the mendeleev package using pipenv. ```bash pipenv install mendeleev ``` -------------------------------- ### Install Mendeleev with Visualization Dependencies Source: https://github.com/lmmentel/mendeleev/blob/master/docs/source/notebooks/visualizations.ipynb Install the mendeleev library with optional visualization dependencies using pip. ```bash pip install mendeleev[vis] ``` -------------------------------- ### Import Element and Get Silicon Source: https://github.com/lmmentel/mendeleev/blob/master/docs/source/electronegativity.rst Import the element class and retrieve the Silicon element object for use in subsequent examples. ```python from mendeleev import element Si = element('Si') ``` -------------------------------- ### Importing Bokeh Visualization Functions and Setup Source: https://github.com/lmmentel/mendeleev/blob/master/docs/source/notebooks/advanced_visualizations.ipynb Import necessary functions for Bokeh visualization and enable notebook output for rendering. ```python from bokeh.plotting import show, output_notebook from mendeleev.vis import periodic_table_bokeh ``` ```python output_notebook() ``` -------------------------------- ### Install mendeleev using conda Source: https://github.com/lmmentel/mendeleev/blob/master/docs/source/install.rst Install the package from the conda-forge channel using conda. ```bash conda install conda-forge::mendeleev ``` -------------------------------- ### Visualize and Color by Density Source: https://github.com/lmmentel/mendeleev/blob/master/docs/source/notebooks/visualizations.ipynb Display the atomic density and color elements based on these values. Requires the 'vis' extra to be installed. ```python periodic_table(attribute="density", colorby="attribute", title="Atomic Volume") ``` -------------------------------- ### Create an Ion Instance Source: https://github.com/lmmentel/mendeleev/blob/master/docs/source/notebooks/ions.ipynb Create an instance of the Ion class by providing the element symbol and its charge. For example, creating an Iron(II) ion. ```python fe_2 = Ion("Fe", 2) ``` -------------------------------- ### Print Mendeleev Version Source: https://github.com/lmmentel/mendeleev/blob/master/docs/source/notebooks/bulk_data_access.ipynb Prints the installed version of the mendeleev package. This is useful for verifying the installation and compatibility. ```python import mendeleev print(f"{mendeleev.__version__=}") ``` -------------------------------- ### Clone Mendeleev Repository Source: https://github.com/lmmentel/mendeleev/blob/master/docs/source/CONTRIBUTING.md Clone your forked repository to your local machine to start contributing. ```bash git clone https://github.com/lmmentel/mendeleev.git ``` -------------------------------- ### Visualize and Color by Covalent Radius Source: https://github.com/lmmentel/mendeleev/blob/master/docs/source/notebooks/visualizations.ipynb Display the covalent radius (Pyykko) for each element and use it to color the background. Requires the 'vis' extra to be installed. ```python periodic_table(attribute="covalent_radius_pyykko", title="Covalent Radii of Pyykko") ``` -------------------------------- ### Color Periodic Table by CPK Scheme Source: https://github.com/lmmentel/mendeleev/blob/master/docs/source/notebooks/visualizations.ipynb Visualize the periodic table colored according to the CPK color scheme. Requires the 'vis' extra to be installed. ```python periodic_table(colorby="cpk_color", title="CPK Colors") ``` -------------------------------- ### get_package_dbpath Source: https://github.com/lmmentel/mendeleev/blob/master/docs/source/api/mendeleev.db.rst Gets the file path to the package database. ```APIDOC ## get_package_dbpath ### Description Gets the file path to the package database. This is useful for locating database files used by the package. ### Signature get_package_dbpath() ### Returns A string representing the absolute path to the package database. ``` -------------------------------- ### Access Element Data by Symbol Source: https://github.com/lmmentel/mendeleev/blob/master/README.md Import elements directly by their symbols to access their properties. Requires no explicit setup beyond importing. ```python from mendeleev import Fe print(Fe.name) print(Fe.atomic_number) print(Fe.thermal_conductivity) ``` -------------------------------- ### Color Periodic Table by Jmol Scheme Source: https://github.com/lmmentel/mendeleev/blob/master/docs/source/notebooks/visualizations.ipynb Visualize the periodic table colored according to the Jmol color scheme. Requires the 'vis' extra to be installed. ```python periodic_table(colorby="jmol_color", title="JMol Colors") ``` -------------------------------- ### Color Periodic Table by MOLCAS GV Scheme Source: https://github.com/lmmentel/mendeleev/blob/master/docs/source/notebooks/visualizations.ipynb Visualize the periodic table colored according to the MOLCAS GV color scheme. Requires the 'vis' extra to be installed. ```python periodic_table(colorby="molcas_gv_color", title="MOLCAS GV Colors") ``` -------------------------------- ### Visualize and Color by Covalent Radius Values Source: https://github.com/lmmentel/mendeleev/blob/master/docs/source/notebooks/visualizations.ipynb Display the covalent radius (Pyykko) and color the elements based on these values. Requires the 'vis' extra to be installed. ```python periodic_table( attribute="covalent_radius_pyykko", colorby="attribute", title="Covalent Radii of Pyykko", ) ``` -------------------------------- ### Visualize and Color by Pauling Electronegativity Source: https://github.com/lmmentel/mendeleev/blob/master/docs/source/notebooks/visualizations.ipynb Display Pauling's electronegativity and color elements based on these values using the 'viridis' colormap. Requires the 'vis' extra to be installed. ```python periodic_table( attribute="en_pauling", colorby="attribute", title="Pauling's Electronegativity", cmap="viridis", ) ``` -------------------------------- ### Visualizing Custom Properties with Plotly Source: https://github.com/lmmentel/mendeleev/blob/master/docs/source/notebooks/advanced_visualizations.ipynb Visualize custom calculated properties on the periodic table using the Plotly backend. This example calculates and visualizes the difference in electronegativity relative to Oxygen. ```python elements.loc[:, "ENX-ENO"] = ( elements.loc[elements["symbol"] == "O", "en_allen" ).values - elements.loc[:, "en_allen"] periodic_table_plotly( elements, attribute="ENX-ENO", colorby="attribute", cmap="viridis", title="Allen Electronegativity wrt. Oxygen", ) ``` -------------------------------- ### Export Data using CLI Source: https://github.com/lmmentel/mendeleev/blob/master/docs/source/data_access.rst Export all tables from the Mendeleev database to various formats (csv, json, html, markdown) using the command-line interface. This requires cloning the repository and installing in development mode. ```bash gh clone lmmentel/mendeleev cd mendeleev poetry install poetry run inv export ``` -------------------------------- ### Display Wide 32-Column Periodic Table Source: https://github.com/lmmentel/mendeleev/blob/master/docs/source/notebooks/visualizations.ipynb Render the periodic table in a wide 32-column format, suitable for displaying the f-block. Requires the 'vis' extra to be installed. ```python periodic_table(height=600, width=1500, wide_layout=True) ``` -------------------------------- ### Accessing Element Properties with Pint Units Source: https://context7.com/lmmentel/mendeleev/llms.txt Accesses element properties with associated units using the '_u' suffix. Requires the 'pint' library to be installed. ```python print(au.melting_point_u) # 1337.33 kelvin print(au.boiling_point_u) # 3129.0 kelvin print(au.density_u) # 19.3 gram / centimeter³ print(au.electron_affinity_u) # 2.3086 electron_volt ``` -------------------------------- ### Get Electronegativity with Different Scales Source: https://context7.com/lmmentel/mendeleev/llms.txt Computes electronegativity using various scales. Some scales, like 'li-xue', return a dictionary. Use `electronegativity_scales()` to list available scales. ```python from mendeleev import element si = element("Si") # Pauling scale (default) print(si.electronegativity(scale="pauling")) # 1.9 print(si.electronegativity(scale="allen")) # 11.33 print(si.electronegativity(scale="mulliken")) # 4.7693... print(si.electronegativity(scale="sanderson")) # computed value # Mulliken scale for an ion (charge=1) print(si.electronegativity(scale="mulliken", charge=1)) # Li-Xue scale returns dict keyed by (coordination, spin) li_xue_vals = si.electronegativity(scale="li-xue", charge=4) for key, val in li_xue_vals.items(): print(key, val) # List all available scale names scales = si.electronegativity_scales() print(scales) # ['allen', 'allred-rochow', 'cottrell-sutton', ...] ``` -------------------------------- ### Build Documentation Locally Source: https://github.com/lmmentel/mendeleev/blob/master/docs/source/CONTRIBUTING.md Build the project documentation locally using Sphinx and make. Results are placed in 'build/_html'. ```bash cd docs make html ``` -------------------------------- ### Initialize ElectronicConfiguration Standalone Source: https://github.com/lmmentel/mendeleev/blob/master/docs/source/notebooks/electronic_configuration.ipynb Instantiate the ElectronicConfiguration class with a specific electronic configuration string. ```python from mendeleev.econf import ElectronicConfiguration ``` ```python ec = ElectronicConfiguration("1s2 2s2 2p6 3s1") ``` -------------------------------- ### Visualize Covalent Radius with Inferno Colormap Source: https://github.com/lmmentel/mendeleev/blob/master/docs/source/notebooks/visualizations.ipynb Display the covalent radius (Pyykko) and color elements by value using the 'inferno' matplotlib colormap. Requires the 'vis' extra to be installed. ```python periodic_table( attribute="covalent_radius_pyykko", colorby="attribute", cmap="inferno", title="Covalent Radii of Pyykko", ) ``` -------------------------------- ### Initialize Database Session Source: https://github.com/lmmentel/mendeleev/blob/master/notebooks/atomic-scattering-factors.ipynb Establishes a writable database session for loading data. ```python session = get_session(read_only=False) ``` -------------------------------- ### Get Oxidation States Source: https://github.com/lmmentel/mendeleev/blob/master/docs/source/notebooks/quick_start.ipynb Access the `oxistates` attribute of an Element object to get a list of its common oxidation states. ```python fe = element("Fe") print(fe.oxistates) ``` -------------------------------- ### Render Data Documentation Source: https://github.com/lmmentel/mendeleev/blob/master/docs/source/CONTRIBUTING.md Generate or update the 'docs/source/data.rst' file by rendering metadata from the PropertyMetadata model. ```bash inv render-data-docs ``` -------------------------------- ### Initialize database session Source: https://github.com/lmmentel/mendeleev/blob/master/notebooks/2025-03-update-g-factors.ipynb Establishes a writable database session using get_session from mendeleev.db. ```python from mendeleev.db import get_session, get_engine from mendeleev.models import Isotope ``` ```python session = get_session(read_only=False) ``` -------------------------------- ### Get Unpaired Electrons Source: https://github.com/lmmentel/mendeleev/blob/master/docs/source/notebooks/electronic_configuration.ipynb Calculate the number of unpaired electrons in the atom. ```python Si.ec.unpaired_electrons() ``` -------------------------------- ### Create Alembic Migration Source: https://github.com/lmmentel/mendeleev/blob/master/docs/source/CONTRIBUTING.md Generate a new database migration script using Alembic. Replace '[your summary of changes here]' with a concise description of your changes. ```bash alembic revision -m "[your summary of changes here]" ``` -------------------------------- ### Get Spin Occupations Source: https://github.com/lmmentel/mendeleev/blob/master/docs/source/notebooks/electronic_configuration.ipynb Display the occupation of each subshell considering electron spins. ```python Si.ec.spin_occupations() ``` -------------------------------- ### Get Last Subshell Source: https://github.com/lmmentel/mendeleev/blob/master/docs/source/notebooks/electronic_configuration.ipynb Identify the last subshell that is occupied in the electronic configuration. ```python Si.ec.last_subshell() ``` -------------------------------- ### Fetching the Phase Transitions Table Source: https://context7.com/lmmentel/mendeleev/llms.txt Retrieves the phase transitions database table. Filters for specific atomic numbers to view allotropes. ```python from mendeleev.fetch import fetch_table # Phase transitions pt = fetch_table("phasetransitions") print(pt[pt["atomic_number"] == 6]) # Carbon allotropes ``` -------------------------------- ### Get Total Number of Electrons Source: https://github.com/lmmentel/mendeleev/blob/master/docs/source/notebooks/electronic_configuration.ipynb Retrieve the total number of electrons in the atom. ```python Si.ec.ne() ``` -------------------------------- ### Fetch Oxidation States Table Source: https://github.com/lmmentel/mendeleev/blob/master/docs/source/notebooks/bulk_data_access.ipynb Retrieve the 'oxidationstates' table using fetch_table. This table lists common oxidation states for elements. ```python ox = fetch_table("oxidationstates") ox ``` -------------------------------- ### Get Valence Electrons Source: https://github.com/lmmentel/mendeleev/blob/master/docs/source/notebooks/electronic_configuration.ipynb Extract the valence electron configuration from a given electronic configuration. ```python ec.get_valence() ``` -------------------------------- ### Import Periodic Table Visualization Function Source: https://github.com/lmmentel/mendeleev/blob/master/docs/source/notebooks/visualizations.ipynb Import the necessary function for creating periodic table visualizations. ```python from mendeleev.vis import periodic_table ``` -------------------------------- ### Get Ghosh Electronegativity Source: https://github.com/lmmentel/mendeleev/blob/master/docs/source/electronegativity.rst Access the Ghosh electronegativity value, which is based on absolute atomic radii and empirical parameters. ```python Si.en_ghosh ``` -------------------------------- ### Apply Database Migrations Source: https://github.com/lmmentel/mendeleev/blob/master/docs/source/CONTRIBUTING.md Apply the pending database migrations to the local mendeleev database. ```bash alembic migrate head ``` -------------------------------- ### Get Allred-Rochow Electronegativity Source: https://github.com/lmmentel/mendeleev/blob/master/docs/source/electronegativity.rst Calculate the Allred-Rochow electronegativity, which is based on the electrostatic force exerted on an electron by the nuclear charge. ```python Si.electronegativity('allred-rochow') ``` -------------------------------- ### Get Unicode Ion Symbol Source: https://github.com/lmmentel/mendeleev/blob/master/docs/source/notebooks/ions.ipynb Obtain the unicode representation of the ion's symbol using the unicode_ion_symbol() method. ```python fe_2.unicode_ion_symbol() ``` -------------------------------- ### Handling Element Phase Transitions Source: https://context7.com/lmmentel/mendeleev/llms.txt Retrieves and iterates through phase transition data for elements that exhibit allotropes. Imports the 'warnings' module. ```python import warnings sn = element("Sn") print(sn.phase_transitions) # list of PhaseTransition objects for pt in sn.phase_transitions: print(pt.allotrope, pt.melting_point, pt.boiling_point) ``` -------------------------------- ### fetch_table() Source: https://context7.com/lmmentel/mendeleev/llms.txt Returns the full contents of any database table as a `pandas.DataFrame`. Available tables: `elements`, `groups`, `ionicradii`, `ionizationenergies`, `isotopedecaymodes`, `isotopes`, `oxidationstates`, `phasetransitions`, `propertymetadata`, `scattering_factors`, `screeningconstants`, `series`. ```APIDOC ## `fetch_table()` — Bulk Database Table Retrieval as pandas DataFrame Returns the full contents of any database table as a `pandas.DataFrame`. Available tables: `elements`, `groups`, `ionicradii`, `ionizationenergies`, `isotopedecaymodes`, `isotopes`, `oxidationstates`, `phasetransitions`, `propertymetadata`, `scattering_factors`, `screeningconstants`, `series`. ```python from mendeleev.fetch import fetch_table # Full elements table ptable = fetch_table("elements") print(ptable.shape) # (118, N) print(ptable.columns.tolist()) # ['atomic_number', 'symbol', 'name', ...] # Subset for analysis cols = ["atomic_number", "symbol", "en_pauling", "atomic_radius", "density"] subset = ptable[cols].dropna() print(subset.describe()) # Isotopes table isotopes = fetch_table("isotopes", index_col="id") print(isotopes[isotopes["atomic_number"] == 14]) # Silicon isotopes # Phase transitions pt = fetch_table("phasetransitions") print(pt[pt["atomic_number"] == 6]) # Carbon allotropes # Property metadata (includes units) meta = fetch_table("propertymetadata") print(meta[meta["unit"].notna()][["attribute_name", "unit"]].head(10)) # Screening constants sc = fetch_table("screeningconstants") print(sc[sc["atomic_number"] == 26]) # Fe screening constants ``` ``` -------------------------------- ### Get Elements by List Source: https://github.com/lmmentel/mendeleev/blob/master/README.md Retrieve multiple Element objects by providing a list or tuple of identifiers (names or atomic numbers). ```python >>> c, h, o = element(['C', 'Hydrogen', 8]) >>> c.name, h.name, o.name ('Carbon', 'Hydrogen', 'Oxygen') ``` -------------------------------- ### Basic Periodic Table Bokeh Visualization Source: https://github.com/lmmentel/mendeleev/blob/master/docs/source/notebooks/advanced_visualizations.ipynb Generate a basic periodic table visualization using the Bokeh backend. Requires a DataFrame with element data and explicit rendering using `show()`. ```python fig = periodic_table_bokeh(elements) show(fig) ``` -------------------------------- ### Get Largest Noble Gas Core Configuration Source: https://github.com/lmmentel/mendeleev/blob/master/docs/source/notebooks/electronic_configuration.ipynb Find the electronic configuration corresponding to the largest noble gas core. ```python Si.ec.get_largest_core() ``` -------------------------------- ### Get Maximum Principal Quantum Number Source: https://github.com/lmmentel/mendeleev/blob/master/docs/source/notebooks/electronic_configuration.ipynb Find the largest value of the principal quantum number (n) in the electronic configuration. ```python Si.ec.max_n() ``` -------------------------------- ### Visualization - Periodic Table Source: https://github.com/lmmentel/mendeleev/blob/master/docs/source/api/api.rst The main entry point for visualizing periodic tables with different properties is the periodic_table function. ```APIDOC ## periodic_table ### Description Generates a visualization of the periodic table with specified properties. ### Function Signature `mendeleev.vis.periodictable.periodic_table()` ### Parameters This function does not explicitly list parameters in the provided documentation. ``` -------------------------------- ### Get All Element Objects Source: https://context7.com/lmmentel/mendeleev/llms.txt Retrieves a list of all 118 Element objects, ordered by atomic number. Suitable for bulk property calculations. ```python from mendeleev import get_all_elements elements = get_all_elements() print(len(elements)) # 118 ``` ```python # Extract a property for all elements symbols = [e.symbol for e in elements] masses = [e.atomic_weight for e in elements] ``` ```python # Filter to metals by series metals = [e for e in elements if e.series in ("Alkali metal", "Alkaline earth metal")] for m in metals: print(f"{m.symbol}: {m.melting_point} K") ``` ```python # Compute hardness for all d-block elements d_block = [e for e in elements if e.block == "d"] for e in d_block: h = e.hardness() if h: print(f"{e.symbol}: η={h:.2f} eV") ``` -------------------------------- ### Get Allen Electronegativity Source: https://github.com/lmmentel/mendeleev/blob/master/docs/source/electronegativity.rst Access the tabulated Allen electronegativity value for an element. This scale is defined by Allen in ref. Allen (1989). ```python Si.en_allen ``` ```python Si.electronegativity('allen') ``` -------------------------------- ### Fetch Phase Transitions Table Source: https://github.com/lmmentel/mendeleev/blob/master/docs/source/notebooks/bulk_data_access.ipynb Retrieve the 'phasetransitions' table using fetch_table. This table includes phase transition properties for elements, with separate entries for allotropes. ```python pt = fetch_table("phasetransitions") pt.sort_values(by="atomic_number").head(15) ``` -------------------------------- ### Get SQLAlchemy Session Source: https://github.com/lmmentel/mendeleev/blob/master/docs/source/data_access.rst Obtain a SQLAlchemy database session for direct interaction with the Mendeleev database. This is useful for advanced database operations. ```python >>> from mendeleev.db import get_session >>> session = get_session() >>> print(session) ``` -------------------------------- ### get_engine Source: https://github.com/lmmentel/mendeleev/blob/master/docs/source/api/mendeleev.db.rst Retrieves the database engine instance. ```APIDOC ## get_engine ### Description Retrieves the database engine instance. This function is used to get access to the underlying database connection. ### Signature get_engine() ### Returns An object representing the database engine. ``` -------------------------------- ### Fetch Electronegativities Source: https://github.com/lmmentel/mendeleev/blob/master/docs/source/notebooks/bulk_data_access.ipynb Fetches all data from electronegativity scales. This operation may take a few seconds as most values require computation. Ensure the fetch_electronegativities function is imported. ```python from mendeleev.fetch import fetch_electronegativities ``` ```python ens = fetch_electronegativities() ens.head(10) ``` -------------------------------- ### Get Single Attribute for All Elements Source: https://context7.com/lmmentel/mendeleev/llms.txt Efficiently retrieves a single attribute for all 118 elements as an ordered list. Useful for quick data retrieval. ```python from mendeleev import get_attribute_for_all_elements # Retrieve all atomic weights masses = get_attribute_for_all_elements("atomic_weight") print(masses[:5]) # [1.008, 4.0026, 6.94, 9.0122, 10.81] ``` ```python # Retrieve all Pauling electronegativities (None for noble gases) en_pauling = get_attribute_for_all_elements("en_pauling") print([x for x in en_pauling if x is not None][:10]) ``` ```python # Retrieve all symbols symbols = get_attribute_for_all_elements("symbol") print(symbols[:10]) # ['H', 'He', 'Li', 'Be', 'B', 'C', 'N', 'O', 'F', 'Ne'] ``` -------------------------------- ### Electronic Configuration Parser Source: https://context7.com/lmmentel/mendeleev/llms.txt Provides a standalone class for parsing and analyzing electronic configurations. Can be accessed via `element.ec` or instantiated directly. ```python from mendeleev.econf import ElectronicConfiguration ``` -------------------------------- ### Get Ionization Energies Source: https://github.com/lmmentel/mendeleev/blob/master/docs/source/notebooks/quick_start.ipynb Access the `ionenergies` attribute of an Element object to retrieve a dictionary of ionization energies in eV, with degrees of ionization as keys. ```python o = element("O") o.ionenergies ``` -------------------------------- ### Get Cottrell-Sutton Electronegativity Source: https://github.com/lmmentel/mendeleev/blob/master/docs/source/electronegativity.rst Retrieve the Cottrell-Sutton electronegativity value, derived from the square root of effective nuclear charge divided by covalent radius. ```python Si.electronegativity('cottrell-sutton') ``` -------------------------------- ### Get SQLAlchemy Engine Source: https://github.com/lmmentel/mendeleev/blob/master/docs/source/data_access.rst Obtain a SQLAlchemy database engine for managing the connection to the Mendeleev database. This provides lower-level control over database interactions. ```python >>> from mendeleev.db import get_engine >>> engine = get_engine() >>> print(engine) ``` -------------------------------- ### Fetch Property Metadata Source: https://github.com/lmmentel/mendeleev/blob/master/docs/source/notebooks/bulk_data_access.ipynb Fetches the 'propertymetadata' table, which contains metadata for rendering data documentation pages, including units compatible with the pint package. ```python metadata = fetch_table("propertymetadata") metadata.head(10) ``` -------------------------------- ### Import Libraries Source: https://github.com/lmmentel/mendeleev/blob/master/notebooks/atomic-scattering-factors.ipynb Imports the required libraries for data manipulation and database interaction. ```python from pathlib import Path import pandas as pd from mendeleev import element from mendeleev.db import get_session from mendeleev.models import ScatteringFactor, PropertyMetadata, ValueOrigin ``` -------------------------------- ### Get Maximum Azimuthal Quantum Number Source: https://github.com/lmmentel/mendeleev/blob/master/docs/source/notebooks/electronic_configuration.ipynb Determine the largest value of the azimuthal quantum number (l) for a given principal quantum number. ```python Si.ec.max_l(n=3) ``` -------------------------------- ### Import Ion Class Source: https://github.com/lmmentel/mendeleev/blob/master/docs/source/notebooks/ions.ipynb Import the Ion class from the mendeleev.ion module to begin working with ions. ```python from mendeleev.ion import Ion ``` -------------------------------- ### Import Electronic Configuration Source: https://github.com/lmmentel/mendeleev/blob/master/docs/source/notebooks/electronic_configuration.ipynb Import the Si element to access its electronic configuration. ```python from mendeleev import Si ``` -------------------------------- ### periodic_table_bokeh(elements_df, **kwargs) Source: https://context7.com/lmmentel/mendeleev/llms.txt Creates an interactive periodic table visualization using Bokeh, complete with hover tools. This is suitable for embedding within web applications and offers customization for coloring and layout. ```APIDOC ## `periodic_table_bokeh()` — Bokeh Periodic Table Visualization Renders an interactive periodic table using Bokeh with hover tools, suitable for embedding in web applications. ```python from mendeleev.vis.utils import create_vis_dataframe from mendeleev.vis.bokeh import periodic_table_bokeh from bokeh.plotting import output_file, show elements_df = create_vis_dataframe() # Color by CPK color scheme (default chemical coloring) p = periodic_table_bokeh( elements_df, attribute="atomic_weight", colorby="cpk_color", # use standard CPK colors title="Periodic Table", width=1400, height=900, ) output_file("periodic_table.html") show(p) # Color by numeric attribute p2 = periodic_table_bokeh( elements_df, attribute="electron_affinity", colorby="attribute", cmap="plasma", missing="#dddddd", title="Electron Affinity", ) show(p2) ``` ``` -------------------------------- ### Initialize database session Source: https://github.com/lmmentel/mendeleev/blob/master/notebooks/querying.ipynb Obtain a database session object to interact with the Mendeleev periodic table data. This session is used for all subsequent queries. ```python session = get_session() ``` -------------------------------- ### Get Sanderson's Electronegativity Source: https://github.com/lmmentel/mendeleev/blob/master/docs/source/electronegativity.rst Retrieve Sanderson's electronegativity for an element. This method is useful for comparing electronegativity based on Sanderson's scale. ```python >>> Si.en_sanderson() 0.3468157872145231 >>> Si.electronegativity() 0.3468157872145231 ``` -------------------------------- ### Element.oxidation_states() Source: https://context7.com/lmmentel/mendeleev/llms.txt Returns the oxidation states for an element, with options for 'main', 'extended', or 'all' categories. ```APIDOC ## Element.oxidation_states(category: str = 'main') ### Description Returns the oxidation states for an element. ### Parameters #### Query Parameters - **category** (str) - Optional - The category of oxidation states to retrieve ('main', 'extended', 'all'). Defaults to 'main'. ### Request Example ```python from mendeleev import element fe = element("Fe") print(fe.oxidation_states()) print(fe.oxidation_states("extended")) print(fe.oxidation_states("all")) ``` ### Response Returns a list of integers representing the oxidation states. ``` -------------------------------- ### Command-Line Element Information Tool Source: https://context7.com/lmmentel/mendeleev/llms.txt Utilize the 'element' command-line utility to quickly retrieve comprehensive information about an element by its symbol, atomic number, or full name. ```bash # Print all properties for Silicon by symbol element Si # By atomic number element 26 # By full name element Oxygen # Output includes: # - ASCII art symbol header (dotmatrix font) # - Description paragraph # - Sources of the element # - Uses section # - Full properties table (sorted alphabetically) # Example output excerpt for "element C": # ██████╗ # ██╔═══╝ Carbon # # Description # =========== # Carbon is a member of group 14, known since ancient times... # # Properties # ========== # Abundance crust 200.0 # Atomic number 6 # Atomic weight 12.011 # Block p # En pauling 2.55 # ... ``` -------------------------------- ### Get Gordy Electronegativity Source: https://github.com/lmmentel/mendeleev/blob/master/docs/source/electronegativity.rst Calculate the Gordy electronegativity, which relates to the work required to achieve charge separation based on effective nuclear charge and covalent radius. ```python Si.electronegativity('gordy') ``` -------------------------------- ### Fetch Ionization Energies Source: https://github.com/lmmentel/mendeleev/blob/master/docs/source/notebooks/bulk_data_access.ipynb Use fetch_ionization_energies to get ionization energy data. The 'degree' argument can be a single integer or a list to fetch multiple ionization levels. ```python from mendeleev.fetch import fetch_ionization_energies ies = fetch_ionization_energies(degree=2) ies.head(10) ``` ```python ies_multiple = fetch_ionization_energies(degree=[1, 3, 5]) ies_multiple.head(10) ``` -------------------------------- ### Define Data Directory Source: https://github.com/lmmentel/mendeleev/blob/master/notebooks/atomic-scattering-factors.ipynb Sets the root path for the atomic scattering factor data files. ```python root = Path("../data/atomic-scattering-factors/") ``` -------------------------------- ### Get Number of Valence Electrons Source: https://context7.com/lmmentel/mendeleev/llms.txt Returns the number of valence electrons. For d/f-block elements, an optional `method` argument ('simple' or default) can be used to specify calculation approach. ```python from mendeleev import element c = element("C") print(c.nvalence()) # 4 fe = element("Fe") print(fe.nvalence()) # 8 (4s + 3d electrons) print(fe.nvalence(method="simple")) # 2 la = element("La") print(la.nvalence()) # 3 ``` -------------------------------- ### Basic Periodic Table Plotly Visualization Source: https://github.com/lmmentel/mendeleev/blob/master/docs/source/notebooks/advanced_visualizations.ipynb Generate a basic periodic table visualization using the Plotly backend. Requires a DataFrame with element data, which can be created using `create_vis_dataframe`. ```python elements = create_vis_dataframe() periodic_table_plotly(elements) ``` -------------------------------- ### Display VdW Radii from CLI Source: https://github.com/lmmentel/mendeleev/blob/master/README.md This output shows the available Van der Waals radii calculation methods accessible via the command-line interface. Use this to check available methods and their default values. ```text Vdw radius 210 Vdw radius alvarez 219 Vdw radius batsanov 210 Vdw radius bondi 210 Vdw radius dreiding 427 Vdw radius mm3 229 Vdw radius rt NaN Vdw radius truhlar NaN Vdw radius uff 429.5 ``` -------------------------------- ### element CLI Tool Source: https://context7.com/lmmentel/mendeleev/llms.txt Command-line utility for printing element properties in the terminal. ```APIDOC ## CLI — Command-Line Element Info Tool ### Description The `mendeleev` package installs a command-line utility `element` (entry point `clielement`) for printing element properties in the terminal. ### Usage ```bash # Print all properties for Silicon by symbol element Si # By atomic number element 26 # By full name element Oxygen # Output includes: # - ASCII art symbol header (dotmatrix font) # - Description paragraph # - Sources of the element # - Uses section # - Full properties table (sorted alphabetically) # Example output excerpt for "element C": # ██████╗ # ██╔═══╝ Carbon # # Description # =========== # Carbon is a member of group 14, known since ancient times... # # Properties # ========== # Abundance crust 200.0 # Atomic number 6 # Atomic weight 12.011 # Block p # En pauling 2.55 # ... ``` ``` -------------------------------- ### Visualize Covalent Radius with Custom Colormap Source: https://github.com/lmmentel/mendeleev/blob/master/docs/source/notebooks/visualizations.ipynb Display the covalent radius (Pyykko) and color elements by value using the 'spring' matplotlib colormap. Requires the 'vis' extra to be installed. ```python periodic_table( attribute="covalent_radius_pyykko", colorby="attribute", cmap="spring", title="Covalent Radii of Pyykko", ) ``` -------------------------------- ### Fetch Data Tables as Pandas DataFrame Source: https://github.com/lmmentel/mendeleev/blob/master/docs/source/data_access.rst Retrieve entire data tables from the Mendeleev database as pandas DataFrames. Use this function to get bulk data for elements, groups, ionic radii, and more. ```python >>> from mendeleev.fetch import fetch_table >>> elements_df = fetch_table('elements') >>> print(elements_df.head()) ``` -------------------------------- ### Import necessary libraries Source: https://github.com/lmmentel/mendeleev/blob/master/notebooks/2025-03-update-nuclear-el-quad-moments.ipynb Imports required libraries for data manipulation, PDF parsing, and database interaction. ```python from fractions import Fraction from pathlib import Path import re import camelot from camelot.io import read_pdf import pandas as pd import numpy as np import polars as pl ``` -------------------------------- ### Print Element Information using CLI Source: https://github.com/lmmentel/mendeleev/blob/master/README.md Use the element.py script to print information about a chemical element. Accepts element symbol, name, or atomic number as an argument. ```bash $ element.py Si ``` -------------------------------- ### fetch_table Source: https://github.com/lmmentel/mendeleev/blob/master/docs/source/api/mendeleev.fetch.rst Retrieves the entire periodic table data. ```APIDOC ## fetch_table ### Description Fetches the complete periodic table data. ### Function Signature `mendeleev.fetch.fetch_table()` ### Returns A dictionary or similar structure representing the entire periodic table. ``` -------------------------------- ### get_session Source: https://github.com/lmmentel/mendeleev/blob/master/docs/source/api/mendeleev.db.rst Retrieves a database session. ```APIDOC ## get_session ### Description Retrieves a database session. Sessions are used to perform database operations. ### Signature get_session() ### Returns An object representing a database session. ``` -------------------------------- ### Exporting Data via CLI Source: https://github.com/lmmentel/mendeleev/blob/master/docs/source/data_access.rst Export all database tables to CSV, JSON, HTML, or Markdown formats using the `inv export` command. ```APIDOC ## Export data The data can be exported to a number of formats using the CLI by invoking `inv export` command. The following formats are supported: - csv - json - html - markdown The command will export all the tables from the database to a set of files in the specified format. In order to use this functionality you'll need to clone the mendeleev repository and install the package in the development mode. Here's how you can do it: .. code-block:: bash gh clone lmmentel/mendeleev cd mendeleev poetry install poetry run inv export After the command is executed you'll find the exported files in the `data` directory. The contents should look like this: .. code-block:: bash data ├── csv │   ├── elements.csv │   ├── groups.csv │   ├── ionicradii.csv │   ├── ionizationenergies.csv │   ├── isotopedecaymodes.csv │   ├── isotopes.csv │   ├── oxidationstates.csv │   ├── phasetransitions.csv │   ├── screeningconstants.csv │   └── series.csv ├── html │   ├── elements.html │   ├── groups.html │   ├── ionicradii.html │   ├── ionizationenergies.html │   ├── isotopedecaymodes.html │   ├── isotopes.html │   ├── oxidationstates.html │   ├── phasetransitions.html │   ├── screeningconstants.html │   └── series.html ├── json │   ├── elements.json │   ├── groups.json │   ├── ionicradii.json │   ├── ionizationenergies.json │   ├── isotopedecaymodes.json │   ├── isotopes.json │   ├── oxidationstates.json │   ├── phasetransitions.json │   ├── screeningconstants.json │   └── series.json └── markdown ├── elements.markdown ├── groups.markdown ├── ionicradii.markdown ├── ionizationenergies.markdown ├── isotopedecaymodes.markdown ├── isotopes.markdown ├── oxidationstates.markdown ├── phasetransitions.markdown ├── screeningconstants.markdown └── series.markdown ``` -------------------------------- ### Parse and Analyze Electronic Configuration Source: https://context7.com/lmmentel/mendeleev/llms.txt Instantiate an ElectronicConfiguration object to parse an element's electron configuration string. Access various properties like electron counts, shell distribution, valence electrons, and magnetic moments. ```python from mendeleev import ElectronicConfiguration ec = ElectronicConfiguration("[Ar] 3d6 4s2") print(ec.conf) # OrderedDict with (n, orbital): electrons print(ec.ne()) # 26 print(ec.max_n()) # 4 print(ec.unpaired_electrons()) # 4 print(ec.spin_only_magnetic_moment()) # ≈ 4.899 μB # Electrons per shell print(ec.electrons_per_shell()) # {'K': 2, 'L': 8, 'M': 14, 'N': 2} # Get valence configuration (strip noble gas core) valence = ec.get_valence() print(valence) # 3d6 4s2 # Spin occupations per subshell so = ec.spin_occupations() for subshell, data in so.items(): print(f"{subshell}: alpha={data['alpha']}, beta={data['beta']}, " f"unpaired={data['unpaired']}, pairs={data['pairs']}") # Ionize: remove n electrons ec_ionized = ec.ionize(n=3) print(ec_ionized) # 1s2 2s2 2p6 3s2 3p6 3d5 ``` -------------------------------- ### Customizing Bokeh Visualization with Atomic Radius Source: https://github.com/lmmentel/mendeleev/blob/master/docs/source/notebooks/advanced_visualizations.ipynb Create a Bokeh periodic table visualization colored by atomic radius. This demonstrates using the `attribute` and `colorby` arguments with the Bokeh backend. ```python fig = periodic_table_bokeh(elements, attribute="atomic_radius", colorby="attribute") show(fig) ``` -------------------------------- ### Bokeh Periodic Table Visualization Source: https://context7.com/lmmentel/mendeleev/llms.txt Renders an interactive periodic table using Bokeh, suitable for web applications. Supports custom coloring and hover tools. ```python from mendeleev.vis.utils import create_vis_dataframe from mendeleev.vis.bokeh import periodic_table_bokeh from bokeh.plotting import output_file, show elements_df = create_vis_dataframe() # Color by CPK color scheme (default chemical coloring) p = periodic_table_bokeh( elements_df, attribute="atomic_weight", colorby="cpk_color", # use standard CPK colors title="Periodic Table", width=1400, height=900, ) output_file("periodic_table.html") show(p) ``` ```python # Color by numeric attribute p2 = periodic_table_bokeh( elements_df, attribute="electron_affinity", colorby="attribute", cmap="plasma", missing="#dddddd", title="Electron Affinity", ) show(p2) ``` -------------------------------- ### Verify Data Load Source: https://github.com/lmmentel/mendeleev/blob/master/notebooks/atomic-scattering-factors.ipynb Compares the number of rows loaded into the database for each element against the number of rows in the corresponding data file. ```python for file in proc.glob("*.nff"): e = element(file.stem.capitalize()) print(file.stem.capitalize(), e.atomic_number) df = pd.read_csv(file, sep="\t", header=0, engine="python", comment="#") db_rows = session.query(ScatteringFactor).filter_by(atomic_number=e.atomic_number).count() if db_rows == df.shape[0]: print("OK") else: print(f"ERROR {db_rows=} {df.shape[0]=}") ``` -------------------------------- ### Join and select comparison columns Source: https://github.com/lmmentel/mendeleev/blob/master/notebooks/2025-03-update-nuclear-el-quad-moments.ipynb Joins the processed quadrupole moments data with the fetched isotopes table on atomic and mass numbers, then selects and renames columns for comparison. ```python qmom.select( [ "atomic_number", "symbol", "mass_number", "spin", "parity", "quadrupole_moment", "quadrupole_moment_uncertainty", ] ).join( isotopes, on=["atomic_number", "mass_number"], suffix="_true", how="left" ).select( [ "atomic_number", "symbol", "mass_number", "spin", "spin_true", "parity", "parity_true", "quadrupole_moment", "quadrupole_moment_true", "quadrupole_moment_uncertainty", "quadrupole_moment_uncertainty_true", ] ) ``` -------------------------------- ### Access Electronic Configuration Object Source: https://context7.com/lmmentel/mendeleev/llms.txt The `ec` attribute provides an `ElectronicConfiguration` object for detailed analysis. It offers methods for raw configuration, electron counts, ionization, and screening constants. ```python from mendeleev import element fe = element("Fe") ec = fe.ec # Raw configuration string print(fe.econf) # [Ar] 3d6 4s2 # As dict: {(n, orbital): electrons} print(ec.conf) # OrderedDict({(1,'s'):2, (2,'s'):2, ...}) # Number of electrons, max principal quantum number print(ec.ne()) # 26 print(ec.max_n()) # 4 # Unpaired electrons (for magnetic properties) print(ec.unpaired_electrons()) # 4 print(ec.spin_only_magnetic_moment()) # sqrt(4*(4+2)) ≈ 4.899 # Electrons per shell print(ec.electrons_per_shell()) # {'K': 2, 'L': 8, 'M': 14, 'N': 2} # Ionize the configuration (remove electrons) ionized = ec.ionize(n=2) print(ionized) # 1s2 2s2 2p6 3s2 3p6 3d6 # Slater screening constant print(ec.slater_screening(n=3, o="d")) ``` -------------------------------- ### clielement Source: https://github.com/lmmentel/mendeleev/blob/master/docs/source/api/mendeleev.cli.rst Provides command-line access to element information. ```APIDOC ## clielement ### Description This function is part of the Mendeleev CLI and allows users to retrieve information about chemical elements directly from the command line. ### Function Signature `clielement()` ### Usage This function is intended to be called from the command line interface. Specific usage details and arguments would typically be provided via command-line help (e.g., `mendeleev clielement --help`). ### Parameters (No specific parameters are detailed in the provided source for direct function calls.) ### Returns (The return type or value is not explicitly detailed in the provided source.) ### Example (Command-line examples are not provided in the source.) ``` -------------------------------- ### Fetch Scattering Factors Source: https://github.com/lmmentel/mendeleev/blob/master/docs/source/notebooks/bulk_data_access.ipynb Fetches the 'scattering_factors' table, which contains data related to scattering factors. ```python scattering_factors = fetch_table("scattering_factors") scattering_factors.head(10) ``` -------------------------------- ### Fetch All Electronegativities Source: https://github.com/lmmentel/mendeleev/blob/master/docs/source/electronegativity.rst Collect all available electronegativity scales for all elements into a pandas DataFrame. This is useful for comprehensive analysis or comparison across different scales. ```python from mendeleev import fetch data = fetch.fetch_electronegativities() ``` -------------------------------- ### Prepare Pettifor Number Data Source: https://github.com/lmmentel/mendeleev/blob/master/notebooks/glawe-pettifor.ipynb Extracts the 'P' column from the data, resets its index, and then sets 'P' as the new index. This prepares the data for updating Pettifor numbers. ```python pn = data["P"].reset_index().set_index("P") ``` -------------------------------- ### Fetch Elements Table Source: https://github.com/lmmentel/mendeleev/blob/master/docs/source/notebooks/bulk_data_access.ipynb Import and use fetch_table to retrieve the 'elements' table into a pandas DataFrame. This provides basic data for each element. ```python from mendeleev.fetch import fetch_table ptable = fetch_table("elements") ```