CederGroupHub / chgnet

Pretrained universal neural network potential for charge-informed atomistic modeling https://chgnet.lbl.gov
https://doi.org/10.1038/s42256-023-00716-3
Other
226 stars 61 forks source link

[Bug]: Bug on saving result to ASE database file #187

Open thatstar opened 4 weeks ago

thatstar commented 4 weeks ago

Email (Optional)

surui1986@gmail.com

Version

v0.3.8

Which OS(es) are you using?

What happened?

I am aiming to store the CHGNet calculator within the ASE's (Atomic Simulation Environment) SQLite3 database for future use. However, I'm encountering an error when attempting to retrieve the CHGNet calculator from the database file.

Code snippet

import warnings
warnings.simplefilter(action='ignore', category=FutureWarning)
from chgnet.model import CHGNetCalculator
from ase.build import bulk
from ase.db import connect
from ase.io import read

a = bulk("Si", cubic=True)
a.calc = CHGNetCalculator()
a.get_forces()
con = connect("ref.db")
con.write(a)
# error on this line
b = read("ref.db")

Log output

CHGNet v0.3.0 initialized with 412,525 parameters
CHGNet will run on cuda:0
Traceback (most recent call last):
  File "/home/surui/work/chgnet_test/test_ase.py", line 14, in <module>
    b = read("ref.db")
        ^^^^^^^^^^^^^^
  File "/home/surui/repo/ase/ase/io/formats.py", line 809, in read
    return next(_iread(filename, slice(index, None), format, io,
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/surui/repo/ase/ase/parallel.py", line 302, in new_generator
    for result in generator(*args, **kwargs):
  File "/home/surui/repo/ase/ase/io/formats.py", line 875, in _iread
    for dct in io.read(fd, *args, **kwargs):
  File "/home/surui/repo/ase/ase/io/db.py", line 26, in read_db
    for row in db.select(offset=start, limit=stop - start):
  File "/home/surui/repo/ase/ase/parallel.py", line 302, in new_generator
    for result in generator(*args, **kwargs):
  File "/home/surui/repo/ase/ase/db/core.py", line 519, in select
    for row in self._select(keys, cmps, explain=explain,
  File "/home/surui/repo/ase/ase/db/sqlite.py", line 706, in _select
    yield self._convert_tuple_to_row(tuple(values))
          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/surui/repo/ase/ase/db/sqlite.py", line 498, in _convert_tuple_to_row
    dct['stress'] = deblob(values[20])
                    ^^^^^^^^^^^^^^^^^^
  File "/home/surui/repo/ase/ase/db/sqlite.py", line 173, in deblob
    array = np.frombuffer(buf, dtype)
            ^^^^^^^^^^^^^^^^^^^^^^^^^
ValueError: buffer size must be a multiple of element size

Code of Conduct