@yangdw2024/hpc-quantchem-workflow 0.0.0-stage → 1.0.1
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.
- package/LICENSE +21 -0
- package/README.md +114 -2
- package/SKILL.md +114 -0
- package/bin/cli.js +135 -0
- package/cordis.patch.yml +3 -0
- package/docs/DETAIL.md +23 -0
- package/icon.svg +19 -0
- package/index.js +71 -0
- package/locale/en.json +7 -0
- package/locale/zh.json +7 -0
- package/package.json +66 -4
- package/references/scheduler-cheatsheet.md +47 -0
- package/references/ssh-onboarding.md +91 -0
- package/scripts/calc_ct_marcus.py +158 -0
- package/scripts/deploy_to_hpc.sh +192 -0
- package/scripts/gen_g16_workflow.py +126 -0
- package/scripts/install.ps1 +48 -0
- package/scripts/install.sh +39 -0
- package/scripts/mwfn_suite.sh +412 -0
- package/scripts/parse_fch_props.py +161 -0
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
# 通用 SSH 免密接入与环境探测指南
|
|
2
|
+
|
|
3
|
+
适用于 Windows 10/11(自带 OpenSSH)、macOS 与 Linux 本地终端。**原则:每台客户端生成一把独立密钥,不跨机器复制私钥,不向聊天记录暴露服务器密码。**
|
|
4
|
+
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
## 1. 本地生成 SSH 密钥对
|
|
8
|
+
|
|
9
|
+
```bash
|
|
10
|
+
# 检查本机是否已有密钥
|
|
11
|
+
ls -la ~/.ssh
|
|
12
|
+
|
|
13
|
+
# 生成新的 ed25519 密钥(推荐独立命名,便于日后按设备撤销)
|
|
14
|
+
mkdir -p ~/.ssh
|
|
15
|
+
ssh-keygen -t ed25519 -f ~/.ssh/id_ed25519_hpc -N "" -C "agent-to-hpc"
|
|
16
|
+
|
|
17
|
+
# 预记录服务器主机指纹,避免首次连接交互卡顿
|
|
18
|
+
ssh-keyscan -T 5 -p <PORT> <HOST_IP_OR_DOMAIN> >> ~/.ssh/known_hosts
|
|
19
|
+
|
|
20
|
+
# 查看公钥(复制整行用于第 3 步)
|
|
21
|
+
cat ~/.ssh/id_ed25519_hpc.pub
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
---
|
|
25
|
+
|
|
26
|
+
## 2. 配置本地 `~/.ssh/config` 主机别名
|
|
27
|
+
|
|
28
|
+
在 `~/.ssh/config`(Windows 为 `C:\Users\<用户名>\.ssh\config`)追加一段配置:
|
|
29
|
+
|
|
30
|
+
```sshconfig
|
|
31
|
+
Host my-hpc
|
|
32
|
+
HostName <HOST_IP_OR_DOMAIN>
|
|
33
|
+
Port 22
|
|
34
|
+
User <USERNAME>
|
|
35
|
+
IdentityFile ~/.ssh/id_ed25519_hpc
|
|
36
|
+
IdentitiesOnly yes
|
|
37
|
+
ServerAliveInterval 60
|
|
38
|
+
ServerAliveCountMax 3
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
---
|
|
42
|
+
|
|
43
|
+
## 3. 在目标服务器安全追加公钥(由用户在已有终端执行一次)
|
|
44
|
+
|
|
45
|
+
请用户登录已打开的 SSH 客户端(Xshell / MobaXterm / FinalShell / 终端),粘贴执行以下一行命令(使用 `>>` 追加,绝不覆盖已有公钥):
|
|
46
|
+
|
|
47
|
+
```bash
|
|
48
|
+
mkdir -p ~/.ssh && chmod 700 ~/.ssh && echo '<整行 id_ed25519_hpc.pub 内容>' >> ~/.ssh/authorized_keys && chmod 600 ~/.ssh/authorized_keys && echo "OK"
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
### 随时撤销权限
|
|
52
|
+
如不再允许该电脑免密登录,在服务器编辑 `~/.ssh/authorized_keys`,删除末尾注释包含 `agent-to-hpc` 的那一行即可立刻失效。
|
|
53
|
+
|
|
54
|
+
---
|
|
55
|
+
|
|
56
|
+
## 4. 连通性验证与远程只读环境探测
|
|
57
|
+
|
|
58
|
+
所有 Agent 调用远程命令时,务必带上 `-o BatchMode=yes`(禁止弹出密码交互卡死)和 `bash -lc`(确保加载 `/etc/profile`、`~/.bash_profile`、`~/.bashrc` 中的调度器与软件环境变量):
|
|
59
|
+
|
|
60
|
+
```bash
|
|
61
|
+
# 1. 连通性验证
|
|
62
|
+
ssh -o BatchMode=yes -o ConnectTimeout=10 my-hpc 'bash -lc "whoami && hostname && pwd"'
|
|
63
|
+
|
|
64
|
+
# 2. 只读环境探测(调度器、硬件规格、软件路径)
|
|
65
|
+
ssh -o BatchMode=yes -o ConnectTimeout=10 my-hpc 'bash -lc "
|
|
66
|
+
echo === SCHEDULER ===
|
|
67
|
+
for c in sbatch squeue sinfo qsub qstat qhost pbsnodes pestat qa; do
|
|
68
|
+
p=\$(command -v \$c 2>/dev/null)
|
|
69
|
+
[ -n \"\$p\" ] && echo \"\$c -> \$p\"
|
|
70
|
+
done
|
|
71
|
+
echo === LOGIN NODE ===
|
|
72
|
+
lscpu 2>/dev/null | grep -E \"CPU\\(s\\):|Core\\(s\\)|Model name\" | head -n 5
|
|
73
|
+
free -h 2>/dev/null | head -n 2
|
|
74
|
+
echo === SOFTWARE ===
|
|
75
|
+
for s in g16 g09 formchk Multiwfn_noGUI Multiwfn orca vasp_std gmx xtb python3; do
|
|
76
|
+
p=\$(command -v \$s 2>/dev/null)
|
|
77
|
+
[ -n \"\$p\" ] && echo \"\$s -> \$p\"
|
|
78
|
+
done
|
|
79
|
+
"'
|
|
80
|
+
```
|
|
81
|
+
|
|
82
|
+
---
|
|
83
|
+
|
|
84
|
+
## 5. 常见故障排查
|
|
85
|
+
|
|
86
|
+
| 现象 | 原因与处理 |
|
|
87
|
+
|---|---|
|
|
88
|
+
| `Permission denied (publickey,...)` | 公钥尚未写入远端 `~/.ssh/authorized_keys`,或远端 `~`/`~/.ssh`/`authorized_keys` 权限过宽(需 `chmod 700 ~/.ssh && chmod 600 ~/.ssh/authorized_keys`)。 |
|
|
89
|
+
| `Host key verification failed` | 服务器重装或 IP 复用导致指纹变化,核对管理员信息后清理 `~/.ssh/known_hosts` 对应行再重新 `ssh-keyscan`。 |
|
|
90
|
+
| `command not found`(如找不到 `qsub`/`sbatch`) | 远端非交互 Shell 未加载环境;改用 `bash -lc "..."` 或检查 `~/.bash_profile` 是否重置了 `PATH`。 |
|
|
91
|
+
| 校园网/内网 IP 超时 | 检查本机是否开启了代理/TUN 模式劫持了私有内网段,确认直连路由后再试。 |
|
|
@@ -0,0 +1,158 @@
|
|
|
1
|
+
#!/usr/bin/env python3
|
|
2
|
+
"""
|
|
3
|
+
Gaussian 激发态 & 电荷转移/复合(Marcus 理论)后处理工具(零第三方依赖)
|
|
4
|
+
子命令:
|
|
5
|
+
1. tddft : 解析 TD-DFT .log,提取激发能 (eV)、波长 (nm)、振子强度 f、跃迁电偶极矩 (Debye) 与主要跃迁
|
|
6
|
+
2. reorg : 从 4 个 .log 自动提取 SCF 能量,按 4 点法计算内重组能 λ1、λ2、λ_in (eV / meV)
|
|
7
|
+
3. marcus : 按半经典 Marcus 公式计算电荷转移速率 k_CT / 电荷复合速率 k_CR (s^-1) 与寿命 τ (ps / ns)
|
|
8
|
+
|
|
9
|
+
用法示例:
|
|
10
|
+
python3 calc_ct_marcus.py tddft mol_tddft.log
|
|
11
|
+
python3 calc_ct_marcus.py reorg --e0-q0 1.log --eion-q0 2.log --eion-qion 3.log --e0-qion 4.log
|
|
12
|
+
python3 calc_ct_marcus.py marcus --V 15.2 --lam-in 0.25 --lam-out 0.30 --dG -0.45 --T 298.15
|
|
13
|
+
"""
|
|
14
|
+
|
|
15
|
+
import argparse
|
|
16
|
+
import math
|
|
17
|
+
import re
|
|
18
|
+
import sys
|
|
19
|
+
from pathlib import Path
|
|
20
|
+
|
|
21
|
+
if hasattr(sys.stdout, "reconfigure"):
|
|
22
|
+
sys.stdout.reconfigure(encoding="utf-8", errors="replace")
|
|
23
|
+
|
|
24
|
+
HARTREE_TO_EV = 27.211386245988
|
|
25
|
+
AU_TO_DEBYE = 2.541746473
|
|
26
|
+
HBAR_EV_S = 6.582119569e-16 # 约化普朗克常数 (eV·s)
|
|
27
|
+
KB_EV_K = 8.617333262e-5 # 玻尔兹曼常数 (eV/K)
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
def extract_last_scf(log_path: Path) -> float:
|
|
31
|
+
text = log_path.read_text(errors="ignore")
|
|
32
|
+
matches = re.findall(r"SCF Done:\s+E\([^)]+\)\s*=\s*(-?\d+\.\d+)", text)
|
|
33
|
+
if not matches:
|
|
34
|
+
raise SystemExit(f"[错误] 未在 {log_path} 中找到 SCF Done 能量")
|
|
35
|
+
if "Normal termination" not in text:
|
|
36
|
+
print(f"[警告] {log_path.name} 未检测到 Normal termination,请确认是否已收敛!")
|
|
37
|
+
return float(matches[-1])
|
|
38
|
+
|
|
39
|
+
|
|
40
|
+
def cmd_reorg(args):
|
|
41
|
+
e0_q0 = extract_last_scf(Path(args.e0_q0))
|
|
42
|
+
eion_q0 = extract_last_scf(Path(args.eion_q0))
|
|
43
|
+
eion_qion = extract_last_scf(Path(args.eion_qion))
|
|
44
|
+
e0_qion = extract_last_scf(Path(args.e0_qion))
|
|
45
|
+
|
|
46
|
+
lam1_au = eion_q0 - eion_qion
|
|
47
|
+
lam2_au = e0_qion - e0_q0
|
|
48
|
+
lam_tot_au = lam1_au + lam2_au
|
|
49
|
+
|
|
50
|
+
print("=== 四点法内重组能计算结果 ===")
|
|
51
|
+
print(f"E0(Q0) = {e0_q0:16.8f} Hartree ({args.e0_q0})")
|
|
52
|
+
print(f"Eion(Q0) = {eion_q0:16.8f} Hartree ({args.eion_q0})")
|
|
53
|
+
print(f"Eion(Qion) = {eion_qion:16.8f} Hartree ({args.eion_qion})")
|
|
54
|
+
print(f"E0(Qion) = {e0_qion:16.8f} Hartree ({args.e0_qion})")
|
|
55
|
+
print("-" * 55)
|
|
56
|
+
print(f"λ1 (离子态弛豫) = {lam1_au:.6f} Ha = {lam1_au * HARTREE_TO_EV:.4f} eV = {lam1_au * HARTREE_TO_EV * 1000:.2f} meV")
|
|
57
|
+
print(f"λ2 (中性态弛豫) = {lam2_au:.6f} Ha = {lam2_au * HARTREE_TO_EV:.4f} eV = {lam2_au * HARTREE_TO_EV * 1000:.2f} meV")
|
|
58
|
+
print(f"λ_in (总内重组能)= {lam_tot_au:.6f} Ha = {lam_tot_au * HARTREE_TO_EV:.4f} eV = {lam_tot_au * HARTREE_TO_EV * 1000:.2f} meV")
|
|
59
|
+
|
|
60
|
+
|
|
61
|
+
def cmd_tddft(args):
|
|
62
|
+
text = Path(args.log).read_text(errors="ignore")
|
|
63
|
+
|
|
64
|
+
tdm_map = {}
|
|
65
|
+
m_blk = re.search(
|
|
66
|
+
r"Ground to excited state transition electric dipole moments \(Au\):(.*?)(?:Ground to excited state transition velocity|Ground to excited state transition magnetic)",
|
|
67
|
+
text,
|
|
68
|
+
re.S,
|
|
69
|
+
)
|
|
70
|
+
if m_blk:
|
|
71
|
+
for ln in m_blk.group(1).splitlines():
|
|
72
|
+
m = re.match(r"^\s*(\d+)\s+(-?\d+\.\d+)\s+(-?\d+\.\d+)\s+(-?\d+\.\d+)\s+(\d+\.\d+)\s+(\d+\.\d+)", ln)
|
|
73
|
+
if m:
|
|
74
|
+
st = int(m.group(1))
|
|
75
|
+
dip_s = float(m.group(5))
|
|
76
|
+
mu_au = math.sqrt(max(dip_s, 0.0))
|
|
77
|
+
tdm_map[st] = (mu_au, mu_au * AU_TO_DEBYE)
|
|
78
|
+
|
|
79
|
+
states = re.finditer(
|
|
80
|
+
r"Excited State\s+(\d+):\s+([^\s]+)\s+(-?\d+\.\d+)\s+eV\s+(-?\d+\.\d+)\s+nm\s+f=(\d+\.\d+)\s+<S\*\*2>=(\d+\.\d+)(.*?)(?=\n\s*Excited State|\n\s*SavETr|\n\s*Leave Link|\Z)",
|
|
81
|
+
text,
|
|
82
|
+
re.S,
|
|
83
|
+
)
|
|
84
|
+
|
|
85
|
+
print(f"{'State':<6} {'Sym':<10} {'E(eV)':>8} {'λ(nm)':>8} {'f':>8} {'|μ|(D)':>8} Main Transitions")
|
|
86
|
+
print("-" * 82)
|
|
87
|
+
count = 0
|
|
88
|
+
for m in states:
|
|
89
|
+
st = int(m.group(1))
|
|
90
|
+
if st > args.max_states:
|
|
91
|
+
break
|
|
92
|
+
count += 1
|
|
93
|
+
sym, e_ev, nm, osc = m.group(2), float(m.group(3)), float(m.group(4)), float(m.group(5))
|
|
94
|
+
mu_d = f"{tdm_map[st][1]:.3f}" if st in tdm_map else "N/A"
|
|
95
|
+
trans = re.findall(r"(\d+\s*->\s*\d+)\s+(-?\d+\.\d+)", m.group(7))
|
|
96
|
+
trans_sorted = sorted(trans, key=lambda x: abs(float(x[1])), reverse=True)[:2]
|
|
97
|
+
trans_str = "; ".join(f"{t.replace(' ', '')} ({2*(float(c)**2)*100:.1f}%)" for t, c in trans_sorted)
|
|
98
|
+
print(f"S{st:<5d} {sym:<10} {e_ev:8.4f} {nm:8.2f} {osc:8.4f} {mu_d:>8} {trans_str}")
|
|
99
|
+
|
|
100
|
+
if count == 0:
|
|
101
|
+
print("[提示] 未找到 Excited State 段落,请确认输入为 Gaussian TD-DFT .log 文件。")
|
|
102
|
+
|
|
103
|
+
|
|
104
|
+
def cmd_marcus(args):
|
|
105
|
+
v_ev = args.V / 1000.0
|
|
106
|
+
lam_tot = args.lam_in + args.lam_out
|
|
107
|
+
if lam_tot <= 0:
|
|
108
|
+
raise SystemExit("[错误] 总重组能 λ = λ_in + λ_out 必须大于 0")
|
|
109
|
+
kbt = KB_EV_K * args.T
|
|
110
|
+
dg = args.dG
|
|
111
|
+
barrier = ((dg + lam_tot) ** 2) / (4.0 * lam_tot)
|
|
112
|
+
prefactor = (2.0 * math.pi / HBAR_EV_S) * (v_ev ** 2) / math.sqrt(4.0 * math.pi * lam_tot * kbt)
|
|
113
|
+
rate = prefactor * math.exp(-barrier / kbt)
|
|
114
|
+
tau_s = (1.0 / rate) if rate > 0 else float("inf")
|
|
115
|
+
|
|
116
|
+
print("=== 半经典 Marcus 电荷转移/复合速率计算 ===")
|
|
117
|
+
print(f"电子耦合 |V| = {args.V:.4f} meV ({v_ev:.6f} eV)")
|
|
118
|
+
print(f"总重组能 λ = {lam_tot:.4f} eV (λ_in={args.lam_in:.4f} + λ_out={args.lam_out:.4f} eV)")
|
|
119
|
+
print(f"吉布斯自由能 ΔG = {dg:.4f} eV")
|
|
120
|
+
print(f"温度 T = {args.T:.2f} K (k_B T = {kbt:.5f} eV)")
|
|
121
|
+
print("-" * 55)
|
|
122
|
+
print(f"活化能垒 ΔG# = {barrier:.4f} eV")
|
|
123
|
+
print(f"反应速率 k = {rate:.4e} s^-1")
|
|
124
|
+
print(f"特征时间 τ = 1/k = {tau_s*1e12:.4e} ps ({tau_s*1e9:.4e} ns)")
|
|
125
|
+
if dg + lam_tot < 0:
|
|
126
|
+
print("[注] |ΔG| > λ,当前处于 Marcus 倒转区(Inverted Region,典型电荷复合区)。")
|
|
127
|
+
|
|
128
|
+
|
|
129
|
+
def main():
|
|
130
|
+
ap = argparse.ArgumentParser(description="Gaussian TD-DFT / 四点重组能 / Marcus 速率计算工具")
|
|
131
|
+
sub = ap.add_subparsers(dest="cmd", required=True)
|
|
132
|
+
|
|
133
|
+
p_td = sub.add_parser("tddft", help="解析 TD-DFT .log 的激发能、波长、振子强度与跃迁偶极矩")
|
|
134
|
+
p_td.add_argument("log", help="Gaussian TD-DFT .log 文件")
|
|
135
|
+
p_td.add_argument("--max-states", type=int, default=15, help="最多显示前 N 个激发态(默认 15)")
|
|
136
|
+
p_td.set_defaults(func=cmd_tddft)
|
|
137
|
+
|
|
138
|
+
p_r = sub.add_parser("reorg", help="从 4 个 .log 自动计算 4 点法内重组能 λ_in")
|
|
139
|
+
p_r.add_argument("--e0-q0", required=True, help="中性分子在中性优化构型下的单点 .log")
|
|
140
|
+
p_r.add_argument("--eion-q0", required=True, help="离子态在中性优化构型下的垂直单点 .log")
|
|
141
|
+
p_r.add_argument("--eion-qion", required=True, help="离子态几何优化后的 .log")
|
|
142
|
+
p_r.add_argument("--e0-qion", required=True, help="中性分子在离子优化构型下的单点 .log")
|
|
143
|
+
p_r.set_defaults(func=cmd_reorg)
|
|
144
|
+
|
|
145
|
+
p_m = sub.add_parser("marcus", help="按 Marcus 公式计算电荷转移/复合速率 k 与寿命 τ")
|
|
146
|
+
p_m.add_argument("--V", type=float, required=True, help="电子耦合 |V|,单位 meV")
|
|
147
|
+
p_m.add_argument("--lam-in", type=float, required=True, help="内重组能 λ_in,单位 eV")
|
|
148
|
+
p_m.add_argument("--lam-out", type=float, default=0.0, help="外重组能 λ_out,单位 eV(默认 0)")
|
|
149
|
+
p_m.add_argument("--dG", type=float, required=True, help="驱动力 ΔG,单位 eV(放能为负值)")
|
|
150
|
+
p_m.add_argument("--T", type=float, default=298.15, help="温度 T,单位 K(默认 298.15)")
|
|
151
|
+
p_m.set_defaults(func=cmd_marcus)
|
|
152
|
+
|
|
153
|
+
args = ap.parse_args()
|
|
154
|
+
args.func(args)
|
|
155
|
+
|
|
156
|
+
|
|
157
|
+
if __name__ == "__main__":
|
|
158
|
+
main()
|
|
@@ -0,0 +1,192 @@
|
|
|
1
|
+
#!/bin/bash
|
|
2
|
+
# ==============================================================================
|
|
3
|
+
# 一键部署本技能的通用量化/有机光电脚本到任意 SSH HPC 集群
|
|
4
|
+
# 用法:
|
|
5
|
+
# bash deploy_to_hpc.sh <ssh_host_alias> <remote_base_dir>
|
|
6
|
+
# 示例:
|
|
7
|
+
# bash deploy_to_hpc.sh my-hpc /home/alice/scripts/qc_kit
|
|
8
|
+
#
|
|
9
|
+
# 说明:
|
|
10
|
+
# - 仅向 <remote_base_dir>/workflows 和 <remote_base_dir>/standalone 写入脚本
|
|
11
|
+
# - 绝不自动修改远端 ~/.bashrc 或 ~/.bash_profile;部署完成后会打印可选 PATH 配置行
|
|
12
|
+
# ==============================================================================
|
|
13
|
+
|
|
14
|
+
set -euo pipefail
|
|
15
|
+
|
|
16
|
+
if [ $# -lt 2 ]; then
|
|
17
|
+
echo "用法: $0 <ssh_host_alias> <remote_base_dir>"
|
|
18
|
+
exit 1
|
|
19
|
+
fi
|
|
20
|
+
|
|
21
|
+
HOST="$1"
|
|
22
|
+
REMOTE_BASE="${2%/}"
|
|
23
|
+
SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)"
|
|
24
|
+
|
|
25
|
+
echo "[1/3] 在远端 ${HOST} 创建目录: ${REMOTE_BASE}/{workflows,standalone}"
|
|
26
|
+
ssh -o BatchMode=yes -o ConnectTimeout=10 "$HOST" "mkdir -p '${REMOTE_BASE}/workflows' '${REMOTE_BASE}/standalone'"
|
|
27
|
+
|
|
28
|
+
echo "[2/3] 上传核心脚本到 ${HOST}:${REMOTE_BASE}/workflows/"
|
|
29
|
+
scp -o BatchMode=yes \
|
|
30
|
+
"${SCRIPT_DIR}/mwfn_suite.sh" \
|
|
31
|
+
"${SCRIPT_DIR}/parse_fch_props.py" \
|
|
32
|
+
"${SCRIPT_DIR}/gen_g16_workflow.py" \
|
|
33
|
+
"${SCRIPT_DIR}/calc_ct_marcus.py" \
|
|
34
|
+
"${HOST}:${REMOTE_BASE}/workflows/"
|
|
35
|
+
|
|
36
|
+
echo "[3/3] 在远端生成 17 个独立快捷脚本并校验语法"
|
|
37
|
+
ssh -o BatchMode=yes -o ConnectTimeout=10 "$HOST" "REMOTE_BASE='${REMOTE_BASE}' bash -s" <<'REMOTE_EOF'
|
|
38
|
+
set -e
|
|
39
|
+
WF="${REMOTE_BASE}/workflows"
|
|
40
|
+
DIR="${REMOTE_BASE}/standalone"
|
|
41
|
+
|
|
42
|
+
# 修正可能来自 Windows 的 CRLF
|
|
43
|
+
for f in "$WF"/mwfn_suite.sh "$WF"/*.py; do
|
|
44
|
+
tr -d '\r' < "$f" > "${f}.tmp" && mv -f "${f}.tmp" "$f"
|
|
45
|
+
done
|
|
46
|
+
chmod +x "$WF"/mwfn_suite.sh "$WF"/*.py
|
|
47
|
+
|
|
48
|
+
cat > "$DIR/run_esp.sh" <<EOF
|
|
49
|
+
#!/bin/bash
|
|
50
|
+
set -euo pipefail
|
|
51
|
+
[ \$# -lt 1 ] && { echo "用法: \$0 <mol.fchk> [核数,默认8] [--dry-run]"; exit 1; }
|
|
52
|
+
WFN="\$1"; N="\${2:-8}"; DRY="\${3:-}"
|
|
53
|
+
[ "\$N" = "--dry-run" ] && { DRY="--dry-run"; N=8; }
|
|
54
|
+
exec "${WF}/mwfn_suite.sh" --task esp --wfn "\$WFN" --nproc "\$N" \${DRY:+\$DRY}
|
|
55
|
+
EOF
|
|
56
|
+
|
|
57
|
+
cat > "$DIR/run_rdg.sh" <<EOF
|
|
58
|
+
#!/bin/bash
|
|
59
|
+
set -euo pipefail
|
|
60
|
+
[ \$# -lt 1 ] && { echo "用法: \$0 <mol.fchk> [网格1|2|3,默认2] [核数,默认8] [--dry-run]"; exit 1; }
|
|
61
|
+
WFN="\$1"; GRID="\${2:-2}"; N="\${3:-8}"; DRY="\${4:-}"
|
|
62
|
+
[ "\$GRID" = "--dry-run" ] && { DRY="--dry-run"; GRID=2; N=8; }
|
|
63
|
+
[ "\$N" = "--dry-run" ] && { DRY="--dry-run"; N=8; }
|
|
64
|
+
exec "${WF}/mwfn_suite.sh" --task rdg --wfn "\$WFN" --grid "\$GRID" --nproc "\$N" \${DRY:+\$DRY}
|
|
65
|
+
EOF
|
|
66
|
+
|
|
67
|
+
cat > "$DIR/run_homo_lumo.sh" <<EOF
|
|
68
|
+
#!/bin/bash
|
|
69
|
+
set -euo pipefail
|
|
70
|
+
[ \$# -lt 1 ] && { echo "用法: \$0 <mol.fchk> [轨道列表,默认h,l] [网格,默认2] [核数,默认8] [--dry-run]"; exit 1; }
|
|
71
|
+
WFN="\$1"; ORBS="\${2:-h,l}"; GRID="\${3:-2}"; N="\${4:-8}"; DRY="\${5:-}"
|
|
72
|
+
[ "\$ORBS" = "--dry-run" ] && { DRY="--dry-run"; ORBS="h,l"; GRID=2; N=8; }
|
|
73
|
+
[ "\$GRID" = "--dry-run" ] && { DRY="--dry-run"; GRID=2; N=8; }
|
|
74
|
+
[ "\$N" = "--dry-run" ] && { DRY="--dry-run"; N=8; }
|
|
75
|
+
exec "${WF}/mwfn_suite.sh" --task orbital --wfn "\$WFN" --orbitals "\$ORBS" --grid "\$GRID" --nproc "\$N" \${DRY:+\$DRY}
|
|
76
|
+
EOF
|
|
77
|
+
|
|
78
|
+
for t in adch hirshfeld mayer; do
|
|
79
|
+
cat > "$DIR/run_${t}.sh" <<EOF
|
|
80
|
+
#!/bin/bash
|
|
81
|
+
set -euo pipefail
|
|
82
|
+
[ \$# -lt 1 ] && { echo "用法: \$0 <mol.fchk> [核数,默认8] [--dry-run]"; exit 1; }
|
|
83
|
+
WFN="\$1"; N="\${2:-8}"; DRY="\${3:-}"
|
|
84
|
+
[ "\$N" = "--dry-run" ] && { DRY="--dry-run"; N=8; }
|
|
85
|
+
exec "${WF}/mwfn_suite.sh" --task ${t} --wfn "\$WFN" --nproc "\$N" \${DRY:+\$DRY}
|
|
86
|
+
EOF
|
|
87
|
+
done
|
|
88
|
+
|
|
89
|
+
cat > "$DIR/run_mpp.sh" <<EOF
|
|
90
|
+
#!/bin/bash
|
|
91
|
+
set -euo pipefail
|
|
92
|
+
[ \$# -lt 1 ] && { echo "用法: \$0 <mol.fchk> [原子选择:a|h|范围,默认a] [核数,默认4] [--dry-run]"; exit 1; }
|
|
93
|
+
WFN="\$1"; ATOMS="\${2:-a}"; N="\${3:-4}"; DRY="\${4:-}"
|
|
94
|
+
[ "\$ATOMS" = "--dry-run" ] && { DRY="--dry-run"; ATOMS="a"; N=4; }
|
|
95
|
+
[ "\$N" = "--dry-run" ] && { DRY="--dry-run"; N=4; }
|
|
96
|
+
exec "${WF}/mwfn_suite.sh" --task mpp --wfn "\$WFN" --atoms "\$ATOMS" --nproc "\$N" \${DRY:+\$DRY}
|
|
97
|
+
EOF
|
|
98
|
+
|
|
99
|
+
cat > "$DIR/get_fch_props.sh" <<EOF
|
|
100
|
+
#!/bin/bash
|
|
101
|
+
set -euo pipefail
|
|
102
|
+
[ \$# -lt 1 ] && { echo "用法: \$0 <mol.fchk 或 目录> [导出csv文件名]"; exit 1; }
|
|
103
|
+
TARGET="\$1"; OUTCSV="\${2:-}"
|
|
104
|
+
if [ -n "\$OUTCSV" ]; then
|
|
105
|
+
exec python3 "${WF}/parse_fch_props.py" "\$TARGET" --csv "\$OUTCSV"
|
|
106
|
+
else
|
|
107
|
+
exec python3 "${WF}/parse_fch_props.py" "\$TARGET"
|
|
108
|
+
fi
|
|
109
|
+
EOF
|
|
110
|
+
|
|
111
|
+
cat > "$DIR/gen_tddft.sh" <<EOF
|
|
112
|
+
#!/bin/bash
|
|
113
|
+
set -euo pipefail
|
|
114
|
+
[ \$# -lt 1 ] && { echo "用法: \$0 <mol.xyz> [泛函,默认cam-b3lyp] [基组,默认def2SVP] [溶剂,可选]"; exit 1; }
|
|
115
|
+
XYZ="\$1"; FUNC="\${2:-cam-b3lyp}"; BASIS="\${3:-def2SVP}"; SOLV="\${4:-}"
|
|
116
|
+
exec python3 "${WF}/gen_g16_workflow.py" --type tddft --xyz "\$XYZ" --func "\$FUNC" --basis "\$BASIS" \${SOLV:+--solvent "\$SOLV"}
|
|
117
|
+
EOF
|
|
118
|
+
|
|
119
|
+
cat > "$DIR/parse_tddft.sh" <<EOF
|
|
120
|
+
#!/bin/bash
|
|
121
|
+
set -euo pipefail
|
|
122
|
+
[ \$# -lt 1 ] && { echo "用法: \$0 <td.log> [最大激发态数,默认15]"; exit 1; }
|
|
123
|
+
exec python3 "${WF}/calc_ct_marcus.py" tddft "\$1" --max-states "\${2:-15}"
|
|
124
|
+
EOF
|
|
125
|
+
|
|
126
|
+
cat > "$DIR/run_hole_elec.sh" <<EOF
|
|
127
|
+
#!/bin/bash
|
|
128
|
+
set -euo pipefail
|
|
129
|
+
[ \$# -lt 2 ] && { echo "用法: \$0 <td.fchk> <td.log> [激发态号,默认1] [核数,默认8] [--dry-run]"; exit 1; }
|
|
130
|
+
WFN="\$1"; TDLOG="\$2"; ST="\${3:-1}"; N="\${4:-8}"; DRY="\${5:-}"
|
|
131
|
+
[ "\$ST" = "--dry-run" ] && { DRY="--dry-run"; ST=1; N=8; }
|
|
132
|
+
[ "\$N" = "--dry-run" ] && { DRY="--dry-run"; N=8; }
|
|
133
|
+
exec "${WF}/mwfn_suite.sh" --task hole_elec --wfn "\$WFN" --tdlog "\$TDLOG" --state "\$ST" --nproc "\$N" \${DRY:+\$DRY}
|
|
134
|
+
EOF
|
|
135
|
+
|
|
136
|
+
cat > "$DIR/run_nto.sh" <<EOF
|
|
137
|
+
#!/bin/bash
|
|
138
|
+
set -euo pipefail
|
|
139
|
+
[ \$# -lt 2 ] && { echo "用法: \$0 <td.fchk> <td.log> [激发态号,默认1] [核数,默认8] [--dry-run]"; exit 1; }
|
|
140
|
+
WFN="\$1"; TDLOG="\$2"; ST="\${3:-1}"; N="\${4:-8}"; DRY="\${5:-}"
|
|
141
|
+
[ "\$ST" = "--dry-run" ] && { DRY="--dry-run"; ST=1; N=8; }
|
|
142
|
+
[ "\$N" = "--dry-run" ] && { DRY="--dry-run"; N=8; }
|
|
143
|
+
exec "${WF}/mwfn_suite.sh" --task nto --wfn "\$WFN" --tdlog "\$TDLOG" --state "\$ST" --nproc "\$N" \${DRY:+\$DRY}
|
|
144
|
+
EOF
|
|
145
|
+
|
|
146
|
+
cat > "$DIR/run_tdm.sh" <<EOF
|
|
147
|
+
#!/bin/bash
|
|
148
|
+
set -euo pipefail
|
|
149
|
+
[ \$# -lt 2 ] && { echo "用法: \$0 <td.fchk> <td.log> [核数,默认8] [--dry-run]"; exit 1; }
|
|
150
|
+
WFN="\$1"; TDLOG="\$2"; N="\${3:-8}"; DRY="\${4:-}"
|
|
151
|
+
[ "\$N" = "--dry-run" ] && { DRY="--dry-run"; N=8; }
|
|
152
|
+
exec "${WF}/mwfn_suite.sh" --task tdm --wfn "\$WFN" --tdlog "\$TDLOG" --nproc "\$N" \${DRY:+\$DRY}
|
|
153
|
+
EOF
|
|
154
|
+
|
|
155
|
+
cat > "$DIR/gen_reorg.sh" <<EOF
|
|
156
|
+
#!/bin/bash
|
|
157
|
+
set -euo pipefail
|
|
158
|
+
[ \$# -lt 1 ] && { echo "用法: \$0 <mol.xyz> [hole|electron,默认hole] [泛函,默认b3lyp] [基组,默认6-311G(d,p)]"; exit 1; }
|
|
159
|
+
exec python3 "${WF}/gen_g16_workflow.py" --type reorg --xyz "\$1" --carrier "\${2:-hole}" --func "\${3:-b3lyp}" --basis "\${4:-6-311G(d,p)}"
|
|
160
|
+
EOF
|
|
161
|
+
|
|
162
|
+
cat > "$DIR/calc_reorg.sh" <<EOF
|
|
163
|
+
#!/bin/bash
|
|
164
|
+
set -euo pipefail
|
|
165
|
+
[ \$# -lt 4 ] && { echo "用法: \$0 <1_neu_at_neu.log> <2_ion_at_neu.log> <3_ion_opt.log> <4_neu_at_ion.log>"; exit 1; }
|
|
166
|
+
exec python3 "${WF}/calc_ct_marcus.py" reorg --e0-q0 "\$1" --eion-q0 "\$2" --eion-qion "\$3" --e0-qion "\$4"
|
|
167
|
+
EOF
|
|
168
|
+
|
|
169
|
+
cat > "$DIR/gen_coupling.sh" <<EOF
|
|
170
|
+
#!/bin/bash
|
|
171
|
+
set -euo pipefail
|
|
172
|
+
[ \$# -lt 2 ] && { echo "用法: \$0 <dimer.xyz> <单体A原子数> [泛函,默认b3lyp] [基组,默认6-31G(d)]"; exit 1; }
|
|
173
|
+
exec python3 "${WF}/gen_g16_workflow.py" --type coupling --xyz "\$1" --split "\$2" --func "\${3:-b3lyp}" --basis "\${4:-6-31G(d)}"
|
|
174
|
+
EOF
|
|
175
|
+
|
|
176
|
+
cat > "$DIR/calc_marcus.sh" <<EOF
|
|
177
|
+
#!/bin/bash
|
|
178
|
+
set -euo pipefail
|
|
179
|
+
[ \$# -lt 3 ] && { echo "用法: \$0 <V_meV> <lam_in_eV> <dG_eV> [lam_out_eV,默认0] [T_K,默认298.15]"; exit 1; }
|
|
180
|
+
exec python3 "${WF}/calc_ct_marcus.py" marcus --V "\$1" --lam-in "\$2" --dG "\$3" --lam-out "\${4:-0}" --T "\${5:-298.15}"
|
|
181
|
+
EOF
|
|
182
|
+
|
|
183
|
+
chmod +x "$DIR"/*.sh
|
|
184
|
+
bash -n "$WF/mwfn_suite.sh"
|
|
185
|
+
for s in "$DIR"/*.sh; do bash -n "$s"; done
|
|
186
|
+
python3 -m py_compile "$WF"/*.py
|
|
187
|
+
echo "DEPLOY_VERIFIED_OK (standalone=$(ls -1 "$DIR"/*.sh | wc -l))"
|
|
188
|
+
REMOTE_EOF
|
|
189
|
+
|
|
190
|
+
echo ""
|
|
191
|
+
echo "[完成] 如需在远端任意目录直接敲脚本名,可在远端 ~/.bashrc 与 ~/.bash_profile 末尾追加:"
|
|
192
|
+
echo " export PATH=\"${REMOTE_BASE}/standalone:\$PATH\""
|
|
@@ -0,0 +1,126 @@
|
|
|
1
|
+
#!/usr/bin/env python3
|
|
2
|
+
"""
|
|
3
|
+
Sobereva 标准 Gaussian 16 输入文件 (.gjf) 批量生成器(零第三方依赖)
|
|
4
|
+
支持从 .xyz 坐标文件一键生成以下工作流输入:
|
|
5
|
+
- optfreq : 基态几何优化 + 频率(默认 b3lyp/6-31G(d) em=gd3bj)
|
|
6
|
+
- tddft : TD-DFT 激发态单点(自动加 IOp(9/40=4) 供 Multiwfn 电子-空穴/NTO/TDM 分析)
|
|
7
|
+
- s1opt : 激发态 S1 几何优化(td=(direct,nstates=6,root=1) opt)
|
|
8
|
+
- reorg : 内重组能 4 点法全套 4 个 .gjf(支持 hole / electron)
|
|
9
|
+
- coupling : 二聚体电子耦合 V 投影法 3 单点(AB 二聚体含 nosymm pop=full iop(3/33=1) + 单体 A/B)
|
|
10
|
+
|
|
11
|
+
用法示例:
|
|
12
|
+
python3 gen_g16_workflow.py --type tddft --xyz mol.xyz --func cam-b3lyp --basis "def2SVP" --solvent chloroform
|
|
13
|
+
python3 gen_g16_workflow.py --type reorg --xyz mol.xyz --carrier hole --func b3lyp --basis "6-311G(d,p)"
|
|
14
|
+
python3 gen_g16_workflow.py --type coupling --xyz dimer.xyz --split 42 --func b3lyp --basis "6-31G(d)"
|
|
15
|
+
"""
|
|
16
|
+
|
|
17
|
+
import argparse
|
|
18
|
+
import sys
|
|
19
|
+
from pathlib import Path
|
|
20
|
+
|
|
21
|
+
if hasattr(sys.stdout, "reconfigure"):
|
|
22
|
+
sys.stdout.reconfigure(encoding="utf-8", errors="replace")
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
def read_xyz(xyz_path: Path):
|
|
26
|
+
lines = [ln.strip() for ln in xyz_path.read_text(errors="ignore").splitlines() if ln.strip()]
|
|
27
|
+
if len(lines) < 3:
|
|
28
|
+
raise SystemExit(f"[错误] 无效的 xyz 文件: {xyz_path}")
|
|
29
|
+
try:
|
|
30
|
+
natoms = int(lines[0].split()[0])
|
|
31
|
+
coord_lines = lines[2 : 2 + natoms]
|
|
32
|
+
except ValueError:
|
|
33
|
+
coord_lines = lines
|
|
34
|
+
coords = []
|
|
35
|
+
for ln in coord_lines:
|
|
36
|
+
parts = ln.split()
|
|
37
|
+
if len(parts) >= 4:
|
|
38
|
+
coords.append(f"{parts[0]:<4s} {float(parts[1]):14.8f} {float(parts[2]):14.8f} {float(parts[3]):14.8f}")
|
|
39
|
+
if not coords:
|
|
40
|
+
raise SystemExit(f"[错误] 未能从 {xyz_path} 解析出原子坐标")
|
|
41
|
+
return coords
|
|
42
|
+
|
|
43
|
+
|
|
44
|
+
def write_gjf(path: Path, nproc: int, mem: str, chk: str, route: str, title: str, charge: int, mult: int, coords: list[str]):
|
|
45
|
+
content = (
|
|
46
|
+
f"%nprocshared={nproc}\n"
|
|
47
|
+
f"%mem={mem}\n"
|
|
48
|
+
f"%chk={chk}\n"
|
|
49
|
+
f"#p {route}\n\n"
|
|
50
|
+
f"{title}\n\n"
|
|
51
|
+
f"{charge} {mult}\n"
|
|
52
|
+
+ "\n".join(coords)
|
|
53
|
+
+ "\n\n"
|
|
54
|
+
)
|
|
55
|
+
path.write_text(content, encoding="utf-8", newline="\n")
|
|
56
|
+
print(f"[生成] {path}")
|
|
57
|
+
|
|
58
|
+
|
|
59
|
+
def main():
|
|
60
|
+
ap = argparse.ArgumentParser(description="生成 Sobereva 规范 Gaussian 16 工作流 .gjf 文件")
|
|
61
|
+
ap.add_argument("--type", required=True, choices=["optfreq", "tddft", "s1opt", "reorg", "coupling"])
|
|
62
|
+
ap.add_argument("--xyz", required=True, help="输入结构 .xyz 文件")
|
|
63
|
+
ap.add_argument("--outdir", default=".", help="输出目录(默认当前目录)")
|
|
64
|
+
ap.add_argument("--func", default="b3lyp", help="泛函(默认 b3lyp;TD-DFT 推荐 cam-b3lyp 或 wB97XD)")
|
|
65
|
+
ap.add_argument("--basis", default="6-31G(d)", help="基组(默认 6-31G(d))")
|
|
66
|
+
ap.add_argument("--disp", default="em=gd3bj", help="色散校正(默认 em=gd3bj;若用 wB97XD 请传空字符串 '')")
|
|
67
|
+
ap.add_argument("--solvent", default="", help="可选隐式溶剂名(如 chloroform, toluene, acetonitrile)")
|
|
68
|
+
ap.add_argument("--nproc", type=int, default=16, help="核数(默认 16)")
|
|
69
|
+
ap.add_argument("--mem", default="24GB", help="内存(默认 24GB)")
|
|
70
|
+
ap.add_argument("--charge", type=int, default=0, help="默认体系净电荷(默认 0)")
|
|
71
|
+
ap.add_argument("--mult", type=int, default=1, help="默认体系自旋多重度(默认 1)")
|
|
72
|
+
ap.add_argument("--nstates", type=int, default=10, help="TD-DFT 激发态数(默认 10)")
|
|
73
|
+
ap.add_argument("--carrier", choices=["hole", "electron"], default="hole", help="reorg 载流子类型: hole(+1) 或 electron(-1)")
|
|
74
|
+
ap.add_argument("--split", type=int, default=0, help="coupling 模式:单体 A 包含前 N 个原子(其余为单体 B)")
|
|
75
|
+
args = ap.parse_args()
|
|
76
|
+
|
|
77
|
+
xyz_path = Path(args.xyz)
|
|
78
|
+
coords = read_xyz(xyz_path)
|
|
79
|
+
outdir = Path(args.outdir)
|
|
80
|
+
outdir.mkdir(parents=True, exist_ok=True)
|
|
81
|
+
stem = xyz_path.stem
|
|
82
|
+
|
|
83
|
+
scrf = f"scrf=(smd,solvent={args.solvent})" if args.solvent else ""
|
|
84
|
+
disp = args.disp.strip()
|
|
85
|
+
base_method = " ".join(x for x in [f"{args.func}/{args.basis}", disp, scrf] if x)
|
|
86
|
+
|
|
87
|
+
if args.type == "optfreq":
|
|
88
|
+
route = f"opt freq {base_method}"
|
|
89
|
+
write_gjf(outdir / f"{stem}_optfreq.gjf", args.nproc, args.mem, f"{stem}_optfreq.chk", route, f"{stem} Opt+Freq", args.charge, args.mult, coords)
|
|
90
|
+
|
|
91
|
+
elif args.type == "tddft":
|
|
92
|
+
route = f"{base_method} td=(direct,nstates={args.nstates}) iop(9/40=4)"
|
|
93
|
+
write_gjf(outdir / f"{stem}_tddft.gjf", args.nproc, args.mem, f"{stem}_tddft.chk", route, f"{stem} TD-DFT (IOp 9/40=4)", args.charge, args.mult, coords)
|
|
94
|
+
|
|
95
|
+
elif args.type == "s1opt":
|
|
96
|
+
route = f"{base_method} td=(direct,nstates=6,root=1) opt"
|
|
97
|
+
write_gjf(outdir / f"{stem}_s1opt.gjf", args.nproc, args.mem, f"{stem}_s1opt.chk", route, f"{stem} S1 Opt", args.charge, args.mult, coords)
|
|
98
|
+
|
|
99
|
+
elif args.type == "reorg":
|
|
100
|
+
ion_chg = args.charge + (1 if args.carrier == "hole" else -1)
|
|
101
|
+
ion_mult = args.mult + 1 if args.mult % 2 == 1 else max(1, args.mult - 1)
|
|
102
|
+
tag = "cat" if args.carrier == "hole" else "ani"
|
|
103
|
+
write_gjf(outdir / f"{stem}_1_neu_at_neu.gjf", args.nproc, args.mem, f"{stem}_1_neu_at_neu.chk", base_method, "E0(Q0) neutral SP at neutral geom", args.charge, args.mult, coords)
|
|
104
|
+
write_gjf(outdir / f"{stem}_2_{tag}_at_neu.gjf", args.nproc, args.mem, f"{stem}_2_{tag}_at_neu.chk", base_method, f"Eion(Q0) {args.carrier} vertical SP at neutral geom", ion_chg, ion_mult, coords)
|
|
105
|
+
write_gjf(outdir / f"{stem}_3_{tag}_opt.gjf", args.nproc, args.mem, f"{stem}_3_{tag}_opt.chk", f"opt {base_method}", f"Eion(Qion) {args.carrier} Opt", ion_chg, ion_mult, coords)
|
|
106
|
+
p4 = outdir / f"{stem}_4_neu_at_{tag}.gjf"
|
|
107
|
+
p4.write_text(
|
|
108
|
+
f"%nprocshared={args.nproc}\n%mem={args.mem}\n%oldchk={stem}_3_{tag}_opt.chk\n%chk={stem}_4_neu_at_{tag}.chk\n"
|
|
109
|
+
f"#p {base_method} geom=check\n\nE0(Qion) neutral SP at optimized {args.carrier} geom\n\n{args.charge} {args.mult}\n\n",
|
|
110
|
+
encoding="utf-8",
|
|
111
|
+
newline="\n",
|
|
112
|
+
)
|
|
113
|
+
print(f"[生成] {p4} (提示:须等 Step 3 优化完成后再提交 Step 4)")
|
|
114
|
+
|
|
115
|
+
elif args.type == "coupling":
|
|
116
|
+
if args.split <= 0 or args.split >= len(coords):
|
|
117
|
+
raise SystemExit(f"[错误] coupling 模式必须指定合理的 --split N(1 <= N < {len(coords)})")
|
|
118
|
+
coords_a = coords[: args.split]
|
|
119
|
+
coords_b = coords[args.split :]
|
|
120
|
+
write_gjf(outdir / f"{stem}_monA.gjf", args.nproc, args.mem, f"{stem}_monA.chk", f"{base_method} nosymm pop=full", f"{stem} Monomer A", args.charge, args.mult, coords_a)
|
|
121
|
+
write_gjf(outdir / f"{stem}_monB.gjf", args.nproc, args.mem, f"{stem}_monB.chk", f"{base_method} nosymm pop=full", f"{stem} Monomer B", args.charge, args.mult, coords_b)
|
|
122
|
+
write_gjf(outdir / f"{stem}_dimerAB.gjf", args.nproc, args.mem, f"{stem}_dimerAB.chk", f"{base_method} nosymm pop=full iop(3/33=1)", f"{stem} Dimer AB (S-matrix)", args.charge, args.mult, coords)
|
|
123
|
+
|
|
124
|
+
|
|
125
|
+
if __name__ == "__main__":
|
|
126
|
+
main()
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
# One-line Windows installer for hpc-quantchem-workflow (no Node.js required)
|
|
2
|
+
# Usage: irm https://raw.githubusercontent.com/yangdw2024/hpc-quantchem-workflow/main/scripts/install.ps1 | iex
|
|
3
|
+
$ErrorActionPreference = 'Stop'
|
|
4
|
+
|
|
5
|
+
$repo = 'yangdw2024/hpc-quantchem-workflow'
|
|
6
|
+
$skillName = 'hpc-quantchem-workflow'
|
|
7
|
+
$zipUrl = "https://github.com/$repo/archive/refs/heads/main.zip"
|
|
8
|
+
$tmp = Join-Path $env:TEMP ("install-" + $skillName + "-" + [guid]::NewGuid().ToString('N'))
|
|
9
|
+
$zipPath = Join-Path $tmp 'repo.zip'
|
|
10
|
+
|
|
11
|
+
try {
|
|
12
|
+
New-Item -ItemType Directory -Path $tmp -Force | Out-Null
|
|
13
|
+
Write-Host "Downloading $repo..." -ForegroundColor Cyan
|
|
14
|
+
Invoke-WebRequest -Uri $zipUrl -OutFile $zipPath -UseBasicParsing
|
|
15
|
+
Expand-Archive -Path $zipPath -DestinationPath $tmp -Force
|
|
16
|
+
$srcRoot = (Get-ChildItem -Path $tmp -Directory | Select-Object -First 1).FullName
|
|
17
|
+
$skillSrc = $srcRoot
|
|
18
|
+
|
|
19
|
+
$candidates = @(
|
|
20
|
+
@{ Root = (Join-Path $env:USERPROFILE '.dsh'); Dest = (Join-Path $env:USERPROFILE ".dsh\skills\$skillName") },
|
|
21
|
+
@{ Root = (Join-Path $env:USERPROFILE '.claude'); Dest = (Join-Path $env:USERPROFILE ".claude\skills\$skillName") },
|
|
22
|
+
@{ Root = (Join-Path $env:USERPROFILE '.codex'); Dest = (Join-Path $env:USERPROFILE ".codex\skills\$skillName") },
|
|
23
|
+
@{ Root = (Join-Path $env:USERPROFILE '.cursor'); Dest = (Join-Path $env:USERPROFILE ".cursor\skills\$skillName") },
|
|
24
|
+
@{ Root = (Join-Path $env:USERPROFILE '.agents'); Dest = (Join-Path $env:USERPROFILE ".agents\skills\$skillName") },
|
|
25
|
+
@{ Root = (Join-Path $env:USERPROFILE '.gemini\antigravity'); Dest = (Join-Path $env:USERPROFILE ".gemini\antigravity\skills\$skillName") }
|
|
26
|
+
)
|
|
27
|
+
|
|
28
|
+
$targets = @($candidates | Where-Object { Test-Path $_.Root })
|
|
29
|
+
if ($targets.Count -eq 0) {
|
|
30
|
+
$targets = @($candidates[0], $candidates[4])
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
$items = @('SKILL.md', 'references', 'scripts', 'LICENSE')
|
|
34
|
+
foreach ($t in $targets) {
|
|
35
|
+
if (Test-Path $t.Dest) { Remove-Item -Recurse -Force $t.Dest }
|
|
36
|
+
New-Item -ItemType Directory -Path $t.Dest -Force | Out-Null
|
|
37
|
+
foreach ($item in $items) {
|
|
38
|
+
$from = Join-Path $skillSrc $item
|
|
39
|
+
if (Test-Path $from) {
|
|
40
|
+
Copy-Item -Path $from -Destination (Join-Path $t.Dest $item) -Recurse -Force
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
Write-Host "[ok] Installed $skillName -> $($t.Dest)" -ForegroundColor Green
|
|
44
|
+
}
|
|
45
|
+
Write-Host "`nDone! Open a new session in DSH / Claude Code / Codex / Cursor / Antigravity to use /$skillName." -ForegroundColor Cyan
|
|
46
|
+
} finally {
|
|
47
|
+
if (Test-Path $tmp) { Remove-Item -Recurse -Force $tmp -ErrorAction SilentlyContinue }
|
|
48
|
+
}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
#!/usr/bin/env bash
|
|
2
|
+
# One-line macOS/Linux installer for hpc-quantchem-workflow (no Node.js required)
|
|
3
|
+
# Usage: curl -fsSL https://raw.githubusercontent.com/yangdw2024/hpc-quantchem-workflow/main/scripts/install.sh | bash
|
|
4
|
+
set -euo pipefail
|
|
5
|
+
|
|
6
|
+
REPO="yangdw2024/hpc-quantchem-workflow"
|
|
7
|
+
SKILL_NAME="hpc-quantchem-workflow"
|
|
8
|
+
TMP_DIR="$(mktemp -d)"
|
|
9
|
+
trap 'rm -rf "$TMP_DIR"' EXIT
|
|
10
|
+
|
|
11
|
+
echo "Downloading $REPO..."
|
|
12
|
+
curl -fsSL "https://github.com/$REPO/archive/refs/heads/main.tar.gz" | tar -xz -C "$TMP_DIR"
|
|
13
|
+
SRC_ROOT="$(find "$TMP_DIR" -mindepth 1 -maxdepth 1 -type d | head -n 1)"
|
|
14
|
+
SKILL_SRC="$SRC_ROOT"
|
|
15
|
+
|
|
16
|
+
TARGETS=()
|
|
17
|
+
for root in "$HOME/.dsh" "$HOME/.claude" "$HOME/.codex" "$HOME/.cursor" "$HOME/.agents" "$HOME/.gemini/antigravity"; do
|
|
18
|
+
if [ -d "$root" ]; then
|
|
19
|
+
TARGETS+=("$root/skills/$SKILL_NAME")
|
|
20
|
+
fi
|
|
21
|
+
done
|
|
22
|
+
if [ "${#TARGETS[@]}" -eq 0 ]; then
|
|
23
|
+
TARGETS=("$HOME/.dsh/skills/$SKILL_NAME" "$HOME/.agents/skills/$SKILL_NAME")
|
|
24
|
+
fi
|
|
25
|
+
|
|
26
|
+
ITEMS=("SKILL.md" "references" "scripts" "LICENSE")
|
|
27
|
+
for dest in "${TARGETS[@]}"; do
|
|
28
|
+
rm -rf "$dest"
|
|
29
|
+
mkdir -p "$dest"
|
|
30
|
+
for item in "${ITEMS[@]}"; do
|
|
31
|
+
if [ -e "$SKILL_SRC/$item" ]; then
|
|
32
|
+
cp -R "$SKILL_SRC/$item" "$dest/$item"
|
|
33
|
+
fi
|
|
34
|
+
done
|
|
35
|
+
echo "[ok] Installed $SKILL_NAME -> $dest"
|
|
36
|
+
done
|
|
37
|
+
|
|
38
|
+
echo ""
|
|
39
|
+
echo "Done! Open a new session in DSH / Claude Code / Codex / Cursor / Antigravity to use /$SKILL_NAME."
|