set_inital_magnetic_moment in Atoms is incompatible with non collinear magnetism setting
I wish to do a calculation with spin-polarised in the presence of spin-orbit coupling in Vasp. As Vasp requires specify the spin along three different axes, the magnum input requires a sequence of three numbers to specify the spin. For an Atoms object myatoms, this will result in 3*len(my atoms) of floats required to specify the initial spin. The setting of the magmom works fine, however the incar.write fails when it tries to condense repeated numerical values, specifically in vast.py at line 1012
for n in range(1, len(magmom)): ----> 2 if magmom[n] == magmom[n - 1]: 3 list[-1][0] += 1 4 else: 5 list.append([1, magmom[n]])
The comparison of magmom[0] and magmom[1] results in the comparison of 1 and [0,0,1] which results in the Boolean array of [True, True, True, dtype=bool]. Python does not know how to evaluate this and crashes with the error:
ValueError: The truth value of an array with more than one element is ambiguous. Use a.any() or a.all()
Solution:
The sorting in vasp.py must not assume that all elements are scalars. The line above
if if magmom[n] == magmom[n - 1]:
should be replace with
if (magmom[n] == magmom[n - 1]).all():