从Gaussian 09的Hartree-Fock计算的fchk文件转换到Columbus的mocoef文件的脚本
来源:互联网 发布:mac git冲突解决 编辑:程序博客网 时间:2024/05/16 07:22
这个脚本用于将Gaussian 09的Hartree-Fock计算的.fchk文件转换到Columbus软件使用的mocoef文件。
需要说明的是,测试工作还不完善,不保证此脚本的正确性。
注意:两个软件所使用的基组以及对称性等等必须完全一致!
#! /usr/bin/perl# code by luozhen# ATTENTION: MAKE SURE that the SAME BASIS SET has been used in the two softwares.# results saved in the file "mocoef"# you MUST have the access to write in the work directory.open (Columbus, ">mocoef") or die "Can not create file \"mocoef\"!";# read input data# use command as "./hfg09tocol.pl inputfile" in bash shell.while (<>) {push @lines, $_;}# check necessary infowhile ($id < @lines) { if ($lines[$id] =~ m/Number of electrons.*([0-9][0-9]+)/) { $count_electrons = $1; } elsif ($lines[$id] =~ m/basis functions.*([0-9][0-9]+)/) {$count_basis_func = $1;} elsif ($lines[$id] =~ m/independent functions.*([0-9][0-9]+)/) {$count_indp_func = $1;} elsif ($lines[$id] =~ m/Alpha Orbital Energies/) {$id_start_energy = $id + 1;} elsif ($lines[$id] =~ m/Alpha MO coefficients/) {$id_start_mocoef = $id + 1;$id_end_energy = $id - 1;} elsif ($lines[$id] =~ m/Total SCF Density/) {$id_end_mocoef = $id - 1;}$id++;}# read orbital energies$lines_count_orbeng = $id_end_energy - $id_start_energy + 1;@data_orbeng = splice @lines, $id_start_energy, $lines_count_orbeng;# read MO coefficients$lines_count_mocoef = $id_end_mocoef - $id_start_mocoef + 1;$id_start_mocoef -= $lines_count_orbeng;@data_mocoef = splice @lines, $id_start_mocoef, $lines_count_mocoef;# necessary lines in the file "mocoef"print Columbus " 2mocoef\nheader\n" . "\t" x 5 . " 2\nHermit Integral Program : Gaussian 09 \nmo coefficients generated by Gaussian 09\n" . "\t" x 5 . " 1\n" . "\t" x 5 . "$count_basis_func" . "\t" x 5 . "$count_indp_func\n A\n";# MO coefficients, printprint Columbus "mocoef\n(1p4e16.8)\n";{ my @numbers; foreach (@data_mocoef) { my @temp = split; push @numbers, @temp; } my $count = 0; my $counts = @numbers; while ($count < $counts) { printf Columbus "%16s", $numbers[$count]; if (($count + 1) % 4 == 0) {# 4 numbers per line print Columbus "\n"; $count ++; } elsif (($count + 1) % $count_basis_func == 0) { print Columbus "\n"; splice @numbers, 0, $count_basis_func; $counts = @numbers; $count = 0; } else { $count ++; } }}# orbocc, calculate and print# there's no data about orbitals occupation in Gaussian's *.fchk file.# so I have to do some calculations myself,# and I can not ensure that the result of the following block is perfectly correct.print Columbus "orbocc\n(1p4e16.8)\n";{ my $count = 0; my @numbers; my $count_double_occ = $count_electrons / 2; if ($count_electrons % 2 == 0) { while ($count < $count_basis_func) { if ($count < $count_double_occ) { push @numbers, "2.00000000E+00"; } else { push @numbers, "0.00000000E+00"; } $count ++; } } else { while ($count < $count_basis_func) { if ($count < $count_double_occ) { push @numbers, "2.00000000E+00"; } elsif ($count < $count_double_occ) { push @numbers, "1.00000000E+00"; } else { push @numbers, "0.00000000E+00"; } $count ++; } } my $count = 0; my $counts = @numbers; while ($count < $counts) { printf Columbus "%16s", $numbers[$count]; if (($count + 1) % 4 == 0) {# 4 numbers per line print Columbus "\n"; } $count ++; } print Columbus "\n";} # energy, printprint Columbus "energy\n(1p4e16.8)\n";{ my @numbers; foreach (@data_orbeng) { my @temp = split; push @numbers, @temp; } my $count = 0; my $counts = @numbers; while ($count < $counts) { printf Columbus "%16s", $numbers[$count]; if (($count + 1) % 4 == 0) {# 4 numbers per line print Columbus "\n"; } $count ++; } print Columbus "\n";}
0 0
- 从Gaussian 09的Hartree-Fock计算的fchk文件转换到Columbus的mocoef文件的脚本
- 转换vcf文件到csv文件的python脚本
- 用于转换和恢复从ipa文件中,提取到的png文件的Python脚本 支持Python 3.3版本
- 从 XML 文件到 MySQL 的转换,调试笔记
- 计算文件及字符串的VBS脚本
- 空间信息到GML的转换(从Shp文件到GML文件)
- 从IE临时文件夹COPY文件的脚本
- 从ftp服务器新版本文件的脚本
- shell脚本-计算从1到输入数字的和
- 批量转换文件内码的脚本
- 恢复正在运行的脚本到文件
- 使用UltraEdit实现从UNIX文件到DOS文件的批量转换
- 使用UltraEdit实现从UNIX文件到DOS文件的批量转换
- 把txt文件转换为tsv文件的python脚本
- 从文件下载学习到的
- linux从文件到进程的过程
- csv到html文件的转换
- mysql 脚本到 oracle脚本的转换
- android获取应用的当前版本号及获取当前android系统的版本号
- 在matlab中num2str()语法
- 斜杠(Slash)与反斜杠(backslash)
- 易混淆名词辨析
- 控制台鼠标程序
- 从Gaussian 09的Hartree-Fock计算的fchk文件转换到Columbus的mocoef文件的脚本
- 复合命令A等效于$a
- 【智能家居篇】通信技术简介
- Android Intent 简介
- OCP 1Z0 053 9
- [git常见问题]error: src refspec matches more than one.
- CentOS6.5桌面版安装VirtualBox提示错误/etc/init.d/vboxdrv setup
- Java Persistence with MyBatis 3(中文版) 前言
- Redis:安装、配置、操作和简单代码实例(C语言Client端)