powder¶
simulation¶
nrxrdct.powder.simulation ¶
calculate_xrd_baseline ¶
calculate_xrd_baseline(y: ndarray, x: ndarray | None = None, method: str = 'iasls', **kwargs) -> tuple[np.ndarray, dict]
Calculate the baseline of an X-ray diffraction (XRD) intensity curve.
| Parameters: |
|
|---|
| Returns: |
|
|---|
Example
import numpy as np two_theta = np.linspace(10, 80, 1000) intensity = np.random.default_rng(0).normal(500, 10, 1000) baseline, info = calculate_xrd_baseline(intensity, two_theta) corrected = intensity - baseline
Source code in src/nrxrdct/powder/simulation.py
get_powder_xrd_peaks ¶
get_powder_xrd_peaks(cif_files, names: list[str] = None, energy_keV: float = 100.0, tth_min: float = None, tth_max: float = None) -> dict[str, pd.DataFrame]
Return peak positions and hkl families for one or more CIF files.
| Parameters: |
|
|---|
| Returns: |
|
|---|
Source code in src/nrxrdct/powder/simulation.py
simulate_powder_xrd_monophase ¶
simulate_powder_xrd_monophase(tth, cif_files, do_plot=True, energy_keV: float = 100.0, crystallite_size: float = 1e-07, do_save: bool = True) -> np.ndarray
Simulate a powder XRD pattern for one or more phases using xrayutilities.
| Parameters: |
|
|---|
| Returns: |
|
|---|
Source code in src/nrxrdct/powder/simulation.py
structures¶
nrxrdct.powder.structures ¶
nrxrdct.powder.structures¶
Build xrayutilities Crystal objects for multi-element solid-solution alloys.
Lattice parameters are estimated via Vegard's law: the molar-fraction-weighted average of per-element CN-12 equivalent metallic radii is converted to the lattice parameter of the target structure.
Metallic radii are derived from crystallographic data when available, using a uniform volume-to-radius formula:
r_CN12 = (3 · V_atom · φ_FCC / (4π))^(1/3)
where V_atom is the volume per atom in the element's own crystal and φ_FCC = π/(3√2) ≈ 0.7405 is the FCC packing fraction. This converts any structure's atomic volume to the CN-12 equivalent radius used in Vegard's-law calculations.
Data sources (in priority order): 1. xrayutilities — crystallographic lattice parameters (exact) 2. xraylib — elemental density + atomic weight (< 1 % error)
elem_radius ¶
Return the CN-12 equivalent metallic radius (Å) for an element symbol.
Tries xrayutilities' crystallographic data first, falls back to xraylib density data.
| Parameters: |
|
|---|
| Returns: |
|
|---|
| Raises: |
|
|---|
Source code in src/nrxrdct/powder/structures.py
list_structures ¶
make_alloy_crystal ¶
make_alloy_crystal(elements: Sequence[str], fractions: Sequence[float] | None = None, *, structure: str = 'BCC', name: str | None = None, a: float | None = None, c: float | None = None, b_factor: float = 0.0) -> xu.materials.Crystal
Build an xrayutilities Crystal for a multi-element solid-solution alloy.
Lattice parameters are estimated via Vegard's law unless overridden. Each element is placed on the same Wyckoff site with occupancy equal to its molar fraction. When fractions is not supplied every element gets equal occupancy (1/N).
| Parameters: |
|
|---|
| Returns: |
|
|---|
| Raises: |
|
|---|
Example
Equiatomic CrMnFeCoNi Cantor alloy (FCC)¶
crystal = make_alloy_crystal( ... ["Cr", "Mn", "Fe", "Co", "Ni"], structure="FCC" ... ) print(f"a = {crystal.a:.4f} A")
Fe60Cr20Ni20 (wt% approximate) BCC steel, explicit a¶
crystal = make_alloy_crystal( ... ["Fe", "Cr", "Ni"], fractions=[0.60, 0.20, 0.20], ... structure="BCC", a=2.874 ... )
Ti-6Al-4V HCP phase (approximate)¶
crystal = make_alloy_crystal( ... ["Ti", "Al", "V"], fractions=[0.90, 0.06, 0.04], ... structure="HCP", ... )
Source code in src/nrxrdct/powder/structures.py
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 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 | |