计算化学公社

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

[Molclus] consearch:一键提交slurm的molclus构象搜索脚本

[复制链接 Copy URL]

45

帖子

4

威望

1082

eV
积分
1207

Level 4 (黑子)

跳转到指定楼层 Go to specific reply
楼主
本帖最后由 Kamistry 于 2024-3-21 20:02 编辑

consearch:一键提交slurm的molclus构象搜索脚本

Author: Zihan Lin @ USTC (Kamistry @ 计算化学公社)
在使用本脚本进行科学研究,研究结果发表时,如若能正确引用,笔者将万分感激!

使用前准备
1、首先需要给予脚本运行权限,可以使用如下命令
  1. chmod +x consearch
复制代码
强烈推荐把consearch加入环境变量中,无需每次复制到计算文件夹中
2、修改 # commands部分 将xtb、crest、molclus、isostat加入环境变量(推荐后者,特别是在不同环境下使用或者不清楚如何更改脚本的情况下)
3、计算前在计算文件夹中提供输入文件(例如input.xyz)、xtb动力学需要的设置(例如md.inp,如果使用了--traj选项则不用提供)、molclus需要的template.gjf、settings.ini、template_SP.inp或template_SP.gjf等(如果使用了-3选项则不用提供)。如果缺少文件会有提示(参见后面的说明)。

用法
  1. consearch 选项 input.xyz
复制代码
以下是可用的选项:
--cpu=
    设置运行核数,只能是正整数。
--mem=
    设置运行内存,单位只能是MB或者GB。
--traj
    使用已有的轨迹文件。使用这个选项时,代表输入的input.xyz是已得到的轨迹文件(例如通过gromacs、gentor等方式获得),此时不会调用xtb做动力学。
--mdinput=
    设置xtb动力学的参数文件,对应xtb --input选项。当使用--traj选项时,此选项会被忽略。如果不使用这个选项去指定文件名,则默认是md.inp。
--solvent=
    设置第2步GFN2-xTB优化的溶剂环境,对应xtb --gbsa选项,当额外参数为空字符串时代表使用气相计算。
--chrg=
    对应xtb --chrg选项,默认值是0。
--uhf=
    对应xtb --uhf选项,默认值是0。
--Nout=
    对应isostat -Nout选项,默认值是10。
--Eout=
    对应isostat -Eout选项,默认值是2.4。
--Edis=
    对应isostat -Edis选项,默认值是0.5。
--Gdis=
    对应isostat -Gdis选项,默认值是0.5。
--temp=
    设置温度,单位是K,对应isostat -T选项,默认值是298.15。
--clean=
    自动清理。设置为0时,保留所有文件;设置为1时,仅保留每一步的最终结果(在计算文件夹下00result.xyz等文件);设置为2时,清理所有中间文件,仅保留最终文件。
-1
    跳过第一步 (GFN0-xTB优化)。此时输入文件将直接提供给后面步骤。
-2
    跳过第二步 (GFN0-xTB优化)。此时输入文件将直接提供给后面步骤。
-3
    跳过第三步 (molclus)。当-1、-2、-3选项同时被使用时,相当于只用xtb跑动力学。当--traj、-1、-2、-3选项同时被使用时没有意义。
-h|--help
    显示帮助

如何设置参数
1、临时更改
临时更改的情况强烈不建议直接修改脚本,请使用命令行参数。当选项后面带有=时,意思是需要提供额外的参数,与长选项以空格或等号隔开。如果为空字符串,例如设置气相条件计算,可以用--solvent=""或--solvent ""
2、多次使用
a. 直接更改脚本# default settings部分(不建议,除了cpu和mem)
b. 写一个如下的调用脚本consearch2.sh(还是推荐加入环境变量)
  1. #!/bin/bash
  2. consearch 要添加的选项 $@
复制代码
然后
  1. chmod u+x consearch2.sh
复制代码
使用时只需要用consearch2.sh替代consearch即可,但是要注意参数冲突的情况。

提交任务
本脚本会自动提交slurm,在提交前会检查已有的文件是否齐全,并输出如下。(注意:不同的超算上可能需要在sbatch << EOF部分加上复制到计算节点的命令,具体参考超算的说明)
  1. --------------------------------------------------------------------------------
  2.                                      Check files
  3. --------------------------------------------------------------------------------
  4. Input file                    :               found input.xyz
  5. Molclus settings              :      found settings.ini
  6. Molclus template              :      found template.gjf
  7. Molclus template_SP           :      found template_SP.inp
复制代码

通过检查后会自动提交slurm,并根据cpu和mem参数请求资源,如果不需要用slurm可以将sbatch << EOF替换为bash << EOF。
输出会被保存在consearch.log中,每一步的中间文件会在0x(x对应具体步骤)子文件夹中,每一步结果会被复制到计算文件夹中,命名为0xresult.xyz。


脚本分析
以下是这个脚本的思路和分析,希望能起到抛砖引玉的作用。

第一行指定默认使用bash运行,之后是用法注释。
  1. #!/bin/bash

  2. # author: Zihan Lin

  3. # Usage:
  4. #     consearch <options> input.xyz
  5. #
  6. # Example:
  7. #     consearch input.xyz
  8. #     consearch --traj --cpu 64 --mem 480GB traj.xyz
  9. #     consearch --solvent toluene input.xyz
  10. #
  11. # Options:
  12. #     --cpu=         : Set the number of cores used
  13. #     --mem=         : Set the number of memery used. Unit is MB or GB.
  14. #     --traj         : Use existed traj file
  15. #     --mdinput=     : Set --input for xtb. Default is md.inp.
  16. #     --solvent=     : Set solvent for xtb. Default is water.
  17. #     --chrg=        : Set --chrg for xtb. Default is 0.
  18. #     --uhf=         : Set --uhf for xtb. Default is 0.
  19. #     --Nout=        : Set -Nout for isostat. Default is 10.
  20. #     --Eout=        : Set -Eout for isostat. Default is 2.4.
  21. #     --Edis=        : Set -Edis for isostat. Default is 0.5.
  22. #     --Gdis=        : Set -Gdis for isostat. Default is 0.5.
  23. #     --temp=        : Set temperature for isostat. Default is 298.15.
  24. #     --clean=       : Auto clean or not. 0: keep all files. 1: keep only the
  25. #                      final result of each step. 2: delete all intermediate files
  26. #     -1             : Skip step 1 (GFN0-xTB optimization).
  27. #     -2             : Skip step 2 (GFN2-xTB optimization).
  28. #     -3             : Skip step 3 (molclus).
  29. #     -h|--help      : Show this information.
复制代码
接下来这一部分是调用命令的设置,请根据自己的情况修改或加入环境变量(推荐后者,省时省力,一劳永逸)。
  1. # commands
  2. # change them or add to environment variables
  3. xtb=xtb
  4. crest=crest
  5. molclus=molclus
  6. isostat=isostat
复制代码
默认设置部分,除了cpu和mem以外不推荐直接修改。
  1. # default settings
  2. # not recommended to change this every time, please use the command line argument
  3. cpu=64              # cpu core
  4. mem=480GB           # memory
  5. omp_stacksize=4000m # memory for xtb
  6. inputTraj=0         # whether use existed traj file or not
  7. mdFile=md.inp       # md settings for xtb
  8. solvent=water       # solvent for xtb (step 2)
  9. chrg=0              # chrg for xtb
  10. uhf=0               # uhf for xtb
  11. Nout=10             # Nout for isostat
  12. Eout=2.4            # Eout for isostat
  13. Edis=0.5            # Edis for isostat
  14. Gdis=0.5            # Gdis for isostat
  15. temperature=298.15  # temperature for isostat
  16. clean=0             # auto clean after completed
  17. skip1=0             # skip step 1 (GFN0-xTB optimization)
  18. skip2=0             # skip step 2 (GFN2-xTB optimization)
  19. skip3=0             # skip step 3 (molclus)
复制代码
其他需要的变量,不要修改,否则可能出错。

  1. # other variables, DO NOT CHANGE!
  2. inputFile=""
  3. divideLine=$(printf '%.0s-' {1..80})
  4. spTemplate=""
复制代码
这一部分是输出帮助信息,因为可能会用到多次,所以写成一个function
  1. function printHelp {
  2.         printf "\n%s\n%42s\n%s\n" "$divideLine" "Help" "$divideLine"
  3.         printf "Usage: \n    %s\n\n" "consearch <options> input.xyz"
  4.         printf "Example: \n    %s\n" "consearch input.xyz"
  5.         printf "    %s\n" "consearch --traj --cpu 64 --mem 480GB traj.xyz"
  6.         printf "    %s\n\n" "consearch --solvent toluene input.xyz"
  7.         printf "Options:\n"
  8.         printf "    %-15s: %s\n" "--cpu=" "Set the number of cores used"
  9.         printf "    %-15s: %s\n" "--mem=" "Set the number of memery used. Unit is MB or GB."
  10.         printf "    %-15s: %s\n" "--traj" "Use existed traj file"
  11.         printf "    %-15s: %s\n" "--mdinput=" "Set --input for xtb. Default is md.inp."
  12.         printf "    %-15s: %s\n" "--solvent=" "Set solvent for xtb. Default is water."
  13.         printf "    %-15s: %s\n" "--chrg=" "Set --chrg for xtb. Default is 0."
  14.         printf "    %-15s: %s\n" "--uhf=" "Set --uhf for xtb. Default is 0."
  15.         printf "    %-15s: %s\n" "--Nout=" "Set -Nout for isostat. Default is 10."
  16.         printf "    %-15s: %s\n" "--Eout=" "Set -Eout for isostat. Default is 2.4."
  17.         printf "    %-15s: %s\n" "--Edis=" "Set -Edis for isostat. Default is 0.5."
  18.         printf "    %-15s: %s\n" "--Gdis=" "Set -Gdis for isostat. Default is 0.5."
  19.         printf "    %-15s: %s\n" "--temp=" "Set temperature for isostat. Default is 298.15."
  20.         printf "    %-15s: %s\n" "--clean=" "Auto clean or not. 0: keep all files. 1: keep only the"
  21.         printf "    %-15s  %s\n" "" "final result of each step. 2: delete all intermediate files"
  22.         printf "    %-15s: %s\n" "-1" "Skip step 1 (GFN0-xTB optimization)."
  23.         printf "    %-15s: %s\n" "-2" "Skip step 2 (GFN2-xTB optimization)."
  24.         printf "    %-15s: %s\n" "-3" "Skip step 3 (molclus)."
  25.         printf "    %-15s: %s\n" "-h|--help" "Show this information."
  26.         printf "\nAuthor: \n    %s\n\n" "Zihan Lin @ USTC"
  27. }
复制代码
主体部分,首先是解析命令行参数
  1. # handle options and parameters
  2. printf "\n%s\n%54s\n%s\n" "$divideLine" "Parse options and parameters" "$divideLine"
  3. options=$(getopt -q -l cpu:,mem:,traj,mdinput:,chrg:,uhf:,solvent:,Nout:,Eout:,Edis:,Gdis:,temp:,clean:,help h123 "$@")
  4. printf "command parameters: %s\n" "$options"
  5. eval set -- "$options"
  6. while [ -n "$1" ]; do
  7.         case "$1" in
  8.         --cpu)
  9.                 if [[ $2 =~ ^[1-9][0-9]*$ ]]; then
  10.                         cpu=$2
  11.                         printf "%-10s: %s\n" "--cpu" "use $2 core(s)"
  12.                 else
  13.                         printf "%-10s: %s\n" "--cpu" "invalid --cpu argument, this will be ignored"
  14.                 fi
  15.                 shift
  16.                 ;;
  17.         --mem)
  18.                 if [[ $2 =~ ^[1-9][0-9]*[mMgG][bB]?$ ]]; then
  19.                         mem=$2
  20.                         printf "%-10s: %s\n" "--mem" "use $2 memory"
  21.                 else
  22.                         printf "%-10s: %s\n" "--mem" "invalid --mem argument, this will be ignored"
  23.                 fi
  24.                 shift
  25.                 ;;
  26.         --traj) # use exists trajectory file
  27.                 printf "%-10s: %s\n" "--traj" "use exists trajectory file"
  28.                 inputTraj=1
  29.                 ;;
  30.         --mdinput) # set input for xtb
  31.                 if [ -n "$2" ]; then
  32.                         mdFile=$2
  33.                         if [ "$2" != "md.inp" ]; then
  34.                                 printf "%-10s: %s\n" "--mdinput" "use $2 instead of md.inp as xtb --input argument"
  35.                         fi
  36.                 else
  37.                         printf "%-10s: %s\n" "--mdinput" "invalid --mdinput argument, this will be ignored"
  38.                 fi
  39.                 shift
  40.                 ;;
  41.         --chrg) # set chrg for xtb
  42.                 if [[ $2 =~ ^[0-9]+$ ]]; then
  43.                         chrg=$2
  44.                         printf "%-10s: %s\n" "--chrg" "use $2 for xtb --chrg argument"
  45.                 else
  46.                         printf "%-10s: %s\n" "--chrg" "invalid --chrg argument, this will be ignored"
  47.                 fi
  48.                 shift
  49.                 ;;
  50.         --uhf) # set uhf for xtb
  51.                 if [[ $2 =~ ^[0-9]+$ ]]; then
  52.                         uhf=$2
  53.                         printf "%-10s: %s\n" "--uhf" "use $2 for xtb --uhf argument"
  54.                 else
  55.                         printf "%-10s: %s\n" "--uhf" "invalid --uhf argument, this will be ignored"
  56.                 fi
  57.                 shift
  58.                 ;;
  59.         --solvent) # set solvent for xtb
  60.                 solvent=$2
  61.                 if [ -n "$solvent" ]; then
  62.                         printf "%-10s: %s\n" "--solvent" "use $2 for xtb --input argument"
  63.                 else
  64.                         printf "%-10s: %s\n" "--solvent" "use gas phase"
  65.                 fi
  66.                 shift
  67.                 ;;
  68.         --Nout) # set Nout for isostat
  69.                 if [[ $2 =~ ^[0-9]+$ ]]; then
  70.                         Nout=$2
  71.                         printf "%-10s: %s\n" "--Nout" "use $2 for isostat -Nout argument"
  72.                 else
  73.                         printf "%-10s: %s\n" "--Nout" "invalid --Nout argument, this will be ignored"
  74.                 fi
  75.                 shift
  76.                 ;;
  77.         --Eout) # set Eout for isostat
  78.                 if [[ $2 =~ ^[0-9]+\.[0-9]+$ ]]; then
  79.                         Eout=$2
  80.                         printf "%-10s: %s\n" "--Eout" "use $2 for isostat -Eout argument"
  81.                 else
  82.                         printf "%-10s: %s\n" "--Eout" "invalid --Eout argument, this will be ignored"
  83.                 fi
  84.                 shift
  85.                 ;;
  86.         --Edis) # set Edis for isostat
  87.                 if [[ $2 =~ ^[0-9]+\.[0-9]+$ ]]; then
  88.                         Edis=$2
  89.                         printf "%-10s: %s\n" "--Edis" "use $2 for isostat -Edis argument"
  90.                 else
  91.                         printf "%-10s: %s\n" "--Edis" "invalid --Edis argument, this will be ignored"
  92.                 fi
  93.                 shift
  94.                 ;;
  95.         --Gdis) # set Gdis for isostat
  96.                 if [[ $2 =~ ^[0-9]+\.[0-9]+$ ]]; then
  97.                         Gdis=$2
  98.                         printf "%-10s: %s\n" "--Gdis" "use $2 for isostat -Gdis argument"
  99.                 else
  100.                         printf "%-10s: %s\n" "--Gdis" "invalid --Gdis argument, this will be ignored"
  101.                 fi
  102.                 shift
  103.                 ;;
  104.         --temp) # set temperature for isostat
  105.                 if [[ $2 =~ ^[0-9]+\.[0-9]+$ ]]; then
  106.                         temperature=$2
  107.                         printf "%-10s: %s\n" "--temp" "use $2 for isostat -T argument"
  108.                 else
  109.                         printf "%-10s: %s\n" "--temp" "invalid --temp argument, this will be ignored"
  110.                 fi
  111.                 shift
  112.                 ;;
  113.         --clean) # auto clean
  114.                 if [[ $2 =~ ^[0-2]$ ]]; then
  115.                         clean=$2
  116.                         case $clean in
  117.                         0)
  118.                                 printf "%-10s: %s\n" "--clean" "keep all files"
  119.                                 ;;
  120.                         1)
  121.                                 printf "%-10s: %s\n" "--clean" "keep only the final result of each step"
  122.                                 ;;
  123.                         2)
  124.                                 printf "%-10s: %s\n" "--clean" "delete all intermediate files"
  125.                                 ;;
  126.                         esac
  127.                 else
  128.                         printf "%-10s: %s\n" "--clean" "invalid --clean argument, this will be ignored"
  129.                 fi
  130.                 shift
  131.                 ;;
  132.         --)
  133.                 shift
  134.                 break
  135.                 ;;
  136.         --help)
  137.                 printHelp
  138.                 exit 0
  139.                 ;;
  140.         -h)
  141.                 printHelp
  142.                 exit 0
  143.                 ;;
  144.         -1)
  145.                 skip1=1
  146.                 printf "%-10s: %s\n" "-1" "skip step 1 (GFN0-xTB optimization)"
  147.                 ;;
  148.         -2)
  149.                 skip2=1
  150.                 printf "%-10s: %s\n" "-2" "skip step 2 (GFN2-xTB optimization)"
  151.                 ;;
  152.         -3)
  153.                 skip3=1
  154.                 printf "%-10s: %s\n" "-3" "skip step 3 (molclus)"
  155.                 ;;
  156.         *)
  157.                 echo "$1 is not an option"
  158.                 ;;
  159.         esac
  160.         shift
  161. done
复制代码
接下来根据不同的选项情况,检查文件是否都已提供

  1. # check if all files provided
  2. printf "\n%s\n%45s\n%s\n" "$divideLine" "Check files" "$divideLine"
  3. allFilesProvided=1

  4. if [ -f "$1" ]; then
  5.         inputFile="$1"
  6.         printf "%-30s: found %s\n" "Input file" "$1"
  7. else
  8.         printHelp
  9.         exit 1
  10. fi
  11. if [ $inputTraj -ne 1 ]; then
  12.         # if md settings file not exists, input and save to md.inp or specified file
  13.         if [ ! -e "$mdFile" ]; then
  14.                 check=N
  15.                 until [[ "$check" == [Yy] ]]; do
  16.                         echo "Please provide the following parameters:"
  17.                         read -r -p "Temperature (K): " temp
  18.                         read -r -p "Total simulation time (ps): " time
  19.                         read -r -p "Dump frequency (fs): " dump
  20.                         read -r -p "Step size (fs): " step
  21.                         cat >"$mdFile" <<-EOF
  22.                                 \$md
  23.                                     temp=$temp
  24.                                     time=$time
  25.                                     dump=$dump
  26.                                     step=$step
  27.                                     hmass=1
  28.                                     shake=1
  29.                                 \$end
  30.                         EOF
  31.                         printf "%s\n" "$divideLine"
  32.                         read -r -p "Is ok? (Y/N) " check
  33.                 done
  34.                 printf "%s\n" "$divideLine"
  35.         fi
  36.         printf "%-30s: found %s\n" "MD settings" "$mdFile"
  37. fi
  38. if [ $skip3 -ne 1 ]; then
  39.         # check if settings.ini is provided
  40.         printf "%-30s: " "Molclus settings"
  41.         if [ -f "settings.ini" ]; then
  42.                 printf "found settings.ini\n"
  43.         else
  44.                 printf "missing\n"
  45.                 allFilesProvided=0
  46.         fi
  47.         # check if template.gjf is provided
  48.         printf "%-30s: " "Molclus template"
  49.         if [ -f "template.gjf" ]; then
  50.                 printf "found template.gjf\n"
  51.                 if [ -e template2.gjf ]; then
  52.                         printf "%-30s: found template2.gjf" "Molclus template2"
  53.                 fi
  54.         else
  55.                 printf "missing\n"
  56.                 allFilesProvided=0
  57.         fi
  58.         # check if template_SP.inp or template_SP.gjf is provided
  59.         printf "%-30s: " "Molclus template_SP"
  60.         if [ -f "template_SP.inp" ]; then
  61.                 printf "found template_SP.inp\n"
  62.                 spTemplate=template_SP.inp
  63.         elif [ -f "template_SP.gjf" ]; then
  64.                 printf "found template_SP.gjf\n"
  65.                 spTemplate=template_SP.gjf
  66.         else
  67.                 printf "missing\n"
  68.                 spTemplate=""
  69.                 check=N
  70.                 read -r -p "Warning: Single point energy is not calculated. Continue? (Y/N) " check
  71.                 if [[ "$check" != [Yy] ]]; then
  72.                         allFilesProvided=0
  73.                 fi
  74.         fi
  75. fi
  76. if [ $allFilesProvided -eq 0 ]; then
  77.         printf "\nMissing file(s). Aborted.\n"
  78.         exit 1
  79. else
  80.         echo "All files provided. Submit to slurm."
  81. fi
复制代码
提交部分,通过here document给sbatch提供运行脚本,一直到最后的EOF。此处设置了任务资源以及输出重定向到consearch.log和xtb需要的export。
  1. # submit to slurm
  2. sbatch <<EOF
  3. #!/bin/bash
  4. #SBATCH -J "consearch"
  5. #SBATCH -n $cpu
  6. #SBATCH --mem $mem

  7. # save to consearch.log
  8. exec 1>consearch.log

  9. export OMP_NUM_THREADS=$cpu # CPU cores for xtb
  10. export MKL_NUM_THREADS=$cpu # CPU cores for xtb
  11. export OMP_STACKSIZE=$omp_stacksize # memory for xtb
复制代码
检查命令是否都可用,如果否,中止并报错。

  1. # check commands are available
  2. printf "\n%s\n%47s\n%s\n" "$divideLine" "Check Commands" "$divideLine"
  3. commandsUnavailable=0
  4. commands=("$xtb" "$crest" "$molclus" "$isostat")
  5. for cmd in "\${commands[@]}"; do
  6.         if ! command -v "\$cmd" &>/dev/null; then
  7.                 printf "Check %-15s: Unavailable\n" "\$cmd"
  8.                 commandsUnavailable=$((commandsUnavailable + 1))
  9.         else
  10.                 printf "Check %-15s: OK\n" "\$cmd"
  11.         fi
  12. done
  13. if [ \$commandsUnavailable -gt 0 ]; then
  14.         printf "\n%s\n" "$divideLine"
  15.         printf "Aborted because %d command(s) are not available, please check if environment variables have been added\n" \$commandsUnavailable
  16.         exit 1
  17. else
  18.         printf "All commands are available. Begin conformation search.\n"
  19. fi
复制代码
如果没有使用--traj选项,则调用xtb跑动力学,否则直接使用输入的轨迹文件
  1. # if trajectory is not provided, generate it by xtb
  2. printf "\n%s\n%50s\n%s\n" "$divideLine" "Trajectory generation" "$divideLine"
  3. if [ $inputTraj -ne 1 ]; then
  4.         mkdir -p 00
  5.         cp -f $mdFile 00/
  6.         cp -f \$inputFile 00/
  7.         cd 00
  8.         $xtb \$inputFile --input "$mdFile" --omd --gfn 0 -P $cpu
  9.         wait
  10.         cd ..
  11.         cp -f 00/xtb.trj 00result.xyz
  12.         inputFile=00result.xyz
  13.         echo "Final result is 00result.xyz"
  14. else
  15.         echo "Trajectory file profided."
  16.         inputFile=\$inputFile
  17. fi
复制代码
在没有-1选项时,通过crest跑GFN0-xtb优化
  1. # step 1: use crest to optimize under GFN0-xTB
  2. if [ $skip1 -ne 1 ];then
  3.         printf "\n%s\n%50s\n%s\n" "$divideLine" "GFN0-xTB Optimization" "$divideLine"
  4.         mkdir -p 01
  5.         cp -f \$inputFile 01/traj.xyz
  6.         cd 01
  7.         $crest -mdopt traj.xyz -chrg $chrg -uhf $uhf -gfn 0 -opt normal -T $cpu
  8.         wait
  9.         $isostat crest_ensemble.xyz -Edis $Edis -Gdis $Gdis -nt $cpu -T $temperature
  10.         wait
  11.         cd ..
  12.         cp -f 01/cluster.xyz 01result.xyz
  13.         inputFile=01result.xyz
  14.         copy -f 01result.xyz final.xyz
  15.         echo "Final result is 01result.xyz"
  16. fi
复制代码
在没有-2选项时,通过crest跑GFN2-xtb优化
  1. # step 2: use crest to optimize under GFN2-xTB
  2. if [ $skip2 -ne 1 ];then
  3.         printf "\n%s\n%50s\n%s\n" "$divideLine" "GFN2-xTB Optimization" "$divideLine"
  4.         mkdir -p 02
  5.         cp -f \$inputFile 02/traj.xyz
  6.         cd 02
  7.         if [ -n $solvent ];then
  8.                 $crest -mdopt traj.xyz -chrg $chrg -uhf $uhf -gfn 2 -opt normal --gbsa $solvent -T $cpu
  9.         else
  10.                 $crest -mdopt traj.xyz -chrg $chrg -uhf $uhf -gfn 2 -opt normal -T $cpu
复制代码
在没有-3选项时,调用molclus
  1. # step 3 use molclus with Gaussian to optimize and calculate energy
  2. if [ $skip3 -ne 1 ];then
  3.         printf "\n%s\n%43s\n%s\n" "$divideLine" "Molclus" "$divideLine"
  4.         mkdir -p 03
  5.         cp -f \$inputFile 03/03traj.xyz
  6.         cp -f settings.ini 03/
  7.         cp -f template.gjf 03/
  8.         if [ -e template2.gjf ];then
  9.                 cp -f template2.gjf 03/
  10.         fi
  11.         if [ -n $spTemplate ];then
  12.                 cp -f $spTemplate 03/
  13.         fi
  14.         cd 03
  15.         $molclus settings.ini 03traj.xyz
  16.         wait
  17.         $isostat isomers.xyz -Nout $Nout -Eout $Eout -Edis $Edis -Gdis $Gdis -nt $cpu -T $temperature
  18.         wait
  19.         cd ..
  20.         cp -f 03/cluster.xyz final.xyz
  21.         echo "Final result is final.xyz"
  22. fi
复制代码
最后根据--clean选项的参数自动清理。最后一行EOF结束here document,完成sbatch命令。

  1. # auto clean
  2. folders=("00" "01" "02" "03")
  3. files=("00result.xyz" "01result.xyz" "02result.xyz")
  4. if [ $clean -ge 1 ]; then
  5.         # delete intermediate file
  6.         for folder in "\${folders[@]}"; do
  7.                 if [ -d "\$folder" ]; then
  8.                         rm -rf "\$folder"
  9.                 fi
  10.         done
  11. fi
  12. if [ $clean -ge 2 ]; then
  13.         # also delete results of each step
  14.         for file in "\${files[@]}"; do
  15.                 if [ -f "\$file" ]; then
  16.                         rm "\$file"
  17.                 fi
  18.         done
  19. fi
  20. EOF
复制代码

consearch

13.53 KB, 下载次数 Times of downloads: 114

consearch:一键提交slurm的molclus构象搜索脚本

评分 Rate

参与人数
Participants 13
威望 +2 eV +53 收起 理由
Reason
Keys + 5
liangt + 4
hang + 4 牛!
shuiningzhu + 4 好物!
小可几何 + 2 好物!
fubai + 5 好物!
wugaxp + 5 好物!
chuanghao + 5 赞!
CalmHarris + 4 GJ!
sobereva + 2
lonemen + 5 好物!
zsu007 + 5 赞!
hdhxx123 + 5 好物!

查看全部评分 View all ratings

41

帖子

0

威望

317

eV
积分
358

Level 3 能力者

2#
发表于 Post on 2025-1-22 23:34:46 | 只看该作者 Only view this author
一键提交slurm的启动molclus调用高斯计算的脚本是什么?

45

帖子

4

威望

1082

eV
积分
1207

Level 4 (黑子)

3#
 楼主 Author| 发表于 Post on 2025-2-10 15:49:27 | 只看该作者 Only view this author
qcn1211 发表于 2025-1-22 23:34
一键提交slurm的启动molclus调用高斯计算的脚本是什么?

molclus settings.ini 03traj.xyz

3

帖子

0

威望

115

eV
积分
118

Level 2 能力者

4#
发表于 Post on 2025-4-1 15:53:16 | 只看该作者 Only view this author
您好,我按照您给的方法提交后有这样的报错:
sbatch: error: Memory specification can not be satisfied
sbatch: error: Batch job submission failed: Requested node configuration is not available
这个是我哪里操作出问题了吗,谢谢您的回复。

consearch2.sh

669 Bytes, 下载次数 Times of downloads: 8

sub82.sh

624 Bytes, 下载次数 Times of downloads: 6

3

帖子

0

威望

115

eV
积分
118

Level 2 能力者

5#
发表于 Post on 2025-4-3 22:07:07 | 只看该作者 Only view this author
BGR_DUT 发表于 2025-4-1 15:53
您好,我按照您给的方法提交后有这样的报错:
sbatch: error: Memory specification can not be satisfied ...

问题已解决

13

帖子

0

威望

285

eV
积分
298

Level 3 能力者

6#
发表于 Post on 2025-7-28 17:07:57 | 只看该作者 Only view this author
本帖最后由 Keys 于 2025-7-28 17:24 编辑

一、文中此处
跳过第二步 (GFN0-xTB优化)。此时输入文件将直接提供给后面步骤。

应该是笔误?应该是调用GFN2-xTB优化吧?
二、分享一下我经过2天的调试,使用脚本的时候,出现过的以下报错情况及我自己的解决方法:
1.请求服务器的内存和节点失败(4楼的报错):要在# submit to slurm这一段落下添加有关于服务器节点的相关信息,更加方便的做法是直接复制自己原本提交的job文件除了“-n”“-mem”“-J“选项以外的#sbatch设置项。
2.copy:command not found:将脚本文件中的2个“copy”改为“cp”即可。
三、经过上述修改后脚本可以在服务器上正常输出0,01,02文件夹,无其余修改
但是在输出03时候文件夹的时候就会因为如下报错终止作业任务,至今尚未解决。下附consearch.log文件是运行“consearch --traj -1 -2 03traj.xyz”产生的
/var/spool/slurm/d/job265439/slurm_script: line 20: /g16/bsd/g16.profile: No such file or directory
sh: g16: command not found
forrtl: severe (24): end-of-file during read, unit -4, file /proc/48777/fd/0
Image              PC                Routine            Line        Source            
molclus            000000000041DBEB  Unknown               Unknown  Unknown
molclus            0000000000449368  Unknown               Unknown  Unknown
molclus            00000000004125E8  Unknown               Unknown  Unknown
molclus            000000000040EF94  Unknown               Unknown  Unknown
molclus            0000000000404422  Unknown               Unknown  Unknown
libc-2.17.so       00002ADEF3199555  __libc_start_main     Unknown  Unknown
molclus            0000000000404329  Unknown               Unknown  Unknown
forrtl: severe (24): end-of-file during read, unit 10, file /home-yx/users/nsyx_wxf/D/lk/consearchlab/03/isomers.xyz
Image              PC                Routine            Line        Source            
isostat            000000000041DEAB  Unknown               Unknown  Unknown
isostat            00000000004496E8  Unknown               Unknown  Unknown
isostat            00000000004134FA  Unknown               Unknown  Unknown
isostat            0000000000412D22  Unknown               Unknown  Unknown
libc-2.17.so       00002B5206C37555  __libc_start_main     Unknown  Unknown
isostat            0000000000412C29  Unknown               Unknown  Unknown
cp: cannot stat '03/cluster.xyz': No such file or directory

consearch.log

2.71 KB, 下载次数 Times of downloads: 0

好好学习,天天向上

本版积分规则 Credits rule

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

GMT+8, 2025-8-12 17:42 , Processed in 0.185741 second(s), 24 queries , Gzip On.

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