{ "cells": [ { "cell_type": "code", "execution_count": 1, "id": "0", "metadata": { "execution": { "iopub.execute_input": "2026-06-30T22:38:56.783715Z", "iopub.status.busy": "2026-06-30T22:38:56.783563Z", "iopub.status.idle": "2026-06-30T22:38:56.787711Z", "shell.execute_reply": "2026-06-30T22:38:56.786690Z" }, "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 - isotropic ADPs\n", "\n", "Verifies the baseline Y2O3 constant-wavelength neutron powder pattern\n", "with isotropic ADPs.\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:38:56.789169Z", "iopub.status.busy": "2026-06-30T22:38:56.788993Z", "iopub.status.idle": "2026-06-30T22:39:00.036314Z", "shell.execute_reply": "2026-06-30T22:39:00.035517Z" } }, "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:39:00.038554Z", "iopub.status.busy": "2026-06-30T22:39:00.038261Z", "iopub.status.idle": "2026-06-30T22:39:00.287678Z", "shell.execute_reply": "2026-06-30T22:39:00.286407Z" } }, "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:39:00.289458Z", "iopub.status.busy": "2026-06-30T22:39:00.289276Z", "iopub.status.idle": "2026-06-30T22:39:00.296694Z", "shell.execute_reply": "2026-06-30T22:39:00.296058Z" } }, "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='Biso', # FullProf N_t = 0\n", " adp_iso=0.3, # FullProf Biso\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='Biso', # FullProf N_t = 0\n", " adp_iso=0.3, # FullProf Biso\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='Biso', # FullProf N_t = 0\n", " adp_iso=0.5, # FullProf Biso\n", ")\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:39:00.298551Z", "iopub.status.busy": "2026-06-30T22:39:00.298389Z", "iopub.status.idle": "2026-06-30T22:39:00.306723Z", "shell.execute_reply": "2026-06-30T22:39:00.305897Z" } }, "outputs": [], "source": [ "FULLPROF_PROJECT_DIR = 'pd-neut-cwl_y2o3_isotropic-adp'\n", "FULLPROF_PRF_FILE = 'y2o3_isotropic_adp.prf'\n", "FULLPROF_SUM_FILE = 'y2o3_isotropic_adp.sum'\n", "FULLPROF_BAC_FILE = 'y2o3_isotropic_adp.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:39:00.308321Z", "iopub.status.busy": "2026-06-30T22:39:00.308164Z", "iopub.status.idle": "2026-06-30T22:39:00.870134Z", "shell.execute_reply": "2026-06-30T22:39:00.869131Z" } }, "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 deg and 137.5-180 deg 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:39:00.871692Z", "iopub.status.busy": "2026-06-30T22:39:00.871534Z", "iopub.status.idle": "2026-06-30T22:39:01.832989Z", "shell.execute_reply": "2026-06-30T22:39:01.832213Z" } }, "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 8.40 | Profile diff (%) | < 2.5 | 0.37 | ✅ |
| 2 | Max deviation (%) | < 6 | 0.29 | ✅ | |
| 3 | Area ratio | 0.99 to 1.01 | 1.0000 | ✅ | |
| 4 | Shape correlation | > 0.999 | 1.0000 | ✅ |