Skip to main content

Welcome to CSSlib 👋

License Version

CSSlib

CSSlib is an open-source code for building configuration search space (CSS) of disordered crystals, loading of the CSS dataset obtained, local/remote MPI or SLURM calculations and data visualization.

Table of content

Installation

CSSlib can be installed through

  1. the pip package manager (in the virtual environment):
pip install csslib
  1. the git clone command:
git clone https://github.com/AIRI-Institute/CSSlib.git CSSlib
cd CSSlib
pip install .
  1. the uv package manager:
uv venv .venv
source .venv/bin/activate
uv pip install csslib

CSSlib requires Python 3.11–3.14. To work through the tutorial notebook, install the separate tutorial dependencies:

pip install "csslib[tutorial]"

For a local editable checkout, use pip install -e ".[tutorial]". The tutorial pipeline diagram also requires the Graphviz executable to be installed and available on PATH.

CSSlib depends on the lightweight pymatgen-core distribution. It provides the same pymatgen.* import paths used by CSSlib without installing the unrelated high-level analysis packages.

Candidate interstitial sites remain explicit placeholder species in the input CIF and must be listed in fictive_atoms. CSSlib can now construct such a candidate sublattice directly, without pymatgen-analysis-defects:

from csslib import generate_interstitial_structure

structure = generate_interstitial_structure(
    "host.cif",
    fictive_atom="Np",
    output_filename="host_interstitial.cif",
)

for site in structure:
    if site.label.startswith("Np"):
        print(site.label, site.frac_coords)

Symmetry-equivalent positions receive the same label (Np0, Np1, and so on), so the generated CIF can be passed to the existing CSS pipeline with "fictive_atoms": ["Np"]. Existing output files are protected unless overwrite=True is passed.

The search uses vertices of a periodic Voronoi tessellation and reports geometric candidates only. It can miss relevant positions on Voronoi faces or edges and does not establish that an interstitial defect is energetically stable. The defaults min_distance=0.9 Å and clustering_tolerance=0.5 Å are numerical filters, not universal physical radii; adjust them for the host structure and intended impurity.

CSSlib by default requires Supercell program. Details on Supercell installation can be found at the corresponding website.

As a calculator for quantum mechanical calculations, CSSlib assumes the use of the VASP (Vienna Ab initio Simulation Package) software package. Also there is an optional dependency for the QuantumEspresso simulation package which can be installed after the normal installation as:

pip install --group espresso .

or

uv sync --group espresso

Agent plugin

The project-local csslib-agent Codex plugin exposes eleven MCP tools covering provenance-aware MP/AFLOW acquisition, CIF inspection, constrained CSS estimation/generation, dataset selection/do-selection, calculation planning/preflight, and calculation launch/status/cancel/resume.

Install CSSlib with the stable MCP v1 extra before loading the plugin directory in Codex:

pip install -e ".[agent]"

Materials Project acquisition is a deliberately separate optional dependency because mp-api brings the full MP client stack:

pip install -e ".[agent,sources]"

CSS generation follows an inspect_cifestimate_css_spacegenerate_css gate. The request must explicitly enable or disable charge/composition constraints; oxidation states are never inferred. Estimates include pre-symmetry configuration count, conservative storage/planning-memory bounds, free disk, and Supercell availability.

Calculations follow a plan_calculationpreflight_calculationrun_calculation gate. Preflight checks disk reserve, best-effort remote quota, the exact launcher and VASP/QE executable, parser support, and live scheduler capacity. Running work can be monitored, cancelled, and resumed safely within the same MCP server process; status is atomically checkpointed to calculation_state.pkl.gz.

Remote passwords, private-key passphrases, and Materials Project API keys are not accepted as tool arguments. Use SSH agent or the documented CSSLIB_SSH_PASSWORD, CSSLIB_SSH_KEY_PASSPHRASE, and MP_API_KEY environment variables outside chat.

See csslib-agent/TESTING.md for automated tests and safe manual smoke scenarios.

Contributors

  • Aleksey Krautsou
  • Aleksandr Solovykh

Tutorial

The best way to learn how to use CSSlib is through the tutorial notebook located at the tests directory or at the google collab. Install it from a local checkout with pip install -e ".[tutorial]" before starting JupyterLab.

References & Citing

If you use this code, please consider citing works that actively used the CSS approach, which resulted in the creation of this library:

  1. A.V. Krautsou, I.S. Humonen, V.D. Lazarev, R.A. Eremin, S.A. Budennyy
    "Impact of crystal structure symmetry in training datasets on GNN-based energy assessments for chemically disordered CsPbI3"
    https://doi.org/10.1038/s41598-025-92669-3
  2. N.A. Matsokin, R.A. Eremin, A.A. Kuznetsova, I.S. Humonen, A.V. Krautsou, V.D. Lazarev, Y.Z. Vassilyeva, A.Y. Pak, S.A. Budennyy, A.G. Kvashnin, A.A. Osiptsov
    "Discovery of chemically modified higher tungsten boride by means of hybrid GNN/DFT approach"
    https://doi.org/10.1038/s41524-025-01628-z
  3. R.A. Zaripov, R.A. Eremin, I.S. Humonen, A.V. Krautsou, V.V. Kuznetsov, K.E. GermanS, S.A. Budennyy, S.V. Levchenko
    "First-principles data-driven approach for assessment of stability of Tc-C systems"
    https://doi.org/10.1016/j.actamat.2025.121704

Download files

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

Source Distribution

csslib-1.2.4.tar.gz (105.9 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

csslib-1.2.4-py3-none-any.whl (97.1 kB view details)

Uploaded Python 3

File details

Details for the file csslib-1.2.4.tar.gz.

File metadata

  • Download URL: csslib-1.2.4.tar.gz
  • Upload date:
  • Size: 105.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.12

File hashes

Hashes for csslib-1.2.4.tar.gz
Algorithm Hash digest
SHA256 af44c1244cb96869af1d526fe2153dc979cf6fdb42c4f5a7286e0775dfa5cd20
MD5 abda1f564285bacb7bf645ec7b8f0fbf
BLAKE2b-256 9f4036d46438a790a0cf194959ba4f82012299bb67e8057e20c6af0309f82ef3

See more details on using hashes here.

File details

Details for the file csslib-1.2.4-py3-none-any.whl.

File metadata

  • Download URL: csslib-1.2.4-py3-none-any.whl
  • Upload date:
  • Size: 97.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.12

File hashes

Hashes for csslib-1.2.4-py3-none-any.whl
Algorithm Hash digest
SHA256 e92345021df83c4564f90a4cb4e33d576b1372bc48b91f37cb87e0350c10ee7c
MD5 140176c4a976449f59fa5267e4e06fe9
BLAKE2b-256 843870112766880f73251a5cc97b67b65ef6ac5b5fde1aa0dd56385696a61e7a

See more details on using hashes here.

Release history Release notifications | RSS feed

This release

1.2.4 This release

2 files

1.2.3

2 files

1.2

2 files

1.0.1

1 file

1.0

1 file

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page