cellify 0.1.2__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (47) hide show
  1. cellify-0.1.2/.github/ISSUE_TEMPLATE/bug_report.yml +46 -0
  2. cellify-0.1.2/.github/ISSUE_TEMPLATE/feature_request.yml +36 -0
  3. cellify-0.1.2/.github/ISSUE_TEMPLATE/question.yml +22 -0
  4. cellify-0.1.2/.github/workflows/autorelease.yml +84 -0
  5. cellify-0.1.2/.github/workflows/check_cmdline.yml +31 -0
  6. cellify-0.1.2/.github/workflows/pre-commit.yml +30 -0
  7. cellify-0.1.2/.github/workflows/tests.yml +37 -0
  8. cellify-0.1.2/.gitignore +47 -0
  9. cellify-0.1.2/.pre-commit-config.yaml +53 -0
  10. cellify-0.1.2/GEMINI.md +86 -0
  11. cellify-0.1.2/NAMES.md +27 -0
  12. cellify-0.1.2/PKG-INFO +202 -0
  13. cellify-0.1.2/README.md +178 -0
  14. cellify-0.1.2/examples/1_vasp_supercell/POSCAR +16 -0
  15. cellify-0.1.2/examples/1_vasp_supercell/POSCAR_222 +72 -0
  16. cellify-0.1.2/examples/1_vasp_supercell/POSCAR_doped +72 -0
  17. cellify-0.1.2/examples/1_vasp_supercell/POSCAR_scaled +224 -0
  18. cellify-0.1.2/examples/1_vasp_supercell/run.sh +21 -0
  19. cellify-0.1.2/examples/2_espresso_doping/qe.in +37 -0
  20. cellify-0.1.2/examples/2_espresso_doping/qe_222.in +97 -0
  21. cellify-0.1.2/examples/2_espresso_doping/qe_doped.in +98 -0
  22. cellify-0.1.2/examples/2_espresso_doping/run.sh +16 -0
  23. cellify-0.1.2/examples/3_primitive_to_conventional/POSCAR_conventional +16 -0
  24. cellify-0.1.2/examples/3_primitive_to_conventional/POSCAR_conventional_222 +72 -0
  25. cellify-0.1.2/examples/3_primitive_to_conventional/POSCAR_primitive +10 -0
  26. cellify-0.1.2/examples/3_primitive_to_conventional/run.sh +16 -0
  27. cellify-0.1.2/examples/4_espresso_supercell/3csic.in +33 -0
  28. cellify-0.1.2/examples/4_espresso_supercell/3csic_conventional.in +41 -0
  29. cellify-0.1.2/examples/4_espresso_supercell/3csic_supercell_222.in +97 -0
  30. cellify-0.1.2/examples/4_espresso_supercell/3csic_vacancy.in +96 -0
  31. cellify-0.1.2/examples/4_espresso_supercell/run.sh +23 -0
  32. cellify-0.1.2/examples/README.md +37 -0
  33. cellify-0.1.2/pyproject.toml +45 -0
  34. cellify-0.1.2/src/cellify/__init__.py +6 -0
  35. cellify-0.1.2/src/cellify/adapters/__init__.py +26 -0
  36. cellify-0.1.2/src/cellify/adapters/base.py +36 -0
  37. cellify-0.1.2/src/cellify/adapters/espresso.py +124 -0
  38. cellify-0.1.2/src/cellify/adapters/standard.py +27 -0
  39. cellify-0.1.2/src/cellify/cli.py +245 -0
  40. cellify-0.1.2/src/cellify/core.py +271 -0
  41. cellify-0.1.2/tests/POSCAR +10 -0
  42. cellify-0.1.2/tests/POSCAR_222 +24 -0
  43. cellify-0.1.2/tests/POSCAR_doped +24 -0
  44. cellify-0.1.2/tests/POSCAR_mindist +136 -0
  45. cellify-0.1.2/tests/qe.in +25 -0
  46. cellify-0.1.2/tests/qe_222.in +42 -0
  47. cellify-0.1.2/tests/test_cellify.py +116 -0
@@ -0,0 +1,46 @@
1
+ name: Bug Report
2
+ description: Report a reproducible bug in the application
3
+ labels: [bug]
4
+ body:
5
+ - type: markdown
6
+ attributes:
7
+ value: |
8
+ Thank you for reporting a bug! Please fill out the form below to help us reproduce and fix the issue.
9
+ - type: input
10
+ id: title
11
+ attributes:
12
+ label: Bug Summary
13
+ placeholder: Short and descriptive summary of the bug
14
+ validations:
15
+ required: true
16
+ - type: textarea
17
+ id: steps
18
+ attributes:
19
+ label: Steps to Reproduce
20
+ placeholder: |
21
+ 1. Run `cellify -i POSCAR -d 2 2 2`
22
+ 2. Observe the error
23
+ description: Please provide a minimal, reproducible example.
24
+ validations:
25
+ required: true
26
+ - type: textarea
27
+ id: expected
28
+ attributes:
29
+ label: Expected Behavior
30
+ description: What did you expect to happen instead?
31
+ validations:
32
+ required: false
33
+ - type: textarea
34
+ id: logs
35
+ attributes:
36
+ label: Error Traceback or Logs (if applicable)
37
+ render: shell
38
+ validations:
39
+ required: false
40
+ - type: input
41
+ id: environment
42
+ attributes:
43
+ label: Environment
44
+ placeholder: "e.g., macOS, Python 3.10"
45
+ validations:
46
+ required: false
@@ -0,0 +1,36 @@
1
+ name: Feature Request
2
+ description: Suggest a new feature or improvement
3
+ labels: [enhancement]
4
+ body:
5
+ - type: markdown
6
+ attributes:
7
+ value: |
8
+ Thank you for your suggestion! Please complete the form below.
9
+ - type: input
10
+ id: summary
11
+ attributes:
12
+ label: Summary
13
+ placeholder: e.g., Add support for CP2K inputs
14
+ validations:
15
+ required: true
16
+ - type: textarea
17
+ id: motivation
18
+ attributes:
19
+ label: Motivation
20
+ description: Why is this feature important? What problem does it solve?
21
+ validations:
22
+ required: false
23
+ - type: textarea
24
+ id: proposal
25
+ attributes:
26
+ label: Proposed Solution
27
+ description: Describe how you'd like the feature to work
28
+ validations:
29
+ required: false
30
+ - type: textarea
31
+ id: alternatives
32
+ attributes:
33
+ label: Alternatives
34
+ description: Any alternative solutions you've considered?
35
+ validations:
36
+ required: false
@@ -0,0 +1,22 @@
1
+ name: Question
2
+ description: Ask a question related to usage or development
3
+ labels: [question]
4
+ body:
5
+ - type: markdown
6
+ attributes:
7
+ value: |
8
+ If you have a question, please provide sufficient context so we can assist you better.
9
+ - type: input
10
+ id: summary
11
+ attributes:
12
+ label: Question Summary
13
+ placeholder: e.g., How to generate a coherent interface between two lattices?
14
+ validations:
15
+ required: true
16
+ - type: textarea
17
+ id: context
18
+ attributes:
19
+ label: Context or Background
20
+ description: What are you trying to do? Any relevant files or errors?
21
+ validations:
22
+ required: false
@@ -0,0 +1,84 @@
1
+ name: Auto Release on Version Bump
2
+
3
+ on:
4
+ push:
5
+ branches:
6
+ - main
7
+
8
+ permissions:
9
+ contents: write
10
+ id-token: write
11
+
12
+ jobs:
13
+ autorelease:
14
+ name: Check version and create release
15
+ runs-on: ubuntu-latest
16
+ outputs:
17
+ release_created: ${{ steps.check_tag.outputs.exists }}
18
+ steps:
19
+ - name: Checkout code
20
+ uses: actions/checkout@v4
21
+ with:
22
+ fetch-depth: 0 # Fetch all history and tags
23
+
24
+ - name: Get current version
25
+ id: get_version
26
+ run: |
27
+ VERSION=$(python -c "
28
+ with open('src/cellify/__init__.py') as f:
29
+ for line in f:
30
+ if '__version__' in line:
31
+ print(line.split('=')[1].strip().strip('\"\''))
32
+ break
33
+ ")
34
+ echo "VERSION=$VERSION" >> $GITHUB_ENV
35
+ echo "version=$VERSION" >> $GITHUB_OUTPUT
36
+
37
+ - name: Check if tag exists
38
+ id: check_tag
39
+ run: |
40
+ TAG_NAME="v${{ env.VERSION }}"
41
+ if git rev-parse "$TAG_NAME" >/dev/null 2>&1; then
42
+ echo "Tag $TAG_NAME already exists. Skipping release."
43
+ echo "exists=true" >> $GITHUB_OUTPUT
44
+ else
45
+ echo "Tag $TAG_NAME does not exist. A new release will be created."
46
+ echo "exists=false" >> $GITHUB_OUTPUT
47
+ fi
48
+
49
+ - name: Create GitHub Release
50
+ if: steps.check_tag.outputs.exists == 'false'
51
+ env:
52
+ GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
53
+ run: |
54
+ TAG_NAME="v${{ env.VERSION }}"
55
+ echo "Creating release for $TAG_NAME..."
56
+ gh release create "$TAG_NAME" \
57
+ --title "$TAG_NAME" \
58
+ --generate-notes
59
+
60
+ publish:
61
+ name: Build & Publish to PyPI
62
+ needs: autorelease
63
+ if: needs.autorelease.outputs.release_created == 'false'
64
+ runs-on: ubuntu-latest
65
+ environment:
66
+ name: pypi
67
+ url: https://pypi.org/p/cellify
68
+ steps:
69
+ - name: Checkout code
70
+ uses: actions/checkout@v4
71
+
72
+ - name: Set up Python
73
+ uses: actions/setup-python@v5
74
+ with:
75
+ python-version: "3.10"
76
+
77
+ - name: Install build dependencies
78
+ run: pip install build
79
+
80
+ - name: Build sdist and wheel
81
+ run: python -m build
82
+
83
+ - name: Publish to PyPI
84
+ uses: pypa/gh-action-pypi-publish@release/v1
@@ -0,0 +1,31 @@
1
+ name: Test if cmdlines work
2
+ on:
3
+ pull_request:
4
+ branches:
5
+ - main
6
+ push:
7
+ branches:
8
+ - main
9
+
10
+ jobs:
11
+ release:
12
+ name: Build
13
+ runs-on: ubuntu-latest
14
+ steps:
15
+ - name: Checkout
16
+ uses: actions/checkout@v4
17
+
18
+ - name: Set up Python
19
+ uses: actions/setup-python@v5
20
+ with:
21
+ python-version: "3.10"
22
+
23
+ - name: Install dependencies
24
+ run: |
25
+ python -m pip install --upgrade pip
26
+ pip install -e .
27
+ working-directory: ${{ github.workspace }}
28
+
29
+ - name: cellify --help test
30
+ run: |
31
+ cellify --help
@@ -0,0 +1,30 @@
1
+ name: pre-commit
2
+
3
+ on:
4
+ pull_request:
5
+ branches:
6
+ - main
7
+ push:
8
+ branches:
9
+ - main
10
+
11
+ jobs:
12
+ pre-commit:
13
+ runs-on: ubuntu-latest
14
+ steps:
15
+ - name: Checkout code
16
+ uses: actions/checkout@v4
17
+
18
+ - name: Set up Python
19
+ uses: actions/setup-python@v5
20
+ with:
21
+ python-version: "3.11"
22
+
23
+ - name: Install dependencies
24
+ run: |
25
+ python -m pip install --upgrade pip
26
+ pip install pre-commit
27
+ pre-commit install
28
+
29
+ - name: Run pre-commit
30
+ run: pre-commit run --all-files
@@ -0,0 +1,37 @@
1
+ name: Test Suite
2
+ on:
3
+ pull_request:
4
+ branches:
5
+ - main
6
+ push:
7
+ branches:
8
+ - main
9
+
10
+ jobs:
11
+ test:
12
+ name: Run pytest
13
+ runs-on: ubuntu-latest
14
+ strategy:
15
+ matrix:
16
+ python-version: ["3.9", "3.10", "3.11", "3.12"]
17
+ steps:
18
+ - name: Checkout code
19
+ uses: actions/checkout@v4
20
+
21
+ - name: Set up Python ${{ matrix.python-version }}
22
+ uses: actions/setup-python@v5
23
+ with:
24
+ python-version: ${{ matrix.python-version }}
25
+
26
+ - name: Install dependencies
27
+ run: |
28
+ python -m pip install --upgrade pip
29
+ pip install -e ".[test]"
30
+
31
+ - name: Run tests
32
+ run: pytest
33
+
34
+ - name: Build package verification
35
+ run: |
36
+ pip install build
37
+ python -m build
@@ -0,0 +1,47 @@
1
+ # Byte-compiled / optimized / DLL files
2
+ __pycache__/
3
+ *.py[cod]
4
+ *$py.class
5
+
6
+ # C extensions
7
+ *.so
8
+
9
+ # Distribution / packaging
10
+ .Python
11
+ build/
12
+ develop-eggs/
13
+ dist/
14
+ downloads/
15
+ eggs/
16
+ .eggs/
17
+ lib/
18
+ lib64/
19
+ parts/
20
+ sdist/
21
+ var/
22
+ wheels/
23
+ share/python-wheels/
24
+ *.egg-info/
25
+ .installed.cfg
26
+ *.egg
27
+ MANIFEST
28
+
29
+ # Pytest / coverage
30
+ .pytest_cache/
31
+ .mypy_cache/
32
+ .pylint_cache/
33
+
34
+ # Virtual Environments
35
+ .venv/
36
+ venv/
37
+ ENV/
38
+ env/
39
+
40
+ # Editor / System files
41
+ .DS_Store
42
+ .vscode/
43
+ .idea/
44
+ .flake8
45
+
46
+ # AI Agent
47
+ .agents/
@@ -0,0 +1,53 @@
1
+ # See https://pre-commit.com for more information
2
+ # See https://pre-commit.com/hooks.html for more hooks
3
+ repos:
4
+ - repo: https://github.com/pre-commit/pre-commit-hooks
5
+ rev: v3.2.0
6
+ hooks:
7
+ - id: trailing-whitespace
8
+ - id: end-of-file-fixer
9
+ - id: check-yaml
10
+ - id: check-json
11
+ - id: check-added-large-files
12
+ - id: check-toml
13
+ - repo: https://github.com/pycqa/isort
14
+ rev: 6.0.1
15
+ hooks:
16
+ - id: isort
17
+ args: ["--profile", "black"]
18
+ files: ^src/
19
+ - repo: https://github.com/psf/black
20
+ rev: 25.1.0
21
+ hooks:
22
+ - id: black
23
+ language_version: python3
24
+ files: ^src/
25
+ - repo: https://github.com/pre-commit/mirrors-mypy
26
+ rev: v1.15.0
27
+ hooks:
28
+ - id: mypy
29
+ args: [--ignore-missing-imports, --strict]
30
+ files: ^src/
31
+ - repo: https://github.com/PyCQA/flake8
32
+ rev: "7.2.0"
33
+ hooks:
34
+ - id: flake8
35
+ # max-line-length setting is the same as black.
36
+ # E203 and W503 are ignored to prevent conflicts with black formatter.
37
+ # Complexity thresholds are set to a realistic value of 15 for practical CLI development.
38
+ args: [--max-line-length, "150", --ignore=E402,--ignore=E800,--ignore=E203,--ignore=W503,--max-complexity, "15", --max-expression-complexity=15, --max-cognitive-complexity=15]
39
+ additional_dependencies: [flake8-bugbear, flake8-builtins, flake8-eradicate, pep8-naming, flake8-expression-complexity, flake8-cognitive-complexity]
40
+ files: ^src/
41
+
42
+ - repo: https://github.com/pylint-dev/pylint
43
+ rev: v3.3.7
44
+ hooks:
45
+ - id: pylint
46
+ name: pylint
47
+ entry: pylint
48
+ language: python
49
+ types: [python]
50
+ additional_dependencies: [ase, pymatgen, numpy]
51
+ # Disable overly strict pylint checks that are not pragmatic for CLI apps (e.g. too many locals/branches/statements/docstrings)
52
+ args: [--max-line-length,"150","--init-hook", "import sys; sys.path.insert(0, 'src')", "--disable=C0415,R0914,R0912,R0915,C0116,C0114"]
53
+ files: ^src/
@@ -0,0 +1,86 @@
1
+ # GEMINI.md - Development History and Code Conventions
2
+
3
+ This document records the development history, technical decisions, and code quality conventions of the `cellify` project, built collaboratively with the AI assistant "Gemini".
4
+
5
+ ---
6
+
7
+ ## 1. Project Background and Decisions
8
+
9
+ ### Purpose of Development
10
+ To provide a command-line (CLI) tool that allows researchers to "easily" generate supercells and modify structures (doping, vacancies, surface slabs) for DFT calculations (VASP, Quantum ESPRESSO, etc.) while "completely preserving calculation parameters" in mixed format files.
11
+
12
+ ### Decision Process
13
+ 1. **Survey of Existing Tools**: Analyzed the pros and cons of `cif2cell`, `phonopy`, `ASE`, and `pymatgen` (issues like brittle dependencies, manual header copy-pasting, etc.).
14
+ 2. **Requirements Definition (README.md)**: Defined specifications including "Calculation-ready input files (especially QE `nat` auto-updates)" and "Automatic scaling based on minimum periodic distances".
15
+ 3. **Naming Decision**: Chose **`cellify`** over other candidates like `scel` to support future general structure-modeling extensions.
16
+ 4. **GitHub Connection**: Created and connected a public repository: `ToAmano/cellify`.
17
+ 5. **Conventional Cell Conversion (Issue #5)**: Added `--conventional` flag to automatically convert primitive cells (commonly downloaded from materials databases) into conventional cells before performing other operations. This ensures intuitive defect index modeling and surface slab cutting.
18
+
19
+ ---
20
+
21
+ ## 2. Development & Coding Conventions
22
+
23
+ ### ① Complete Type Hinting 【Strictly Required】
24
+ All Python modules under `src/cellify/` must have **complete type annotations** to ensure maintainability, static verification, and readability.
25
+
26
+ * **Function Signatures**: Specify parameter and return types using the `typing` module or built-in generics.
27
+ ```python
28
+ from typing import Tuple, Dict, Any
29
+ from pymatgen.core import Structure
30
+
31
+ def load_structure_file(filepath: str) -> Tuple[Structure, Dict[str, Any]]:
32
+ ...
33
+ ```
34
+ * **Local Variables**: Annotate local variables when they hold complex types.
35
+ * **Static Analysis**: Ensure all changes are validated and raise no errors when checked with static type checkers like `mypy`.
36
+
37
+ ### ② Parameter Preservation (Plain-Text Substitution)
38
+ To prevent parse errors or accidental default overwrites (such as `K_POINTS None` introduction) in mixed-format calculations like Quantum ESPRESSO, adapters must keep calculation parameters (namelists, comments, formatting) in plain text and only modify parameters like `nat` and `ntyp` using regex matching. This is referred to as the `text_replace` engine.
39
+
40
+ ### ③ Modular Architecture (Separation of I/O Adapters and Core)
41
+ To keep the codebase maintainable and open for future DFT software additions:
42
+ * **`adapters` Package**: Any format-specific file reading/writing (and parameter-preserving text substitutions) must be encapsulated under adapters inheriting the abstract `BaseAdapter` class (e.g., `EspressoAdapter`, `StandardAdapter`).
43
+ * **`core` Module**: Structural manipulation logic (supercells, defects, slabs) must be written as modular, pure-like functions that receive a `Structure` and return a modified `Structure` without being aware of input/output files.
44
+ * **Future Modulations**: The core logic remains in a single `core.py` for simplicity now, but is kept decoupled so it can be easily split into a `core/` package when the number of features increases.
45
+
46
+ ### ④ Branch Management and PR Lifecycle
47
+ To maintain clean git history and keep features isolated:
48
+ * **One Branch Per Task/Feature**: Always create a new, dedicated branch for each feature or task. Do not implement unrelated requests or new tasks on an existing, open feature branch.
49
+ * **Cleanup After Merge**: Once a branch's Pull Request is merged into `main`, delete the branch locally and remotely to prevent reuse.
50
+
51
+ ---
52
+
53
+ ## 3. Testing & Linting Conventions and Execution
54
+ To guarantee code quality and stability, unit/integration tests are managed using `pytest` inside the [tests/](file:///Users/amano/works/research/supercell/tests/) directory, and static analysis/formatting are managed by `pre-commit`.
55
+
56
+ ### ① Execution Before Commit 【Strictly Required】
57
+ You **must** run and pass both the test suite and pre-commit checks locally before executing any `git commit`:
58
+
59
+ 1. **Run Pytest**:
60
+ ```bash
61
+ # Install dependencies including test tools
62
+ pip install -e ".[test]"
63
+
64
+ # Run tests
65
+ pytest
66
+ ```
67
+ 2. **Run Pre-commit**:
68
+ ```bash
69
+ # Install pre-commit hook (first time only to enable commit-time validation)
70
+ pre-commit install
71
+
72
+ # Run checks manually on all files before committing
73
+ pre-commit run --all-files
74
+ ```
75
+
76
+ ### ② Conventions
77
+ * Whenever implementing new features or fixing bugs, corresponding tests **must** be added to the `tests/` directory.
78
+ * Always maintain a fully passing (`passed`) state for all tests and linters in local verification and CI. Do not commit or push failing code.
79
+
80
+ ---
81
+
82
+ ## 4. Future Roadmap and Milestones
83
+ * Further stabilization and validation of vacancy generation (`--vacancy`) logic.
84
+ * Adding test data and verification for surface slab models (`--slab`).
85
+ * Integrating a lattice mismatch auto-relaxation module for heterostructures.
86
+ * Setting up linting and formatting configuration files (`mypy`, `flake8`, `black`, `ruff`).
cellify-0.1.2/NAMES.md ADDED
@@ -0,0 +1,27 @@
1
+ # Name Candidates for the DFT Supercell Generator Tool
2
+
3
+ A list of command-line name candidates representing the tool's identity (ease of use, parameter preservation, automatic expansion based on periodic distances, etc.), which are easy to type and memorable.
4
+
5
+ ---
6
+
7
+ ## Proposed Name Candidates
8
+
9
+ | Name | Pronunciation | Command Example | Description & Origin |
10
+ | :--- | :--- | :--- | :--- |
11
+ | **`scel`** | s-cell | `scel -i POSCAR -o SPOSCAR -d 2 2 2` | Short for **S**uper**cel**l. Extremely short and optimal for CLI typing. Least prone to command conflicts. |
12
+ | **`cellify`** | cell-i-fy | `cellify -i qe.in --min-dist 15.0` | **【Selected】** A verb meaning "to convert into a cell" or "to supercell". Sounds modern, friendly, and easy to remember. |
13
+ | **`dftsc`** | d-f-t-s-c | `dftsc -i POSCAR -o SPOSCAR` | Short for **D**FT **S**uper**c**ell. Immediately conveys its DFT-specific usage and contains no fluff. |
14
+ | **`readycell`** | ready-cell | `readycell -i qe.in -o qe_super.in` | Highlights the tool's core feature of creating **Calculation-ready** inputs (preserving calculations and updating headers automatically). |
15
+ | **`scgen`** | s-c-gen | `scgen -i input.cif -d 2 2 2` | Short for **S**uper**c**ell **Gen**erator. An orthodox name that clearly defines its purpose. |
16
+ | **`autosuper`** | auto-super | `autosuper -i POSCAR --min-dist 12.0` | Focuses on the smart feature of **automatically (Auto)** generating the optimal supercell based on a specified distance constraint. |
17
+
18
+ ---
19
+
20
+ ## Selection Criteria
21
+
22
+ 1. **CLI Ergonomics**:
23
+ * `scel` and `dftsc` are only 4–5 characters, making them highly efficient to type.
24
+ * `cellify` and `scgen` are easy to type without spelling errors.
25
+ 2. **PyPI Package Availability**:
26
+ * Ensures that when publishing the tool to PyPI, it does not conflict with existing packages.
27
+ * `cellify` is clear, clean, and stands out as a unique and descriptive project name.