aiidateam / aiida-core

The official repository for the AiiDA code
https://aiida-core.readthedocs.io
Other
437 stars 192 forks source link

Cannot set RealhydrogenOrbital to OrbitalData: No valid module name #2783

Closed DanielMarchand closed 5 years ago

DanielMarchand commented 5 years ago

@giovannipizzi Currently if I try to set RealhydrogenOrbital to OrbitalData the whole thing fails:

from aiida.plugins import OrbitalFactory
from aiida.orm import OrbitalData

my_real_hydrogen_dict = {'angular_momentum': -3, 'diffusivity': None, 'kind_name': 'As', 'magnetic_number': 0, 'position': [-1.420047044832945, 1.420047044832945, 1.420047044832945], 
'radial_nodes': 0, 'spin': 0, 'spin_orientation': None, 'x_orientation': None, 'z_orientation': None}
RealHydrogen = OrbitalFactory('realhydrogen')
orbital = RealHydrogen(**my_real_hydrogen_dict)
node = OrbitalData()
node.set_orbitals(orbital=orbital)
--------------------------------------------------------
ValidationError: No valid module name found in orbital

Internally this is because the following inside the set_oribtals routine is failing:

            orbital_dict = this_projection.get_orbital_dict()
            OrbitalClass = self._get_orbital_class_from_orbital_dict(
                           orbital_dict
....
._get_orbital_class_from_orbital_dict
....
        try:
            module_name = orbital_dict['module_name']
        except KeyError:
            raise ValidationError("No valid module name found in orbital")

So for some reason at one point orbitals (or at least RealHydrogenOrbitals) once returned their module name, but now they dont. I'm not really clear what this section of the code is supposed to test. I"m going to disable it on my end to move forward with the wannier90 testing. Maybe we can make some changes in how the set_orbital method is run? Actually, it seems like OrbitalData really depends on having access to a 'module_name' to return RealHydrogenOrbitals, the internals are a bit strange. I saw that commit 4adc6db640c took out the module_name variable, perhaps we put it back in but with a different name. Either that or restructure how OrbitalData sets and dumps its orbital contents

giovannipizzi commented 5 years ago

Mmm, indeed I removed the module_name as I didn't think this was the right approach. I'll try to check next week how to properly implement what you need - we'll need to add some tests.

sphuber commented 5 years ago

Fixed in PR #2844