{ "cells": [ { "cell_type": "code", "execution_count": 1, "id": "0", "metadata": { "execution": { "iopub.execute_input": "2026-06-30T22:32:51.308040Z", "iopub.status.busy": "2026-06-30T22:32:51.307859Z", "iopub.status.idle": "2026-06-30T22:32:51.312699Z", "shell.execute_reply": "2026-06-30T22:32:51.311886Z" }, "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": [ "# LBCO — powder neutron CW — basic pseudo-Voigt\n", "\n", "Verifies the baseline constant-wavelength neutron powder pattern for\n", "LBCO with a pseudo-Voigt peak shape and no correction models.\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:32:51.314196Z", "iopub.status.busy": "2026-06-30T22:32:51.314032Z", "iopub.status.idle": "2026-06-30T22:32:54.233416Z", "shell.execute_reply": "2026-06-30T22:32:54.232087Z" } }, "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:32:54.235482Z", "iopub.status.busy": "2026-06-30T22:32:54.235078Z", "iopub.status.idle": "2026-06-30T22:32:54.451269Z", "shell.execute_reply": "2026-06-30T22:32:54.450379Z" } }, "outputs": [], "source": [ "project = edi.Project()" ] }, { "cell_type": "markdown", "id": "5", "metadata": {}, "source": [ "## Define the structure" ] }, { "cell_type": "code", "execution_count": 4, "id": "6", "metadata": { "execution": { "iopub.execute_input": "2026-06-30T22:32:54.452869Z", "iopub.status.busy": "2026-06-30T22:32:54.452701Z", "iopub.status.idle": "2026-06-30T22:32:54.460862Z", "shell.execute_reply": "2026-06-30T22:32:54.460028Z" } }, "outputs": [], "source": [ "structure = StructureFactory.from_scratch(name='lbco')\n", "\n", "structure.space_group.name_h_m = 'P m -3 m' # FullProf Space group symbol\n", "\n", "structure.cell.length_a = 3.890790 # FullProf a\n", "\n", "structure.atom_sites.create(\n", " id='La', # FullProf Atom\n", " type_symbol='La', # FullProf Typ\n", " fract_x=0.0, # FullProf X\n", " fract_y=0.0, # FullProf Y\n", " fract_z=0.0, # FullProf Z\n", " occupancy=0.5, # FullProf Occ\n", " adp_type='Biso', # FullProf Biso\n", " adp_iso=0.57511, # FullProf Biso\n", ")\n", "structure.atom_sites.create(\n", " id='Ba', # FullProf Atom\n", " type_symbol='Ba', # FullProf Typ\n", " fract_x=0.0, # FullProf X\n", " fract_y=0.0, # FullProf Y\n", " fract_z=0.0, # FullProf Z\n", " occupancy=0.5, # FullProf Occ\n", " adp_type='Biso', # FullProf Biso\n", " adp_iso=0.57511, # FullProf Biso\n", ")\n", "structure.atom_sites.create(\n", " id='Co', # FullProf Atom\n", " type_symbol='Co', # FullProf Typ\n", " fract_x=0.5, # FullProf X\n", " fract_y=0.5, # FullProf Y\n", " fract_z=0.5, # FullProf Z\n", " occupancy=1.0, # FullProf Occ\n", " adp_type='Biso', # FullProf Biso\n", " adp_iso=0.26023, # FullProf Biso\n", ")\n", "structure.atom_sites.create(\n", " id='O', # FullProf Atom\n", " type_symbol='O', # FullProf Typ\n", " fract_x=0.0, # FullProf X\n", " fract_y=0.5, # FullProf Y\n", " fract_z=0.5, # FullProf Z\n", " occupancy=0.97856, # FullProf Occ\n", " adp_type='Biso', # FullProf Biso\n", " adp_iso=1.36662, # 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:32:54.462531Z", "iopub.status.busy": "2026-06-30T22:32:54.462318Z", "iopub.status.idle": "2026-06-30T22:32:54.475495Z", "shell.execute_reply": "2026-06-30T22:32:54.474682Z" } }, "outputs": [], "source": [ "FULLPROF_PROJECT_DIR = 'pd-neut-cwl_lbco_basic'\n", "FULLPROF_PRF_FILE = 'lbco.prf'\n", "FULLPROF_SUM_FILE = 'lbco.sum'\n", "FULLPROF_BAC_FILE = 'lbco.bac'\n", "FULLPROF_LABEL = verify.fullprof_label(FULLPROF_PROJECT_DIR, FULLPROF_SUM_FILE)\n", "\n", "FULLPROF_ZERO = 0.62040 # FullProf Zero\n", "FULLPROF_SCALE = 9.405870 # FullProf Scale\n", "FULLPROF_WAVELENGTH = 1.494000 # FullProf Lambda\n", "FULLPROF_U = 0.081547 # FullProf U\n", "FULLPROF_V = -0.115345 # FullProf V\n", "FULLPROF_W = 0.121125 # FullProf W\n", "FULLPROF_X = 0.0 # FullProf X\n", "FULLPROF_Y = 0.083038 # FullProf Y\n", "FULLPROF_WDT = 30.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:32:54.477618Z", "iopub.status.busy": "2026-06-30T22:32:54.477387Z", "iopub.status.idle": "2026-06-30T22:32:54.963424Z", "shell.execute_reply": "2026-06-30T22:32:54.962571Z" } }, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "\u001b[1;36mPeak profile type for experiment \u001b[0m\u001b[32m'lbco'\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='lbco',\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='lbco', 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", "experiment.peak.broad_lorentz_x = FULLPROF_X\n", "experiment.peak.broad_lorentz_y = FULLPROF_Y\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:32:54.964937Z", "iopub.status.busy": "2026-06-30T22:32:54.964769Z", "iopub.status.idle": "2026-06-30T22:32:55.718824Z", "shell.execute_reply": "2026-06-30T22:32:55.717883Z" } }, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "\u001b[1;36mCalculator for experiment \u001b[0m\u001b[32m'lbco'\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.68 | ✅ |
| 2 | Max deviation (%) | < 6 | 0.42 | ✅ | |
| 3 | Area ratio | 0.99 to 1.01 | 0.9916 | ✅ | |
| 4 | Shape correlation | > 0.999 | 1.0000 | ✅ | |
| 5 | edi 0.19.1 (crysfml 0.7.0) vs FullProf 8.40 | Profile diff (%) | < 2.5 | 0.08 | ✅ |
| 6 | Max deviation (%) | < 6 | 0.35 | ✅ | |
| 7 | Area ratio | 0.99 to 1.01 | 0.9999 | ✅ | |
| 8 | Shape correlation | > 0.999 | 1.0000 | ✅ |