cif¶
Convert an OPTIMADE structure, in the format of
StructureResource
to a CIF file (Crystallographic Information File).
For more information on the CIF file format, see the official documentation.
Note
This conversion function is inspired heavily by the similar conversion function in the ASE library.
See here for the original ASE code.
For more information on the ASE library, see their documentation.
This conversion function relies on the NumPy library.
NUMPY_NOT_FOUND = 'NumPy not found, cannot convert structure to CIF'
module-attribute
¶
__all__ = ('get_cif')
module-attribute
¶
AdapterPackageNotFound
¶
Bases: OptimadeWarning
The package for an adapter cannot be found.
Source code in optimade/adapters/warnings.py
6 7 |
|
OptimadeStructure
¶
Bases: EntryResource
Representing a structure.
Source code in optimade/models/structures.py
1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 1178 1179 1180 1181 1182 1183 1184 1185 1186 1187 1188 1189 1190 1191 1192 1193 |
|
OptimadeStructureSpecies
¶
Bases: BaseModel
A list describing the species of the sites of this structure.
Species can represent pure chemical elements, virtual-crystal atoms representing a statistical occupation of a given site by multiple chemical elements, and/or a location to which there are attached atoms, i.e., atoms whose precise location are unknown beyond that they are attached to that position (frequently used to indicate hydrogen atoms attached to another element, e.g., a carbon with three attached hydrogens might represent a methyl group, -CH3).
- Examples:
[ {"name": "Ti", "chemical_symbols": ["Ti"], "concentration": [1.0]} ]
: any site with this species is occupied by a Ti atom.[ {"name": "Ti", "chemical_symbols": ["Ti", "vacancy"], "concentration": [0.9, 0.1]} ]
: any site with this species is occupied by a Ti atom with 90 % probability, and has a vacancy with 10 % probability.[ {"name": "BaCa", "chemical_symbols": ["vacancy", "Ba", "Ca"], "concentration": [0.05, 0.45, 0.5], "mass": [0.0, 137.327, 40.078]} ]
: any site with this species is occupied by a Ba atom with 45 % probability, a Ca atom with 50 % probability, and by a vacancy with 5 % probability. The mass of this site is (on average) 88.5 a.m.u.[ {"name": "C12", "chemical_symbols": ["C"], "concentration": [1.0], "mass": [12.0]} ]
: any site with this species is occupied by a carbon isotope with mass 12.[ {"name": "C13", "chemical_symbols": ["C"], "concentration": [1.0], "mass": [13.0]} ]
: any site with this species is occupied by a carbon isotope with mass 13.[ {"name": "CH3", "chemical_symbols": ["C"], "concentration": [1.0], "attached": ["H"], "nattached": [3]} ]
: any site with this species is occupied by a methyl group, -CH3, which is represented without specifying precise positions of the hydrogen atoms.
Source code in optimade/models/structures.py
64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 |
|
cell_to_cellpar(cell, radians=False)
¶
Returns the cell parameters [a, b, c, alpha, beta, gamma]
.
Angles are in degrees unless radian=True
is used.
Note
Based on ASE code.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
cell |
tuple[Vector3D, Vector3D, Vector3D]
|
A Cartesian 3x3 cell. This equates to the
|
required |
radians |
bool
|
Use radians instead of degrees (default) for angles. |
False
|
Returns:
Type | Description |
---|---|
list[float]
|
The unit cell parameters as a |
Source code in optimade/adapters/structures/utils.py
104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 |
|
fractional_coordinates(cell, cartesian_positions)
¶
Returns fractional coordinates and wraps coordinates to [0,1[
.
Note
Based on ASE code.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
cell |
tuple[Vector3D, Vector3D, Vector3D]
|
A Cartesian 3x3 cell. This equates to the
|
required |
cartesian_positions |
list[Vector3D]
|
A list of cartesian atomic positions. This equates to the
|
required |
Returns:
Type | Description |
---|---|
list[Vector3D]
|
A list of fractional coordinates for the atomic positions. |
Source code in optimade/adapters/structures/utils.py
65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 |
|
get_cif(optimade_structure)
¶
Get CIF file as string from OPTIMADE structure.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
optimade_structure |
StructureResource
|
OPTIMADE structure. |
required |
Returns:
Type | Description |
---|---|
str
|
The CIF file as a single Python |
Source code in optimade/adapters/structures/cif.py
41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 |
|
valid_lattice_vector(lattice_vec)
¶
Source code in optimade/adapters/structures/utils.py
23 24 25 26 27 28 29 30 31 |
|