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

Element symbols are now used when generating an ase atom. #1571

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 3 additions & 1 deletion optimade/adapters/structures/ase.py
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,9 @@ def get_ase_atoms(optimade_structure: OptimadeStructure) -> Atoms:
if current_species.mass:
mass = current_species.mass[0]
Copy link
Member

@ml-evs ml-evs Mar 26, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could probably do with an additional check for partial/multiple occupancy here, e.g.,

Suggested change
mass = current_species.mass[0]
mass = current_species.mass[0]
if len(current_species.chemical_symbols) != 1:
raise RuntimeError

Copy link
Contributor Author

@JPBergsma JPBergsma Mar 27, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In principle, the disorder flag should be set in the structure_features when more than 1 element is present in a species.chemical_symbols.
And we already check for this. Do you want me to make an additional check for the fields that could potentially have more than 1 value ? i.e. mass and chemical symbols ?

PS. I do not think it is possible to generate a StructureResource object which has multiple entries for chemical_symblos or mass without also setting disorder. So I do not think this test is necessary.


atoms.append(Atom(symbol=species_name, position=site, mass=mass))
atoms.append(
Atom(symbol=current_species.chemical_symbols[0], position=site, mass=mass)
)

info = {}
for key in attributes.dict().keys():
Expand Down
15 changes: 12 additions & 3 deletions optimade/server/data/test_structures.json
Original file line number Diff line number Diff line change
Expand Up @@ -267,7 +267,16 @@
"concentration": [
1.0
],
"name": "Ac"
"name": "Ac1"
},
{
"chemical_symbols": [
"Ac"
],
"concentration": [
1.0
],
"name": "Ac2"
},
{
"chemical_symbols": [
Expand All @@ -289,8 +298,8 @@
}
],
"species_at_sites": [
"Ac",
"Ac",
"Ac1",
"Ac2",
"Ag",
"Pb"
],
Expand Down