CP2K学习记录-(如何选择合适的CUTOFF, REL_CUTOFF)

简单的了解一下概念就行。

QUICKSTEP需要使用多网格系统将乘积高斯函数映射到real-space(RS)网格上,关键词“CUTOFF”定义平面波cutoff, 平面波cutoff值越高,对应的网格越精细。关键词“REL_CUTOFF”控制乘积高斯函数映射到不同级别的多网格。综上所述,“CUTOFF”, “REL_CUTOFF”影响积分网络和计算的准确性。如果“CUTOFF”太低,所有的多网格将会变得粗糙并且不准确。如果“REL_CUTOFF”太低,即使具有高的“CUTOFF”, 所有高斯将会映射到多网格的最粗糙的部分,因此有效积分过少也会导致计算的不准确。

(上面一堆话,总结出来就是要找到合适的“CUTOFF”和“REL_CUTOFF”来保障计算的准确性,具体做法如下)

第一步,“REL_CUTOFF”设置为60Ry, 然后动态变化“CUTOFF”,确定合适的“CUTOFF”。(控制变量法)

生成输入文件的脚本:cutoff_inputs.sh (需要将其权限设置为可执行, chmod u+x ./cutoff_inputs.sh)

#!/bin/bash

cutoffs="50 100 150 200 250 300 350 400 450 500"

basis_file=BASIS_SET
potential_file=BASIS_SET
template_file=template.inp
input_file=Si_bulk8.inp

rel_cutoff=60

for ii in $cutoffs ; do
    work_dir=cutoff_${ii}Ry
    if [ ! -d $work_dir ] ; then
        mkdir $work_dir
    else
        rm -r $work_dir/*
    fi
    sed -e "s/LT_rel_cutoff/${rel_cutoff}/g" \ 
        -e "s/LT_cutoff/${ii}/g" \
        $template_file > $work_dir/$input_file
    cp $basis_file $work_dir
    cp $potential_file $work_dir
done

运行它们的脚本:cutoff_run.sh(chmod u+x ./cutoff_run.sh)

#!/bin/bash

cutoffs="50 100 150 200 250 300 350 400 450 500"

cp2k_bin=cp2k.popt #系统的编译的cp2k程序,文件路径
input_file=Si_bulk8.inp
output_file=Si_bulk8.out
no_proc_per_calc=2 #设置用MPI过程中并行运算的核数
no_proc_to_use=16 #设置总的处理器的数量, 8个任务可以进行,每个任务分配2个核

counter=1
max_parallel_calcs=$(expr $no_proc_to_use / $no_proc_per_calc)
for ii in $cutoffs ; do
    work_dir=cutoff_${ii}Ry
    cd $work_dir
    if [ -f $output_file ] ; then
        rm $output_file
    fi
    mpirun -np $no_proc_per_calc $cp2k_bin -o $output_file $input_file &
    cd ..
    mod_test=$(echo "$counter % $max_parallel_calcs" | bc)
    if [ $mod_test -eq 0 ] ; then
        wait
    fi
    counter=$(expr $counter + 1)
done
wait
#输出文件中的[a.u.]意味着Hartree能量单位,1 Ha = 2 Ry


把生成的文件夹中的将所有能量都提取出来:cutoff_analyse.sh (chmod u+x ./cutoff_analyse.sh)zuih

#!/bin/bash

cutoffs="50 100 150 200 250 300 350 400 450 500"

input_file=Si_bulk8.inp
output_file=Si_bulk8.out
plot_file=cutoff_data.ssv

rel_cutoff=60

echo "# Grid cutoff vs total energy" > $plot_file
echo "# Date: $(date)" >> $plot_file
echo "# PWD: $PWD" >> $plot_file
echo "# REL_CUTOFF = $rel_cutoff" >> $plot_file
echo -n "# Cutoff (Ry) | Total Energy (Ha)" >> $plot_file
grid_header=true
for ii in $cutoffs ; do
    work_dir=cutoff_${ii}Ry
    total_energy=$(grep -e '^[ \t]*Total energy' $work_dir/$output_file | awk '{print $3}')
    ngrids=$(grep -e '^[ \t]*QS| Number of grid levels:' $work_dir/$output_file | \
             awk '{print $6}')
    if $grid_header ; then
        for ((igrid=1; igrid <= ngrids; igrid++)) ; do
            printf " | NG on grid %d" $igrid >> $plot_file
        done
        printf "\n" >> $plot_file
        grid_header=false
    fi
    printf "%10.2f  %15.10f" $ii $total_energy >> $plot_file
    for ((igrid=1; igrid <= ngrids; igrid++)) ; do
        grid=$(grep -e '^[ \t]*count for grid' $work_dir/$output_file | \
               awk -v igrid=$igrid '(NR == igrid){print $5}')
        printf "  %6d" $grid >> $plot_file
    done
    printf "\n" >> $plot_file
done

最后根据输出结果:筛选出合适的cutoff值。 

第二步,固定cutoff为250Ry, 动态变化REL_CUTOFF(和上述步骤一样)REL_CUTOFF越大高斯函数就会越多的分布在精细的网格上面

最后得出结论,

&MGRID

        CUTOFF 250

        REL_CUTOFF 60

&END MGRID

计算能够达到所要求的的精度。

总结,对于其他的计算每次都应当需要确定系统的“CUTOFF”和“REL_CUTOFF”,来达到后续计算的精度要求。

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

小朱朱荣咿呀咿呀

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值