{ "cells": [ { "cell_type": "code", "execution_count": 1, "id": "0", "metadata": { "execution": { "iopub.execute_input": "2026-06-30T22:34:58.375134Z", "iopub.status.busy": "2026-06-30T22:34:58.374756Z", "iopub.status.idle": "2026-06-30T22:34:58.379443Z", "shell.execute_reply": "2026-06-30T22:34:58.378794Z" }, "tags": [ "hide-in-docs" ] }, "outputs": [], "source": [ "# Check whether easydiffraction is installed; install it if needed.\n", "# Required for remote environments such as Google Colab.\n", "import importlib.util\n", "\n", "if importlib.util.find_spec('easydiffraction') is None:\n", " %pip install easydiffraction==0.19.1" ] }, { "cell_type": "markdown", "id": "1", "metadata": {}, "source": [ "# Y2O3 - powder neutron CW - beta ADPs\n", "\n", "Verifies dimensionless beta-tensor anisotropic ADPs on a pseudo-Voigt\n", "neutron powder pattern with other correction models disabled.\n", "\n", "**Refinement:** none — every parameter is taken from the FullProf\n", "reference; only the calculated patterns are compared." ] }, { "cell_type": "code", "execution_count": 2, "id": "2", "metadata": { "execution": { "iopub.execute_input": "2026-06-30T22:34:58.381662Z", "iopub.status.busy": "2026-06-30T22:34:58.381501Z", "iopub.status.idle": "2026-06-30T22:35:01.177270Z", "shell.execute_reply": "2026-06-30T22:35:01.176364Z" } }, "outputs": [], "source": [ "import easydiffraction as edi\n", "from easydiffraction import ExperimentFactory\n", "from easydiffraction import StructureFactory\n", "from easydiffraction.analysis import verification as verify" ] }, { "cell_type": "markdown", "id": "3", "metadata": {}, "source": [ "## Build the project" ] }, { "cell_type": "code", "execution_count": 3, "id": "4", "metadata": { "execution": { "iopub.execute_input": "2026-06-30T22:35:01.179163Z", "iopub.status.busy": "2026-06-30T22:35:01.178854Z", "iopub.status.idle": "2026-06-30T22:35:01.393656Z", "shell.execute_reply": "2026-06-30T22:35:01.392731Z" } }, "outputs": [], "source": [ "project = edi.Project()" ] }, { "cell_type": "markdown", "id": "5", "metadata": {}, "source": [ "## Define the structure\n", "\n", "Occupancies are the crystallographic site fractions (all fully\n", "occupied). FullProf's `.pcr` lists the multiplicity-weighted values\n", "(0.5, 0.16667, 1.0 for the 24d, 8b and 48e sites); cryspy derives the\n", "site multiplicity from the symmetry, so the fractions are 1.0 here." ] }, { "cell_type": "code", "execution_count": 4, "id": "6", "metadata": { "execution": { "iopub.execute_input": "2026-06-30T22:35:01.395451Z", "iopub.status.busy": "2026-06-30T22:35:01.395277Z", "iopub.status.idle": "2026-06-30T22:35:01.404991Z", "shell.execute_reply": "2026-06-30T22:35:01.404372Z" } }, "outputs": [], "source": [ "structure = StructureFactory.from_scratch(name='y2o3')\n", "\n", "structure.space_group.name_h_m = 'I a -3' # FullProf Space group symbol\n", "\n", "structure.cell.length_a = 10.605744 # FullProf a\n", "\n", "structure.atom_sites.create(\n", " id='Y1', # FullProf Atom\n", " type_symbol='Y', # FullProf Typ\n", " fract_x=-0.03236, # FullProf X\n", " fract_y=0.0, # FullProf Y\n", " fract_z=0.25, # FullProf Z\n", " occupancy=1.0, # FullProf Occ 0.50000 (24d site)\n", " adp_type='beta', # FullProf N_t = 2 (anisotropic β)\n", ")\n", "structure.atom_sites.create(\n", " id='Y2', # FullProf Atom\n", " type_symbol='Y', # FullProf Typ\n", " fract_x=0.25, # FullProf X\n", " fract_y=0.25, # FullProf Y\n", " fract_z=0.25, # FullProf Z\n", " occupancy=1.0, # FullProf Occ 0.16667 (8b site)\n", " adp_type='beta', # FullProf N_t = 2 (anisotropic β)\n", ")\n", "structure.atom_sites.create(\n", " id='O1', # FullProf Atom\n", " type_symbol='O', # FullProf Typ\n", " fract_x=0.39072, # FullProf X\n", " fract_y=0.15204, # FullProf Y\n", " fract_z=0.38030, # FullProf Z\n", " occupancy=1.0, # FullProf Occ 1.00000 (48e site)\n", " adp_type='beta', # FullProf N_t = 2 (anisotropic β)\n", ")\n", "\n", "# β tensor components (FullProf Betas), dimensionless.\n", "structure.atom_site_aniso['Y1'].adp_11 = 0.00303 # FullProf beta11\n", "structure.atom_site_aniso['Y1'].adp_22 = 0.00272 # FullProf beta22\n", "structure.atom_site_aniso['Y1'].adp_33 = 0.00295 # FullProf beta33\n", "structure.atom_site_aniso['Y1'].adp_23 = -0.00025 # FullProf beta23\n", "\n", "structure.atom_site_aniso['Y2'].adp_11 = 0.00304 # FullProf beta11\n", "structure.atom_site_aniso['Y2'].adp_12 = -0.00013 # FullProf beta12\n", "\n", "structure.atom_site_aniso['O1'].adp_11 = 0.00299 # FullProf beta11\n", "structure.atom_site_aniso['O1'].adp_22 = 0.00310 # FullProf beta22\n", "structure.atom_site_aniso['O1'].adp_33 = 0.00273 # FullProf beta33\n", "structure.atom_site_aniso['O1'].adp_12 = -0.00007 # FullProf beta12\n", "structure.atom_site_aniso['O1'].adp_13 = -0.00020 # FullProf beta13\n", "structure.atom_site_aniso['O1'].adp_23 = -0.00001 # FullProf beta23\n", "\n", "project.structures.add(structure)" ] }, { "cell_type": "markdown", "id": "7", "metadata": {}, "source": [ "## Load the FullProf reference" ] }, { "cell_type": "code", "execution_count": 5, "id": "8", "metadata": { "execution": { "iopub.execute_input": "2026-06-30T22:35:01.407061Z", "iopub.status.busy": "2026-06-30T22:35:01.406881Z", "iopub.status.idle": "2026-06-30T22:35:01.415346Z", "shell.execute_reply": "2026-06-30T22:35:01.414524Z" } }, "outputs": [], "source": [ "FULLPROF_PROJECT_DIR = 'pd-neut-cwl_y2o3_beta-adp'\n", "FULLPROF_PRF_FILE = 'y2o3.prf'\n", "FULLPROF_SUM_FILE = 'y2o3.sum'\n", "FULLPROF_BAC_FILE = 'y2o3.bac'\n", "FULLPROF_LABEL = verify.fullprof_label(FULLPROF_PROJECT_DIR, FULLPROF_SUM_FILE)\n", "\n", "FULLPROF_ZERO = -0.01625 # FullProf Zero\n", "FULLPROF_SCALE = 1.0602 # FullProf Scale\n", "FULLPROF_WAVELENGTH = 1.54822 # FullProf Lambda\n", "FULLPROF_U = 0.036631 # FullProf U\n", "FULLPROF_V = -0.068345 # FullProf V\n", "FULLPROF_W = 0.131426 # FullProf W\n", "FULLPROF_WDT = 20.0 # FullProf Wdt\n", "\n", "x, calc_fullprof = verify.load_fullprof_calc_profile(\n", " FULLPROF_PROJECT_DIR,\n", " FULLPROF_PRF_FILE,\n", " FULLPROF_BAC_FILE,\n", " FULLPROF_ZERO,\n", ")" ] }, { "cell_type": "markdown", "id": "9", "metadata": {}, "source": [ "## Create the experiment" ] }, { "cell_type": "code", "execution_count": 6, "id": "10", "metadata": { "execution": { "iopub.execute_input": "2026-06-30T22:35:01.416959Z", "iopub.status.busy": "2026-06-30T22:35:01.416802Z", "iopub.status.idle": "2026-06-30T22:35:01.897834Z", "shell.execute_reply": "2026-06-30T22:35:01.897015Z" } }, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "\u001b[1;36mPeak profile type for experiment \u001b[0m\u001b[32m'y2o3'\u001b[0m\u001b[1;36m changed to\u001b[0m\n" ] }, { "name": "stdout", "output_type": "stream", "text": [ "pseudo-voigt\n" ] } ], "source": [ "experiment = ExperimentFactory.from_scratch(\n", " name='y2o3',\n", " sample_form='powder',\n", " beam_mode='constant wavelength',\n", " radiation_probe='neutron',\n", " scattering_type='bragg',\n", ")\n", "verify.set_reference_as_measured(experiment, x, calc_fullprof)\n", "\n", "experiment.linked_structures.create(structure_id='y2o3', scale=FULLPROF_SCALE)\n", "\n", "experiment.instrument.setup_wavelength = FULLPROF_WAVELENGTH\n", "experiment.instrument.calib_twotheta_offset = FULLPROF_ZERO\n", "\n", "experiment.peak.type = 'pseudo-voigt'\n", "experiment.peak.broad_gauss_u = FULLPROF_U\n", "experiment.peak.broad_gauss_v = FULLPROF_V\n", "experiment.peak.broad_gauss_w = FULLPROF_W\n", "\n", "# FullProf excluded the 0–12° and 137.5–180° regions (.pcr).\n", "experiment.excluded_regions.create(id='1', start=0.0, end=12.0)\n", "experiment.excluded_regions.create(id='2', start=137.5, end=180.0)\n", "\n", "experiment.peak.cutoff_fwhm = FULLPROF_WDT\n", "\n", "project.experiments.add(experiment)" ] }, { "cell_type": "markdown", "id": "11", "metadata": {}, "source": [ "## edi-cryspy VS FullProf" ] }, { "cell_type": "code", "execution_count": 7, "id": "12", "metadata": { "execution": { "iopub.execute_input": "2026-06-30T22:35:01.899468Z", "iopub.status.busy": "2026-06-30T22:35:01.899289Z", "iopub.status.idle": "2026-06-30T22:35:02.720551Z", "shell.execute_reply": "2026-06-30T22:35:02.719726Z" } }, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "\u001b[1;36mCalculator for experiment \u001b[0m\u001b[32m'y2o3'\u001b[0m\u001b[1;36m already set to\u001b[0m\n" ] }, { "name": "stdout", "output_type": "stream", "text": [ "cryspy\n" ] }, { "data": { "text/html": [ "
| Comparison | Metric | Expected | Actual | OK | |
|---|---|---|---|---|---|
| 1 | edi 0.19.1 (cryspy 0.12.1) vs FullProf 7.95 | Profile diff (%) | < 2.5 | 0.40 | ✅ |
| 2 | Max deviation (%) | < 6 | 0.29 | ✅ | |
| 3 | Area ratio | 0.99 to 1.01 | 1.0000 | ✅ | |
| 4 | Shape correlation | > 0.999 | 1.0000 | ✅ |