materialscloud-org / tools-barebone

A framework to develop apps that can be contributed in the Work/Tools section of the Materials Cloud
https://www.materialscloud.org/work/tools
Other
4 stars 6 forks source link

Fix the CASTEP importer #12

Closed giovannipizzi closed 4 years ago

giovannipizzi commented 4 years ago

The ASE importer used now fails with most input files. See e.g. Si2-bs.cell.txt that returns

    Generating castep_keywords.py ... hang on.
    The castep_keywords.py contains abstractions for CASTEP input
    parameters (for both .cell and .param input files), including some
    format checks and descriptions. The latter are extracted from the
    internal online help facility of a CASTEP binary, thus allowing to
    easily keep the calculator synchronized with (different versions of)
    the CASTEP code. Consequently, avoiding licensing issues (CASTEP is
    distributed commercially by accelrys), we consider it wise not to
    provide castep_keywords.py in the first place.

read_cell: Warning - Was not able to initialize CASTEP calculator.
           This may be due to a non-existing "castep.keywords.py"
           file or a non-existing CASTEP installation.
           Original error message appears below:

           Could not determine the version of your CASTEP binary 
           This usually means one of the following 
              * you do not have CASTEP installed 
              * you have not set the CASTEP_COMMAND to call it 
              * you have provided a wrong CASTEP_COMMAND. 
                Make sure it is in your PATH

           Fallback-mode will be applied to provide at least the
           geometric information contained in the *.cell file.
Warning: the keyword BS_KPOINT_LIST is not
         interpreted in cell files
---------------------------------------------------------------------------
AttributeError                            Traceback (most recent call last)
<ipython-input-5-4323c05a7564> in <module>()
----> 1 get_structure_tuple(open('/home/pizzi/Desktop/Si2-bs.cell'), 'castep')

/home/pizzi/git/seekpath/webservice/structure_importers/__init__.pyc in get_structure_tuple(fileobject, fileformat)
     55     elif fileformat == 'castep':
     56         import ase.io.castep
---> 57         asestructure = ase.io.castep.read_castep_cell(fileobject)
     58         return tuple_from_ase(asestructure)
     59     elif fileformat == 'qe-inp':

/home/pizzi/.local/lib/python2.7/site-packages/ase/io/castep.pyc in read_castep_cell(fd, index)
    599                     else:
    600                         block_lines.append(lines[l-1].strip())
--> 601                 calc.__setattr__(block_name, block_lines)
    602                 # raise UserWarning
    603         else:

AttributeError: 'NoneType' object has no attribute 'BS_KPOINT_LIST'

Action: reimplement a simple parser just for the cell and the atomic positions.

Moved from giovannipizzi/seekpath#24

giovannipizzi commented 4 years ago

This was an old issue - now in v1.0 formats are tested, and the CASTEP importer is working