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

[BUG] LabeledSystem from OUTCAR not working #359

Open
hoba87 opened this issue Sep 29, 2022 · 6 comments
Open

[BUG] LabeledSystem from OUTCAR not working #359

hoba87 opened this issue Sep 29, 2022 · 6 comments
Labels
bug Something isn't working vasp

Comments

@hoba87
Copy link

hoba87 commented Sep 29, 2022

Summary

The generation of a LabeledSystem from an OUTCAR file is not working (anymore, since version 0.2.6).

Running on CentOS 8 with python 3.7.9.

Steps to Reproduce

dsys = dpdata.LabeledSystem('OUTCAR.out', fmt='vasp/outcar')

Command works until version 0.2.5, with >=0.2.6 getting an error, here evaluated for version 0.2.8:

---------------------------------------------------------------------------
IndexError                                Traceback (most recent call last)
<ipython-input-2-d285c09cc64a> in <module>
----> 1 dsys = dpdata.LabeledSystem('OUTCAR.out', fmt='vasp/outcar')

/opt/python/python-3.7.9/lib/python3.7/site-packages/dpdata/system.py in __init__(self, file_name, fmt, type_map, begin, step, data, **kwargs)
    225         if file_name is None :
    226             return
--> 227         self.from_fmt(file_name, fmt, type_map=type_map, begin= begin, step=step, **kwargs)
    228 
    229         if type_map is not None:

/opt/python/python-3.7.9/lib/python3.7/site-packages/dpdata/system.py in from_fmt(self, file_name, fmt, **kwargs)
    251         if fmt == 'auto':
    252             fmt = os.path.basename(file_name).split('.')[-1].lower()
--> 253         return self.from_fmt_obj(load_format(fmt), file_name, **kwargs)
    254 
    255     def from_fmt_obj(self, fmtobj, file_name, **kwargs):

/opt/python/python-3.7.9/lib/python3.7/site-packages/dpdata/system.py in from_fmt_obj(self, fmtobj, file_name, **kwargs)
   1011 
   1012     def from_fmt_obj(self, fmtobj, file_name, **kwargs):
-> 1013         data = fmtobj.from_labeled_system(file_name, **kwargs)
   1014         if data:
   1015             if isinstance(data, (list, tuple)):

/opt/python/python-3.7.9/lib/python3.7/site-packages/dpdata/plugins/vasp.py in from_labeled_system(self, file_name, begin, step, **kwargs)
     75                 vol = np.linalg.det(np.reshape(data['cells'][ii], [3, 3]))
     76                 data['virials'][ii] *= v_pref * vol
---> 77         data = uniq_atom_names(data)
     78         return data
     79 

/opt/python/python-3.7.9/lib/python3.7/site-packages/dpdata/utils.py in uniq_atom_names(data)
     87     data['atom_names'] = unames
     88     tmp_type = list(data['atom_types']).copy()
---> 89     data['atom_types'] = np.array([uidxmap[jj] for jj in tmp_type], dtype=int)
     90     data['atom_numbs'] = [sum( ii == data['atom_types'] ) for ii in range(len(data['atom_names'])) ]
     91     return data

/opt/python/python-3.7.9/lib/python3.7/site-packages/dpdata/utils.py in <listcomp>(.0)
     87     data['atom_names'] = unames
     88     tmp_type = list(data['atom_types']).copy()
---> 89     data['atom_types'] = np.array([uidxmap[jj] for jj in tmp_type], dtype=int)
     90     data['atom_numbs'] = [sum( ii == data['atom_types'] ) for ii in range(len(data['atom_names'])) ]
     91     return data

IndexError: list index out of range
@hoba87 hoba87 added the bug Something isn't working label Sep 29, 2022
@njzjz
Copy link
Member

njzjz commented Sep 29, 2022

Please provide your file.

@hoba87
Copy link
Author

hoba87 commented Sep 30, 2022

OUTCAR.zip

@HuangJiameng
Copy link
Collaborator

HuangJiameng commented Sep 30, 2022

https://github.com/deepmodeling/dpdata/blob/master/dpdata/vasp/outcar.py#L10

There is no "TITLE" in this OUTCAR.out, so atoms are failed to be extracted...

@Chensons
Copy link

data = dpdata.LabeledSystem("OUTCAR")
Traceback (most recent call last):
File "", line 1, in
File "/vol01/homes/hy38185/miniconda3/lib/python3.10/site-packages/dpdata/system.py", line 183, in init
self.from_fmt(
File "/vol01/homes/hy38185/miniconda3/lib/python3.10/site-packages/dpdata/system.py", line 220, in from_fmt
return self.from_fmt_obj(load_format(fmt), file_name, **kwargs)
File "/vol01/homes/hy38185/miniconda3/lib/python3.10/site-packages/dpdata/system.py", line 1113, in from_fmt_obj
data = fmtobj.from_labeled_system(file_name, **kwargs)
File "/vol01/homes/hy38185/miniconda3/lib/python3.10/site-packages/dpdata/plugins/vasp.py", line 94, in from_labeled_system
data = uniq_atom_names(data)
File "/vol01/homes/hy38185/miniconda3/lib/python3.10/site-packages/dpdata/utils.py", line 97, in uniq_atom_names
data["atom_types"] = np.array([uidxmap[jj] for jj in tmp_type], dtype=int)
File "/vol01/homes/hy38185/miniconda3/lib/python3.10/site-packages/dpdata/utils.py", line 97, in
data["atom_types"] = np.array([uidxmap[jj] for jj in tmp_type], dtype=int)
IndexError: list index out of range
data = dpdata.LabeledSystem("OUTCAR")
Traceback (most recent call last):
File "", line 1, in
File "/vol01/homes/hy38185/miniconda3/lib/python3.10/site-packages/dpdata/system.py", line 183, in init
self.from_fmt(
File "/vol01/homes/hy38185/miniconda3/lib/python3.10/site-packages/dpdata/system.py", line 220, in from_fmt
return self.from_fmt_obj(load_format(fmt), file_name, **kwargs)
File "/vol01/homes/hy38185/miniconda3/lib/python3.10/site-packages/dpdata/system.py", line 1113, in from_fmt_obj
data = fmtobj.from_labeled_system(file_name, **kwargs)
File "/vol01/homes/hy38185/miniconda3/lib/python3.10/site-packages/dpdata/plugins/vasp.py", line 94, in from_labeled_system
data = uniq_atom_names(data)
File "/vol01/homes/hy38185/miniconda3/lib/python3.10/site-packages/dpdata/utils.py", line 97, in uniq_atom_names
data["atom_types"] = np.array([uidxmap[jj] for jj in tmp_type], dtype=int)
File "/vol01/homes/hy38185/miniconda3/lib/python3.10/site-packages/dpdata/utils.py", line 97, in
data["atom_types"] = np.array([uidxmap[jj] for jj in tmp_type], dtype=int)
IndexError: list index out of range

@Chensons
Copy link

OUTCAR.zip

@Chensons
Copy link

Chensons commented May 23, 2024

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working vasp
Projects
None yet
Development

No branches or pull requests

4 participants