Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
*.sh text eol=lf

48 changes: 48 additions & 0 deletions .github/workflows/publish-conda.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
name: Publish Conda Package

on:
push:
tags:
- 'v*'
workflow_dispatch:

jobs:
build:
name: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
include:
- os: ubuntu-latest
- os: macos-13 # Intel Mac (osx-64)
- os: macos-latest # Apple Silicon Mac (osx-arm64)

runs-on: ${{ matrix.os }}

steps:
- uses: actions/checkout@v4

- name: Setup Miniconda
uses: conda-incubator/setup-miniconda@v3
with:
auto-update-conda: true
channels: conda-forge
python-version: '3.11'

- name: Set package version from tag
run: |
TAG="${{ github.ref_name }}"
VERSION="${TAG#v}"
echo "VERSION=${VERSION}" >> $GITHUB_ENV
echo "Building gpumdkit ${VERSION}"

- name: Build conda package
run: conda build conda/ -c conda-forge

- name: Upload to Anaconda.org
if: startsWith(github.ref, 'refs/tags/v')
env:
ANACONDA_API_TOKEN: ${{ secrets.ANACONDA_TOKEN }}
run: |
anaconda upload --user ${{ vars.ANACONDA_USER }} \
$CONDA_PREFIX/conda-bld/*/gpumdkit-*.conda
52 changes: 26 additions & 26 deletions AGENTS.md
Original file line number Diff line number Diff line change
@@ -1,38 +1,38 @@
# GPUMDkit

GPUMDkit is a Bash + Python command-line toolkit for [GPUMD](https://gpumd.org/) and [NEP](https://gitlab.com/brucefan1983/nep) — molecular dynamics and neuroevolution potential programs. It provides format conversion, structure sampling, workflows, property calculation, plotting, and analysis utilities.
GPUMDkit is a Bash + Python CLI toolkit for GPUMD and NEP package: data conversion/sampling, workflows, calculations, analysis, plotting, simulation, training, and post-processing. Docs: <https://gpumdkit.cn/html/index.html>.

**Entry point**: `gpumdkit.sh` — dual-mode (interactive menu + CLI flags):
## Architecture

```bash
gpumdkit.sh # Interactive mode
gpumdkit.sh -h # Show all CLI flags
gpumdkit.sh -plt train # Plot NEP training
gpumdkit.sh -calc msd dump.xyz Li 10 # Calculate MSD
gpumdkit.sh -dp2xyz database train.xyz # DeepMD npy → extxyz
```text
gpumdkit.sh -> src/fN_*.sh menu wrappers -> Scripts/<module>/ implementations
```

**Documentation**: https://zhyan0603.github.io/GPUMDkit/
- `gpumdkit.sh`: interactive and CLI entry point (`-h` lists commands; `-skill` locates skills).
- `Scripts/`: conversion, sampling, workflow, calculator, analyzer, plot, and utility implementations.
- `docs/tutorials/{en,zh}/`: bilingual sources; `docs/mkdocs.yml`: site config.
- `skills/gpumdkit-skill/`: canonical agent skill; `gpumdkit-skill-zh/`: Chinese version.

## Agent Skills
## Agent Routing

When the user asks about GPUMDkit features, use the skills in `.opencode/skills/`:
For any GPUMDkit, GPUMD, NEP, atomistic-data, workflow, plotting, or post-processing task:

| Skill | Use When |
|-------|----------|
| `gpumdkit-main` | General usage, navigation, entry point |
| `gpumdkit-format-conversion` | Converting structure files between formats |
| `gpumdkit-calculators` | Computing material properties |
| `gpumdkit-analyzers` | Analyzing structures and datasets |
| `gpumdkit-visualization` | Plotting simulation data |
| `gpumdkit-workflows` | Batch processing and automation |
| `gpumdkit-sampling` | Sampling and selecting structures |
1. Read `skills/gpumdkit-skill/SKILL.md`.
2. Classify the request and load only its routed references; combine them for cross-module work.
3. Inspect local help/files, then prefer documented `gpumdkit.sh` commands over direct scripts.

## If You Need to Modify Code
Key references under `skills/gpumdkit-skill/references/`:

**Read [skills/gpumdkit-contributing/SKILL.md](skills/gpumdkit-contributing/SKILL.md) first.** It contains all coding conventions, function templates, shell/Python patterns, and explicit rejections (things NOT to propose). The project follows a strict minimum-invasion principle — do not touch working code unless fixing a confirmed bug.
- Navigation: `overview.md`.
- Data/tools: `format-conversion.md`, `sampling.md`, `workflows.md`, `calculators.md`, `analyzers.md`.
- Plots: `visualization.md`, `plotting-style.md`.
- GPUMD: start with `gpumd.md`; it routes to `gpumd-{inputs,setup,ensembles,computes,outputs}.md`.
- NEP: start with `nep.md`; it routes to `nep-{data,parameters,outputs}.md`.
- Diffusion/conductivity fits: `arrhenius.md` plus relevant simulation, calculator, and plot references.
- Code, docs, CLI, scripts, or skills: `contributing.md` plus the affected module reference.

Key facts:
- Tutorials are bilingual (`docs/tutorials/en/` + `zh/`). Feature changes must update both languages.
- After Python edits: `python3 -m py_compile <file>` then clean `__pycache__`.
- After doc edits: `mkdocs build -f docs/mkdocs.yml`.
## Rules

- Never invent consequential scientific or execution choices; ask the user.
- Simulations, training, DFT, scheduler jobs, destructive operations, and expensive runs require explicit authorization.
- Preserve unrelated changes. Before repository edits, read `contributing.md`; keep changes minimal, update both documentation languages for user-visible features, and run its validation checklist.
49 changes: 28 additions & 21 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ The structure of `GPUMDkit` consists of:
- `f5_analyzers.sh`
- `f6_plots.sh`
- `f7_utilities.sh`
- **`skills/`**: AI agent skill definitions (SKILL.md files for opencode/Claude Code integration)
- **`skills/`**: Portable Agent Skills definition (`gpumdkit-skill/SKILL.md`) and on-demand references
- **`docs/`**: Documentation files
- `tutorials/en/` and `tutorials/zh/`: Bilingual tutorial pages
- `mkdocs.yml`: MkDocs configuration for building tutorial HTML
Expand Down Expand Up @@ -185,7 +185,7 @@ To add a new feature accessible through the interactive menu:
echo " Input <required_param1> <required_param2>"
echo " Example: input.xyz output.lmp"
echo " ------------>>"
read -r -a converter_args
read_menu_array converter_args || return 1
echo " ---------------------------------------------------"
python ${GPUMDkit_path}/Scripts/format_conversion/new_converter.py "${converter_args[@]}"
echo " Code path: ${GPUMDkit_path}/Scripts/format_conversion/new_converter.py"
Expand Down Expand Up @@ -230,18 +230,28 @@ To add a new command-line flag or subcommand:
touch Scripts/analyzer/analyze_bonds.py
```

2. **Implement your functionality** with clear parameter requirements:
2. **Implement your functionality** with clear parameter requirements. Python scripts
should own detailed argument parsing, help text, type conversion, file checks, and
user-facing error messages:
```python
# Example: Scripts/analyzer/analyze_bonds.py
import sys

if len(sys.argv) != 3:
print("Usage: gpumdkit.sh -analyze_bonds <input.xyz> <cutoff_distance>")
print("Example: gpumdkit.sh -analyze_bonds structure.xyz 3.0")
sys.exit(1)
args = sys.argv[1:]
if len(args) < 2 or args[0] in ("-h", "--help"):
print(" Usage: gpumdkit.sh -analyze_bonds <input.xyz> <cutoff_distance>")
print(" or: python3 analyze_bonds.py <input.xyz> <cutoff_distance>")
print("")
print(" Arguments:")
print(" input.xyz Input extxyz file")
print(" cutoff_distance Bond cutoff distance")
print("")
print(" Example: gpumdkit.sh -analyze_bonds structure.xyz 3.0")
print("")
sys.exit(0 if args and args[0] in ("-h", "--help") else 1)

input_file = sys.argv[1]
cutoff = float(sys.argv[2])
input_file = args[0]
cutoff = float(args[1])

# Your implementation here
```
Expand All @@ -250,21 +260,17 @@ To add a new command-line flag or subcommand:
> You may use a `main()` function with `if __name__ == "__main__":` guard if you prefer,
> but it is not required. Most existing scripts execute at module level.

3. **Add the command-line flag handler** in `gpumdkit.sh`:
3. **Add the command-line flag handler** in `gpumdkit.sh`. Keep this layer as a
lightweight router. Detailed parameter validation should stay in the Python script,
not in the main shell entry point.
```bash
# Find the command-line parsing section (the large "case $1 in" block)
# Add your new flag in the appropriate location

case $1 in
# ... existing cases ...
-analyze_bonds)
if [ ! -z "$2" ] && [ "$2" != "-h" ] && [ ! -z "$3" ]; then
python ${analyzer_path}/analyze_bonds.py $2 $3
else
echo " Usage: gpumdkit.sh -analyze_bonds <input.xyz> <cutoff_distance>"
echo " Example: gpumdkit.sh -analyze_bonds structure.xyz 3.0"
echo " Code path: ${analyzer_path}/analyze_bonds.py"
fi ;;
run_python_script "Your Name (your@email.com)" "${analyzer_path}/analyze_bonds.py" "${@:2}" ;;
# ... rest of cases ...
esac
```
Expand Down Expand Up @@ -316,7 +322,7 @@ esac

- **Shell Scripts**:
- Use `${variable}` for variable expansion
- Use `[ ! -z "$var" ]` for non-empty checks (project convention)
- Use `[ ! -z "$var" ]` for shell control flow and broad dispatch checks (project convention)
- Interactive functions should follow the banner format:
```bash
echo " >-------------------------------------------------<"
Expand All @@ -325,7 +331,7 @@ esac
echo " | Developer: <Name> (<email>) |"
echo " >-------------------------------------------------<"
```
- Use `read -r -a varname` for multi-word input, then pass with `"${varname[@]}"`
- Use `read_menu_choice varname || return 1` or `read_menu_array varname || return 1` for interactive input, then pass arrays with `"${varname[@]}"`
- Shell scripts in `src/` should start with a file header block:
```bash
# ============================================================
Expand All @@ -338,8 +344,9 @@ esac
- **Python Scripts**:
- Write clear, maintainable code
- Use meaningful variable names
- Use `sys.argv` for argument parsing (consistent with most existing scripts)
- Provide clear usage messages with `print("Usage: ...")` and `print("Example: ...")`
- Use `args = sys.argv[1:]` for simple positional argument parsing, or `argparse` for complex option sets
- Provide clear usage messages with leading-space prints such as `print(" Usage: ...")` and `print(" Example: ...")`
- Put help and missing-argument checks before heavy optional imports so `-h` works without optional packages installed
- If your script uses heavy/special packages (`NepTrain`, `calorine`, `dpdata`), add a
`print_dependency_notice()` function to inform users about citation recommendations

Expand Down
23 changes: 12 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@
&nbsp;·&nbsp;
<a href="./docs/README_zh-CN.md">简体中文</a>
&nbsp;·&nbsp;
<a href="https://zhyan0603.github.io/GPUMDkit/">Website</a> &nbsp;·&nbsp;
<a href="https://zhyan0603.github.io/GPUMDkit/htmls/index.html">Documentation</a>
<a href="https://gpumdkit.cn/">Website</a> &nbsp;·&nbsp;
<a href="https://gpumdkit.cn/htmls/index.html">Documentation</a>
&nbsp;·&nbsp;
<a href="https://zhyan0603.github.io/GPUMDkit/gallery.html">Gallery</a>
<a href="https://gpumdkit.cn/gallery.html">Gallery</a>
&nbsp;
</p>
<p align="center">
Expand Down Expand Up @@ -102,7 +102,7 @@ There are two options, <u>*interactive mode*</u> and <u>*command-line mode*</u>
| |_| | __/| |_| | | | | |_| | <| | |_
\____|_| \___/|_| |_|____/|_|\_\_|\__|

GPUMDkit Version 1.5.6 (dev) (2026-06-17)
GPUMDkit Version 1.5.6 (dev) (2026-07-10)
Core Developer: Zihan YAN (yanzihan@westlake.edu.cn)
Main Contributors: Denan LI, Xin WU, Zhoulin LIU & Chen HUA

Expand Down Expand Up @@ -132,13 +132,14 @@ the help information:

```
+-------------------------------------------------------------------------------------------------------+
| GPUMDkit 1.5.6 (dev) (2026-06-17) Command Help |
| GPUMDkit 1.5.6 (dev) (2026-07-10) Command Help |
+-------------------------------------------------------------------------------------------------------+
| MAIN FUNCTIONS |
+-------------------------------------------------------------------------------------------------------+
| -h Show this help table | -plt <type> Plot and visualization tools |
| -calc <type> Calculator tools | -time <gpumd|nep> Time-consuming analyzer |
| -update Update GPUMDkit | -clean Clean extra files in current dir |
| -skill Show GPUMDkit agent skill info | -doctor Check Python environment |
+-------------------------------------------------------------------------------------------------------+
| FORMAT CONVERSION |
+-------------------------------------------------------------------------------------------------------+
Expand All @@ -150,7 +151,7 @@ the help information:
| -traj2exyz ASE traj -> extxyz | -replicate Replicate structure |
| -addgroup Add group labels | -addweight Add structure weight in extxyz |
| -clean_xyz Clean extra info in extxyz | -get_frame Extract specific frame |
| -frame_range Extract frames by range | |
| -frame_range Extract frames by range | -dp2xyz DeepMD npy -> extxyz |
+-------------------------------------------------------------------------------------------------------+
| ANALYSIS |
+-------------------------------------------------------------------------------------------------------+
Expand All @@ -161,7 +162,7 @@ the help information:
| -pda Probability density analysis | -filter_box Filter by box-edge length |
| -pynep Deprecated PyNEP sampling | -nep_modifier Modify NEP model interactively |
+-------------------------------------------------------------------------------------------------------+
| Detailed usage: gpumdkit.sh -<option> -h Plot details: gpumdkit.sh -plt <type> -h |
| Python option help: gpumdkit.sh -<option> -h Plot list: gpumdkit.sh -plt -h |
+-------------------------------------------------------------------------------------------------------+
```

Expand All @@ -175,9 +176,9 @@ the help information:

```
+-----------------------------------------------------------------------------------------------+
| GPUMDkit 1.5.6 (dev) (2026-06-17) PLOT & VISUALIZATION TOOLS |
| GPUMDkit 1.5.6 (dev) (2026-07-10) PLOT & VISUALIZATION TOOLS |
+-----------------------------------------------------------------------------------------------+
| Usage: gpumdkit.sh -plt <type> Help: gpumdkit.sh -plt <type> -h |
| Usage: gpumdkit.sh -plt <type> List: gpumdkit.sh -plt -h |
+-----------------------------------------------------------------------------------------------+
| NEP Training & Evaluation |
+-----------------------------------------------------------------------------------------------+
Expand Down Expand Up @@ -265,13 +266,13 @@ You can also save images as PNG if your device doesn't support visualization:
gpumdkit.sh -plt thermo save
```

Refer to our [documentation](https://zhyan0603.github.io/GPUMDkit/) for more detailed examples and command options.
Refer to our [documentation](https://gpumdkit.cn/) for more detailed examples and command options.

#### Custom Commands

`GPUMDkit` now supports custom commands via `~/.gpumdkit.in`.

You can add your own shortcuts (e.g., `gpumdkit.sh -yourcommand`) by defining functions in this file. This allows you to extend `GPUMDkit` with personal scripts. See [custom command documentation](https://zhyan0603.github.io/GPUMDkit/) for details.
You can add your own shortcuts (e.g., `gpumdkit.sh -yourcommand`) by defining functions in this file. This allows you to extend `GPUMDkit` with personal scripts. See [custom command documentation](https://gpumdkit.cn/) for details.

#### Tab Completion Support

Expand Down
41 changes: 18 additions & 23 deletions Scripts/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@ Structure sampling and selection tools:
- Farthest point sampling (FPS)
- Structure perturbation for training sets
- Maximum force deviation selection
- Training/test splitting with uniform, random, or FPS selection

**Quick Start:**
```bash
Expand Down Expand Up @@ -118,11 +119,15 @@ Workflow automation scripts for high-throughput calculations:
# Via interactive mode:
gpumdkit.sh
# Select: 3) Workflow
------------>>
301) SCF batch pretreatment
302) MD sample batch pretreatment (gpumd)
303) MD sample batch pretreatment (lmp)
000) Return to the main menu
+---------------------------------------------------------+
| WORKFLOW TOOLS |
+---------------------------------------------------------+
| 301) SCF batch pretreatment |
| 302) MD sample batch pretreatment (gpumd) |
| 303) MD sample batch pretreatment (lmp) |
+---------------------------------------------------------+
| 000) Return to the main menu |
+---------------------------------------------------------+
```

## Usage Modes
Expand All @@ -134,23 +139,13 @@ gpumdkit.sh
```
Navigate through numbered menus to access different functionalities.

```
____ ____ _ _ __ __ ____ _ _ _
/ ___| _ \| | | | \/ | _ \| | _(_) |_
| | _| |_) | | | | |\/| | | | | |/ / | __|
| |_| | __/| |_| | | | | |_| | <| | |_
\____|_| \___/|_| |_|____/|_|\_\_|\__|

GPUMDkit Version 1.5.6 (dev) (2026-06-17)
Core Developer: Zihan YAN (yanzihan@westlake.edu.cn)
Main Contributors: Denan LI, Xin WU, Zhoulin LIU & Chen HUA

----------------------- GPUMD -----------------------
1) Format Conversion 2) Sample Structures
3) Workflow 4) Calculators
5) Analyzer 6) Visualization
7) Utilities 8) Help
0) Exit
```text
---------------------- GPUMD ------------------------
1) Format Conversion 2) Sample Structures
3) Workflow 4) Calculators
5) Analyzer 6) Visualization
7) Utilities 8) Help
0) Exit
------------>>
Input the function number:
```
Expand Down Expand Up @@ -194,7 +189,7 @@ Check individual subdirectory READMEs for specific requirements.

## Support

- **Documentation**: [https://zhyan0603.github.io/GPUMDkit/home.html](https://zhyan0603.github.io/GPUMDkit/home.html)
- **Documentation**: [https://gpumdkit.cn/home.html](https://gpumdkit.cn/home.html)
- **Issues**: [GitHub Issues](https://github.com/zhyan0603/GPUMDkit/issues)
- **Contact**: Zihan YAN (yanzihan@westlake.edu.cn)

Expand Down
Loading
Loading