Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

to_ase error when kind name includes string tag. #26

Open
superstar54 opened this issue Jul 19, 2024 · 2 comments
Open

to_ase error when kind name includes string tag. #26

superstar54 opened this issue Jul 19, 2024 · 2 comments

Comments

@superstar54
Copy link
Member

structure_dict = {
    'cell':[[2.75,2.75,0],[0,2.75,2.75],[2.75,0,2.75]],
    'pbc': [True,True,True],
    'sites':[
        {
            'symbol':'Si',
            'position':[3/4, 3/4, 3/4],
            'charge': +1,
            'kind_name': 'Si_up',
        },
        {
            'symbol':'Si',
            'position':[1/2, 1/2, 1/2],
            'kind_name': 'Si_down',
        },
    ],
}

mutable_structure = StructureDataMutable(**structure_dict)
structure = StructureData(**structure_dict)
structure.to_ase().get_tags()

Error message

structure_dict = {
    'cell':[[2.75,2.75,0],[0,2.75,2.75],[2.75,0,2.75]],
    'pbc': [True,True,True],
    'sites':[
        {
            'symbol':'Si',
            'position':[3/4, 3/4, 3/4],
            'charge': +1,
            'kind_name': 'Si_up',
        },
        {
            'symbol':'Si',
            'position':[1/2, 1/2, 1/2],
            'kind_name': 'Si_down',
        },
    ],
}

mutable_structure = StructureDataMutable(**structure_dict)
structure = StructureData(**structure_dict)
structure.to_ase().get_tags()
@mikibonacci
Copy link
Collaborator

Hi @xing, thanks a lot for testing the StructureData. In this case, the issue is in the ASE object: the tags are strings ('_up','_down'), whereas ASE accepts only integers.
This will work:

structure_dict = {
    'cell':[[2.75,2.75,0],[0,2.75,2.75],[2.75,0,2.75]],
    'pbc': [True,True,True],
    'sites':[
        {
            'symbol':'Si',
            'position':[3/4, 3/4, 3/4],
            'charge': +1,
            'kind_name': 'Si0',
        },
        {
            'symbol':'Si',
            'position':[1/2, 1/2, 1/2],
            'kind_name': 'Si1',
        },
    ],
}

mutable_structure = StructureDataMutable(**structure_dict)
structure = StructureData(**structure_dict)
structure.to_ase().get_tags()

tags being [0,1].

Do you think that we should provide a check for the kind_names? i.e. to provide only the element+integers, or we should automatically change Si_up to Si0? I think we should not allow element+strings, as also in ASE it is not allowed to provide tags as strings.

@superstar54
Copy link
Member Author

The old StructureData has a mechanism to handle this.
https://github.com/aiidateam/aiida-core/blob/1dafdf2ddb38c801d2075d9af9bbde9e0d26c8ca/aiida/orm/nodes/data/structure.py#L2403

However, this makes the user somehow confused, because the kind name is changed, which may affect other input parameters.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants