Dear AJ,
Sorry to have to bother you again. I am having this trouble for over a whole day, and tried to validate it through different angles.
moving_cation = Element(‘Mg’)
struct = Structure.from_dict(doc[‘gamma_structure’])
cation_site = PeriodicSite.from_dict(doc[‘path’][image_num])
struct.insert(0, cation_site.specie, cation_site.frac_coords, properties=doc[‘path’][image_num][‘properties’])
task1 = WritePointRunInput(structure=struct.as_dict(), moving_cation=moving_cation.as_dict())
In the above code, I am creating a FireTask with two arguments, a pymatgen.Structure object and an pymatgen.Element object, The WritePointRunInput FireTask uses these two inputs as below:
@explicit_serialize
class WritePointRunInput(FireTaskBase):
"""
Write Vasp Gamma input set, using parameters settings in generateGammaRun.py
"""
required_params = ['structure', "moving_cation"]
def run_task(self, fw_spec):
struct = Structure.from_dict(self["structure"])
params = PointRunInput(struct, ggaU=False)
incar = params.get_incar(relax=True)
poscar = params.get_poscar(Element.from_dict(self["moving_cation"]))
potcar = params.get_potcar()
kpoints = params.get_kpoints()
# WRite out VASP input files
incar.write_file("INCAR")
poscar.write_file("POSCAR")
potcar.write_file("POTCAR")
kpoints.write_file("KPOINTS")
return FWAction()
However, this code
struct = Structure.from_dict(self["structure"])
will run into error:
Traceback (most recent call last):
File “/global/u1/r/rongzq/sr_neb/codes/fireworks/fireworks/core/rocket.py”, line 213, in run
m_action = t.run_task(my_spec)
File “/global/u1/r/rongzq/sr_neb/codes/MultiFil/HTApproxNEB/hierarchy_screening/PointEnergyTask.py”, line 34, in run_task
struct = Structure.from_dict(self[“structure”])
File “/global/u1/r/rongzq/sr_neb/codes/pymatgen/pymatgen/core/structure.py”, line 1348, in from_dict
lattice = Lattice.from_dict(d[“lattice”])
File “/global/u1/r/rongzq/sr_neb/codes/pymatgen/pymatgen/core/structure.py”, line 188, in getitem
return self.sites[ind]
TypeError: list indices must be integers, not unicode
I can successfully reconstruct the pymatgen.Structure object both locally and on the remote machine with code:
ss = Structure.from_dict(struct.as_dict())
while not running into any error as above. So I think it might be Fireworks is digesting the inputs through a unicode encryption?
Two add on information:
-
I used similar codes with the previous Fireworks codebase on a high-throughput application and it is totally working fine
-
I have tried to pass the inputs with two other ways:
2.1 Pass it in fw_spec,
2.2 Pass it within a key-value dictionary as the python example shown in https://pythonhosted.org/FireWorks/firetask_tutorial.html
But both these two methods run into same unicode Type error.
Thank you very much.
Rong