Skip to content

Commit ea2009b

Browse files
committed
Add space_group_hall and space_group_it_number to structure model
1 parent b5169a8 commit ea2009b

File tree

2 files changed

+59
-7
lines changed

2 files changed

+59
-7
lines changed

openapi/openapi.json

Lines changed: 22 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3359,9 +3359,9 @@
33593359
"type": "number"
33603360
},
33613361
"description": "If present MUST be a list of floats expressed in a.m.u.\nElements denoting vacancies MUST have masses equal to 0.",
3362+
"x-optimade-unit": "a.m.u.",
33623363
"x-optimade-queryable": "optional",
3363-
"x-optimade-support": "optional",
3364-
"x-optimade-unit": "a.m.u."
3364+
"x-optimade-support": "optional"
33653365
},
33663366
"original_name": {
33673367
"title": "Original Name",
@@ -3639,9 +3639,25 @@
36393639
},
36403640
"description": "The three lattice vectors in Cartesian coordinates, in \u00e5ngstr\u00f6m (\u00c5).\n\n- **Type**: list of list of floats or unknown values.\n\n- **Requirements/Conventions**:\n - **Support**: SHOULD be supported by all implementations, i.e., SHOULD NOT be `null`.\n - **Query**: Support for queries on this property is OPTIONAL.\n If supported, filters MAY support only a subset of comparison operators.\n - MUST be a list of three vectors *a*, *b*, and *c*, where each of the vectors MUST BE a list of the vector's coordinates along the x, y, and z Cartesian coordinates.\n (Therefore, the first index runs over the three lattice vectors and the second index runs over the x, y, z Cartesian coordinates).\n - For databases that do not define an absolute Cartesian system (e.g., only defining the length and angles between vectors), the first lattice vector SHOULD be set along *x* and the second on the *xy*-plane.\n - MUST always contain three vectors of three coordinates each, independently of the elements of property `dimension_types`.\n The vectors SHOULD by convention be chosen so the determinant of the `lattice_vectors` matrix is different from zero.\n The vectors in the non-periodic directions have no significance beyond fulfilling these requirements.\n - The coordinates of the lattice vectors of non-periodic dimensions (i.e., those dimensions for which `dimension_types` is `0`) MAY be given as a list of all `null` values.\n If a lattice vector contains the value `null`, all coordinates of that lattice vector MUST be `null`.\n\n- **Examples**:\n - `[[4.0,0.0,0.0],[0.0,4.0,0.0],[0.0,1.0,4.0]]` represents a cell, where the first vector is `(4, 0, 0)`, i.e., a vector aligned along the `x` axis of length 4 \u00c5; the second vector is `(0, 4, 0)`; and the third vector is `(0, 1, 4)`.",
36413641
"nullable": true,
3642+
"x-optimade-unit": "\u00c5",
3643+
"x-optimade-queryable": "optional",
3644+
"x-optimade-support": "should"
3645+
},
3646+
"space_group_hall": {
3647+
"title": "Space Group Hall",
3648+
"type": "string",
3649+
"description": "A Hall space group symbol representing the symmetry of the structure as defined in Hall, S. R. (1981), Acta Cryst. A37, 517-525 and erratum (1981), A37, 921.\n\n- **Type**: string\n\n- **Requirements/Conventions**:\n - **Support**: OPTIONAL support in implementations, i.e., MAY be `null`.\n - **Query**: Support for queries on this property is OPTIONAL.\n - Each component of the Hall symbol MUST be separated by a single space symbol.\n - If there exists a standard Hall symbol which represents the symmetry it SHOULD be used.\n - MUST be null if `nperiodic_dimensions` is not equal to 3.",
36423650
"x-optimade-queryable": "optional",
3643-
"x-optimade-support": "should",
3644-
"x-optimade-unit": "\u00c5"
3651+
"x-optimade-support": "optional"
3652+
},
3653+
"space_group_it_number": {
3654+
"title": "Space Group It Number",
3655+
"maximum": 230.0,
3656+
"minimum": 1.0,
3657+
"type": "integer",
3658+
"description": "Space group number for the structure assigned by the International Tables for Crystallography Vol. A.\n- **Type**: integer\n\n- **Requirements/Conventions**:\n - **Support**: OPTIONAL support in implementations, i.e., MAY be `null`.\n - **Query**: Support for queries on this property is OPTIONAL.\n - The integer value MUST be between 1 and 230.\n - MUST be null if `nperiodic_dimensions` is not equal to 3.",
3659+
"x-optimade-queryable": "optional",
3660+
"x-optimade-support": "optional"
36453661
},
36463662
"cartesian_site_positions": {
36473663
"title": "Cartesian Site Positions",
@@ -3656,9 +3672,9 @@
36563672
},
36573673
"description": "Cartesian positions of each site in the structure.\nA site is usually used to describe positions of atoms; what atoms can be encountered at a given site is conveyed by the `species_at_sites` property, and the species themselves are described in the `species` property.\n\n- **Type**: list of list of floats\n\n- **Requirements/Conventions**:\n - **Support**: SHOULD be supported by all implementations, i.e., SHOULD NOT be `null`.\n - **Query**: Support for queries on this property is OPTIONAL.\n If supported, filters MAY support only a subset of comparison operators.\n - It MUST be a list of length equal to the number of sites in the structure, where every element is a list of the three Cartesian coordinates of a site expressed as float values in the unit angstrom (\u00c5).\n - An entry MAY have multiple sites at the same Cartesian position (for a relevant use of this, see e.g., the property `assemblies`).\n\n- **Examples**:\n - `[[0,0,0],[0,0,2]]` indicates a structure with two sites, one sitting at the origin and one along the (positive) *z*-axis, 2 \u00c5 away from the origin.",
36583674
"nullable": true,
3675+
"x-optimade-unit": "\u00c5",
36593676
"x-optimade-queryable": "optional",
3660-
"x-optimade-support": "should",
3661-
"x-optimade-unit": "\u00c5"
3677+
"x-optimade-support": "should"
36623678
},
36633679
"nsites": {
36643680
"title": "Nsites",

optimade/models/structures.py

Lines changed: 37 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
from functools import reduce
88
from typing import List, Optional, Union
99

10-
from pydantic import BaseModel, conlist, root_validator, validator
10+
from pydantic import BaseModel, conint, conlist, root_validator, validator
1111

1212
from optimade.models.entries import EntryResource, EntryResourceAttributes
1313
from optimade.models.utils import (
@@ -525,6 +525,36 @@ class StructureResourceAttributes(EntryResourceAttributes):
525525
queryable=SupportLevel.OPTIONAL,
526526
)
527527

528+
space_group_hall: Optional[str] = OptimadeField(
529+
None,
530+
description="""A Hall space group symbol representing the symmetry of the structure as defined in Hall, S. R. (1981), Acta Cryst. A37, 517-525 and erratum (1981), A37, 921.
531+
532+
- **Type**: string
533+
534+
- **Requirements/Conventions**:
535+
- **Support**: OPTIONAL support in implementations, i.e., MAY be `null`.
536+
- **Query**: Support for queries on this property is OPTIONAL.
537+
- Each component of the Hall symbol MUST be separated by a single space symbol.
538+
- If there exists a standard Hall symbol which represents the symmetry it SHOULD be used.
539+
- MUST be null if `nperiodic_dimensions` is not equal to 3.""",
540+
support=SupportLevel.OPTIONAL,
541+
queryable=SupportLevel.OPTIONAL,
542+
)
543+
544+
space_group_it_number: Optional[conint(ge=1, le=230)] = OptimadeField( # type: ignore[valid-type]
545+
None,
546+
description="""Space group number for the structure assigned by the International Tables for Crystallography Vol. A.
547+
- **Type**: integer
548+
549+
- **Requirements/Conventions**:
550+
- **Support**: OPTIONAL support in implementations, i.e., MAY be `null`.
551+
- **Query**: Support for queries on this property is OPTIONAL.
552+
- The integer value MUST be between 1 and 230.
553+
- MUST be null if `nperiodic_dimensions` is not equal to 3.""",
554+
support=SupportLevel.OPTIONAL,
555+
queryable=SupportLevel.OPTIONAL,
556+
)
557+
528558
cartesian_site_positions: Optional[List[Vector3D]] = OptimadeField( # type: ignore[valid-type]
529559
...,
530560
description="""Cartesian positions of each site in the structure.
@@ -950,6 +980,12 @@ def check_periodic_dimensions(cls, v, values):
950980

951981
return v
952982

983+
@validator("space_group_hall", "space_group_it_number")
984+
def check_space_group_vs_nperiodic_dimensions(cls, v, values, field):
985+
if v is not None and values.get("nperiodic_dimensions", 3) != 3:
986+
raise ValueError(f"{field.name} provided but `nperiodic_dimensions!=3`")
987+
return v
988+
953989
@validator("lattice_vectors", always=True)
954990
def required_if_dimension_types_has_one(cls, v, values):
955991
if v is None:

0 commit comments

Comments
 (0)