crystal¶
nrxrdct.laue.crystal ¶
crystal_from_cif.py¶
Utility to build an xrayutilities Crystal object from a CIF file, ready for use in Laue / powder diffraction simulations.
Supports
- CIF files on disk (pass a file path)
- CIF content as a Python string (useful for embedded or downloaded CIFs)
- Multiple datasets within a single CIF file
- Partial site occupancies
- Isotropic displacement parameters (Biso / Uiso -> b-factor)
- All crystal systems handled by xrayutilities.materials.CIFFile
Quick usage from crystal_from_cif import crystal_from_cif
# From a file on disk
crystal = crystal_from_cif('my_phase.cif')
# From a CIF string (e.g. downloaded from COD / ICSD / CCDC)
crystal = crystal_from_cif(cif_string, name='My Phase')
# Use in Laue simulation (see laue_white_synchrotron.py)
spots = simulate_laue(crystal, U, camera)
# Use in powder simulation
import xrayutilities as xu
import numpy as np
pm = xu.simpack.PowderModel(xu.simpack.Powder(crystal, 1.0), I0=1e6)
tt = np.linspace(10, 100, 2000)
pattern = pm.simulate(tt)
pm.close()
build_MLed ¶
build_MLed(UB_GaN=np.eye(3), UB_subst=np.eye(3), x_in_defect=0.03, x_in_active=0.15, x_al_clad=0.1, x_in_clad=0.02, x_al_ebl=0.2)
Build a single LayeredCrystal for an EBL/QW nitride LED-laser stack,
with four sections stacked bottom (substrate) to top (surface):
Al2O3 / GaN undoped / GaN doped buffer (non-repeating)
80 nm defect-filtering : InGaN / GaN MQW 5x
40 nm active region : InGaN / GaN MQW 4x
80 nm optical cladding : InGaAlN / GaAlN MQW 8x
160 nm AlGaN electron-blocking layer (EBL) 1x (cap, top)
Each MQW section is its own independently-repeated block (one
add_pseudomorphic_layer pair followed by set_repetitions) within the
same LayeredCrystal -- see :meth:LayeredCrystal.add_layer for how
block boundaries work. The EBL cap is added with add_layer (not
add_buffer_layer): buffer layers always sit at the very bottom of the
stack, so a genuine top-side cap layer must be its own trailing block
instead. All MQW/cap layers are grown pseudomorphically on a common GaN
template (a_substrate=GaN.lattice.a), [001] (c-axis) growth.
Compositions are illustrative -- adjust to your real epitaxy.
Wells/barriers split each group's total thickness evenly.
| Returns: |
|
|---|
Example
stack = build_MLed() stack.describe() from nrxrdct.laue.simulation import simulate_laue_stack spots = simulate_laue_stack(combine_stacks([stack]), camera, allowed_hkl=allowed)
Source code in src/nrxrdct/laue/crystal.py
313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 | |
build_aln ¶
build_inn ¶
crystal_from_cif ¶
Build an xu.materials.Crystal from a CIF file or CIF string.
| Parameters: |
|
|---|
| Returns: |
|
|---|
| Raises: |
|
|---|
Note: xrayutilities uses the Cromer-Mann parameterisation for atomic scattering factors f0(Q) and the Henke tables for anomalous corrections f'(E), f''(E). These are automatically assigned based on the element symbols in the CIF.
The _atom_site_U_iso_or_equiv tag (if present) is converted to the
B-factor used by xrayutilities via B = 8*pi^2 * U.
Common CIF sources - Crystallography Open Database (COD): https://www.crystallography.net/cod/ - ICSD (subscription): https://icsd.fiz-karlsruhe.de/ - Materials Project: https://next-gen.materialsproject.org/ - CCDC (organics): https://www.ccdc.cam.ac.uk/
Example:
From a file¶
fe = crystal_from_cif('bcc_iron.cif')
From a string¶
cif_text = open('al2o3.cif').read() al2o3 = crystal_from_cif(cif_text, name='Corundum')
Use in Laue simulation¶
import numpy as np from scipy.spatial.transform import Rotation U = Rotation.from_euler('ZXZ', [0, 90, 0], degrees=True).as_matrix() G = al2o3.Q(1, 0, 4) F = al2o3.StructureFactor(G, en=17000) print(f'|F(104)| = {abs(F):.3f} e.u.')
Use in powder simulation¶
import xrayutilities as xu pm = xu.simpack.PowderModel(xu.simpack.Powder(fe, 1.0), I0=1e6) tt = np.linspace(20, 100, 2000) pattern = pm.simulate(tt) pm.close()
Source code in src/nrxrdct/laue/crystal.py
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 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 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 | |
crystals_from_cifs ¶
Load multiple Crystal objects from a list of CIF files or strings.
| Parameters: |
|
|---|
| Returns: |
|
|---|
Example:
bcc, b2 = crystals_from_cifs(['bcc.cif', 'b2.cif'])