deepmodeling / abacus-develop

An electronic structure package based on either plane wave basis or numerical atomic orbitals.
http://abacus.ustc.edu.cn
GNU Lesser General Public License v3.0
164 stars 128 forks source link

Bug: broken CIF file output by ABACUS #4998

Closed kirk0830 closed 2 weeks ago

kirk0830 commented 1 month ago

Describe the bug

As feedback from user, the STRU.cif output cannot be parsed by ASE read() function. Related developer should make sure a standard format of CIF is provided instead of a broken one. Here I copy the error message given by ASE: OH$0Q9Q}YMJX6T`GIM{V`$P_tmb

Expected behavior

No response

To Reproduce

No response

Environment

No response

Additional Context

No response

Task list for Issue attackers (only for developers)

QuantumMisaka commented 1 month ago

Here I copied my error message:

Traceback (most recent call last):
  File "/Users/apple/miniconda3/envs/research/bin/ase", line 8, in <module>
    sys.exit(main())
  File "/Users/apple/miniconda3/envs/research/lib/python3.10/site-packages/ase/cli/main.py", line 102, in main
    f(args)
  File "/Users/apple/miniconda3/envs/research/lib/python3.10/site-packages/ase/gui/ag.py", line 68, in run
    images.read(args.filenames, args.image_number)
  File "/Users/apple/miniconda3/envs/research/lib/python3.10/site-packages/ase/gui/images.py", line 137, in read
    imgs = read(filename, index, filetype)
  File "/Users/apple/miniconda3/envs/research/lib/python3.10/site-packages/ase/io/formats.py", line 803, in read
    return list(_iread(filename, index, format, io, parallel=parallel,
  File "/Users/apple/miniconda3/envs/research/lib/python3.10/site-packages/ase/parallel.py", line 302, in new_generator
    for result in generator(*args, **kwargs):
  File "/Users/apple/miniconda3/envs/research/lib/python3.10/site-packages/ase/io/formats.py", line 872, in _iread
    for dct in io.read(fd, *args, **kwargs):
  File "/Users/apple/miniconda3/envs/research/lib/python3.10/site-packages/ase/io/formats.py", line 628, in wrap_read_function
    yield read(filename, **kwargs)
  File "/Users/apple/miniconda3/envs/research/lib/python3.10/site-packages/ase/utils/__init__.py", line 577, in iofunc
    obj = func(fd, *args, **kwargs)
  File "/Users/apple/miniconda3/envs/research/lib/python3.10/site-packages/ase/io/abacus.py", line 702, in read_abacus
    [line.split() for line in specie_pattern.search(contents).group(1).split("\n")]
AttributeError: 'NoneType' object has no attribute 'group'

in OUT.suffix dir, STRU.cif and STRU_NOW.cif will both have this problem. Also, if read them by ATOMKIT, the error message will be:

 -->> (01) Reading Structure from STRU_NOW.cif File...
Error: No Symmetry data available.

Also, CIF files exported by ATOMKIT will have same read-in problem in using ASE, but they can be tackled by ATOMKIT itself. One example in attachments is STRU_ION_D.cif

Attachments CIF.tar.gz

QuantumMisaka commented 3 weeks ago

@kirk0830 I've tried your new branch, and found that

Outputed STRU.cif STRU.cif.txt

kirk0830 commented 3 weeks ago

@kirk0830 I've tried your new branch, and found that

  • STRU.cif still cannot be read-in by ASE
 ~> ase -T gui STRU.cif
Traceback (most recent call last):
  File "/Users/apple/miniconda3/envs/research/bin/ase", line 8, in <module>
    sys.exit(main())
  File "/Users/apple/miniconda3/envs/research/lib/python3.10/site-packages/ase/cli/main.py", line 102, in main
    f(args)
  File "/Users/apple/miniconda3/envs/research/lib/python3.10/site-packages/ase/gui/ag.py", line 68, in run
    images.read(args.filenames, args.image_number)
  File "/Users/apple/miniconda3/envs/research/lib/python3.10/site-packages/ase/gui/images.py", line 137, in read
    imgs = read(filename, index, filetype)
  File "/Users/apple/miniconda3/envs/research/lib/python3.10/site-packages/ase/io/formats.py", line 803, in read
    return list(_iread(filename, index, format, io, parallel=parallel,
  File "/Users/apple/miniconda3/envs/research/lib/python3.10/site-packages/ase/parallel.py", line 302, in new_generator
    for result in generator(*args, **kwargs):
  File "/Users/apple/miniconda3/envs/research/lib/python3.10/site-packages/ase/io/formats.py", line 872, in _iread
    for dct in io.read(fd, *args, **kwargs):
  File "/Users/apple/miniconda3/envs/research/lib/python3.10/site-packages/ase/io/formats.py", line 628, in wrap_read_function
    yield read(filename, **kwargs)
  File "/Users/apple/miniconda3/envs/research/lib/python3.10/site-packages/ase/utils/__init__.py", line 577, in iofunc
    obj = func(fd, *args, **kwargs)
  File "/Users/apple/miniconda3/envs/research/lib/python3.10/site-packages/ase/io/abacus.py", line 702, in read_abacus
    [line.split() for line in specie_pattern.search(contents).group(1).split("\n")]
AttributeError: 'NoneType' object has no attribute 'group'
  • by ATOMKIT, there will also be error
113 STRU.cif
 -->> (01) Reading Structure from STRU.cif File...
 +---------------------------------------------------------------+
 | This utility is in experimental stage & needs to be improved. |   
 +---------------------------------------------------------------+
 +---------------------------------------------------------------+
  Species and Wyckoff Sites 
  [H ]  0.628  0.517  0.713
  [H ]  0.369  0.517  0.454
  [Au]  0.040  0.100  0.040
  [Au]  0.290  0.100  0.040
  [Au]  0.540  0.100  0.040
  [Au]  0.790  0.100  0.040
  [Au]  0.040  0.100  0.290
  [Au]  0.290  0.100  0.290
  [Au]  0.540  0.100  0.290
  [Au]  0.790  0.100  0.290
  [Au]  0.040  0.100  0.540
  [Au]  0.290  0.100  0.540
  [Au]  0.540  0.100  0.540
  [Au]  0.790  0.100  0.540
  [Au]  0.040  0.100  0.790
  [Au]  0.290  0.100  0.790
  [Au]  0.540  0.100  0.790
  [Au]  0.790  0.100  0.790
  [Au]  0.123  0.224  0.207
  [Au]  0.373  0.224  0.207
  [Au]  0.623  0.224  0.207
  [Au]  0.873  0.224  0.207
  [Au]  0.123  0.224  0.457
  [Au]  0.373  0.224  0.457
  [Au]  0.623  0.224  0.457
  [Au]  0.873  0.224  0.457
  [Au]  0.123  0.224  0.707
  [Au]  0.373  0.224  0.707
  [Au]  0.623  0.224  0.707
  [Au]  0.873  0.224  0.707
  [Au]  0.123  0.224  0.957
  [Au]  0.373  0.224  0.957
  [Au]  0.623  0.224  0.957
  [Au]  0.873  0.224  0.957
  [Au]  0.209  0.347  0.126
  [Au]  0.455  0.346  0.122
  [Au]  0.706  0.347  0.123
  [Au]  0.957  0.347  0.123
  [Au]  0.207  0.347  0.373
  [Au]  0.458  0.348  0.376
  [Au]  0.707  0.347  0.373
  [Au]  0.956  0.347  0.374
  [Au]  0.207  0.348  0.622
  [Au]  0.457  0.348  0.623
  [Au]  0.704  0.348  0.623
  [Au]  0.958  0.346  0.625
  [Au]  0.206  0.346  0.874
  [Au]  0.458  0.348  0.873
  [Au]  0.707  0.347  0.873
  [Au]  0.954  0.347  0.871
  [Au]  0.042  0.473  0.040
  [Au]  0.290  0.474  0.039
  [Au]  0.539  0.474  0.041
  [Au]  0.791  0.473  0.042
  [Au]  0.038  0.473  0.289
  [Au]  0.286  0.478  0.283
  [Au]  0.541  0.472  0.288
  [Au]  0.790  0.475  0.290
  [Au]  0.039  0.474  0.541
  [Au]  0.285  0.475  0.542
  [Au]  0.545  0.480  0.537
  [Au]  0.793  0.472  0.539
  [Au]  0.042  0.473  0.791
  [Au]  0.289  0.473  0.791
  [Au]  0.538  0.475  0.796
  [Au]  0.799  0.477  0.795
  [Au]  0.545  0.480  0.537
  [Au]  0.793  0.472  0.539
  [Au]  0.042  0.473  0.791
  [Au]  0.289  0.473  0.791
  [Au]  0.538  0.475  0.796
  [Au]  0.799  0.477  0.795
 +---------------------------------------------------------------+
 |      Cell Parameters After Applying Symmetry Operations       |
 +---------------------------------------------------------------+
     Import File Format:   CIF
      Lattice Constants:  11.535     NaN     NaN
         Lattice Angles:     NaN     NaN     NaN
            Total Atoms:  72
        Number of Atoms:  [H ]   2
        Number of Atoms:  [Au]  70
 +---------------------------------------------------------------+
 ERR**NOT INV
  • VESTA will QUIT while reading this cif file

Outputed STRU.cif STRU.cif.txt

@QuantumMisaka Thanks, it is because of my careless mistake, now you can have a try again, I guess this time there would not be problems.