计算化学公社

 找回密码 Forget password
 注册 Register
Views: 55567|回复 Reply: 33
打印 Print 上一主题 Last thread 下一主题 Next thread

[辅助/分析程序] 批量转换量子化学软件I/O文件以及提取输出信息的Shell脚本

  [复制链接 Copy URL]

1102

帖子

18

威望

6693

eV
积分
8155

Level 6 (一方通行)

計算化学の社畜

跳转到指定楼层 Go to specific reply
楼主
本帖最后由 冰释之川 于 2024-11-3 08:03 编辑

之前看到了社长写的一键把所有gjf文件转成xyz文件、把所有Gaussian输出文件转成gjf文件的脚本:
http://sobereva.com/530http://bbs.keinsci.com/thread-16161-1-1.html

于是乎本人心血来潮,基于Multiwfn编写了多种常用量子化学程序间I/O文件转换的脚本包
1 Convert [*.gjf/*.xyz/*.fchk/*.fch/*.out/*.log] files to [*.gjf/*.inp/*.mop/*.xyz] files by Multiwfn
2 Convert [*.fchk/*.fch] files to [*.mkl] files by Multiwfn
3 Interconvert between [*.fchk/*.fch] and [*.molden] files by Multiwfn
4 Interconvert between [*.fchk] and [*.chk] Gaussian checkpoint files by formchk/unfchk tool
5 Interconvert between [*.gbw] and [*.mkl] ORCA files by orca_2mkl tool
6 Convert [*.gbw] files to [*.molden] files by orca_2mkl tool

Conversion_Scripts.sh (17.08 KB, 下载次数 Times of downloads: 366)


另外附上提取ORCA和Gaussian输出文件信息,利用freqchk重新计算热力学量的提取脚本
1 Extract single point energy (SPE) of DFT and HF from Gaussian16 output files
2 Extract Zero-point energy (ZPE) and thermal correction to G, H and U (Gcorr, Hcorr, and Ucorr) from Gaussian16 output files
3 Extract TDDFT information from Gaussian16 output files
4 Extract SPE from ORCA-4.2.1 output files
5 Extract Zero-point energy (ZPE) and thermal correction to G, H and U (Gcorr, Hcorr, and Ucorr) from ORCA-4.2.1 output files [ updated on 2020.04.03 ]
6 Recalculate Gcorr and Hcorr by using freqchk tool and Gaussian16 [*.fchk] files
7 Detect the status of Gaussian optimization outputs (imaginary frequency, opt/SCF convergency, etc.)
8 Extract SPE from xtb-6.3(pre) output files  [ updated on 2020.04.07 ]
9 Calculate ZPE, Gcorr, Hcorr, and Ucorr by using Shermo 2.0 [ updated on 2020.05.12 ]

P.s. Shermo 2.0 下载地址为http://sobereva.com/soft/shermo/
在~/.bashrc中设置Shermo 2.0的环境变量:
  1. export Shermopath=/sob/Shermo_2.0
  2. export PATH=$PATH:/sob/Shermo_2.0
复制代码

Extraction_Scripts.sh (28.99 KB, 下载次数 Times of downloads: 241)

#PS 感谢Jingdan Chen同学对Extraction_Scripts.sh脚本进行修订,修订日志如下
  1. ```ORCA version 6.0.0

  2. Line 272-289, Function extr_thermal_orca_process
  3. 1. 如果ORCA的优化任务包含Calc_Hess或Recalc_Hess关键词,与Gaussian不同,在每次频率分析后ORCA都会以相同格式输出热力学量,因此原脚本会出现拉出不止一个数值的情况,导致拿到的数值异常且有报错信息(但程序会正常跑完)。修改:  awk 加入END机制,
  4. 2. 修改: printf 补充 \n换行

  5. Line 74-75
  6. 1. 修改: 补充mainchoice == 5 的分析结束后的信息输出
  7. ```
复制代码
Extraction_Scripts_rev.sh (29.15 KB, 下载次数 Times of downloads: 11) (Jingdan Chen修订版)



批量删除文件脚本 [ added on 2020.02.10 ]
Files_Cleaner.sh (2.72 KB, 下载次数 Times of downloads: 92)


批量为*.gjf/*.inp/*.xyz/*.mop生成PBS作业提交文件的脚本(请酌情修改PBS模板文件)[ updated on 2022.06.23 ]
PBS模板文件为:Gaussian.pbs, ORCA.pbs, MOPAC.pbs, xtb.pbs, xtb_md.pbs和xtb_md_temp_search.pbs
其中folder_qsub_all.sh为批量提交PBS任务的脚本
Scripts_PBS_Allocation.zip (18.74 KB, 下载次数 Times of downloads: 130)


具体使用方法:
(1) 把*.sh脚本放到工作目录下
(2) 用bash命令 运行之
(3) 脚本会深度遍历该目录下所有的子目录,并处理目标文件。

如果发现Bug,烦请邮箱联系本人











评分 Rate

参与人数
Participants 24
威望 +1 eV +108 收起 理由
Reason
Pokémon + 4 赞!
pinpo + 5
dadaoqiuzhi + 2 好物!
Henge + 5 赞!
Chlorine@Chem + 5 谢谢
bannc + 5 谢谢
Y30181009 + 5 牛!
wangxc + 4 谢谢
北大-陶豫 + 5 牛!
hdhxx123 + 5 精品内容
Hanz + 5 GJ!
pika02 + 5 bbj大法好
snljty + 5 也是辛苦
小红豆 + 3
小苹果 + 5 牛!
ggdh + 5 GJ!
978142355 + 5 bb姐强悍
biogon + 5
tjuptz + 5 牛!
zsu007 + 5 好物!

查看全部评分 View all ratings

Stand on the shoulders of giants

17

帖子

0

威望

77

eV
积分
94

Level 2 能力者

34#
发表于 Post on 3 day ago | 只看该作者 Only view this author
好工具,学习了!

1102

帖子

18

威望

6693

eV
积分
8155

Level 6 (一方通行)

計算化学の社畜

33#
 楼主 Author| 发表于 Post on 2024-11-3 08:04:19 | 只看该作者 Only view this author
#PS 感谢Jingdan Chen同学对Extraction_Scripts.sh脚本进行修订,修订日志如下:
  1. ```ORCA version 6.0.0

  2. Line 272-289, Function extr_thermal_orca_process
  3. 1. 如果ORCA的优化任务包含Calc_Hess或Recalc_Hess关键词,与Gaussian不同,在每次频率分析后ORCA都会以相同格式输出热力学量,因此原脚本会出现拉出不止一个数值的情况,导致拿到的数值异常且有报错信息(但程序会正常跑完)。修改:  awk 加入END机制,
  4. 2. 修改: printf 补充 \n换行

  5. Line 74-75
  6. 1. 修改: 补充mainchoice == 5 的分析结束后的信息输出
  7. ```
复制代码
Stand on the shoulders of giants

16

帖子

0

威望

3017

eV
积分
3033

Level 5 (御坂)

32#
发表于 Post on 2021-7-17 22:01:22 | 只看该作者 Only view this author
谢谢老师,我试试看

1102

帖子

18

威望

6693

eV
积分
8155

Level 6 (一方通行)

計算化学の社畜

31#
 楼主 Author| 发表于 Post on 2021-7-17 21:22:20 | 只看该作者 Only view this author
Y30181009 发表于 2021-7-16 18:15
冰老师在使用Extraction_Scripts.sh 的子功能3 Extract TDDFT information from Gaussian16 output files输 ...

自行抓取 Total Energy, E(TD-HF/TD-KS) = 等号后面的数值
Stand on the shoulders of giants

16

帖子

0

威望

3017

eV
积分
3033

Level 5 (御坂)

30#
发表于 Post on 2021-7-16 18:15:42 | 只看该作者 Only view this author
冰老师在使用Extraction_Scripts.sh 的子功能3 Extract TDDFT information from Gaussian16 output files输出S1信息的时候没有输出S1单点能,冰老师如果想输出S1单点能的话需要怎么改一下脚本?

202107161812581618..png (18.59 KB, 下载次数 Times of downloads: 99)

202107161812581618..png

202107161816222485..png (18.29 KB, 下载次数 Times of downloads: 76)

202107161816222485..png

255

帖子

0

威望

2370

eV
积分
2625

Level 5 (御坂)

29#
发表于 Post on 2021-6-30 17:19:11 | 只看该作者 Only view this author
冰释之川 发表于 2021-6-24 20:46
linux命令dos2unix filename,直接把文件转换为unix格式

谢谢老师!处理好了

1102

帖子

18

威望

6693

eV
积分
8155

Level 6 (一方通行)

計算化学の社畜

28#
 楼主 Author| 发表于 Post on 2021-6-24 20:46:58 | 只看该作者 Only view this author
万卷书万里路 发表于 2021-6-24 19:31
请问冰老师,我用multiwfn批量生成gjf文件以后,按照这里的方法用notepad++把第一行换成了新的三行(chk ...

linux命令dos2unix filename,直接把文件转换为unix格式
Stand on the shoulders of giants

255

帖子

0

威望

2370

eV
积分
2625

Level 5 (御坂)

27#
发表于 Post on 2021-6-24 19:31:26 | 只看该作者 Only view this author
冰释之川 发表于 2020-2-8 15:59
这是调用Multiwfn批量输出gjf的,要取10位小数得改Multiwfn了
关于输出的gjf如何批量改关键词,我 ...

请问冰老师,我用multiwfn批量生成gjf文件以后,按照这里的方法用notepad++把第一行换成了新的三行(chk路径、内存、关键词),在集群上提交一直报错。
我在windows下的notepad++窗口中看到的是三行,但是报错内容显示我的输入文件有错,显示的是前三行在一行里。
然后我在集群的ssh终端窗口中打开输入文件,显示是这样:


这些 ^M, 不知道为什么在notepad++里就看不到,请问是格式的问题么?
谢谢老师!


1102

帖子

18

威望

6693

eV
积分
8155

Level 6 (一方通行)

計算化学の社畜

26#
 楼主 Author| 发表于 Post on 2021-5-18 08:16:20 | 只看该作者 Only view this author

PAd3_opt2gjf.7z (212.08 KB, 下载次数 Times of downloads: 1)
我这边转换没问题啊
Stand on the shoulders of giants

56

帖子

1

威望

1278

eV
积分
1354

Level 4 (黑子)

25#
发表于 Post on 2021-5-17 16:50:54 | 只看该作者 Only view this author
谢谢您

PAd3_opt.7z

180.5 KB, 下载次数 Times of downloads: 2

留给自己点琢磨的时间。

1102

帖子

18

威望

6693

eV
积分
8155

Level 6 (一方通行)

計算化学の社畜

24#
 楼主 Author| 发表于 Post on 2021-5-17 08:18:11 | 只看该作者 Only view this author
skdmax 发表于 2021-5-16 08:23
OPT FREQ任务的out文件可以转化成gjf文件吗?我用这个时候转出来都是空白的。

可以啊,我一直在用优化任务的输出文件转成gjf,你贴一下你的*.out文件看看
Stand on the shoulders of giants

56

帖子

1

威望

1278

eV
积分
1354

Level 4 (黑子)

23#
发表于 Post on 2021-5-16 08:23:46 | 只看该作者 Only view this author
OPT FREQ任务的out文件可以转化成gjf文件吗?我用这个时候转出来都是空白的。
留给自己点琢磨的时间。

148

帖子

0

威望

888

eV
积分
1036

Level 4 (黑子)

22#
发表于 Post on 2021-5-16 01:55:04 | 只看该作者 Only view this author
666,很棒的脚本,谢谢分享!

48

帖子

0

威望

1323

eV
积分
1371

Level 4 (黑子)

21#
发表于 Post on 2020-5-12 23:23:24 | 只看该作者 Only view this author
附上批量修改gjf关键词的bash脚本,是在sob老师的基础上修改的

#!/bin/bash
for inf in *.gjf
do

sed '1c %nprocshared=64' ${inf} > ${inf}.txt
sed '2c %mem=32GB' ${inf}.txt > ${inf}
sed '4c #p M062X/Def2TZVP SCRF(Solvent=Ethanol) int=ultrafine freq geom=allcheck guess=read' ${inf} > ${inf}.txt

cp ${inf}.txt ${inf}
done
rm *.txt

评分 Rate

参与人数
Participants 1
eV +5 收起 理由
Reason
冰释之川 + 5 谢谢分享

查看全部评分 View all ratings

手机版 Mobile version|北京科音自然科学研究中心 Beijing Kein Research Center for Natural Sciences|京公网安备 11010502035419号|计算化学公社 — 北京科音旗下高水平计算化学交流论坛 ( 京ICP备14038949号-1 )|网站地图

GMT+8, 2025-8-16 11:06 , Processed in 0.176160 second(s), 25 queries , Gzip On.

快速回复 返回顶部 返回列表 Return to list