vossjo / ase-espresso

ase interface for Quantum Espresso
GNU General Public License v3.0
65 stars 55 forks source link

Creation of faulty PW input for heavy elements with mass==NaN #16

Closed ralphk86 closed 7 years ago

ralphk86 commented 8 years ago

When creating PW input files for systems that contain heavy elements (e.g. Po, At, Rn, ...), for which ASE has no defined atomic mass (i.e. NaN in ase/data/__init__.py), a string "nan" is written to the input file. This causes pw.x to crash.

Since the correct mass for these elements is typically not needed, I'd propose the following quick fix: In __init__.py, line 798 change the following code region

self.specdict = {}
for i,s in dic.values():
    self.specdict[s] = specobj(s = s.strip('0123456789'), #chemical symbol w/o index
        mass = masses[i],                   #<=== THIS LINE
        magmom = magmoms[i],
        U = Ulist[i],
        J = Jlist[i],

to

        mass = masses[i] if masses[i]>0. else 0.0,   #<=== NEW LINE

This will substitute 0.0 for unknown masses, which allows pw to run through.

Possible issues arise if old python versions don't support the something if some-condition else something-else syntax.

vossjo commented 7 years ago

Thanks, Ralph. Fixed in a similar fashion (possibly working with older python versions if needed).