yux1991 / PyRHEED

RHEED analysis and simulation
MIT License
25 stars 11 forks source link

Simulation crashes when loading .cif file #1

Open DaanWielens opened 5 years ago

DaanWielens commented 5 years ago

I would like to try to use the software to simulate RHEED patterns of InP(111)A. To start, I have simply downloaded a InP .cif file (http://crystallography.net/cod/1010146.cif). From the main window, I selected 'Simulation', then 'Diffraction Pattern'. When loading the .cif file, the log shows:

Initialized! CIF opened! Adding sample 1 Sample 1 loaded! Constructing sample 1 Finished construction of sample 1

Then, Windows notifies me that Python has stopped working.

The console shows:

C:\Users\Daan\git\PyRHEED\Source>python Main.py
Shadows are not yet supported for OpenGL ES2
Traceback (most recent call last):
  File "C:\Program Files (x86)\Python\lib\site-packages\pandas\core\indexes\base.py", line 2657, in get_loc
    return self._engine.get_loc(key)
  File "pandas\_libs\index.pyx", line 108, in pandas._libs.index.IndexEngine.get_loc
  File "pandas\_libs\index.pyx", line 132, in pandas._libs.index.IndexEngine.get_loc
  File "pandas\_libs\hashtable_class_helper.pxi", line 1601, in pandas._libs.hashtable.PyObjectHashTable.get_item
  File "pandas\_libs\hashtable_class_helper.pxi", line 1608, in pandas._libs.hashtable.PyObjectHashTable.get_item
KeyError: 'P3-'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "C:\Users\Daan\git\PyRHEED\Source\SimulateRHEED.py", line 581, in getCifPath
    self.addSampleData(self.structure_index)
  File "C:\Users\Daan\git\PyRHEED\Source\SimulateRHEED.py", line 677, in addSampleData
    colorPicker = IndexedColorPicker(str(name),self.colors[i],self.AR.loc[str(name)].at['Normalized Radius'],index)
  File "C:\Program Files (x86)\Python\lib\site-packages\pandas\core\indexing.py", line 1500, in __getitem__
    return self._getitem_axis(maybe_callable, axis=axis)
  File "C:\Program Files (x86)\Python\lib\site-packages\pandas\core\indexing.py", line 1913, in _getitem_axis
    return self._get_label(key, axis=axis)
  File "C:\Program Files (x86)\Python\lib\site-packages\pandas\core\indexing.py", line 141, in _get_label
    return self.obj._xs(label, axis=axis)
  File "C:\Program Files (x86)\Python\lib\site-packages\pandas\core\generic.py", line 3585, in xs
    loc = self.index.get_loc(key)
  File "C:\Program Files (x86)\Python\lib\site-packages\pandas\core\indexes\base.py", line 2659, in get_loc
    return self._engine.get_loc(self._maybe_cast_indexer(key))
  File "pandas\_libs\index.pyx", line 108, in pandas._libs.index.IndexEngine.get_loc
  File "pandas\_libs\index.pyx", line 132, in pandas._libs.index.IndexEngine.get_loc
  File "pandas\_libs\hashtable_class_helper.pxi", line 1601, in pandas._libs.hashtable.PyObjectHashTable.get_item
  File "pandas\_libs\hashtable_class_helper.pxi", line 1608, in pandas._libs.hashtable.PyObjectHashTable.get_item
KeyError: 'P3-'

It looks like the program has trouble in reading the .cif file, but since it is downloaded directly from the crystallographic database and is working fine in VESTA, I assume the file itself is fine...

yux1991 commented 5 years ago

@DaanWielens Hi Daan: Thank you for reporting this issue. Your CIF file crashed on my computer as well, raising the same error. Actually there's no problem with your CIF file. It turns out that I've failed to consider the situation where the atom species could be charged ions since I am mostly dealing with covalent compounds. I've fixed the bug regarding this issue. Please let me know if you experience any other issue.

DaanWielens commented 5 years ago

Today I have had the time to check your new code. However, I did not bring my laptop so I have created a virtual machine with Win10, downloaded Python 3.7.3 and installed the packages as listed in your Readme requirements section.

Today, I received an error

C:\Users\Daan Wielens\git\PyRHEED\Source>python Main.py
Traceback (most recent call last):
  File "Main.py", line 5, in <module>
    import broadening
ModuleNotFoundError: No module named 'broadening'

It looks like the re-styled code in commit aa9faa27925168673d4516f9930753799843d454 causes the problem, as I am able to import Broadening but not broadening. Same holds for Process which is now called from Main.py as process. Probably all files need to be renamed to match the 'import' lines of code. I am not sure if all other re-styling options lead to any problems.

yux1991 commented 5 years ago

@DaanWielens Yes, that's because I've renamed all my filenames. I did not set my git to be case sensitive therefore it did not pick up some of the filename changes. I've fixed it in my last commit. Thanks.