Skip to content

LePingKYXK/PWmat_tools

Repository files navigation

PWmat tools

Python scripts dealing with the output files obtained from PWmat. Instructions for all scripts are available by adding the -h option, e.g.,

$ python check_PWmat_convergence.py -h
usage: check_PWmat_convergence.py [-h] [-i <etot.input file>] [-r <RELAXSTEPS file>] [-p <plot graph>] [-v]

Author: Dr. Huan Wang, Email: huan.wang@whut.edu.cn, Version: v1.0, Date: August 7, 2024

optional arguments:
  -h, --help            show this help message and exit
  -i <etot.input file>  you can specify the file name (default: ~/etot.input)
  -r <RELAXSTEPS file>  you can specify the file name (default: ~/RELAXSTEPS)
  -p <plot graph>       plot graph (default: "yes")
  -v, --verbose         verbose mode, show details of the RELAXSTEPS file (default: False)

Package Requirements

  • Python >= 3.8.3
  • Numpy >= 1.23.0
  • Scipy >= 1.5.0
  • Matplotlib >= 3.2.2

I strongly recommend using Anaconda3 to manage these packages.

check_PWmat_convergence.py

The check_PWmat_convergence.py script is designed to check cell and ionic optimization convergence using the PEB or HSE06 functionals in PWmat. This script plots the trends of Total Energy and Average Force as a function of the number of optimization steps, facilitating observation during the calculation process.

Usage:

$ python check_PWmat_convergence.py

If one wishes to view values of total energy, average force, SCF cycles, etc., the inclusion of the -v option is advised.

$ python check_PWmat_convergence.py -v

convert_MDSTEPS.py

The convert_MDSTEPS.py script is designed to convert the MDSTEPS file generated by PWmat during the AIMD or rt-TDDFT simulations into a .csv format table. Additionally, it facilitates the creation of a $4 \times 2$ grid plot illustrating Total Energy vs. MD Time, Potential Energy vs. MD Time, Kinetic Energy vs. MD Time, $\Delta$ Energy vs. MD Time, Temperature vs. MD Time, and SCF Loops vs. MD Time. The resulting MDsteps.csv file will be convenient for subsequent plotting purposes.

Usage:

$ python convert_MDSTEPS.py

check_rtTDDFT_Time.py

The check_rtTDDFT_Time.py script is employed to extract the TDDFT_TIME= parameters from the input file (etot.input) of PWmat in rt-TDDFT calculations and visualize it as a waveform profile of laser intensity over time.

Usage:

$ python check_rtTDDFT_Time.py

split_MOVEMENT.py

The split_MOVEMENT.py script split the MOVEMENT file generated by PWmat in rt-TDDFT calculations. This script has been devised as a subsequent analysis that requires the computation of the density of states (DOS) at specific time points. It swiftly divides the MOVEMENT file into several atom_XXXfs.config files based on user-specified time intervals.

Usage:

$ python split_MOVEMENT.py -s 10  30.5  100.7  240

then, the atom_10.0fs.configatom_30.5fs.configatom_100.7fs.config,and atom_240.0fs.config files are obtained.

set_rtTDDFT_time.py

Still in testing The set_rtTDDFT_time.py script is designed to configure the TDDFT_TIME= parameters $b1,b2,b3, \dots, bN$ according to the experimental conditions, i.e., laser wavelength, laser power, pulse diameter, peak center, FWHM, etc.

num_excited_electrons.py

The num_excited_electrons.py script is employed to calculate and plot the number of excited electrons over time in the conduction band during the rt-TDDFT calculations. It processes the plot.TDDFT.DOS file generated by PWmat's built-in plot_TDDFT.x script. Moreover, it extracts the total number of electrons from the REPORT file to derive the percentage of excited electrons.

Usage:

$ python num_excited_electrons.py

parse_force.py

The parse_force.py script is employed to parse the MOVEMENT file and plot the Force obtained from the rt-TDDFT calculations. The script will read the MOVEMENT file by default. Users can also specify the file name by typing -f MOVEMNT_1st_try if the file name has changed. By using the -i option, users can select the elements by the index (indices), e.g., -i 3 7 11 or select All elements by typing -i 0. In addition, the parsed force values will automatically save as a .csv file, with the output file name as the combination of element symbols and their index (e.g. if the user types -i 3 7 11 and if the corresponding elements are H, C, and N, then the output file name is H_1_C_3_N_11.csv). Moreover, the -p option provides two types of plotting results. By default, each panel illustrates each element with the force components. If users type -p xyz, the figure will present three panels for the x, y, z components of the specific elements.

Usage:

$ python parse_force.py -f MOVEMENT -i 1 2 5

PWmat_tools 简介

PWmat_tools系列脚本用于处理PWmat计算的结果文件。这些脚本以Python3语言编写,调用了NumpyScipyMatplotlib等库,因此建议使用Anaconda3套件来管理和运行这些脚本。

所有的脚本均有说明文档,可以通过 -h 查看具体的说明。例如:

$ python check_PWmat_convergence.py -h
usage: check_PWmat_convergence.py [-h] [-i <etot.input file>] [-r <RELAXSTEPS file>] [-p <plot graph>] [-v]

Author: Dr. Huan Wang, Email: huan.wang@whut.edu.cn, Version: v1.0, Date: August 7, 2024

optional arguments:
  -h, --help            show this help message and exit
  -i <etot.input file>  you can specify the file name (default: ~/etot.input)
  -r <RELAXSTEPS file>  you can specify the file name (default: ~/RELAXSTEPS)
  -p <plot graph>       plot graph (default: yes)
  -v, --verbose         verbose mode, show details of the RELAXSTEPS file (default: False)

Python及相关库的版本要求

  • Python >= 3.8.3
  • Numpy >= 1.23.0
  • Scipy >= 1.5.0
  • Matplotlib >= 3.2.2

check_PWmat_convergence.py

check_PWmat_convergence.py 脚本用于检查PWmat结构优化(适用PBE,HSE06等泛函的晶胞优化+结构优化,结构优化)的收敛情况。此脚本将能量,平均受力随优化步数的变化趋势绘制成图,方便计算过程中观察。

使用方法:

$ python check_PWmat_convergence.py

如果想查看能量平均受力SCF循环次数等随优化步数的变化数据,则可以添加-v选项

$ python check_PWmat_convergence.py -v

convert_MDSTEPS.py

convert_MDSTEPS.py脚本用于将PWmat在AIMD和rt-TDDFT计算产生的MDSTEPS文件转换成.csv格式的表格。同时,绘制含有总能量-时间(Total Energy vs. MD Time), 势能-时间(Potential Energy vs. MD Time), 动能-时间(Kinetic Energy vs. MD Time),动能变化量-时间$\Delta$ Energy vs. MD Time), 以及温度-时间(Temperature vs. MD Time)和自洽步数-时间(SCF Loops vs. MD Time)的四两行两列拼图。此外,转换后的MDsteps.csv文件也可以方便后续绘图。

使用方法:

$ python convert_MDSTEPS.py

check_rtTDDFT_Time.py

check_rtTDDFT_Time.py 脚本用于读取PWmat在rt-TDDFT计算的输入文件(etot.input)中的TDDFT_TIME=参数,并绘制成激光强度-时间的波形图.

使用方法:

$ python check_rtTDDFT_Time.py

split_MOVEMENT.py

split_MOVEMENT.py 脚本用于读取PWmat在rt-TDDFT计算中产生的的MOVEMENT文件。由于后续处理时需要计算某些时刻的态密度(DOS),因此开发了此拆分脚本。split_MOVEMENT.py脚本可以按照使用者输入的时刻迅速将MOVEMENT文件拆分成若干个atom_XXXfs.config文件。

使用方法:

$ python check_rtTDDFT_Time.py -s 10  30.5  100.7  240

即可得到 atom_10.0fs.configatom_30.5fs.configatom_100.7fs.configatom_240.0fs.config 等文件。

set_rtTDDFT_time.py

仍在测试中 set_rtTDDFT_time.py 脚本用于根据实验条件设置TDDFT_TIME$b1, b2, b3, \dots, bN$ 参数。仍在测试中

num_excited_electrons.py

num_excited_electrons.py 脚本用于计算PWmat在rt-TDDFT计算中被激发到导带中的电子数。此脚本读取的是PWmat自带的plot_TDDFT.x脚本处理得到的plot.TDDFT.DOS文件,得到被激发的电子数随时间变化的数据。另外,此脚本读取REPORT文件中的总电子数,从而进一步得到被激发的电子数的百分比。

使用方法:

$ python num_excited_electrons.py

parse_force.py

parse_force.py 脚本用于解析PWmat在rt-TDDFT计算中产生的 MOVEMENT 文件中的 Force。此脚本读取每个时刻的Force分量。默认不需要输入MOVEMENT文件名,但是如果用户修改了文件名,可以用-f来指定文件名,例如 -i MOVEMENT_first_try。用户可以通过 -i选项来输入元素的索引号选取元素。脚本将处理后的Force分量保存为.csv格式的文件,文件名为元素符号和对应的原子索引号(例如,输入的是 -i 1 3 11,假如对应的元素是 H C N,则保存的文件名为 H_1_C_3_N_11.csv)。另外,脚本提供-p选项用户绘图,其中默认的是根据绘制用户输入的序号对应的各个元素的受力分量(选了多少元素就有多少个图层,每个图层绘制一个元素的受力 x, y, z 随时间的变化 )。如果用户希望按x,y,z来观察,也可以用 -p xyz功能可以得到受力的 x y z三个分量的图(上,中,下三个图分别绘制所选元素的 x, y, z 分量)。

使用方法:

$ python parse_force.py -i 1 2 5

About

Python scripts for PWmat

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages