0%

使用 KimariPlot 绘制 Free Energy Profile

注!KimariPlot 已经全新升级至 1.3 版本!在内容和便利性上进行了全方面的升级!

注!KimariPlot 已经全新升级至 1.3 版本!在内容和便利性上进行了全方面的升级!

注!KimariPlot 已经全新升级至 1.3 版本!在内容和便利性上进行了全方面的升级!

前言

最近笔者在闲来无事的时候,使用 Python 写了一个小程序 KimariDraw。KimariDraw 是一个是一个用来绘制化学能量图的小程序。KimariDraw 在最近最后一次更新至 1.2.0 后,将停止更新,并且将重构整个项目。笔者将 KimariDraw 1.2.0 的所有功能都移植到了 KimariPlot 1.0.0 中,并且在原有的基础上添加了很多可自定义的选项,也增加了另一种势图的绘制。算是一个不小的升级。

目前 KimariDraw 1.2.0 已经停止维护。但是还可以通过 pip install kimariDraw 安装。KimariPlot 并没有在 pypi 上托管,因此无法通过 pip install 命令安装。具体的安装和使用方法,可以浏览 KimariPlot 的 Github 主页。

和 KimariDraw 相比,最大的区别就是输入文件的不同。KimariDraw 是使用 .kd 文件作为输入的文件,而 KimariPlot 则需要提供 .kpi 文件。.kpi 文件是 KimariPlot 唯一支持的可解析的文件类型,格式非常简单。使用 KimariPlot 绘制势能图是否方便和快捷,下面介绍如何使用 KimariPlot 绘制势能图。

目前 KimariPlot 以及全新升级,迎来了 1.3 版本。在 1.3 版本以及之后的所有版本,以上的内容都是废话了,没有丝毫用处!

在 Aug-4-2023 的更新之后,KimariPlot 已经不需要一个 kpi 文件记录数据和配置了。笔者使用了一个现有的文件格式来记录这些信息,Toml 是一个非常好用的配置文件格式,笔者将 Toml 文件作为 KimariPlot 需要读取的文件。同时,为使用 KimariPlot 的用户提供了几个参数,用于修改绘图的格式。

具体的安装和使用方法,可以浏览 KimariPlot 的 Github 主页。最简单的安装方法是使用 pip 工具进行安装。

1
pip install kimariplot,matplotlib,toml

绘制 Energy Profile

前文提到了,使用 kimariplot 绘制 Energy Profile 需要使用一个 Toml 文件。这里随便写一个 profile.toml 用来记录不同反应路径的 Energy Profile。

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
[[path]]
color = "black"
style = "-"
data = [
["R", "1", "0.0"],
["", "2", "-2.9"],
["", "3", "16.6"],
["CP2", "4", "-3.6"],
["P", "5", "-2.1"]
]

[[path]]
color = "red"
style = "--"
data = [
["R", "1", "0.0"],
["CP1", "2", "-4.4"],
["TS1", "3", "13.5"],
["", "4", "-1.5"],
["P", "5", "-2.1"]
]

[[path]]
color = "blue"
style = "--"
data = [
["", "1", "0.0"],
["", "2", "1.2"],
["", "3", "18.1"],
["", "4", "1.3"],
["", "5", "-2.1"]
]

[[path]]
color = "green"
style = "--"
data = [
["", "1", "0.0"],
["", "2", "2.3"],
["", "3", "19.8"],
["", "4", "2.5"],
["", "5", "-2.1"]
]

接着在命令行输入以下命令,就可以生成下图所示的 Energy Profile。

1
kimariplot -s 11,9 profile.toml

其中 -s 是用来指定绘制图片的大小的参数。KimariPlot 还支持很多参数,可以输入 kimariplot -h 查看参数的具体用法。可以看见 KimariPlot 绘制的 Free Energy Profile 还是非常美观的。

支持的参数

这里将 KimariPlot 运行时的参数列出来,以供参考。这里提供一个小技巧,可以在命令行中输入 kimariplot -v 来检查是否安装 KimariPlot,并且检查 KimariPlot 的版本。

1
2
3
kimariplot -v

v1.3.0

同时也可以输入 kimariplot -h 查看支持的参数以及参数的使用方法。

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
kimariplot -h

usage: KimariPlot [--help] [--output_type OUTPUT] [--dpi DPI] [--font FONT]
[--size SIZE] [--version]
input_file

KimariPlot -- A plotting software used for quickly creating energy profile.

positional arguments:
input_file Please input a Toml file

options:
--help, -h Show this help message and exit
--output_type OUTPUT, -o OUTPUT
The output type of the graph
--dpi DPI, -d DPI The dpi of the output graph
--font FONT, -f FONT The font family of the graph
--size SIZE, -s SIZE The size of the graph
--version, -v Show the version information

结语

KimariPlot 是一个非常便利的绘制 Energy Profile 的 Python 脚本。不过正因为其便利,所以用户自定义的地方比较少,可交互性极低。因此 KimariPlot 不一定符合每一个人的绘图审美与习惯。

如果想要更好的 Energy Profile 图,笔者推荐使用 Li Yuanhe 的绘制 Energy Profile 的小工具 Energy_Diagram_Plotter_CDXML,详细信息请浏览该项目的 Github 主页:https://github.com/liyuanhe211/Energy_Diagram_Plotter_CDXML。下图是使用 Energy_Diagram_Plotter_CDXML 绘制的效果,需要注意的是如果使用 Energy_Diagram_Plotter_CDXML 绘制 Energy Profile 注意引用哦!如果使用笔者的脚本就不需要引用了,因为本身没什么技术含量。

  • 本文作者: Hsiun YuBin
  • 本文链接: https://ikuns.icu/010/
  • 版权声明: 本博客所有文章除特别声明外,均采用 BY-NC-SA 许可协议。转载请注明出处!