Geometry Optimizer logo

Geometry Optimizer

Organization
InternScience
geometry-optimizer

使用半经验方法 (xTB) 对分子三维结构进行几何优化,支持 SMILES 自动转 3D、XYZ 文件输入,输出优化后坐标、能量、收敛状态。

Overview

PublisherInternScience
RepositoryChemClaw
Skill namegeometry-optimizer
Stars
53
Forks
13
Bundled files
10
LicenseMIT
Links
  • Markdown instructions

    A SKILL.md file the model loads on demand, so it only costs tokens when a request actually matches.

  • Works with any LLM

    AI skills are plain Markdown, not provider-specific code, so this works with GPT, Claude, Gemini, Grok, or a local model.

  • 10 bundled files

    Scripts, templates, and references the model can read while it works. Files are read-only and never executed.

  • Open source

    Published by InternScience on GitHub. Read the source before you install it.

Installation

Install the Geometry Optimizer AI skill in TypingMind to use it with any LLM, or drop it into another agent that reads SKILL.md.

1

Install in TypingMind

TypingMind installs a skill straight from its GitHub folder — it reads SKILL.md, bundles the resource files, and stores the result locally.

  1. Open the app and go to Plugins → Skills.
  2. Choose "Install from GitHub".
  3. Paste the skill folder URL below and confirm.
    https://github.com/InternScience/ChemClaw/tree/main/skills/geometry-optimizer
  4. Enable the skill in any chat where you want it available.
Plugins → Skills → Add skill → From GitHub URL, then paste the folder URL and press Continue.
2

Install in another agent

Any agent that reads the Agent Skills format can use this skill — copy the folder into that agent's skills directory.

Claude Code — .claude/skills
git clone --depth 1 https://github.com/InternScience/ChemClaw.git /tmp/ChemClaw
mkdir -p .claude/skills
cp -r /tmp/ChemClaw/skills/geometry-optimizer .claude/skills/geometry-optimizer
Restart Claude Code after copying so it picks up the new skill.

Use it in TypingMind

Enable Geometry Optimizer in any TypingMind chat and the model takes it from there. Its name and description sit in the system prompt, and the moment a request matches, the model loads the full instructions itself — you never invoke it by hand, and it costs no tokens until it is actually used.

The model loads Geometry Optimizer on its own as soon as a request matches it.

Works with any AI model

AI skills are plain Markdown instructions rather than provider-specific code, so Geometry Optimizer is not tied to the model it was written for. Install it once in TypingMind and use it with GPT-5, Claude, Gemini, Grok, DeepSeek, Mistral, Llama, or a local model you run yourself — all on your own API keys.

  • Loaded only when it is needed

    The system prompt carries just the name and description. The instructions are fetched on the first matching request, so an idle skill costs nothing.

  • Switch models mid-chat

    Because the skill is instructions rather than code, changing model does not break it — the next model reads the same SKILL.md.

Skill instructions

This is the SKILL.md content the model loads. Read it before installing — a skill is instructions your model will follow.

Geometry Optimizer

geometry-optimizer 是一个用于 分子三维几何结构优化 的化学类 skill。
它基于 GFN-xTB 半经验量子化学方法,对用户提供的分子初始结构进行快速、可落地的本地优化,输出优化后的坐标、能量、收敛状态等结果。


核心功能

  • ✅ SMILES → 3D → 优化:自动从 SMILES 生成初始 3D 构象并进行 xTB 优化
  • ✅ XYZ 文件输入:直接对已有 3D 坐标文件进行优化
  • ✅ GFN2-xTB 方法:默认使用高精度的 GFN2-xTB 半经验方法
  • ✅ 完整结果输出:优化后坐标、最终能量、梯度、收敛状态、日志文件
  • ✅ 批量处理:支持 JSON 批量输入,多分子连续优化

适用场景

当用户有以下需求时,应调用本 skill:

用户需求示例
优化分子 3D 结构"帮我优化这个分子的 3D 结构"
SMILES 转 3D 并优化"把这个 SMILES 生成 3D 后优化"
xTB 几何优化"用 xTB 做一下 geometry optimization"
获取优化后坐标"给我一个预优化后的 xyz 坐标"
半经验快速优化"用半经验方法快速优化一下分子结构"
DFT 预优化"在做 DFT 前先用 xTB 预优化"
XYZ/SDF 结构优化"对这个 XYZ 结构做几何优化"

不适用场景

以下情况不应调用本 skill:

场景原因建议
高精度 DFT / ab initio 优化xTB 是半经验方法,精度有限使用 Gaussian、ORCA、Psi4 等
过渡态搜索、IRC、频率分析当前不支持使用专用量化软件
晶体/周期性体系优化xTB 不支持 PBC使用 VASP、Quantum ESPRESSO
蛋白质/超大体系计算成本高,可能需要特殊处理使用分子力学或专用工具
发表级精确结果半经验方法适合预优化/筛选使用高精度方法复核

输入格式

1. SMILES(推荐)

bash
python scripts/main_script.py --smiles "CCO" --name "乙醇"
  • 自动使用 RDKit 生成初始 3D 构象
  • 自动推断电荷和未成对电子数
  • 适用于只有二维分子表达式的场景

2. XYZ 文件

bash
python scripts/main_script.py --input-xyz molecule.xyz --output-dir ./results
  • 直接使用已有 3D 坐标
  • 适合从实验结构或其他软件导出的坐标

3. 批量 JSON 输入

bash
python scripts/main_script.py --input input.json --output output.json --output-dir ./results

input.json 格式:

json
[
  {"name": "乙醇", "smiles": "CCO"},
  {"name": "水", "smiles": "O"},
  {"name": "自定义", "input_xyz": "path/to/molecule.xyz"}
]

输出格式

JSON 结果

json
{
  "status": "completed",
  "backend_used": "xtb",
  "total": 1,
  "success": 1,
  "partial_success": 0,
  "error": 0,
  "results": [
    {
      "name": "乙醇",
      "input_type": "smiles",
      "smiles": "CCO",
      "canonical_smiles": "CCO",
      "status": "success",
      "backend_used": "xtb",
      "method": "gfn2",
      "charge": 0,
      "uhf": 0,
      "solvent": null,
      "converged": true,
      "energy_hartree": -11.394338789631,
      "energy_kcal_mol": -7150.050139542559,
      "final_gradient": 0.000195893782,
      "num_atoms": 9,
      "optimized_xyz_path": "./test_output/optimized.xyz",
      "log_path": "./test_output/xtbopt.log",
      "runtime_seconds": 0.26,
      "warnings": [],
      "message": "Geometry optimization completed. Converged."
    }
  ]
}

输出字段说明

字段类型说明
statusstringsuccess / partial_success / error
convergedboolean是否达到收敛标准 (梯度 < 0.001 Eh/a₀)
energy_hartreefloat最终能量 (Hartree)
energy_kcal_molfloat最终能量 (kcal/mol)
final_gradientfloat最终梯度范数 (Eh/a₀)
num_atomsint原子数
optimized_xyz_pathstring优化后 XYZ 坐标文件路径
log_pathstringxTB 日志文件路径
runtime_secondsfloat运行时间 (秒)
warningsarray警告信息列表

XYZ 坐标文件

xyz
9
Optimized with xTB gfn2, energy=-11.394338789631 Ha
C -0.915405  0.082880  0.018580
C  0.513691 -0.435657 -0.103334
O  1.452768  0.397316  0.535701
H -1.015673  1.046445 -0.479628
...

命令行参数

bash
python scripts/main_script.py \
  --smiles "CCO" \
  --name "乙醇" \
  --method gfn2 \
  --charge 0 \
  --uhf 0 \
  --solvent water \
  --max-cycles 200 \
  --output-dir ./results \
  --output ./results/result.json
参数说明默认值
--smilesSMILES 字符串 (与 --input-xyz 互斥)-
--input-xyz输入 XYZ 文件路径 (与 --smiles 互斥)-
--input批量输入 JSON 文件路径-
--name分子名称-
--output输出 JSON 文件路径-
--output-dir输出目录 (XYZ 和日志文件)-
--backend后端 (xtb)xtb
--methodxTB 方法 (gfn2/gfn1/gfnff)gfn2
--charge分子电荷自动推断
--uhf未成对电子数自动推断
--solvent溶剂模型 (如 water, ethanol)无
--max-cycles最大优化步数200

方法选择

方法适用场景精度速度
GFN2-xTB (默认)通用有机分子、主族元素高中等
GFN1-xTB某些无机体系、过渡金属中等中等
GFN-FF大分子、生物分子、超分子较低快

收敛标准

xTB 几何优化收敛标准:

  • 梯度范数 < 0.001 Eh/a₀ (约 0.5 kcal/mol/Å)
  • 达到收敛:status: "success", converged: true
  • 未收敛但有结果:status: "partial_success", converged: false

安装指南

系统要求

  • Python 3.8+
  • xTB 6.3+(半经验量子化学程序)

1. 安装 Python 依赖

bash
cd /home/administratorlulaiao/.openclaw/workspace/skills/geometry-optimizer
pip install -r requirements.txt

或直接安装:

bash
pip install rdkit

2. 安装 xTB

xTB 是该 skill 的核心依赖,必须安装。以下是几种安装方式:

方式 A: Conda(推荐)
bash
conda install -c conda-forge xtb

验证安装:

bash
xtb --version
方式 B: Ubuntu/Debian

检查系统仓库:

bash
apt-cache search xtb

如果仓库中没有,需要从源码编译或使用 Conda。

方式 C: 源码编译
bash
# 安装依赖
sudo apt install cmake gfortran libblas-dev liblapack-dev

# 克隆源码
git clone https://github.com/grimme-lab/xtb.git
cd xtb

# 编译
mkdir build && cd build
cmake .. -DCMAKE_INSTALL_PREFIX=$HOME/.local
make -j4
make install

# 添加到 PATH
export PATH=$HOME/.local/bin:$PATH

详细编译说明:https://xtb-docs.readthedocs.io/en/latest/installation.html

3. 验证安装

运行测试脚本:

bash
python scripts/test_xtb_backend.py

预期输出:

✓ xTB is available: xtb version X.X.X
✓ Full optimization tests can be run!

4. 可选:安装 CREST(构象搜索)

如需进行构象搜索,可安装 CREST:

bash
# Conda
conda install -c conda-forge crest

# 或从源码:https://github.com/grimme-lab/crest

验证:

bash
crest --version

系统依赖

必须安装

  • xTB (6.x 版本)
bash
# Ubuntu/Debian
sudo apt install xtb

# Conda
conda install -c conda-forge xtb

# 验证安装
xtb --version

Python 依赖

bash
pip install rdkit

文件结构

geometry-optimizer/
├── SKILL.md                    # 本文件
├── README.md                   # 使用文档
├── INSTALL.md                  # 安装指南
├── requirements.txt            # Python 依赖
├── input.json                  # 批量输入示例
├── scripts/
│   ├── main_script.py          # 主入口脚本
│   ├── test_xtb_backend.py     # 测试脚本
│   ├── backends/
│   │   └── xtb_backend.py      # xTB 后端实现
│   └── utils/
│       ├── io_utils.py         # XYZ 读写工具
│       ├── smiles_utils.py     # SMILES→3D 生成
│       └── xtb_utils.py        # xTB 调用/解析工具
└── references/
    └── xtb_documentation.md    # xTB 命令参考

使用示例

示例 1: 单分子优化 (SMILES)

bash
python scripts/main_script.py --smiles "CN1C=NC2=C1C(=O)N(C(=O)N2C)C" --name "咖啡因" --output-dir ./results

示例 2: 单分子优化 (XYZ 文件)

bash
python scripts/main_script.py --input-xyz molecule.xyz --output-dir ./results

示例 3: 批量优化

bash
python scripts/main_script.py --input input.json --output output.json --output-dir ./results

示例 4: 指定溶剂模型

bash
python scripts/main_script.py --smiles "CCO" --solvent water --output-dir ./results

示例 5: 使用 GFN-FF 快速优化大分子

bash
python scripts/main_script.py --smiles "大分子 SMILES" --method gfnff --max-cycles 500 --output-dir ./results

常见问题

xTB 未找到

xTB not available: xtb command not found

解决: 安装 xTB,参考上方"系统依赖"。

3D 构象生成失败

Failed to generate 3D structure

解决:

  • 检查 SMILES 是否正确
  • 尝试提供 XYZ 文件而非 SMILES

优化不收敛

status: "partial_success", converged: false

解决:

  • 增加 --max-cycles (如 500)
  • 尝试 --method gfnff 预优化,再用 gfn2 精修
  • 检查初始结构是否合理

参考资料


版本历史

版本日期更新内容
1.02026-03-19初始版本,支持 xTB 单结构优化、SMILES→3D、XYZ 输入、批量处理

待扩展功能

  • CREST 构象搜索后端
  • 约束几何优化
  • 频率分析
  • 溶剂化自由能计算
  • 更多输入格式支持 (MOL, SDF, PDB)

Bundled files

The model reads these on demand while the skill is loaded. They are exposed as readable files and are never executed.

Frequently asked questions

What does the Geometry Optimizer AI skill do?

使用半经验方法 (xTB) 对分子三维结构进行几何优化,支持 SMILES 自动转 3D、XYZ 文件输入,输出优化后坐标、能量、收敛状态。

Why use Geometry Optimizer on TypingMind?

Because you install it once and use it with any model. Geometry Optimizer is plain Markdown rather than provider-specific code, so the same skill runs on GPT-5, Claude, Gemini, Grok, or a local model — and you can switch model mid-chat without it breaking. TypingMind runs on your own API keys, so you pay providers directly instead of a per-seat subscription, and your skills and chats stay in your own storage.

How do I install Geometry Optimizer in TypingMind?

Open Plugins → Skills → Install from GitHub in TypingMind and paste https://github.com/InternScience/ChemClaw/tree/main/skills/geometry-optimizer. TypingMind reads its SKILL.md and bundles its files and installs it as a skill you can enable per chat.

Which AI models can use Geometry Optimizer?

Any model you connect in TypingMind. AI skills are plain Markdown instructions rather than provider-specific code, so GPT, Claude, Gemini, Grok, and local models can all load this skill when a request matches it.

How many AI models can I use with Geometry Optimizer?

As many as you like. As long as a model supports skills, you can use Geometry Optimizer with it — GPT, Claude, Gemini, Grok, DeepSeek, Mistral, Llama and more — all on TypingMind with your own API keys.

Is the Geometry Optimizer AI skill free?

Yes. It is published on GitHub by InternScience under the MIT license. You only pay your own AI provider for the tokens you use.

What are AI skills?

An AI skill is a reusable instruction bundle that teaches an AI model how to do one specific task. It follows the open Agent Skills format: a SKILL.md file with a name and description, plus any scripts, templates or reference files the model may need. The model reads the instructions only when your request matches the skill, so an installed skill costs nothing until it is used.

How are AI skills different from plugins or MCP servers?

A plugin or MCP server gives a model new tools to call — code that runs somewhere and returns a result. An AI skill gives the model knowledge and process instead: how to approach a task, which steps to follow, what good output looks like. Skills are plain Markdown, so they need no server, no API key and no runtime, and they work with any model.

View all

Set up your own AI workspace now

Get notified about new features and future giveaways by subscribing to our newsletter 👇