|
1 | 1 | # Contributing to dftio |
2 | 2 |
|
3 | | -Thank you for your interest in contributing to dftio! |
| 3 | +Thank you for your interest in contributing to dftio! We welcome contributions of all kinds, from bug fixes to new features. |
4 | 4 |
|
5 | 5 | ## Development Setup |
6 | 6 |
|
7 | | -1. Clone the repository: |
8 | | -```bash |
9 | | -git clone https://github.com/deepmodeling/dftio.git |
10 | | -cd dftio |
11 | | -``` |
| 7 | +1. **Clone the repository:** |
| 8 | + ```bash |
| 9 | + git clone https://github.com/deepmodeling/dftio.git |
| 10 | + cd dftio |
| 11 | + ``` |
12 | 12 |
|
13 | | -2. Install with development dependencies: |
14 | | -```bash |
15 | | -./install.sh # or specify GPU version |
16 | | -uv sync --group dev |
17 | | -``` |
| 13 | +2. **Install dependencies:** |
| 14 | + This project uses `uv` for package management. To install all required dependencies, including those for development and testing, run: |
| 15 | + ```bash |
| 16 | + uv sync --group dev |
| 17 | + ``` |
18 | 18 |
|
19 | | -3. Run tests: |
20 | | -```bash |
21 | | -uv run pytest |
22 | | -``` |
| 19 | +3. **Run tests:** |
| 20 | + To make sure everything is set up correctly, run the test suite: |
| 21 | + ```bash |
| 22 | + uv run pytest -m "not integration" |
| 23 | + ``` |
23 | 24 |
|
24 | 25 | ## Code Style |
25 | 26 |
|
26 | | -- Follow PEP 8 guidelines |
27 | | -- Use meaningful variable and function names |
28 | | -- Add docstrings to all public functions and classes |
| 27 | +- Follow PEP 8 guidelines for Python code. |
| 28 | +- Use clear and meaningful names for variables, functions, and classes. |
| 29 | +- Add docstrings to all public functions and classes, explaining their purpose, arguments, and return values. |
29 | 30 |
|
30 | 31 | ## Testing |
31 | 32 |
|
32 | | -- Write tests for new features |
33 | | -- Ensure all tests pass before submitting PR |
34 | | -- Use pytest markers for integration tests |
| 33 | +- All new features and bug fixes should be accompanied by tests. |
| 34 | +- Ensure that the full test suite passes before submitting a pull request. |
| 35 | +- Use `pytest` markers (e.g., `@pytest.mark.integration`) for tests that are slow or require external resources. |
35 | 36 |
|
36 | 37 | ## Pull Request Process |
37 | 38 |
|
38 | | -1. Fork the repository |
39 | | -2. Create a feature branch |
40 | | -3. Make your changes |
41 | | -4. Run tests |
42 | | -5. Submit a pull request |
| 39 | +1. Fork the repository on GitHub. |
| 40 | +2. Create a new feature branch from the `main` branch. |
| 41 | +3. Make your changes in the new branch. |
| 42 | +4. Add or update tests as needed. |
| 43 | +5. Run the tests to ensure everything passes. |
| 44 | +6. Submit a pull request to the `main` branch of the original repository. |
43 | 45 |
|
44 | | -## Adding Support for New DFT Software |
| 46 | +## Implementing a New Parser |
45 | 47 |
|
46 | | -See the [Developer Guide](developer-guide.md) for details on implementing parsers for new DFT packages. |
| 48 | +If you are adding support for a new DFT package, please see the [Developer Guide](developer-guide.md) for a general overview. When implementing the parser class, you will need to provide several key methods. Below are the details of what each method should return. |
| 49 | + |
| 50 | +### `get_structure(idx)` |
| 51 | + |
| 52 | +This method should return a dictionary containing the atomic structure for the `idx`-th calculation. The dictionary should have the following keys (defined in `dftio.data._keys`): |
| 53 | + |
| 54 | +- `_keys.ATOMIC_NUMBERS_KEY`: Atomic numbers as a 1D tensor (`[natom]`). |
| 55 | +- `_keys.PBC_KEY`: Periodic boundary conditions as a boolean tensor (`[3]`). |
| 56 | +- `_keys.POSITIONS_KEY`: Atomic positions in Ångströms (`[nframe, natom, 3]`). |
| 57 | +- `_keys.CELL_KEY`: Lattice vectors in Ångströms (`[nframe, 3, 3]`). |
| 58 | + |
| 59 | +### `get_eigenvalues(idx)` |
| 60 | + |
| 61 | +This method should return a dictionary containing the eigenvalues and k-points: |
| 62 | + |
| 63 | +- `_keys.KPOINT_KEY`: K-point coordinates (`[nk, 3]`). |
| 64 | +- `_keys.ENERGY_EIGENVALUE_KEY`: Eigenvalues (`[nframe, nk, nband]`). |
| 65 | + |
| 66 | +### `get_basis(idx)` |
| 67 | + |
| 68 | +This method should return a dictionary describing the basis set, for example: `{"Si": "2s2p1d"}`. |
| 69 | + |
| 70 | +### `get_blocks(idx, ...)` |
| 71 | + |
| 72 | +This method should parse the real-space Hamiltonian, overlap, and/or density matrices. It should return a tuple of three lists: `(hamiltonians, overlaps, density_matrices)`. Each list should contain one dictionary per frame, where each dictionary's keys are strings like `"i_j_Rx_Ry_Rz"` (representing the matrix element between orbital `i` and orbital `j` in a neighboring cell at `(Rx, Ry, Rz)`) and the values are the corresponding matrix blocks as NumPy arrays. |
0 commit comments