API quick reference#
Calibrated import paths, attribute types, and method names for agents and humans. Prefer this page + llms.txt for copy-paste; use the class pages for full autodoc.
Package: cifkit · pip: pip install cifkit
Docs: https://bobleesj.github.io/cifkit/
LLM recipes: https://bobleesj.github.io/cifkit/llms.txt
Imports (canonical)#
from cifkit import Cif, CifEnsemble, Example
from cifkit.sources.oliynyk import Oliynyk, Property # OLED
from cifkit.parsers.formula import Formula
from cifkit.sorters.element_sorter import ElementSorter
OLED = Oliynyk Elemental Data. Load only via
cifkit.sources.oliynyk.Oliynyk. Not a separate package.
Example - demo data paths#
from cifkit import Example
Example.GdSb_file_path # str path to packaged GdSb.cif
Example.demo_cif_folder_path # str path to folder with GdSb.cif + HoSb.cif
Cif - one .cif file#
cif = Cif(
file_path, # str, required
is_formatted=False, # if False, preprocess for gemmi
logging_enabled=False,
supercell_size=3, # 3 → ±1 shifts (3×3×3)
compute_CN=False, # True runs coordination at init
)
Parsed structure attributes#
Attribute |
Type (typical) |
Meaning |
|---|---|---|
|
|
Path given to the constructor |
|
|
Basename, e.g. |
|
|
e.g. |
|
|
Structure type label, e.g. |
|
|
e.g. |
|
|
e.g. |
|
|
|
|
|
|
|
|
e.g. |
|
|
Element symbols in the file |
|
|
Number of unique elements (1 unary, 2 binary, …) |
|
|
Tag parsed from the CIF header line |
|
|
Origin DB if known ( |
|
|
Atoms in the unit cell |
|
|
Atoms in the generated supercell |
|
|
Occupancy / site info from the CIF loops |
Distance attributes (lazy: may call compute_connections())#
Attribute |
Type |
Meaning |
|---|---|---|
|
|
Global shortest neighbor distance (Å) |
|
|
Shortest per element-pair, e.g. |
|
|
Per site label: nearest neighbor label + distance |
|
|
Per site: |
|
|
Flattened neighbor records |
|
|
Element pairs present |
|
varies |
Site-label pairing helpers |
|
same shape |
Mendeleev-ordered variants of pair structures |
Mixing and radii#
Attribute |
Type |
Meaning |
|---|---|---|
|
|
e.g. |
|
|
Mixing label per site-label pair |
|
|
Per element: CIF / refined / Pauling radii |
|
varies |
Pair radius sums used in CN methods |
|
|
Whether radius tables cover the elements |
Coordination (after compute_CN() or compute_CN=True)#
CN method keys (exact strings):
dist_by_shortest_distdist_by_CIF_radius_sumdist_by_CIF_radius_refined_sumdist_by_Pauling_radius_sum
Attribute |
Type |
Meaning |
|---|---|---|
|
|
Per site → per method → |
|
|
Per site: chosen method + polyhedron metrics |
|
|
Neighbor shell using min-dist CN |
|
|
Neighbor shell using best-method CN |
|
|
Bond counts per site |
|
|
Global bond-pair fractions |
|
|
Unique CN values |
|
numeric |
Summary stats |
|
same family |
Parallel attributes using best-method CN |
CN_best_methods[site] metric keys (exact):
volume_of_polyhedron, distance_from_avg_point_to_center,
number_of_vertices, number_of_edges, number_of_faces,
shortest_distance_to_face, shortest_distance_to_edge,
volume_of_inscribed_sphere, packing_efficiency, method_used.
Methods#
Method |
Role |
|---|---|
|
Build neighbor lists (also triggered lazily) |
|
Run four CN methods + best-method selection |
|
PyVista polyhedron PNG / interactive window |
|
Coordinates/labels for min-dist shell |
|
Coordinates/labels for best-method shell |
Full autodoc: Cif. Tutorial: physical features.
CifEnsemble - folder of .cif files#
ensemble = CifEnsemble(
cif_dir_path, # str folder
add_nested_files=..., # include nested dirs if supported
# preprocessing runs on init for database compatibility
)
Overview attributes#
Attribute |
Meaning |
|---|---|
|
Paths and count after preprocess |
|
Formulas present |
|
Structure-type labels |
|
Space groups |
|
Elements across the folder |
|
Other uniques |
|
Count maps |
|
Per-file shortest distances |
|
Per-file supercell sizes |
|
CN uniques |
Filters (return path sets / collections)#
Exact method names:
filter_by_formulasfilter_by_structuresfilter_by_space_group_names/filter_by_space_group_numbersfilter_by_elements_containing/filter_by_elements_exact_matchingfilter_by_tags/filter_by_composition_types/filter_by_site_mixing_typesfilter_by_min_distance/filter_by_supercell_countfilter_by_CN_min_dist_method_containing/filter_by_CN_min_dist_method_exact_matchingfilter_by_CN_best_methods_containing/filter_by_CN_best_methods_exact_matching
File ops and histograms#
copy_cif_files(paths, dest_dir)/move_cif_files(paths, dest_dir)generate_structure_histogram/generate_formula_histogram/generate_tag_histogram/generate_space_group_name_histogram/generate_space_group_number_histogram/generate_elements_histogram/generate_supercell_size_histogram/generate_composition_type_histogram/generate_site_mixing_type_histogram/generate_CN_by_min_dist_method_histogram/generate_CN_by_best_methods_histogram
Full autodoc: CifEnsemble. Tutorial: statistics.
OLED - Oliynyk + Property#
from cifkit.sources.oliynyk import Oliynyk, Property
oled = Oliynyk()
oled.elements # list[str], length 76
oled.db # dict[symbol, dict[property_key, float]]
oled.db["Si"][Property.AW]
Methods#
Method |
Role |
|---|---|
|
Same as |
|
All elements in OLED? |
|
Split lists |
|
One property, all elements |
|
One property, elements in formula |
|
Full table |
|
Write CSV, return path |
|
Raw load of the nested dict (also used by |
Exact Property enum (do not rename)#
Enum name |
|
|---|---|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Spelling as shipped: UNPARIED_E (not UNPAIRED_E), column
valencee_total (double “e”).
What each OLED property means#
Subset of the Oliynyk table (22 of ~98 features in the dataset paper). Short definitions follow Data in Brief Table 1 (https://doi.org/10.1016/j.dib.2024.110178). Full narrative: OLED tutorial - What each property means.
Enum |
Column |
Meaning (short) |
|---|---|---|
|
|
Isotopic-mean atomic mass |
|
|
Proton count Z |
|
|
Periodic-table period (row) |
|
|
Periodic-table group (column) |
|
|
Similarity-based element order |
|
|
Total valence electrons |
|
|
Unpaired valence electrons |
|
|
Gilman valence-electron count |
|
|
Effective nuclear charge (shielded) |
|
|
First ionization energy |
|
|
Characteristic CN in this table |
|
|
Size / packing ratio descriptor |
|
|
Local packing distortion metric |
|
|
Radius for CIF-radius normalization (Å) |
|
|
Pauling metallic radius (CN12) |
|
|
Pauling electronegativity |
|
|
Martynov-Batsanov electronegativity |
|
|
Melting point (K) |
|
|
Bulk density |
|
|
Specific heat capacity |
|
|
Solid → free-atom energy |
|
|
Resistance to compression |
Formula → feature vector (ML)#
from cifkit.parsers.formula import Formula
from cifkit.sources.oliynyk import Oliynyk, Property
oled = Oliynyk()
parsed = Formula("NdSi2").parsed_formula # [('Nd', 1.0), ('Si', 2.0)]
total = sum(c for _, c in parsed)
features = {
prop.value: sum(oled.db[el][prop] * c for el, c in parsed) / total
for prop in Property
}
Formula#
from cifkit.parsers.formula import Formula
f = Formula("NdSi2")
f.formula # str
f.elements # ['Nd', 'Si']
f.parsed_formula # [('Nd', 1.0), ('Si', 2.0)]
f.indices # [1.0, 2.0]
f.element_count # int number of element types
f.get_normalized_formula()
Class/static helpers include: filter_by_elements_containing,
filter_by_elements_matching, filter_by_composition,
sort_by_stoichiometry, sort_by_elemental_property,
order_by_alphabetical, count_by_formula, get_unique_formulas, …
Autodoc: Formula.
ElementSorter#
from cifkit.sorters.element_sorter import ElementSorter
sorter = ElementSorter(...) # see autodoc for label maps / Excel sheets
sorter.sort(elements)
Autodoc: ElementSorter.
Coordination submodules#
Low-level helpers under cifkit.coordination.* (method, filter, geometry,
composition, connection, bond_distance, site_distance). Prefer the Cif
attributes above unless you need the functions directly.
Autodoc: Coordination.
Publications#
cifkit (JOSS): https://doi.org/10.21105/joss.07205
OLED / Oliynyk dataset (Data in Brief): https://doi.org/10.1016/j.dib.2024.110178