Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Why not correctly predict the energy by using deepmd.calculator in ASE? #1366

Closed
taipinghu opened this issue Dec 21, 2021 · 2 comments
Closed
Labels

Comments

@taipinghu
Copy link

taipinghu commented Dec 21, 2021

Dear developers,
I want to predict the energy using deepmd.calculator in ASE module according to the https://github.com/deepmodeling/deepmd-kit/blob/master/doc/third-party/ase.md, but some errors occur. The obtained energy is not correct.
My code is :
`#!/bin/env python

from ase import Atoms
from deepmd.calculator import DP

import ase.io as IO

system_ase = IO.read("OUTCAR")
print(system_ase.get_potential_energy())

import dpdata
system_dpdata = dpdata.LabeledSystem("OUTCAR", fmt="vasp/outcar")
print(system_dpdata["energies"][0])
atype = system_dpdata["atom_types"]

system_ase_tmp = Atoms("Li12Co12O24", positions=system_ase.get_positions(), cell=system_ase.get_cell(), calculator=DP(model="graph.000.pb"))
print(system_ase_tmp.get_potential_energy())

from deepmd.infer import DeepPot
import numpy as np
dp = DeepPot("graph.000.pb")
coordinate = np.array(system_ase.get_positions()).reshape([1, -1])
cell = np.array(system_ase.get_cell()).reshape([1, -1])
e, f, v = dp.eval(coordinate, cell, atype)
print(e)`

the output of the code is:
WARNING:tensorflow:From /data/hutaiping/hutaiping/bin/Software/anaconda3/envs/deepmodeling/lib/python3.9/site-packages/tensorflow/python/compat/v2_compat.py:96: disable_resource_variables (from tensorflow.python.ops.variable_scope) is deprecated and will be removed in a future version.
Instructions for updating:
non-resource variables are not supported in the long term
WARNING:root:Environment variable KMP_BLOCKTIME is empty. Use the default value 0
WARNING:root:Environment variable KMP_AFFINITY is empty. Use the default value granularity=fine,verbose,compact,1,0
/data/hutaiping/hutaiping/bin/Software/anaconda3/envs/deepmodeling/lib/python3.9/importlib/init.py:169: UserWarning: The NumPy module was reloaded (imported a second time). This can in some cases result in small but subtle issues and is discouraged.
_bootstrap._exec(spec, module)
OMP: Info #155: KMP_AFFINITY: Initial OS proc set respected: 0-7
OMP: Info #216: KMP_AFFINITY: decoding x2APIC ids.
OMP: Info #216: KMP_AFFINITY: cpuid leaf 11 not supported.
OMP: Info #216: KMP_AFFINITY: decoding legacy APIC ids.
OMP: Info #157: KMP_AFFINITY: 8 available OS procs
OMP: Info #158: KMP_AFFINITY: Uniform topology
OMP: Info #287: KMP_AFFINITY: topology layer "LL cache" is equivalent to "socket".
OMP: Info #192: KMP_AFFINITY: 1 socket x 4 cores/socket x 2 threads/core (4 total cores)
OMP: Info #218: KMP_AFFINITY: OS proc to physical thread map:
OMP: Info #172: KMP_AFFINITY: OS proc 0 maps to socket 0 core 0 thread 0
OMP: Info #172: KMP_AFFINITY: OS proc 1 maps to socket 0 core 0 thread 1
OMP: Info #172: KMP_AFFINITY: OS proc 2 maps to socket 0 core 1 thread 0
OMP: Info #172: KMP_AFFINITY: OS proc 3 maps to socket 0 core 1 thread 1
OMP: Info #172: KMP_AFFINITY: OS proc 4 maps to socket 0 core 2 thread 0
OMP: Info #172: KMP_AFFINITY: OS proc 5 maps to socket 0 core 2 thread 1
OMP: Info #172: KMP_AFFINITY: OS proc 6 maps to socket 0 core 3 thread 0
OMP: Info #172: KMP_AFFINITY: OS proc 7 maps to socket 0 core 3 thread 1
OMP: Info #254: KMP_AFFINITY: pid 823851 tid 823851 thread 0 bound to OS proc set 0
-274.46677386
-274.46677386

2021-12-21 09:57:57.948274: I tensorflow/core/platform/cpu_feature_guard.cc:142] This TensorFlow binary is optimized with oneAPI Deep Neural Network Library (oneDNN) to use the following CPU instructions in performance-critical operations: SSE4.1 SSE4.2 AVX AVX2 AVX512F FMA
To enable them in other operations, rebuild TensorFlow with the appropriate compiler flags.
2021-12-21 09:57:57.948639: I tensorflow/core/common_runtime/process_util.cc:146] Creating new thread pool with default inter op setting: 2. Tune using inter_op_parallelism_threads for best performance.
2021-12-21 09:57:57.969967: I tensorflow/core/platform/profile_utils/cpu_utils.cc:114] CPU Frequency: 2499995000 Hz
OMP: Info #254: KMP_AFFINITY: pid 823851 tid 825240 thread 1 bound to OS proc set 2
OMP: Info #254: KMP_AFFINITY: pid 823851 tid 825998 thread 3 bound to OS proc set 6
OMP: Info #254: KMP_AFFINITY: pid 823851 tid 825999 thread 4 bound to OS proc set 1
OMP: Info #254: KMP_AFFINITY: pid 823851 tid 826000 thread 5 bound to OS proc set 3
OMP: Info #254: KMP_AFFINITY: pid 823851 tid 826002 thread 7 bound to OS proc set 7
OMP: Info #254: KMP_AFFINITY: pid 823851 tid 826003 thread 8 bound to OS proc set 0
OMP: Info #254: KMP_AFFINITY: pid 823851 tid 826001 thread 6 bound to OS proc set 5
OMP: Info #254: KMP_AFFINITY: pid 823851 tid 825997 thread 2 bound to OS proc set 4
-157.2026545916724
OMP: Info #254: KMP_AFFINITY: pid 823851 tid 825241 thread 9 bound to OS proc set 2
OMP: Info #254:
test.tar.gz
KMP_AFFINITY: pid 823851 tid 826769 thread 11 bound to OS proc set 6
OMP: Info #254: KMP_AFFINITY: pid 823851 tid 826771 thread 13 bound to OS proc set 3
OMP: Info #254: KMP_AFFINITY: pid 823851 tid 826772 thread 14 bound to OS proc set 5
OMP: Info #254: KMP_AFFINITY: pid 823851 tid 826774 thread 16 bound to OS proc set 0
OMP: Info #254: KMP_AFFINITY: pid 823851 tid 826768 thread 10 bound to OS proc set 4
OMP: Info #254: KMP_AFFINITY: pid 823851 tid 826770 thread 12 bound to OS proc set 1
OMP: Info #254: KMP_AFFINITY: pid 823851 tid 826773 thread 15 bound to OS proc set 7
[[-274.50289425]]

my python version is 3.9.7, deepmd kit version is 2.0.3.
Here I attach all my files.
test.tar.gz

@njzjz
Copy link
Member

njzjz commented Dec 21, 2021

You did not set correct pbc in ASE. Refer https://wiki.fysik.dtu.dk/ase/ase/atoms.html#ase.Atoms.

@taipinghu
Copy link
Author

You did not set correct pbc in ASE. Refer https://wiki.fysik.dtu.dk/ase/ase/atoms.html#ase.Atoms.

OK, Thanks a lot.
when pbc was used in ase.Atoms, the output is normal.

@njzjz njzjz closed this as completed Dec 21, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants