From dbd3e452bec0b8070b990ca312bc8300f18a21e7 Mon Sep 17 00:00:00 2001 From: root Date: Sat, 5 Oct 2024 14:41:34 +0800 Subject: [PATCH] add plot script --- Gaussian/README.md | 8 ++++- script/S112D/plot_potential.sh | 63 ++++++++++++++++++++++++++++++++++ 2 files changed, 70 insertions(+), 1 deletion(-) create mode 100755 script/S112D/plot_potential.sh diff --git a/Gaussian/README.md b/Gaussian/README.md index 1126cd9..27a70fd 100755 --- a/Gaussian/README.md +++ b/Gaussian/README.md @@ -1 +1,7 @@ -[Gaussian的安装方法及运行时的相关问题](http://sobereva.com/439) \ No newline at end of file +[Gaussian的安装方法及运行时的相关问题](http://sobereva.com/439) + +量子化学 + +红外光谱的验证: + +https://www.bilibili.com/video/BV16t411g7AU/?share_source=copy_web&vd_source=ffdb342aff614708231fb471e93de948 \ No newline at end of file diff --git a/script/S112D/plot_potential.sh b/script/S112D/plot_potential.sh new file mode 100755 index 0000000..64d87f0 --- /dev/null +++ b/script/S112D/plot_potential.sh @@ -0,0 +1,63 @@ +#!/bin/bash + +# 检查 Gnuplot 是否已安装 +if ! command -v gnuplot &> /dev/null; then + echo "Gnuplot is not installed. Attempting to install..." + + # 尝试自动安装 Gnuplot + if [[ "$(uname -s)" == "Linux" ]]; then + # 检查是否是基于 Debian/Ubuntu 的系统并使用 apt 安装 + if command -v apt &> /dev/null; then + sudo apt update && sudo apt install -y gnuplot + # 检查是否是基于 RedHat/CentOS 的系统并使用 yum 安装 + elif command -v yum &> /dev/null; then + sudo yum install -y gnuplot + else + echo "Unsupported package manager. Please install Gnuplot manually." + exit 1 + fi + else + echo "Unsupported operating system. Please install Gnuplot manually." + exit 1 + fi + + # 再次检查是否安装成功 + if ! command -v gnuplot &> /dev/null; then + echo "Gnuplot installation failed. Please install it manually." + exit 1 + fi + + echo "Gnuplot installed successfully." +fi + +# 检查输入参数数量 +if [ "$#" -ne 2 ]; then + echo "Usage: $0 input.xvg output.svg" + exit 1 +fi + +# 获取输入和输出文件名 +input_file=$1 +output_file=$2 + +# 检查输入文件是否存在 +if [ ! -f "$input_file" ]; then + echo "Error: Input file '$input_file' not found!" + exit 1 +fi + +# 使用 Gnuplot 生成输出文件 +gnuplot << EOF +set terminal svg size 800,600 +set output '${output_file}' + +# 设置标题和轴标签 +set title 'Potential Energy Minimization' +set xlabel 'Step' +set ylabel 'Potential (kJ/mol)' + +# 读取数据文件并绘制,使用第1列和第2列,忽略注释行 +plot '${input_file}' using 1:2 with lines title 'Potential Energy (kJ/mol)' +EOF + +echo "Plot generated: ${output_file}"