pyiron_atomistics
pyiron_atomistics copied to clipboard
Sorry. But, the problem was not solved. Should I reinstall pyiron in the "cmti001.bc.rzg.mpg.de"?
It seems like the pyiron has been updated recently. The code worked well before but now failed with the following issue. And the kernel frequently died when loading data...
---------------------------------------------------------------------------
KeyError Traceback (most recent call last)
Cell In[3], line 5
3 pr, structure = io.load(filename,filetype)
4 structure_spin = io.add_spin(pr,structure,'Fe','2.5','B','0')
----> 5 structure_spin.plot3d()
File /u/system/SLES12/soft/pyiron/dev/anaconda3/lib/python3.8/site-packages/pyiron_atomistics/atomistics/structure/atoms.py:1215, in Atoms.plot3d(self, mode, show_cell, show_axes, camera, spacefill, particle_size, select_atoms, background, color_scheme, colors, scalar_field, scalar_start, scalar_end, scalar_cmap, vector_field, vector_color, magnetic_moments, view_plane, distance_from_camera, opacity)
1192 def plot3d(
1193 self,
1194 mode="NGLview",
(...)
1213 opacity=1.0,
1214 ):
-> 1215 return self.visualize.plot3d(
1216 mode=mode,
1217 show_cell=show_cell,
1218 show_axes=show_axes,
1219 camera=camera,
1220 spacefill=spacefill,
1221 particle_size=particle_size,
1222 select_atoms=select_atoms,
1223 background=background,
1224 color_scheme=color_scheme,
1225 colors=colors,
1226 scalar_field=scalar_field,
1227 scalar_start=scalar_start,
1228 scalar_end=scalar_end,
1229 scalar_cmap=scalar_cmap,
1230 vector_field=vector_field,
1231 vector_color=vector_color,
1232 magnetic_moments=magnetic_moments,
1233 view_plane=view_plane,
1234 distance_from_camera=distance_from_camera,
1235 opacity=opacity,
1236 )
File /u/system/SLES12/soft/pyiron/dev/anaconda3/lib/python3.8/site-packages/pyiron_atomistics/atomistics/structure/_visualize.py:100, in Visualize.plot3d(self, mode, show_cell, show_axes, camera, spacefill, particle_size, select_atoms, background, color_scheme, colors, scalar_field, scalar_start, scalar_end, scalar_cmap, vector_field, vector_color, magnetic_moments, view_plane, distance_from_camera, opacity)
24 def plot3d(
25 self,
26 mode="NGLview",
(...)
45 opacity=1.0,
46 ):
47 """
48 Plot3d relies on NGLView or plotly to visualize atomic structures. Here, we construct a string in the "protein database"
49
(...)
98 * The colour interpretation of some hex codes is weird, e.g. 'green'.
99 """
--> 100 return plot3d(
101 structure=self._ref_atoms,
102 mode=mode,
103 show_cell=show_cell,
104 show_axes=show_axes,
105 camera=camera,
106 spacefill=spacefill,
107 particle_size=particle_size,
108 select_atoms=select_atoms,
109 background=background,
110 color_scheme=color_scheme,
111 colors=colors,
112 scalar_field=scalar_field,
113 scalar_start=scalar_start,
114 scalar_end=scalar_end,
115 scalar_cmap=scalar_cmap,
116 vector_field=vector_field,
117 vector_color=vector_color,
118 magnetic_moments=magnetic_moments,
119 view_plane=view_plane,
120 distance_from_camera=distance_from_camera,
121 opacity=opacity,
122 )
File /u/system/SLES12/soft/pyiron/dev/anaconda3/lib/python3.8/site-packages/structuretoolkit/visualize.py:100, in plot3d(structure, mode, show_cell, show_axes, camera, spacefill, particle_size, select_atoms, background, color_scheme, colors, scalar_field, scalar_start, scalar_end, scalar_cmap, vector_field, vector_color, magnetic_moments, view_plane, distance_from_camera, opacity)
46 """
47 Plot3d relies on NGLView or plotly to visualize atomic structures. Here, we construct a string in the "protein database"
48
(...)
97 * The colour interpretation of some hex codes is weird, e.g. 'green'.
98 """
99 if mode == "NGLview":
--> 100 return _plot3d(
101 structure=structure,
102 show_cell=show_cell,
103 show_axes=show_axes,
104 camera=camera,
105 spacefill=spacefill,
106 particle_size=particle_size,
107 select_atoms=select_atoms,
108 background=background,
109 color_scheme=color_scheme,
110 colors=colors,
111 scalar_field=scalar_field,
112 scalar_start=scalar_start,
113 scalar_end=scalar_end,
114 scalar_cmap=scalar_cmap,
115 vector_field=vector_field,
116 vector_color=vector_color,
117 magnetic_moments=magnetic_moments,
118 view_plane=view_plane,
119 distance_from_camera=distance_from_camera,
120 )
121 elif mode == "plotly":
122 return _plot3d_plotly(
123 structure=structure,
124 camera=camera,
(...)
130 opacity=opacity,
131 )
File /u/system/SLES12/soft/pyiron/dev/anaconda3/lib/python3.8/site-packages/structuretoolkit/visualize.py:304, in _plot3d(structure, show_cell, show_axes, camera, spacefill, particle_size, select_atoms, background, color_scheme, colors, scalar_field, scalar_start, scalar_end, scalar_cmap, vector_field, vector_color, magnetic_moments, view_plane, distance_from_camera)
301 vector_field = structure.get_initial_magnetic_moments()
303 elements = structure.get_chemical_symbols()
--> 304 atomic_numbers = get_atomic_numbers(structure=structure)
305 positions = structure.positions
307 # If `select_atoms` was given, visualize only a subset of the `parent_basis`
File /u/system/SLES12/soft/pyiron/dev/anaconda3/lib/python3.8/site-packages/structuretoolkit/helper.py:7, in get_atomic_numbers(structure)
6 def get_atomic_numbers(structure):
----> 7 return [atomic_numbers[el] for el in structure.get_chemical_symbols()]
File /u/system/SLES12/soft/pyiron/dev/anaconda3/lib/python3.8/site-packages/structuretoolkit/helper.py:7, in <listcomp>(.0)
6 def get_atomic_numbers(structure):
----> 7 return [atomic_numbers[el] for el in structure.get_chemical_symbols()]
KeyError: 'Fe_spin'
Hi @RhettZhou. To me it seems like some of our steps to only rely on ase.Atoms
fired back such that 'non-standard' element names are now broken?
Which pyiron(_base, _atomistics) versions are/were you using?
Hi @RhettZhou. To me it seems like some of our steps to only rely on
ase.Atoms
fired back such that 'non-standard' element names are now broken? Which pyiron(_base, _atomistics) versions are/were you using?
Hi, @niklassiemer. Many thanks for your reply. I am using the pyiron on "cmti001.bc.rzg.mpg.de". pyiron version: 0.4.7
Ok, so this is a problem on the garching cluster in generell! I will look up the most recent changes in our environment and try to reproduce the error. However, I did not update last week because if the upcoming long weekend where I did not want to disturb running calculations unnoticed.
Could you provide a MWE I could use to check?
%matplotlib inline
import numpy as np
import matplotlib.pylab as plt
import jupyter_capture_output
def load(filename,filetype):
pr = Project(path=filename)
structure = ase_to_pyiron(ase.io.read(filename='structure/'+
filename + '.' + filetype, format=filetype))
return pr, structure
def add_spin(pr,structure,matrix,matrix_spin,solute,solute_spin):
structure_spin = structure.copy()
M_spin = pr.create.structure.element(new_element_name=matrix+'_spin',parent_element=matrix,spin=matrix_spin)
S_spin = pr.create.structure.element(new_element_name=solute+'_spin',parent_element=solute,spin=solute_spin)
for i in range(len(structure_spin)):
if structure_spin[i].symbol == matrix:
structure_spin[i] = M_spin
elif structure_spin[i].symbol == solute:
structure_spin[i] = S_spin
return structure_spin
filename = 'Fe444'
filetype = 'cif'
pr, structure = load(filename,filetype)
structure_spin = add_spin(pr,structure,'Fe','2.5','B','0')
structure_spin.plot3d()
## Here the structure file could be "Fe444.cif". But does not really matter. Many thanks!!
from pyiron.project import Project import ase from pyiron_atomistics.atomistics.structure.atoms import ase_to_pyiron
A few more modules need to be loaded, I forgot to mention above.
Ok, so this is a problem on the garching cluster in generell! I will look up the most recent changes in our environment and try to reproduce the error. However, I did not update last week because if the upcoming long weekend where I did not want to disturb running calculations unnoticed.
I wonder if there is a steady version that will not change on the garching cluster. Then I could use it all the time. :-)) Best regards
%matplotlib inline
import numpy as np import matplotlib.pylab as plt import jupyter_capture_output
def load(filename,filetype): pr = Project(path=filename) structure = ase_to_pyiron(ase.io.read(filename='structure/'+ filename + '.' + filetype, format=filetype)) return pr, structure
def add_spin(pr,structure,matrix,matrix_spin,solute,solute_spin): structure_spin = structure.copy() M_spin = pr.create.structure.element(new_element_name=matrix+'_spin',parent_element=matrix,spin=matrix_spin) S_spin = pr.create.structure.element(new_element_name=solute+'_spin',parent_element=solute,spin=solute_spin) for i in range(len(structure_spin)): if structure_spin[i].symbol == matrix: structure_spin[i] = M_spin elif structure_spin[i].symbol == solute: structure_spin[i] = S_spin return structure_spin
filename = 'Fe444' filetype = 'cif'
pr, structure = load(filename,filetype) structure_spin = add_spin(pr,structure,'Fe','2.5','B','0') structure_spin.plot3d()
Here the structure file could be "Fe444.cif". But does not really matter. Many thanks!!
Thanks! However, this is not a minimal working example. Actually, the structure causing the error in the end is the most crucial part which is missing.
I suppose this be condensed to something like
from pyiron import Project
pr = Project('MWE')
struc = pr.create.structure.bulk('Fe').repeat(3)
struc[0]=pr.create.structure.element(new_element_name='Fe_spin',parent_element=Fe,spin='2.5')
struc.plot3d()
raising the same error?
Ok, so this is a problem on the garching cluster in generell! I will look up the most recent changes in our environment and try to reproduce the error. However, I did not update last week because if the upcoming long weekend where I did not want to disturb running calculations unnoticed.
I wonder if there is a steady version that will not change on the garching cluster. Then I could use it all the time. :-)) Best regards
Something like this is actually planned :)
%matplotlib inline import numpy as np import matplotlib.pylab as plt import jupyter_capture_output def load(filename,filetype): pr = Project(path=filename) structure = ase_to_pyiron(ase.io.read(filename='structure/'+ filename + '.' + filetype, format=filetype)) return pr, structure def add_spin(pr,structure,matrix,matrix_spin,solute,solute_spin): structure_spin = structure.copy() M_spin = pr.create.structure.element(new_element_name=matrix+'_spin',parent_element=matrix,spin=matrix_spin) S_spin = pr.create.structure.element(new_element_name=solute+'_spin',parent_element=solute,spin=solute_spin) for i in range(len(structure_spin)): if structure_spin[i].symbol == matrix: structure_spin[i] = M_spin elif structure_spin[i].symbol == solute: structure_spin[i] = S_spin return structure_spin filename = 'Fe444' filetype = 'cif' pr, structure = load(filename,filetype) structure_spin = add_spin(pr,structure,'Fe','2.5','B','0') structure_spin.plot3d()
Here the structure file could be "Fe444.cif". But does not really matter. Many thanks!!
Thanks! However, this is not a minimal working example. Actually, the structure causing the error in the end is the most crucial part which is missing.
I suppose this be condensed to something like
from pyiron import Project pr = Project('MWE') struc = pr.create.structure.bulk('Fe').repeat(3) struc[0]=pr.create.structure.element(new_element_name='Fe_spin',parent_element=Fe,spin='2.5') struc.plot3d()
raising the same error?
There is an error if I run the codes above. However, if I change parent_element='Fe', it ran. But the same issue comes.
@jan-janssen as we separated the https://github.com/pyiron/structuretoolkit, we did not include any and thus broke the own atom definition we had on the pure pyiron side for some tools like plot3d()
. Probably we need another concept/translation here.
The issue seems to be spins not being correctly converted from pyiron to ASE:
from structuretoolkit.visualize import plot3d
from pyiron_atomistics import Project, pyiron_to_ase
pr = Project('MWE')
struc = pr.create.structure.bulk('Fe').repeat(3)
struc[0]=pr.create.structure.element(new_element_name='Fe_spin', parent_element="Fe", spin='2.5')
plot3d(pyiron_to_ase(struc))
I would presume this is related to the changes in https://github.com/pyiron/pyiron_atomistics/pull/984 , https://github.com/pyiron/pyiron_atomistics/pull/982 or https://github.com/pyiron/pyiron_atomistics/pull/978 . But most likely @samwaseda can provide more details on how the conversion of new elements and the spin tags is handled now.
Ah I guess I know where it comes from. It’s probably something I removed a few months ago. Sorry for the disruption.
It should be solved after this one, but to be honest after having looked into it I don't really understand why it could work before - from what I could see it should have never worked.
The issue seems to be spins not being correctly converted from pyiron to ASE:
Maybe I should have explained what I saw - the problem comes from the fact that we change the name of the element when we create our own species, and ASE does not recognise it, and that's the error that @RhettZhou was getting in his very first post. It is possible that there's a problem with the spin, but that's an independent one.