Skip to main content

MatCraft Toolkit

Project description

mckit — MatCraft Toolkit

A modular Python framework for building and analyzing atomic structures. Backed by ASE and pymatgen for materials modelling.

Features

  • Operations — modelling materials
  • Observations — inspect structures and run sanity checks

1. Usage

Installation

You can simply use:

pip install matcraft-kit

For development, clone the repository and install in editable mode:

pip install -e ".[dev]"

CLI

# for observations:
mckit observe -h
# for operations:
mckit operate -h

2. Development

Click to expand development instructions

Prerequisites

  • Python ≥ 3.9
  • pip

Setup

# Clone the repository
git clone <repo-url>
cd matcraft-kit

# Create and activate a virtual environment
python -m venv .venv
source .venv/bin/activate        # Linux/macOS
# .venv\Scripts\activate         # Windows

# Install in editable mode with dev dependencies
pip install -e ".[dev]"

Project Structure

mckit/
├── __init__.py              # Package root — exports public API
├── core/
│   ├── lattice.py           # Lattice dataclass (3×3 matrix, ASE Cell-backed)
│   ├── structure.py         # Structure dataclass (lattice + species + positions)
│   └── tool.py              # Abstract base classes: Operation, Observation
├── operate/
│   ├── bulk.py              # BulkBuilder — standard crystal structures
│   └── surface.py           # SurfaceBuilder, TerminationAnalyzer, MoleculeDetector
├── observe/
│   ├── inspect.py              # StructureInspect — structural summary
│   └── fundamental.py       # FundamentalCheck — geometric validity checks
└── io/
    ├── reader.py            # read_structure() -> ASE Atoms
    └── writer.py            # write_structure() — ASE io.write

Architecture

The framework follows an Operation / Observation pattern:

  • Operation (abstract) — tools that build or modify structures. Subclasses implement apply(...) and return a Structure.
  • Observation (abstract) — tools that inspect structures without modifying them. Subclasses implement observe(structure) → Any.

Both are single-method ABCs defined in mckit.core.tool, making it straightforward to add new operations or observations.

Core data flow:

File (CIF, VASP, ...) ──read_structure()──▶ ase.Atoms ──Operation──▶ Structure/ase.Atoms ──write_structure()──▶ File
                                                │
                                                └──Observation──▶ dict / CheckResult / ...

Running Tests

pytest

With coverage:

pytest --cov=mckit --cov-report=term-missing

Adding a New Operation

Create a file under mckit/operate/ and subclass Operation:

from mckit.core.structure import Structure
from mckit.core.tool import Operation

class MyBuilder(Operation):
    """Build or modify a structure."""

    def apply(self, *, some_param: float, **kwargs) -> Structure:
        # ... your logic here ...
        return new_structure

Then re-export it from mckit/operate/__init__.py.

Adding a New Observation

Create a file under mckit/observe/ and subclass Observation:

from mckit.core.structure import Structure
from mckit.core.tool import Observation

class MyAnalysis(Observation):
    """Inspect a structure and return results."""

    def observe(self, structure: Structure, **kwargs):
        # ... your logic here ...
        return result_dict

Then re-export it from mckit/observe/__init__.py.

Building the Package

pip install build
python -m build

This produces a wheel and sdist under dist/.

Dependencies

Package Purpose
numpy ≥ 1.21 Numerical computing
ase ≥ 3.22 Atomic Simulation Environment — crystal builders, I/O, coordinate transforms
pymatgen ≥ 2022.0.0 Python Materials Genomics — CIF parsing, symmetry analysis

Project details


Download files

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

Source Distribution

matcraft_kit-0.1.3.tar.gz (77.0 kB view details)

Uploaded Source

Built Distribution

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

matcraft_kit-0.1.3-py3-none-any.whl (83.8 kB view details)

Uploaded Python 3

File details

Details for the file matcraft_kit-0.1.3.tar.gz.

File metadata

  • Download URL: matcraft_kit-0.1.3.tar.gz
  • Upload date:
  • Size: 77.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.4

File hashes

Hashes for matcraft_kit-0.1.3.tar.gz
Algorithm Hash digest
SHA256 a75dfc4d94caf940baa4e2981741bf2d170f5845676b1571ce690f4a81dcc27b
MD5 0a2c8ae64618face4d01d2853eb3654f
BLAKE2b-256 97a5b8e65b7109c1a5350ab37a83c40a1e9a6a764db2d4dafab7ce62127c735e

See more details on using hashes here.

File details

Details for the file matcraft_kit-0.1.3-py3-none-any.whl.

File metadata

  • Download URL: matcraft_kit-0.1.3-py3-none-any.whl
  • Upload date:
  • Size: 83.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.4

File hashes

Hashes for matcraft_kit-0.1.3-py3-none-any.whl
Algorithm Hash digest
SHA256 a721288ed3f65818ab868d38b52c4a4ee0f5b5ddb8668d9669311d1fd974862a
MD5 dcf8aa8c3fd1b89846193043ec48e41c
BLAKE2b-256 914a0689f994b949c5a97c7665e363ce91317c58386da1d48a2803d6cf902a10

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page