Bohrium
robot
新建

空间站广场

论文
Notebooks
比赛
课程
Apps
我的主页
我的Notebooks
我的知识库
我的足迹

我的工作空间

任务
节点
文件
数据集
镜像
项目
数据库
公开
Instructions for OpenLAM structure optimization tools
OpenLAM
OpenLAM
zjgemi
更新于 2024-11-20
推荐镜像 :lam-crystal-philately:openlam
推荐机型 :c12_m92_1 * NVIDIA V100
lam-crystal-model(v3)

Installation

Clone the project to the local

代码
文本
[1]
!git clone https://github.com/deepmodeling/openlam
Cloning into 'openlam'...
remote: Enumerating objects: 103, done.
remote: Counting objects: 100% (103/103), done.
remote: Compressing objects: 100% (73/73), done.
remote: Total 103 (delta 52), reused 68 (delta 26), pack-reused 0 (from 0)
Receiving objects: 100% (103/103), 33.91 KiB | 394.00 KiB/s, done.
Resolving deltas: 100% (52/52), done.
代码
文本

Install it with dependencies

代码
文本
[2]
!pip install ./openlam
Looking in indexes: https://pypi.tuna.tsinghua.edu.cn/simple
Processing /openlam
  Installing build dependencies ... done
  Getting requirements to build wheel ... done
  Preparing metadata (pyproject.toml) ... done
Collecting pydflow>=1.7.23 (from lam-crystal-philately==0.1.dev23+g7d4fc12)
  Downloading https://pypi.tuna.tsinghua.edu.cn/packages/6d/b7/2c067e6d5e7a274eb449418948d772c5cb692ddea53fbbec15c97958bb73/pydflow-1.8.85-py3-none-any.whl (163 kB)
     ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 163.1/163.1 kB 14.2 MB/s eta 0:00:00
Collecting ase==3.22.1 (from lam-crystal-philately==0.1.dev23+g7d4fc12)
  Using cached https://pypi.tuna.tsinghua.edu.cn/packages/38/b0/3c0a7afaf66274588216c251376ac2bea0269eb7a5e1da77521811060553/ase-3.22.1-py3-none-any.whl (2.2 MB)
Requirement already satisfied: numpy==1.26.4 in /opt/mamba/envs/matbench/lib/python3.11/site-packages (from lam-crystal-philately==0.1.dev23+g7d4fc12) (1.26.4)
Requirement already satisfied: tqdm==4.66.2 in /opt/mamba/envs/matbench/lib/python3.11/site-packages (from lam-crystal-philately==0.1.dev23+g7d4fc12) (4.66.2)
Collecting pymatgen==2024.3.1 (from lam-crystal-philately==0.1.dev23+g7d4fc12)
  Using cached https://pypi.tuna.tsinghua.edu.cn/packages/73/43/f7e3b8ab721c488a8b7321012a6585977d638630e4469c8e47644982db58/pymatgen-2024.3.1-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (10.1 MB)
Requirement already satisfied: matplotlib>=3.1.0 in /opt/mamba/envs/matbench/lib/python3.11/site-packages (from ase==3.22.1->lam-crystal-philately==0.1.dev23+g7d4fc12) (3.8.3)
Requirement already satisfied: scipy>=1.1.0 in /opt/mamba/envs/matbench/lib/python3.11/site-packages (from ase==3.22.1->lam-crystal-philately==0.1.dev23+g7d4fc12) (1.12.0)
Requirement already satisfied: monty>=2024.2.2 in /opt/mamba/envs/matbench/lib/python3.11/site-packages (from pymatgen==2024.3.1->lam-crystal-philately==0.1.dev23+g7d4fc12) (2024.2.26)
Requirement already satisfied: networkx>=2.2 in /opt/mamba/envs/matbench/lib/python3.11/site-packages (from pymatgen==2024.3.1->lam-crystal-philately==0.1.dev23+g7d4fc12) (3.2.1)
Requirement already satisfied: palettable>=3.1.1 in /opt/mamba/envs/matbench/lib/python3.11/site-packages (from pymatgen==2024.3.1->lam-crystal-philately==0.1.dev23+g7d4fc12) (3.3.3)
Requirement already satisfied: pandas in /opt/mamba/envs/matbench/lib/python3.11/site-packages (from pymatgen==2024.3.1->lam-crystal-philately==0.1.dev23+g7d4fc12) (2.2.1)
Requirement already satisfied: plotly>=4.5.0 in /opt/mamba/envs/matbench/lib/python3.11/site-packages (from pymatgen==2024.3.1->lam-crystal-philately==0.1.dev23+g7d4fc12) (5.20.0)
Requirement already satisfied: pybtex in /opt/mamba/envs/matbench/lib/python3.11/site-packages (from pymatgen==2024.3.1->lam-crystal-philately==0.1.dev23+g7d4fc12) (0.24.0)
Requirement already satisfied: requests in /opt/mamba/envs/matbench/lib/python3.11/site-packages (from pymatgen==2024.3.1->lam-crystal-philately==0.1.dev23+g7d4fc12) (2.31.0)
Requirement already satisfied: ruamel.yaml>=0.17.0 in /opt/mamba/envs/matbench/lib/python3.11/site-packages (from pymatgen==2024.3.1->lam-crystal-philately==0.1.dev23+g7d4fc12) (0.18.6)
Requirement already satisfied: spglib>=2.0.2 in /opt/mamba/envs/matbench/lib/python3.11/site-packages (from pymatgen==2024.3.1->lam-crystal-philately==0.1.dev23+g7d4fc12) (2.3.1)
Requirement already satisfied: sympy in /opt/mamba/envs/matbench/lib/python3.11/site-packages (from pymatgen==2024.3.1->lam-crystal-philately==0.1.dev23+g7d4fc12) (1.12)
Requirement already satisfied: tabulate in /opt/mamba/envs/matbench/lib/python3.11/site-packages (from pymatgen==2024.3.1->lam-crystal-philately==0.1.dev23+g7d4fc12) (0.9.0)
Requirement already satisfied: uncertainties>=3.1.4 in /opt/mamba/envs/matbench/lib/python3.11/site-packages (from pymatgen==2024.3.1->lam-crystal-philately==0.1.dev23+g7d4fc12) (3.1.7)
Requirement already satisfied: joblib in /opt/mamba/envs/matbench/lib/python3.11/site-packages (from pymatgen==2024.3.1->lam-crystal-philately==0.1.dev23+g7d4fc12) (1.3.2)
Requirement already satisfied: six in /opt/mamba/envs/matbench/lib/python3.11/site-packages (from pydflow>=1.7.23->lam-crystal-philately==0.1.dev23+g7d4fc12) (1.16.0)
Requirement already satisfied: python-dateutil in /opt/mamba/envs/matbench/lib/python3.11/site-packages (from pydflow>=1.7.23->lam-crystal-philately==0.1.dev23+g7d4fc12) (2.9.0.post0)
Requirement already satisfied: urllib3 in /opt/mamba/envs/matbench/lib/python3.11/site-packages (from pydflow>=1.7.23->lam-crystal-philately==0.1.dev23+g7d4fc12) (2.2.1)
Requirement already satisfied: certifi in /opt/mamba/envs/matbench/lib/python3.11/site-packages (from pydflow>=1.7.23->lam-crystal-philately==0.1.dev23+g7d4fc12) (2024.2.2)
Collecting argo-workflows==5.0.0 (from pydflow>=1.7.23->lam-crystal-philately==0.1.dev23+g7d4fc12)
  Downloading https://pypi.tuna.tsinghua.edu.cn/packages/b1/6a/8f13d5124b111e8e054594d23782ea9c5dadda0517d1dd9ad08c7c055732/argo_workflows-5.0.0-py3-none-any.whl (452 kB)
     ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 452.5/452.5 kB 25.2 MB/s eta 0:00:00
Collecting jsonpickle (from pydflow>=1.7.23->lam-crystal-philately==0.1.dev23+g7d4fc12)
  Downloading https://pypi.tuna.tsinghua.edu.cn/packages/e4/cb/1fb5ed5f1bc65779f0a14cb428ffe205924b2941ca50c53cfa566aed9583/jsonpickle-3.2.2-py3-none-any.whl (41 kB)
     ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 41.8/41.8 kB 7.9 MB/s eta 0:00:00
Collecting minio (from pydflow>=1.7.23->lam-crystal-philately==0.1.dev23+g7d4fc12)
  Downloading https://pypi.tuna.tsinghua.edu.cn/packages/34/89/f4d5cfb0a5494e7dae1c11d6d1ab82811d93f6af8ca54e1393c046ff0e75/minio-7.2.8-py3-none-any.whl (93 kB)
     ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 93.5/93.5 kB 14.5 MB/s eta 0:00:00
Collecting kubernetes (from pydflow>=1.7.23->lam-crystal-philately==0.1.dev23+g7d4fc12)
  Downloading https://pypi.tuna.tsinghua.edu.cn/packages/62/a1/2027ddede72d33be2effc087580aeba07e733a7360780ae87226f1f91bd8/kubernetes-30.1.0-py2.py3-none-any.whl (1.7 MB)
     ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 1.7/1.7 MB 25.0 MB/s eta 0:00:00a 0:00:01
Requirement already satisfied: pyyaml in /opt/mamba/envs/matbench/lib/python3.11/site-packages (from pydflow>=1.7.23->lam-crystal-philately==0.1.dev23+g7d4fc12) (6.0.1)
Collecting cloudpickle==2.2.0 (from pydflow>=1.7.23->lam-crystal-philately==0.1.dev23+g7d4fc12)
  Downloading https://pypi.tuna.tsinghua.edu.cn/packages/cf/26/cd6c4177273ee35f7a31245893489c68bc340988f12ca315b392f1f18a93/cloudpickle-2.2.0-py3-none-any.whl (25 kB)
Requirement already satisfied: psutil in /opt/mamba/envs/matbench/lib/python3.11/site-packages (from pydflow>=1.7.23->lam-crystal-philately==0.1.dev23+g7d4fc12) (5.9.8)
Requirement already satisfied: contourpy>=1.0.1 in /opt/mamba/envs/matbench/lib/python3.11/site-packages (from matplotlib>=3.1.0->ase==3.22.1->lam-crystal-philately==0.1.dev23+g7d4fc12) (1.2.0)
Requirement already satisfied: cycler>=0.10 in /opt/mamba/envs/matbench/lib/python3.11/site-packages (from matplotlib>=3.1.0->ase==3.22.1->lam-crystal-philately==0.1.dev23+g7d4fc12) (0.12.1)
Requirement already satisfied: fonttools>=4.22.0 in /opt/mamba/envs/matbench/lib/python3.11/site-packages (from matplotlib>=3.1.0->ase==3.22.1->lam-crystal-philately==0.1.dev23+g7d4fc12) (4.50.0)
Requirement already satisfied: kiwisolver>=1.3.1 in /opt/mamba/envs/matbench/lib/python3.11/site-packages (from matplotlib>=3.1.0->ase==3.22.1->lam-crystal-philately==0.1.dev23+g7d4fc12) (1.4.5)
Requirement already satisfied: packaging>=20.0 in /opt/mamba/envs/matbench/lib/python3.11/site-packages (from matplotlib>=3.1.0->ase==3.22.1->lam-crystal-philately==0.1.dev23+g7d4fc12) (24.0)
Requirement already satisfied: pillow>=8 in /opt/mamba/envs/matbench/lib/python3.11/site-packages (from matplotlib>=3.1.0->ase==3.22.1->lam-crystal-philately==0.1.dev23+g7d4fc12) (10.2.0)
Requirement already satisfied: pyparsing>=2.3.1 in /opt/mamba/envs/matbench/lib/python3.11/site-packages (from matplotlib>=3.1.0->ase==3.22.1->lam-crystal-philately==0.1.dev23+g7d4fc12) (3.1.2)
Requirement already satisfied: tenacity>=6.2.0 in /opt/mamba/envs/matbench/lib/python3.11/site-packages (from plotly>=4.5.0->pymatgen==2024.3.1->lam-crystal-philately==0.1.dev23+g7d4fc12) (8.2.3)
Requirement already satisfied: ruamel.yaml.clib>=0.2.7 in /opt/mamba/envs/matbench/lib/python3.11/site-packages (from ruamel.yaml>=0.17.0->pymatgen==2024.3.1->lam-crystal-philately==0.1.dev23+g7d4fc12) (0.2.8)
Requirement already satisfied: future in /opt/mamba/envs/matbench/lib/python3.11/site-packages (from uncertainties>=3.1.4->pymatgen==2024.3.1->lam-crystal-philately==0.1.dev23+g7d4fc12) (1.0.0)
Requirement already satisfied: google-auth>=1.0.1 in /opt/mamba/envs/matbench/lib/python3.11/site-packages (from kubernetes->pydflow>=1.7.23->lam-crystal-philately==0.1.dev23+g7d4fc12) (2.29.0)
Collecting websocket-client!=0.40.0,!=0.41.*,!=0.42.*,>=0.32.0 (from kubernetes->pydflow>=1.7.23->lam-crystal-philately==0.1.dev23+g7d4fc12)
  Downloading https://pypi.tuna.tsinghua.edu.cn/packages/5a/84/44687a29792a70e111c5c477230a72c4b957d88d16141199bf9acb7537a3/websocket_client-1.8.0-py3-none-any.whl (58 kB)
     ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 58.8/58.8 kB 7.9 MB/s eta 0:00:00
Requirement already satisfied: requests-oauthlib in /opt/mamba/envs/matbench/lib/python3.11/site-packages (from kubernetes->pydflow>=1.7.23->lam-crystal-philately==0.1.dev23+g7d4fc12) (2.0.0)
Requirement already satisfied: oauthlib>=3.2.2 in /opt/mamba/envs/matbench/lib/python3.11/site-packages (from kubernetes->pydflow>=1.7.23->lam-crystal-philately==0.1.dev23+g7d4fc12) (3.2.2)
Collecting argon2-cffi (from minio->pydflow>=1.7.23->lam-crystal-philately==0.1.dev23+g7d4fc12)
  Downloading https://pypi.tuna.tsinghua.edu.cn/packages/a4/6a/e8a041599e78b6b3752da48000b14c8d1e8a04ded09c88c714ba047f34f5/argon2_cffi-23.1.0-py3-none-any.whl (15 kB)
Requirement already satisfied: pycryptodome in /opt/mamba/envs/matbench/lib/python3.11/site-packages (from minio->pydflow>=1.7.23->lam-crystal-philately==0.1.dev23+g7d4fc12) (3.20.0)
Requirement already satisfied: typing-extensions in /opt/mamba/envs/matbench/lib/python3.11/site-packages (from minio->pydflow>=1.7.23->lam-crystal-philately==0.1.dev23+g7d4fc12) (4.10.0)
Requirement already satisfied: pytz>=2020.1 in /opt/mamba/envs/matbench/lib/python3.11/site-packages (from pandas->pymatgen==2024.3.1->lam-crystal-philately==0.1.dev23+g7d4fc12) (2024.1)
Requirement already satisfied: tzdata>=2022.7 in /opt/mamba/envs/matbench/lib/python3.11/site-packages (from pandas->pymatgen==2024.3.1->lam-crystal-philately==0.1.dev23+g7d4fc12) (2024.1)
Requirement already satisfied: latexcodec>=1.0.4 in /opt/mamba/envs/matbench/lib/python3.11/site-packages (from pybtex->pymatgen==2024.3.1->lam-crystal-philately==0.1.dev23+g7d4fc12) (3.0.0)
Requirement already satisfied: charset-normalizer<4,>=2 in /opt/mamba/envs/matbench/lib/python3.11/site-packages (from requests->pymatgen==2024.3.1->lam-crystal-philately==0.1.dev23+g7d4fc12) (3.3.2)
Requirement already satisfied: idna<4,>=2.5 in /opt/mamba/envs/matbench/lib/python3.11/site-packages (from requests->pymatgen==2024.3.1->lam-crystal-philately==0.1.dev23+g7d4fc12) (3.6)
Requirement already satisfied: mpmath>=0.19 in /opt/mamba/envs/matbench/lib/python3.11/site-packages (from sympy->pymatgen==2024.3.1->lam-crystal-philately==0.1.dev23+g7d4fc12) (1.3.0)
Requirement already satisfied: cachetools<6.0,>=2.0.0 in /opt/mamba/envs/matbench/lib/python3.11/site-packages (from google-auth>=1.0.1->kubernetes->pydflow>=1.7.23->lam-crystal-philately==0.1.dev23+g7d4fc12) (5.3.3)
Requirement already satisfied: pyasn1-modules>=0.2.1 in /opt/mamba/envs/matbench/lib/python3.11/site-packages (from google-auth>=1.0.1->kubernetes->pydflow>=1.7.23->lam-crystal-philately==0.1.dev23+g7d4fc12) (0.4.0)
Requirement already satisfied: rsa<5,>=3.1.4 in /opt/mamba/envs/matbench/lib/python3.11/site-packages (from google-auth>=1.0.1->kubernetes->pydflow>=1.7.23->lam-crystal-philately==0.1.dev23+g7d4fc12) (4.9)
Collecting argon2-cffi-bindings (from argon2-cffi->minio->pydflow>=1.7.23->lam-crystal-philately==0.1.dev23+g7d4fc12)
  Downloading https://pypi.tuna.tsinghua.edu.cn/packages/ec/f7/378254e6dd7ae6f31fe40c8649eea7d4832a42243acaf0f1fff9083b2bed/argon2_cffi_bindings-21.2.0-cp36-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (86 kB)
     ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 86.2/86.2 kB 6.2 MB/s eta 0:00:00
Requirement already satisfied: pyasn1<0.7.0,>=0.4.6 in /opt/mamba/envs/matbench/lib/python3.11/site-packages (from pyasn1-modules>=0.2.1->google-auth>=1.0.1->kubernetes->pydflow>=1.7.23->lam-crystal-philately==0.1.dev23+g7d4fc12) (0.6.0)
Requirement already satisfied: cffi>=1.0.1 in /opt/mamba/envs/matbench/lib/python3.11/site-packages (from argon2-cffi-bindings->argon2-cffi->minio->pydflow>=1.7.23->lam-crystal-philately==0.1.dev23+g7d4fc12) (1.16.0)
Requirement already satisfied: pycparser in /opt/mamba/envs/matbench/lib/python3.11/site-packages (from cffi>=1.0.1->argon2-cffi-bindings->argon2-cffi->minio->pydflow>=1.7.23->lam-crystal-philately==0.1.dev23+g7d4fc12) (2.21)
Building wheels for collected packages: lam-crystal-philately
  Building wheel for lam-crystal-philately (pyproject.toml) ... done
  Created wheel for lam-crystal-philately: filename=lam_crystal_philately-0.1.dev23+g7d4fc12-py3-none-any.whl size=31517 sha256=ceed84fdf74cb619ef0c5b30c8b652f0a9001ed9f6c72316640a06768e392af2
  Stored in directory: /tmp/pip-ephem-wheel-cache-hzsquqgd/wheels/61/47/de/ef330879f8aedf68b464ac99bcc69a236487ada5c119f4671e
Successfully built lam-crystal-philately
Installing collected packages: argo-workflows, websocket-client, jsonpickle, cloudpickle, argon2-cffi-bindings, pymatgen, kubernetes, ase, argon2-cffi, minio, pydflow, lam-crystal-philately
  Attempting uninstall: pymatgen
    Found existing installation: pymatgen 2024.4.13
    Uninstalling pymatgen-2024.4.13:
      Successfully uninstalled pymatgen-2024.4.13
  Attempting uninstall: ase
    Found existing installation: ase 3.23.0b1
    Uninstalling ase-3.23.0b1:
      Successfully uninstalled ase-3.23.0b1
Successfully installed argo-workflows-5.0.0 argon2-cffi-23.1.0 argon2-cffi-bindings-21.2.0 ase-3.22.1 cloudpickle-2.2.0 jsonpickle-3.2.2 kubernetes-30.1.0 lam-crystal-philately-0.1.dev23+g7d4fc12 minio-7.2.8 pydflow-1.8.85 pymatgen-2024.3.1 websocket-client-1.8.0
WARNING: Running pip as the 'root' user can result in broken permissions and conflicting behaviour with the system package manager. It is recommended to use a virtual environment instead: https://pip.pypa.io/warnings/venv
代码
文本

A DP model exists in the dataset of this notebook, soft-link it to current directory

代码
文本
[1]
!ln -s /bohr/lam-crystal-model-01oe/v3/dp0529.pth dp.pth
代码
文本

Optimize Structures Locally

Optimize example structures locally using commandline tool.

After structures are optimized, their convergence (skip with argument --skip-check-convergence) and duplicate in OpenLAM Database or not (skip with argument --skip-check-duplicate) will be checked by default. The latter check requires environmental variable BOHRIUM_ACCESS_KEY, which can be generated from https://bohrium.dp.tech/settings/user

代码
文本
[20]
%env BOHRIUM_ACCESS_KEY=xxx
env: BOHRIUM_ACCESS_KEY=xxx
代码
文本
[6]
!lam-opt relax -i openlam/examples/data -m dp.pth -o results.json --skip-check-convergence
To get the best performance, it is recommended to adjust the number of threads by setting the environment variables OMP_NUM_THREADS, DP_INTRA_OP_PARALLELISM_THREADS, and DP_INTER_OP_PARALLELISM_THREADS. See https://deepmd.rtfd.io/parallelism/ for more information.

Start to relax structures.

Relaxing: 0it [00:00, ?it/s]      Step     Time          Energy         fmax
BFGS:    0 11:59:39       -3.432330        1.4856
BFGS:    1 11:59:42       -3.462572        1.2149
BFGS:    2 11:59:52       -3.474138        1.2986
BFGS:    3 11:59:56       -3.499632        0.2218
BFGS:    4 11:59:56       -3.500611        0.0249
BFGS:    5 11:59:56       -3.500631        0.0114
BFGS:    6 11:59:56       -3.500635        0.0110
BFGS:    7 11:59:56       -3.500739        0.0496
BFGS:    8 11:59:57       -3.500918        0.0937
BFGS:    9 11:59:57       -3.501440        0.1756
BFGS:   10 11:59:57       -3.502467        0.2799
BFGS:   11 11:59:57       -3.504224        0.3837
BFGS:   12 11:59:57       -3.540719        0.7027
BFGS:   13 11:59:57       -3.545436        0.2616
BFGS:   14 11:59:57       -3.546308        0.1420
BFGS:   15 11:59:57       -3.546664        0.0037
BFGS:   16 11:59:57       -3.546664        0.0000
Relaxing: 1it [00:22, 22.67s/it]      Step     Time          Energy         fmax
BFGS:    0 11:59:57       -5.405985        0.7214
BFGS:    1 12:00:07       -5.421183        0.7691
BFGS:    2 12:00:07       -5.421177        2.1633
BFGS:    3 12:00:07       -5.503029        0.4127
BFGS:    4 12:00:07       -5.515699        0.5083
BFGS:    5 12:00:07       -5.550243        0.5736
BFGS:    6 12:00:07       -5.302219        3.1964
BFGS:    7 12:00:08       -5.563675        0.8995
BFGS:    8 12:00:08       -5.438606        0.7443
BFGS:    9 12:00:08       -5.545653        0.3734
BFGS:   10 12:00:08       -5.563606        1.3026
BFGS:   11 12:00:08       -5.564468        0.3407
BFGS:   12 12:00:08       -5.577429        0.3208
BFGS:   13 12:00:08       -5.247499        2.8527
BFGS:   14 12:00:08       -5.588167        0.5249
BFGS:   15 12:00:08       -5.569788        0.3426
BFGS:   16 12:00:08       -5.586407        0.2904
BFGS:   17 12:00:08       -5.291737        2.2892
BFGS:   18 12:00:08       -5.568543        1.3995
BFGS:   19 12:00:09       -5.467279        0.7000
BFGS:   20 12:00:09       -5.541057        0.4039
BFGS:   21 12:00:09       -5.550354        1.7077
BFGS:   22 12:00:09       -5.561118        0.3295
BFGS:   23 12:00:09       -5.571989        0.3297
BFGS:   24 12:00:09       -5.325982        1.6277
BFGS:   25 12:00:09       -5.590947        0.4720
BFGS:   26 12:00:09       -5.559236        0.3329
BFGS:   27 12:00:09       -5.581635        0.3157
BFGS:   28 12:00:09       -5.310092        2.1232
BFGS:   29 12:00:09       -5.582313        0.9937
BFGS:   30 12:00:09       -5.460432        0.7097
BFGS:   31 12:00:10       -5.551491        0.3550
BFGS:   32 12:00:10       -5.578869        1.1455
BFGS:   33 12:00:10       -5.568943        0.3095
BFGS:   34 12:00:10       -5.579210        0.3042
BFGS:   35 12:00:10       -5.317244        1.7866
BFGS:   36 12:00:10       -5.587033        0.7966
BFGS:   37 12:00:10       -5.461176        0.7112
BFGS:   38 12:00:10       -5.559699        0.3170
BFGS:   39 12:00:10       -5.592966        0.3663
BFGS:   40 12:00:10       -5.583208        0.2907
BFGS:   41 12:00:11       -5.592933        0.1862
BFGS:   42 12:00:11       -5.545587        1.7609
BFGS:   43 12:00:11       -5.594824        0.1668
BFGS:   44 12:00:11       -5.595295        0.1689
BFGS:   45 12:00:11       -5.595634        0.1508
BFGS:   46 12:00:11       -5.595848        0.1382
BFGS:   47 12:00:11       -5.596218        0.0995
BFGS:   48 12:00:11       -5.596359        0.0997
BFGS:   49 12:00:11       -5.596817        0.1094
BFGS:   50 12:00:11       -5.597326        0.1168
BFGS:   51 12:00:11       -5.598318        0.1175
BFGS:   52 12:00:12       -5.552859        0.4600
BFGS:   53 12:00:12       -5.574159        0.7846
BFGS:   54 12:00:12       -5.588147        0.5505
BFGS:   55 12:00:12       -5.595027        0.2559
BFGS:   56 12:00:12       -5.602665        0.1604
BFGS:   57 12:00:12       -5.604079        0.0749
BFGS:   58 12:00:12       -5.604216        0.1023
BFGS:   59 12:00:12       -5.604481        0.0826
BFGS:   60 12:00:12       -5.605446        0.0526
BFGS:   61 12:00:12       -5.606199        0.0744
BFGS:   62 12:00:13       -5.605357        0.4217
BFGS:   63 12:00:13       -5.607068        0.0346
BFGS:   64 12:00:13       -5.607500        0.0342
BFGS:   65 12:00:13       -5.581688        1.1910
BFGS:   66 12:00:13       -5.607893        0.0296
BFGS:   67 12:00:13       -5.608146        0.0301
BFGS:   68 12:00:13       -5.608311        0.1705
BFGS:   69 12:00:13       -5.608587        0.0554
BFGS:   70 12:00:13       -5.608691        0.0569
BFGS:   71 12:00:13       -5.609182        0.0947
BFGS:   72 12:00:13       -5.609566        0.0651
BFGS:   73 12:00:14       -5.600396        0.7815
BFGS:   74 12:00:14       -5.612574        0.1182
BFGS:   75 12:00:14       -5.614660        0.0937
BFGS:   76 12:00:14       -5.620260        0.0549
BFGS:   77 12:00:14       -5.619484        0.1918
BFGS:   78 12:00:14       -5.620855        0.0646
BFGS:   79 12:00:14       -5.620925        0.0391
BFGS:   80 12:00:14       -5.620993        0.0274
BFGS:   81 12:00:14       -5.621018        0.0179
BFGS:   82 12:00:14       -5.621036        0.0132
BFGS:   83 12:00:14       -5.621049        0.0236
BFGS:   84 12:00:15       -5.621061        0.0309
BFGS:   85 12:00:15       -5.621082        0.0386
BFGS:   86 12:00:15       -5.621136        0.0500
BFGS:   87 12:00:15       -5.621274        0.0678
BFGS:   88 12:00:15       -5.621747        0.0900
BFGS:   89 12:00:15       -5.626878        0.1020
BFGS:   90 12:00:15       -5.626784        0.2829
BFGS:   91 12:00:15       -5.630610        0.1543
BFGS:   92 12:00:15       -5.631596        0.0634
BFGS:   93 12:00:15       -5.631780        0.0422
BFGS:   94 12:00:16       -5.631856        0.0149
BFGS:   95 12:00:16       -5.631868        0.0015
BFGS:   96 12:00:16       -5.631869        0.0004
BFGS:   97 12:00:16       -5.631869        0.0001
Relaxing: 2it [00:41, 20.62s/it]

Saved to df.

代码
文本

The optimized structures and energies are included in the result file.

代码
文本
[9]
!cat results.json
{"final_structure":{"MP_mp-1006815":{"@module":"pymatgen.core.structure","@class":"Structure","charge":0,"lattice":{"matrix":[[7.230147594,-0.6129705837,-0.2359834023],[-4.1459218943,7.1809473651,0.4719668046],[-0.4390057784,0.760380313,14.2020498528]],"pbc":[true,true,true],"a":7.2599211658,"b":8.3052649614,"c":14.2291645685,"alpha":83.2045861827,"beta":93.8807974416,"gamma":124.8894017167,"volume":698.8008411647},"properties":{},"sites":[{"species":[{"element":"Cs","occu":1}],"abc":[-0.0,-0.0,0.0],"xyz":[0.0,-0.0,0.0],"properties":{},"label":"Cs"},{"species":[{"element":"H","occu":1}],"abc":[-0.0,0.1209169629,0.7997949989],"xyz":[-0.8524269099,1.4764467177,11.4157972395],"properties":{},"label":"H"},{"species":[{"element":"H","occu":1}],"abc":[0.0,0.8790830371,0.2002050011],"xyz":[-3.7325007628,6.4648809604,3.258219418],"properties":{},"label":"H"}]},"MP_mp-1093779":{"@module":"pymatgen.core.structure","@class":"Structure","charge":0,"lattice":{"matrix":[[16.0670444689,-0.0,-0.0],[-0.0,14.2111,-0.0],[-0.0,-0.0,20.0251]],"pbc":[true,true,true],"a":16.0670444689,"b":14.2111,"c":20.0251,"alpha":90.0000000001,"beta":90.0,"gamma":90.0,"volume":4572.3386054619},"properties":{},"sites":[{"species":[{"element":"K","occu":1}],"abc":[0.0,0.0,0.0],"xyz":[0.0,0.0,0.0],"properties":{},"label":"K"},{"species":[{"element":"Na","occu":1}],"abc":[0.1905935253,0.5,0.5],"xyz":[3.0622746457,7.10555,10.01255],"properties":{},"label":"Na"},{"species":[{"element":"Na","occu":1}],"abc":[0.8094064747,0.5,0.5],"xyz":[13.0047698232,7.10555,10.01255],"properties":{},"label":"Na"},{"species":[{"element":"Tl","occu":1}],"abc":[0.0,0.5,0.5],"xyz":[0.0,7.10555,10.01255],"properties":{},"label":"Tl"}]}},"final_energy":{"MP_mp-1006815":-5.6318688293,"MP_mp-1093779":-3.5466640916}}
代码
文本

The structures that pass the check are saved as CIF format files in the directory relaxed.

代码
文本
[7]
!ls relaxed
final-CsH2.cif	final-KNa2Tl.cif
代码
文本

Optimize Structures by Submitting Workflow

First create a configuration file for workflow. After structures are optimized, their convergence (skip with "check_convergence": false in relax.inputs of the config) and duplicate in OpenLAM Database or not (skip with "check_duplicate": false relax.inputs of the config) will be checked by default. The latter check requires environmental variable BOHRIUM_ACCESS_KEY, which can be generated from https://bohrium.dp.tech/settings/user

代码
文本
[ ]
%env BOHRIUM_ACCESS_KEY=xxx
代码
文本
[16]
%%file input.json
{
"relax": {
"inputs": {
"check_convergence": false
},
"image": "registry.dp.tech/dptech/prod-26832/lam-crystal-philately:dp-mptraj-ase-utype",
"executor": {
"image_pull_policy": "IfNotPresent",
"machine_dict": {
"batch_type": "Bohrium",
"context_type": "Bohrium",
"remote_profile": {
"input_data": {
"job_type": "container",
"platform": "ali",
"scass_type": "1 * NVIDIA T4_16g",
"maxRescheduleTimes": 10
}
}
},
"retry_on_submission_error": 10
}
}
}
Overwriting input.json
代码
文本

Here, we allocate 2 parallel tasks to optimize the 2 example structures

代码
文本
[9]
!mkdir -p part0 part1
!cp openlam/examples/data/MP_mp-1006815.cif part0
!cp openlam/examples/data/MP_mp-1093779.cif part1
代码
文本

Set environmental variables for workflows

代码
文本
[21]
%env DFLOW_HOST=https://workflows.deepmodeling.com
%env DFLOW_K8S_API_SERVER=https://workflows.deepmodeling.com
%env DFLOW_S3_REPO_KEY=oss-bohrium
%env DFLOW_S3_STORAGE_CLIENT=dflow.plugins.bohrium.TiefblueClient
%env BOHRIUM_USERNAME=xxx
%env BOHRIUM_PASSWORD=xxx
%env BOHRIUM_PROJECT_ID=xxx
env: DFLOW_HOST=https://workflows.deepmodeling.com
env: DFLOW_K8S_API_SERVER=https://workflows.deepmodeling.com
env: DFLOW_S3_REPO_KEY=oss-bohrium
env: DFLOW_S3_STORAGE_CLIENT=dflow.plugins.bohrium.TiefblueClient
env: BOHRIUM_USERNAME=xxx
env: BOHRIUM_PASSWORD=xxx
env: BOHRIUM_PROJECT_ID=xxx
代码
文本

Submit workflow

代码
文本
[18]
!lam-opt submit input.json -i part0 part1 -m dp.pth

Workflow has been submitted (ID: parallel-relax-ghxnh, UID: d391313a-d9e5-4947-ab11-da0b7c88b13c)
Workflow link: https://workflows.deepmodeling.com/workflows/argo/parallel-relax-ghxnh
代码
文本

Click on the workflow link to track the workflow status

alt

After the workflow finishes, download results by

代码
文本
[19]
!lam-opt download parallel-relax-ghxnh -o outputs
!tree outputs
100%|█████████████████████████████████████████████| 5/5 [00:00<00:00,  7.92it/s]
100%|█████████████████████████████████████████████| 5/5 [00:00<00:00,  7.87it/s]
outputs
├── 0
│   ├── relaxed
│   │   └── final-CsH2.cif
│   └── results.json
└── 1
    ├── relaxed
    │   └── final-KNa2Tl.cif
    └── results.json

4 directories, 4 files
代码
文本

Query crystal structures from OpenLAM Database

Set environmental variable BOHRIUM_ACCESS_KEY, which can be generated from https://bohrium.dp.tech/settings/user

代码
文本
[6]
%env BOHRIUM_ACCESS_KEY=xxx
env: BOHRIUM_ACCESS_KEY=xxx
代码
文本

Query crystal structures by Python API (The method query_by_page is deprecated! Use query_by_offset instead.)

代码
文本
[4]
from lam_optimize import CrystalStructure
data = CrystalStructure.query_by_offset()
print(data)
{'nextStartId': 18, 'items': [<lam_optimize.db.CrystalStructure object at 0x7f2ed5cf8590>, <lam_optimize.db.CrystalStructure object at 0x7f2ed57e71d0>, <lam_optimize.db.CrystalStructure object at 0x7f2ed5bb7290>, <lam_optimize.db.CrystalStructure object at 0x7f2ed5696450>, <lam_optimize.db.CrystalStructure object at 0x7f2ed5247810>, <lam_optimize.db.CrystalStructure object at 0x7f2ed5628950>, <lam_optimize.db.CrystalStructure object at 0x7f2ed5c0f650>, <lam_optimize.db.CrystalStructure object at 0x7f2ed5ba12d0>, <lam_optimize.db.CrystalStructure object at 0x7f2ed6d6ca90>, <lam_optimize.db.CrystalStructure object at 0x7f2ed4b899d0>]}
代码
文本

The method query_by_offset accepts following arguments as query conditions

formula: Optional[str] = None
min_energy: Optional[float] = None
max_energy: Optional[float] = None
min_submission_time: Optional[datetime.datetime] = None
max_submission_time: Optional[datetime.datetime] = None
offset: int = 0
limit: int = 10

returned data includes nextStartId (as offset for next query), and items which is a list of CrystalStructure objects, each object has following properties

class CrystalStructure:
    formula: str
    structure: pymatgen.core.Structure
    energy: float
    submission_time: datetime.datetime

The method query merging paged results is also provided

代码
文本
[5]
structures = CrystalStructure.query(formula="Sr2YSbO6")
print(structures)
[<lam_optimize.db.CrystalStructure object at 0x7f2ed5661050>, <lam_optimize.db.CrystalStructure object at 0x7f2ed54a3910>, <lam_optimize.db.CrystalStructure object at 0x7f2ed4baf850>]
代码
文本

which returns a list of CrystalStructure objects.

NOTE: Calling non-paging method without query condition will be extremely slow.

代码
文本

Query hull from OpenLAM Database

Set environmental variable BOHRIUM_ACCESS_KEY, which can be generated from https://bohrium.dp.tech/settings/user

代码
文本
[ ]
%env BOHRIUM_ACCESS_KEY=xxx
代码
文本

Query hull by composition from OpenLAM Database using Python API. If the hull of the composition has not been calculated in OpenLAM Database, this function will throw a RuntimeError.

代码
文本
[ ]
from lam_optimize.utils import query_hull_by_composition
hull = query_hull_by_composition(["K", "Na", "Tl"])
代码
文本

You can calculate energy above hull using the hull

代码
文本
[ ]
from lam_optimize.utils import get_e_above_hull
from pymatgen.core import Structure
structure = Structure.from_file("examples/data/MP_mp-1093779.cif")
get_e_above_hull(structure, hull, 0.123)
代码
文本
OpenLAM
OpenLAM
点个赞吧
{/**/}