xiaoqiugood的个人博客分享 http://blog.sciencenet.cn/u/xiaoqiugood

博文

结构优化与插值:SED命令使用等

已有 6348 次阅读 2014-10-11 18:00 |个人分类:结构优化|系统分类:科研笔记

关注:

   1) 虚频处理及其他;

   2) 结构优化

   3)通过NEB是一种好方式

 

注意nebmake.pl  必须在解压后的vtstscripts-894下使用

../nebmake.pl  cont_3500-01 CONTCAR_3500-04 10
Can't locate Vasp.pm in @INC (@INC contains: /data/hoffmann/xy83/work/strucSearch/optimization/done-opt/schx-opt/sch-300G-2f-58_63-opt250G-cmcm/barri /usr/local/lib64/perl5 /usr/local/share/perl5 /usr/lib64/perl5/vendor_perl /usr/share/perl5/vendor_perl /usr/lib64/perl5 /usr/share/perl5 .) at ../nebmake.pl line 8.
BEGIN failed--compilation aborted at ../nebmake.pl line 8.
[xy83@hoffmann-warewulf 3500]$ ../../vtstscripts-894/nebmake.pl cont_3500-01 CONTCAR_3500-04  10
filetype1: vasp4
filetype2: vasp4
WARNING: BASIS VECTORS ARE NOT THE SAME
BASIS ELEMENT 0 0 ...
... IS IN FILE 1:  3.35348979556186

... IS IN FILE 2:  3.39169712662629

I HOPE YOU KNOW WHAT YOU ARE DOING

OK, ALL SETUP HERE
FOR LATER ANALYSIS, PUT OUTCARs IN FOLDERS 00 and 11 !!!

在相转变过程中,NEB插值不仅仅改变的是原子坐标,还改变了晶格常数:

 cat  00/POSCAR

sch-300G-2f-58_63-opt250G-cmcm          
  1.00000000000000    
  3.3002831160173800   0.0000000000000000   0.0000000000000000
  0.0000000000000000   3.3002956639159100  -0.0000000000090908
  0.0000000000000000  -0.0000000000090786   3.3002484283393301
4  4  
Direct
 0.0000000000000000  0.7500223561929740  0.2500000000000000  
 0.0000000000000000  0.2499776438070260  0.7500000000000000  
 0.5000000000000000  0.2500223561929740  0.2500000000000000  
 0.5000000000000000  0.7499776438070260  0.7500000000000000  
 0.5000000000000000  0.7500184339853838  0.2500000000000000  
 0.5000000000000000  0.2499815660146233  0.7500000000000000  
 0.0000000000000000  0.2500184339853767  0.2500000000000000  
 0.0000000000000000  0.7499815660146162  0.7500000000000000  
 
 
 
 
   cat  01/POSCAR
sch-300G-2f-58_63-opt250G-cmcm          
1
  3.3030911362626600   0.0000000000000000   0.0000000000000000
  0.0000000000000000   3.3242584027687800  -0.0000000000082644
  0.0000000000000000  -0.0000000000082533   3.2699862517846698  【这是一种什么插值方法?】
4  4  
Direct
 0.0000000000000000  0.7606943774479580  0.2500000000000000  
 0.0000000000000000  0.2393056225520420  0.7500000000000000  
 0.5000000000000000  0.2606943774479580  0.2500000000000000  
 0.5000000000000000  0.7393056225520420  0.7500000000000000  
 0.5000000000000000  0.7562141529115850  0.2500000000000000  
 0.5000000000000000  0.2437858470884210  0.7500000000000000  
 0.0000000000000000  0.2562141529115790  0.2500000000000000  
 0.0000000000000000  0.7437858470884150  0.7500000000000000  
 ........
 
 
     cat  02/POSCAR
sch-300G-2f-58_63-opt250G-cmcm          
1
  3.3058991565079401   0.0000000000000000   0.0000000000000000
  0.0000000000000000   3.3482211416216598  -0.0000000000074379
  0.0000000000000000  -0.0000000000074279   3.2397240752300100
4  4  
Direct
 0.0000000000000000  0.7713663987029410  0.2500000000000000  
 0.0000000000000000  0.2286336012970590  0.7500000000000000  
 0.5000000000000000  0.2713663987029410  0.2500000000000000  
 0.5000000000000000  0.7286336012970590  0.7500000000000000  
 0.5000000000000000  0.7624098718377870  0.2500000000000000  
 0.5000000000000000  0.2375901281622190  0.7500000000000000  
 0.0000000000000000  0.2624098718377810  0.2500000000000000  
 0.0000000000000000  0.7375901281622130  0.7500000000000000  
 
..........
 cat  10/POSCAR
sch-300G-2f-58_63-opt250G-cmcm          
1
  3.3283633184701502   0.0000000000000000   0.0000000000000000
  0.0000000000000000   3.5399230524446499  -0.0000000000008263
  0.0000000000000000  -0.0000000000008252   2.9976266627927699
4  4  
Direct
 0.0000000000000000  0.8567425687428100  0.2500000000000000  
 0.0000000000000000  0.1432574312571910  0.7500000000000000  
 0.5000000000000000  0.3567425687428100  0.2500000000000000  
 0.5000000000000000  0.6432574312571900  0.7500000000000000  
 0.5000000000000000  0.8119756232473980  0.2500000000000000  
 0.5000000000000000  0.1880243767526030  0.7500000000000000  
 0.0000000000000000  0.3119756232473970  0.2500000000000000  
 0.0000000000000000  0.6880243767526020  0.7500000000000000
 
cat  11/POSCAR
sch-300G-2f-58_63-opt250G-cmcm          
  1.00000000000000    
  3.3311713387154200   0.0000000000000000   0.0000000000000000
  0.0000000000000000   3.5638857912975199   0.0000000000000001
  0.0000000000000000   0.0000000000000001   2.9673644862381101
4  4  
Direct
 0.0000000000000000  0.8674145899977930  0.2500000000000000  
 0.0000000000000000  0.1325854100022070  0.7500000000000000  
 0.5000000000000000  0.3674145899977930  0.2500000000000000  
 0.5000000000000000  0.6325854100022070  0.7500000000000000  
 0.5000000000000000  0.8181713421735992  0.2500000000000000  
 0.5000000000000000  0.1818286578264008  0.7500000000000000  
 0.0000000000000000  0.3181713421735992  0.2500000000000000  
 0.0000000000000000  0.6818286578264008  0.7500000000000000

 

 

 

通信摘录:

 

 

问题:

> Comments from Roald,
>
> "the Cmcm structure looks to me like a distorted rock salt structure. If so, this needs to be said you need to say that. Moreover its enthalpy is so close to rocksalt structure (old fig4, diamond and dotted lines)which makes me think there is a flat surface between the two structures.
>
> Do you have phonons of the two structures at two pressures -- say 1 atm and 100GPa? At two pressures, can you Take the two structures, and run a linear transit between them, i.e interpolating distances in a series of single-point calculations.

解决方案:

Thanks must be given to Andreas,

 

I think I know what Roald is talking about. Your Cmcm structure looks like every second plane of atoms (in the a-b plane) is shifted along the b axis, compared to the ideal rock salt structure.

      I have attached a CIF file where I shifted (within Cmcm symmetry) the Sc and H atoms such that they now form a rocksalt lattice.

          The distortion is small, atomic positions going from 0.75 (rock salt) to 0.817 or 0.853 for Cmcm. To do a linear interpolation, you need both structures in comparable unit cells. If you create VASP POSCAR’s from both your Cmcm-CIF and my modified CIF, you will have those.

 

 

These are your starting and end points. You then create a series of POSCAR’s with linear interpolation between those two structures, both for lattice vectors and atomic positions.

 

 

I have attached a primitive script I use for this purpose: edit the file names of your POSCAR files and the number of desired images, and you are good to go.

 

 

Then do a single-point calculation for each structure, and plot enthalpy as function of distortion.

【at which pressure?】

 

This will give you the potential energy surface. You may want to edit the rock salt lattice constants (in the Cmcm representation), because rock salt and Cmcm will surely have different volumes at the same pressure. 

 

Indeed, instead of single-point calculations, you can optimize【at which pressure?】 the unit cell volume for each structure (keeping atomic positions and cell shape constant), 【ISIF=7? 】that will give you a better potential energy surface.

 


Hope that helps, let me know if you have any questions or further problems. I promise I won’t take that long to reply again. ;)
 

Very best wishes,

 

 

 

In addition ISIF determines which degrees of freedom  (ions, cell volume, cell shape) are allowed to change.

The following table shows the meaning of ISIF.  At the moment cell changes are only supported for  relaxations and nor fot molecular dynamics simulations.

ISIFcalculatecalculaterelaxchangechange
 forcestress tensorionscell shapecell volume
0yesnoyesnono
1yestrace only $ ^*$yesnono
2yesyesyesnono
3yesyesyesyesyes
4yesyesyesyesno
5yesyesnoyesno
6yesyesnoyesyes
7yesyesnonoyes

$ ^*$ Trace only means that only the total pressure, i.e. the line

 

 

 

 

 

插值脚本:

 

#!/bin/bash

# Number of interpolated images

NINTERP=24

 

# Number of atoms in unit cell
NATOMS=4


# First frame:
POS1=CONTCAR-I41amd.vasp


# Final frame:
POS2=CONTCAR-C2m.vasp

 

# Pattern for interpolated file names (will be $POSINT$image.vasp):
POSINT=CONTCAR-step

A0X=`sed -n "3p" $POS1 | awk '{print $1}'`
A0Y=`sed -n "3p" $POS1 | awk '{print $2}'`
A0Z=`sed -n "3p" $POS1 | awk '{print $3}'`
B0X=`sed -n "4p" $POS1 | awk '{print $1}'`
B0Y=`sed -n "4p" $POS1 | awk '{print $2}'`
B0Z=`sed -n "4p" $POS1 | awk '{print $3}'`
C0X=`sed -n "5p" $POS1 | awk '{print $1}'`
C0Y=`sed -n "5p" $POS1 | awk '{print $2}'`
C0Z=`sed -n "5p" $POS1 | awk '{print $3}'`

 

for im in $(jot $((NINTERP+1)) 0 $NINTERP); do

sed -n "1,2p" $POS2 > $POSINT$im.vasp


sed -n "3p" $POS2 | awk -v ax=$A0X -v ay=$A0Y -v az=$A0Z -v im=$im -v nim=$NINTERP '{print ($1*im+ax*(nim-im))/nim,($2*im+ay*(nim-im))/nim,($3*im+az*(nim-im))/nim}' >> $POSINT$im.vasp
sed -n "4p" $POS2 | awk -v ax=$B0X -v ay=$B0Y -v az=$B0Z -v im=$im -v nim=$NINTERP '{print ($1*im+ax*(nim-im))/nim,($2*im+ay*(nim-im))/nim,($3*im+az*(nim-im))/nim}' >> $POSINT$im.vasp
sed -n "5p" $POS2 | awk -v ax=$C0X -v ay=$C0Y -v az=$C0Z -v im=$im -v nim=$NINTERP '{print ($1*im+ax*(nim-im))/nim,($2*im+ay*(nim-im))/nim,($3*im+az*(nim-im))/nim}' >> $POSINT$im.vasp
sed -n "6,7p" $POS2 >> $POSINT$im.vasp
#echo "Selective Dynamics" >> $POSINT$im.vasp
echo "Direct" >> $POSINT$im.vasp

done

for at in $(jot $NATOMS 9 $(( NATOMS + 8 )) ); do

AT0X=`sed -n "$at p" $POS1 | awk '{print $1}'`
AT0Y=`sed -n "$at p" $POS1 | awk '{print $2}'`
AT0Z=`sed -n "$at p" $POS1 | awk '{print $3}'`

for im in $(jot $NINTERP 1 $NINTERP); do

#sed -n "$at p" $POS2 | awk -v ax=$AT0X -v ay=$AT0Y -v az=$AT0Z -v im=$im -v nim=$NINTERP '{print ($1*im+ax*(nim-im))/nim,($2*im+ay*(nim-im))/nim,($3*im+az*(nim-im))/nim, " F F F"}' >> $POSINT$im.vasp
sed -n "$at p" $POS2 | awk -v ax=$AT0X -v ay=$AT0Y -v az=$AT0Z -v im=$im -v nim=$NINTERP '{print ($1*im+ax*(nim-im))/nim,($2*im+ay*(nim-im))/nim,($3*im+az*(nim-im))/nim}' >> $POSINT$im.vasp


done
done

 

SED命令使用摘录:

 

 sed [-nefri] ‘command’ 输入文本        

常用选项:
       
-n∶使用安静(silent)模式。在一般 sed 的用法中,所有来自 STDIN的资料一般都会被列出到萤幕上。但如果加上 -n 参数后,则只有经过sed 特殊处理的那一行(或者动作)才会被列出来。
       -e∶直接在指令列模式上进行 sed 的动作编辑;
       -f∶直接将 sed 的动作写在一个档案内, -f filename 则可以执行 filename 内的sed 动作;
       -r∶sed 的动作支援的是延伸型正规表示法的语法。(预设是基础正规表示法语法)
       -i∶直接修改读取的档案内容,而不是由萤幕输出。
     

常用命令:
      a   ∶新增, a 的后面可以接字串,而这些字串会在新的一行出现(目前的下一行)~
       c   ∶取代, c 的后面可以接字串,这些字串可以取代 n1,n2 之间的行!
     
 d   ∶删除,因为是删除啊,所以 d 后面通常不接任何咚咚;
        i   ∶插入, i 的后面可以接字串,而这些字串会在新的一行出现(目前的上一行);
 
      p  ∶列印,亦即将某个选择的资料印出。通常 p 会与参数 sed -n 一起运作~
        s  ∶取代,可以直接进行取代的工作哩!通常这个 s 的动作可以搭配正规表示法!例如 1,20s/old/new/g 就是啦!

举例:(假设我们有一文件名为ab)
    删除某行
    [root@localhost ruby] # sed '1d' ab              #删除第一行
    [root@localhost ruby] # sed '$d' ab              #删除最后一行
    [root@localhost ruby] # sed '1,2d' ab           #删除第一行到第二行
    [root@localhost ruby] # sed '2,$d' ab           #删除第二行到最后一行

  显示某行
.    [root@localhost ruby] # sed -n '1p' ab           #显示第一行
    [root@localhost ruby] # sed -n '$p' ab           #显示最后一行
    [root@localhost ruby] # sed -n '1,2p' ab        #显示第一行到第二行
    [root@localhost ruby] # sed -n '2,$p' ab        #显示第二行到最后一行

 

2. AWK命令

 

 

awk :对于文件中一行行的独处来执行操作 。

awk -F :'{print $1,$4}'   :使用‘:’来分割这一行,把这一行的第一第四个域打印出来 。

1.命令行方式

awk [-F  field-separator]  'commands'  input-file(s)

其中,commands 是真正awk命令,[-F分隔符]是可选的。 input-file(s) 是待处理的文件。

在awk中,文件的每一行中,由域分隔符分开的每一项称为一个域。通常,在不指名-F域分隔符的情况下,默认的域分隔符是空格。

 

 

[-F域分隔符]是可选的,因为awk使用空格作为缺省的域分隔符,因此如果要浏览域间有空格的文本,不必指定这个选项,如果要浏览诸如passwd文件,此文件各域以冒号作为分隔符,则必须指明-F选项,如:
awk -F: 'commands' input-file

 

 

awk 'commands' input-file

awk '{print $0}' temp.txt > sav.txt  

表示打印所有域并把结果重定向到sav.txt中

 

awk '{print $1,$4}' temp.txt

只打印出第1和第4域

 

 

 

awk命令形式:
awk [-F|-f|-v] ‘BEGIN{} //{command1; command2} END{}’ file
[-F|-f|-v]   大参数,-F指定分隔符,-f调用脚本,-v定义变量 var=value
'  '          引用代码块
BEGIN   初始化代码块,在对每一行进行处理之前,初始化代码,主要是引用全局变量,设置FS分隔符
//           匹配代码块,可以是字符串或正则表达式
{}           命令代码块,包含一条或多条命令
;          多条命令使用分号分隔
END      结尾代码块,在对每一行进行处理之后再执行的代码块,主要是进行最终计算或输出结尾摘要信息

 

 

3. jot, seq命令

 

这些工具用来生成一系列整数, 用户可以指定生成范围.

 

一个实例:使用seq命令来产生循环参数

  1. for a in `seq 20`  # or   for a in $( seq 80 )  

  2. # 与 for a in 1 2 3 4 5 ... 20   相同(少敲了好多字!).  

  3. # 也可以使用'jot'(如果系统上有的话).  

  4. do  

  5.  echo -n "$a "  

  6. done      # 1 2 3 4 5 ... 20  

  7. # 这也是一个通过使用命令输出  

  8. # 来产生"for"循环中[list]列表的例子.

 

 

  1. COUNT=20  # 当然, 'seq'也可以使用一个可替换的参数.  

  2.  

  3. for a in `seq $COUNT`  # 或者   for a in $( seq $COUNT )  

  4. do  

  5.  echo -n "$a "  

  6. done      # 1 2 3 4 5 ... 20  

 

 

 

  1. for a in `seq $BEGIN $END`  

  2. #  传给"seq"两个参数, 从第一个参数开始增长,  

  3. #+ 一直增长到第二个参数为止.  

  4. do  

  5.  echo -n "$a "  

  6. done      # 15 16 17 18 19 20  

//////////////////////////////

  1. for a in `seq $BEGIN $INTERVAL $END`  

  2. #  传给"seq"三个参数, 从第一个参数开始增长,  

  3. #+ 并以第二个参数作为增量,  

  4. #+ 一直增长到第三个参数为止.  

  5. do  

  6.  echo -n "$a "  

  7. done      # 45 50 55 60 65 70 75 80  

 

 

jot

正如其名所示,jot的为generates some text,包括从数字到字符以及一些乱码。如果你想生成一定范围内的数字,可运行下面的命令:

jot [number_of_numbers] [starting_number]

如果你只提供一个参数,它将会生成从1到这个数字之间的数字。

-r 参数可生成随机数,语法如下:

jot -r [number_of_numbers] [lower_limit] [upper_limit]

 

 

 

 

 

 

 

 

 

 

 

 



https://blog.sciencenet.cn/blog-567091-834868.html

上一篇:励志故事:活出个样来给自己看
下一篇:再谈phonopy计算声子谱虚频的处理方法
收藏 IP: 159.226.159.*| 热度|

0

该博文允许注册用户评论 请点击登录 评论 (3 个评论)

数据加载中...
扫一扫,分享此博文

Archiver|手机版|科学网 ( 京ICP备07017567号-12 )

GMT+8, 2024-5-21 12:21

Powered by ScienceNet.cn

Copyright © 2007- 中国科学报社

返回顶部