atomate 安装

安装


安装流程

  • 使用 conda 创建 Python 虚拟环境,如 atomate_env(名字可任意),安装 atomate(会自动安装 pymatgen、custodian、FireWorks 依赖 packages)

  • pymatgen 和 custodian 包更新频率相比 atomate 和 FireWorks 要高很多

  • 当一个 Python 虚拟环境使用了很久且修改过相关包中的模块源代码,不建议单独升级某个包,有可能会破坏包之间的依赖关系

1
2
3
pip install atomate

pip install -U pymatgen custodian

配置文件

  • atomate 标准 config 配置文件参考:standard_config

  • 配置文件内容中涉及到路径填写时,需填写绝对路径,不可使用相对路径或 $HOME 等环境变量(否则会报错,重要提醒!!!

  • atomate 配置文件目录结构(目录名可任意)

1
2
3
4
5
6
7
8
atomate_env
├── config/
│   ├── db.json
│   ├── FW_config.yaml
│   ├── my_fworker.yaml
│   ├── my_launchpad.yaml
│   └── my_qadapter.yaml
└── logs/

db.json

  • 连接 MongoDB 数据库(注:除了 port 条目(entry)的 value 是整数;其他都是字符串,且条目及对应的 value 值都应用双引号);不能有注释 //,否则会报错(无法解析)从而无法将计算数据存储至 MongoDB 中
1
2
3
4
5
6
7
8
9
10
11
{
"host": "<HOSTNAME>",
"port": <PORT>,
"database": "<DB_NAME>",
"collection": "tasks",
"admin_user": "<ADMIN_USERNAME>",
"admin_password": "<ADMIN_PASSWORD>",
"readonly_user": "<READ_ONLY_PASSWORD>",
"readonly_password": "<READ_ONLY_PASSWORD>",
"aliases": {}
}

FW_config.yaml

  • 配置 Fireworks
1
2
3
4
5
6
7
ADD_USER_PACKAGES:
- atomate.vasp.firetasks
CONFIG_FILE_DIR: <INSTALL_DIR>/config
ECHO_TEST: Atomate environment of SLY
QUEUE_UPDATE_INTERVAL: 5
ALWAYS_CREATE_NEW_BLOCK: True
RAPIDFIRE_SLEEP_SECS: 10
1
RAPIDFIRE_SLEEP_SECS = 60    # seconds to sleep between rapidfire loops
  • 需将其路径添加到 PATH 中
1
export FW_CONFIG_FILE=<_dir>/config/FW_config.yaml
  • 若 atomate 环境有多个,可进行如下设置(可使用 $HOME 等变量;切换 atomate 环境后,source 使其生效):
1
2
3
4
5
6
conda_venv_name=$(conda info -e | grep \* | awk '{print $1}')
if [[ $conda_venv_name == atomate_env1 ]]; then
export FW_CONFIG_FILE=<INSTALL_DIR1>/config/FW_config.yaml
elif [[ $conda_venv_name == atomate_env2 ]]; then
export FW_CONFIG_FILE=<INSTALL_DIR2>/config/FW_config.yaml
fi

my_fworker.yaml

  • fireworks/core/fworker.py 中的 FWorker 类
1
2
3
4
5
6
7
name: <WORKER_NAME>
category: ''
query: '{}'
env:
db_file: <INSTALL_DIR>/config/db.json
vasp_cmd: <VASP_CMD> # eg: mpirun vasp_std
scratch_dir: null # optional

my_launchpad.yaml

  • fireworks/core/launchpad.py 中的 LaunchPad 类
1
2
3
4
5
6
7
8
9
10
host: <HOSTNAME>
port: <PORT>
name: <DB_NAME>
username: <ADMIN_USERNAME>
password: <ADMIN_PASSWORD>
ssl_ca_file: null
logdir: null
strm_lvl: INFO
user_indices: []
wf_user_indices: []

my_qadapter.yaml

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
_fw_name: CommonAdapter
_fw_q_type: SLURM
rocket_launch: rlaunch -c <INSTALL_DIR>/config rapidfire
nodes: 1
ntasks: 1
ntasks_per_node: 1
walltime: "72:00:00"
queue: cpu
account: null
job_name: null
pre_rocket: |+
ulimit -s unlimited
ulimit -l unlimited

post_rocket: null
logdir: <INSTALL_DIR>/logs

配置 pymatgen

  • VASP 赝势路径 + Material Project 网站 API

  • 方式 1:新建 ~/.pmgrc.yaml~/.config/.pmgrc.yaml 文件,添加以下内容

1
2
PMG_VASP_PSP_DIR: <psp_dir>
PMG_MAPI_KEY: <api_key>
  • 方式 2:使用 pmg 命令来生成配置文件
1
2
pmg config --add PMG_VASP_PSP_DIR <psp_dir>
pmg config --add PMG_MAPI_KEY <api_key>
  • 赝势目录结构
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
pseudopotentials
├── POT_GGA_PAW_PBE
│ ├── POTCAR.Ac.gz
│ ├── POTCAR.Ac_s.gz
│ ├── POTCAR.Ag.gz
│ └── ...
├── POT_GGA_PAW_PW91
│ ├── POTCAR.Ac.gz
│ ├── POTCAR.Ac_s.gz
│ ├── POTCAR.Ag.gz
│ └── ...
└── POT_LDA_PAW
├── POTCAR.Ac.gz
├── POTCAR.Ac_s.gz
├── POTCAR.Ag.gz
└── ...
  • pymatgen 寻找 POTCAR 路径的两种形式
1
2
3
4
# 形式 1 所有元素 POTCAR 在一个目录下;可以是压缩文件
psp_dir/POT_GGA_PAW_PBE/POTCAR.XXX
# 形式 2 元素 POTCAR 按元素分类在子目录下
psp_dir/POT_GGA_PAW_PBE/XXX/POTCAR

注:若 <psp_dir> 目录下无 POT_GGA_PAW_PBE 名称目录,可设置软链接

1
ln -s PBE_folder POT_GGA_PAW_PBE

相关问题

  • db.json 中的文件路径没有设置为绝对路径
1
ValueError: Could not get next FW id! If you have not yet initialized the database, please do so by performing a database reset (e.g., lpad reset)
  • 赝势路径或赝势目录结构没有设置正确:参照上节中赝势路径和赝势目录结构设置
1
OSError: You do not have the right POTCAR with functional PBE and label Nb_pv in your VASP_PSP_DIR. Paths tried: ['/home/xxx/src/POT/PAW_PBE/POT_GGA_PAW_PBE/POTCAR.Nb_pv', '/home/xxx/src/POT/PAW_PBE/POT_GGA_PAW_PBE/Nb_pv/POTCAR']
  • 没有创建 logs 目录:创建 config 目录的同时创建 logs 目录
1
2
3
4
5
6
7
8
FileNotFoundError: [Errno 2] No such file or directory: 'path/atomate/logs/launchpad-debug.log'

During handling of the above exception, another exception occurred:

File "conda_path/envs/atomate_nbsi/lib/python3.11/site-packages/fireworks/scripts/lpad_run.py", line 132, in get_lp
f"FireWorks was not able to connect to MongoDB at {lp.host}:{lp.port}. Is the server running? "
^^
UnboundLocalError: cannot access local variable 'lp' where it is not associated with a value
  • 未添加 FW_CONFIG_FILE 环境变量
1
ValueError: Fireworks was not able to connect to MongoDB.
  • 不生成 VASP 计算输入文件,只生成.err .out(空文件)和 FW_submit.script 文件,job 处于不断提交 - kill - 再提交的循环
    • 解决方法:这是自己遇到过的一个特殊情况。自己安装过 zsh,且将 zsh 加入到 ~/.bash_profile 中使登录服务器便切换到 zsh,最终导致上述问题出现(发现的原因是该问题出现后只有这个新变量因素)。将 ~/.bash_profile 中与 zsh 相关的内容注释掉,问题可得到解决