要计算分子的 NMR,需要使用量子化学计算软件,如 Gaussian、ORCA 或 MOLPRO。以下是一个基本的 Python 代码示例,用于使用 Gaussian 计算分子的 NMR:

import os

# 设置 Gaussian 的路径
gaussian_path = '/path/to/gaussian'

# 设置输入文件名和输出文件名
input_file = 'molecule.com'
output_file = 'molecule.log'

# 编写 Gaussian 输入文件
input_text = """
%chk=molecule
#p B3LYP/6-31G(d) NMR

molecule

0 1
<分子结构>

"""

# 将输入文件写入磁盘
with open(input_file, 'w') as f:
    f.write(input_text)

# 调用 Gaussian 运行计算
os.system(f'{gaussian_path} {input_file} > {output_file}')

# 从输出文件中提取 NMR 结果
with open(output_file, 'r') as f:
    output_text = f.read()

nmr_start = output_text.find('Isotropic =')
nmr_end = output_text.find('Anisotropy =')
nmr_text = output_text[nmr_start:nmr_end]

print(nmr_text)

请注意,此代码示例仅提供了一个基本的框架,需要进行适当的修改才能适应特定的分子和计算软件。此外,对于大型或复杂的分子,计算可能需要较长时间。

python 计算分子 NMR

原文地址: https://www.cveoy.top/t/topic/bWPP 著作权归作者所有。请勿转载和采集!

免费AI点我,无需注册和登录