No project description provided
Project description
🦆⚛️ DuckAtoms
Fast, flexible databases for atomic structures with minimal SQL
DuckAtoms helps you to efficiently store and analyze your growing collection of atomic structures with a DuckDB database. The database is structured to allow you to add custom per-structure or per-atom properties such as MACE embeddings, SOAP vectors, etc., which are challenging to manage with a standard ASE database. In essence this package bridges ASE's familiar interface to DuckDB's analytical speed.
✨ Key Features
- Fast: DuckDB is one of the fastest databases for single-node environments
- SQL Queryable: All per-structure and per-atom properties are directly accessible via SQL
- Flexible Storage: Store data as numbers, arrays, text and any other type DuckDB has to offer
- Seamless Integration: Native ASE Atoms compatibility, with the ability to define custom conversions
- Scalable: Handle thousands to millions of structures efficiently
- Future Plans: Including vector similarity search using either the VSS or FAISS - extension.
🚀 Quick Start
from ase import Atoms
from duckatoms import Factory, DB
# Create a new database
factory = Factory("my_structures.duckdb")
factory.add_property("structures", "energy", "DOUBLE")
factory.add_property("atoms", "mace", "DOUBLE[128]")
# Add your atomic structures
db = DB("my_structures.duckdb")
structures = [atoms1, atoms2, atoms3] # Your ASE Atoms objects
db.add_structures(structures)
mace_descriptors = {1: mace1, 2: mace2, 3: mace3}
db.update_atom_properties('mace', mace_descriptors) # Your mace descriptors
# Query with SQL - get lowest energy structures
high_energy_atoms = db.sql("""
SELECT id
FROM structures
ORDER BY energy
LIMIT 10;
""").atoms()
# Query with SQL - obtain specific descriptors and keep track of their indices
mace_df = db.sql("""
SELECT id, structure_id, mace
FROM atoms
WHERE number == 44 and z > 6 -- Ru atoms above 6 Angstrom in z direction.
""").df()
For further details check out the documentation.
📦 Installation
Using pip
pip install duckatoms
Development Installation
git clone https://gitlab.com/cedhan/duckatoms.git
cd duckatoms
# Install with development dependencies (for contributors)
poetry install --with dev,docs
FAQ
How is the data stored?
The data managed by this package is inserted into a DuckDB database, which contains a structures and a atoms table. When you add an atomic structure to the database, all structure related data, like the cell vectors or pbc, are stored in the structures table. The position of each atom, its atomic number and other single atom properties are stored in the atoms table. To both tables, you can add arbitrary columns to store custom data.
Why not use an ASE database?
- Many properties of atomic structures, such as positions, forces, etc. are saved in a binary format (BLOB), which does not allow to query them directly with SQL. DuckAtoms prevents this by using a database that can handle the storage of numbers, arrays and more without using a not readable binary format and still maintain its speed.
- DuckDB allows state of the art (fast) column first analytics.
- Once queried the most interesting properties, you can transform them to numpy.arrays and pandas.DataFrames
- DuckDB is serverless and thus there is no need to set up a server
I've never used SQL before, where can I start?
Taking a very basic introduction, like sqlbolt offers it for free, should suffice for most queries.
Architecture
- Type Safety: Pydantic models ensure data validation and type checking
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file duckatoms-0.0.1b1.tar.gz.
File metadata
- Download URL: duckatoms-0.0.1b1.tar.gz
- Upload date:
- Size: 14.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.5
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
b8efb819cdefcf179eebae967f0e2b4d532c761a6b6410b37a0bd9df637a2b6b
|
|
| MD5 |
faad48eabf38fbdae803c3c72b231f66
|
|
| BLAKE2b-256 |
8d43fa8a8949b6f89db156024c1b22fbf92b22c194cc072d86d4bcd8b22e71c9
|
File details
Details for the file duckatoms-0.0.1b1-py3-none-any.whl.
File metadata
- Download URL: duckatoms-0.0.1b1-py3-none-any.whl
- Upload date:
- Size: 14.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.5
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
769b739b843d6dc9a81e4c54abde36839d40ae6eaac55431ec5e4d5e9b514dc2
|
|
| MD5 |
495af482abae779f7531223ffe044a6e
|
|
| BLAKE2b-256 |
bbbbf507bafe59d8db9e8cfb8741889450d1b96e434b440cc3b3c1ed9a4897bb
|