{ "cells": [ { "cell_type": "code", "execution_count": 1, "id": "0", "metadata": { "execution": { "iopub.execute_input": "2026-06-30T22:30:41.436247Z", "iopub.status.busy": "2026-06-30T22:30:41.436055Z", "iopub.status.idle": "2026-06-30T22:30:41.440371Z", "shell.execute_reply": "2026-06-30T22:30:41.439598Z" }, "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": [ "# LaB6 - powder neutron CW - SyCos/SySin shifts\n", "\n", "Verifies the LaB6 baseline with only the SyCos/SySin sample-displacement\n", "and transparency peak-position corrections enabled. cryspy 0.12.0\n", "implements both (offset_SyCos/offset_SySin), so the pattern agrees with\n", "FullProf.\n", "\n", "**Refinement:** none." ] }, { "cell_type": "code", "execution_count": 2, "id": "2", "metadata": { "execution": { "iopub.execute_input": "2026-06-30T22:30:41.442251Z", "iopub.status.busy": "2026-06-30T22:30:41.442069Z", "iopub.status.idle": "2026-06-30T22:30:44.285022Z", "shell.execute_reply": "2026-06-30T22:30:44.284057Z" } }, "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:30:44.286735Z", "iopub.status.busy": "2026-06-30T22:30:44.286462Z", "iopub.status.idle": "2026-06-30T22:30:44.500135Z", "shell.execute_reply": "2026-06-30T22:30:44.499273Z" } }, "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:30:44.501761Z", "iopub.status.busy": "2026-06-30T22:30:44.501596Z", "iopub.status.idle": "2026-06-30T22:30:44.507678Z", "shell.execute_reply": "2026-06-30T22:30:44.506697Z" } }, "outputs": [], "source": [ "structure = StructureFactory.from_scratch(name='lab6')\n", "structure.space_group.name_h_m = 'P m -3 m' # FullProf Space group symbol\n", "structure.cell.length_a = 4.156885 # FullProf a\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", " adp_type='Biso', # FullProf Biso\n", " adp_iso=0.25812, # FullProf Biso\n", ")\n", "structure.atom_sites.create(\n", " id='B', # FullProf Atom\n", " type_symbol='B', # FullProf Typ\n", " fract_x=0.19972, # FullProf X\n", " fract_y=0.5, # FullProf Y\n", " fract_z=0.5, # FullProf Z\n", " adp_type='Biso', # FullProf Biso\n", " adp_iso=0.11925, # 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:30:44.509333Z", "iopub.status.busy": "2026-06-30T22:30:44.509177Z", "iopub.status.idle": "2026-06-30T22:30:44.517472Z", "shell.execute_reply": "2026-06-30T22:30:44.516657Z" } }, "outputs": [], "source": [ "FULLPROF_PROJECT_DIR = 'pd-neut-cwl_lab6'\n", "FULLPROF_PRF_FILE = 'ECH0030684_LaB6_1p622A_sycos_sysin.prf'\n", "FULLPROF_SUM_FILE = 'ECH0030684_LaB6_1p622A_sycos_sysin.sum'\n", "FULLPROF_BAC_FILE = 'ECH0030684_LaB6_1p622A_sycos_sysin.bac'\n", "FULLPROF_LABEL = verify.fullprof_label(FULLPROF_PROJECT_DIR, FULLPROF_SUM_FILE)\n", "\n", "FULLPROF_ZERO = -0.45778 # FullProf Zero\n", "FULLPROF_SCALE = 42.98374 # FullProf Scale\n", "FULLPROF_WAVELENGTH = 1.623899 # FullProf Lambda\n", "FULLPROF_U = 0.143431 # FullProf U\n", "FULLPROF_V = -0.523140 # FullProf V\n", "FULLPROF_W = 0.590412 # FullProf W\n", "FULLPROF_X = 0.0 # FullProf X\n", "FULLPROF_Y = 0.054515 # FullProf Y\n", "FULLPROF_WDT = 12.0 # FullProf Wdt\n", "FULLPROF_SYCOS = 0.01153 # FullProf SyCos\n", "FULLPROF_SYSIN = 0.24334 # FullProf SySin\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:30:44.519053Z", "iopub.status.busy": "2026-06-30T22:30:44.518846Z", "iopub.status.idle": "2026-06-30T22:30:44.999019Z", "shell.execute_reply": "2026-06-30T22:30:44.998104Z" } }, "outputs": [], "source": [ "experiment = ExperimentFactory.from_scratch(\n", " name='lab6',\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='lab6', scale=FULLPROF_SCALE)\n", "\n", "experiment.instrument.setup_wavelength = FULLPROF_WAVELENGTH\n", "experiment.instrument.calib_twotheta_offset = FULLPROF_ZERO\n", "experiment.instrument.calib_sample_displacement = FULLPROF_SYCOS\n", "experiment.instrument.calib_sample_transparency = FULLPROF_SYSIN\n", "\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:30:45.000810Z", "iopub.status.busy": "2026-06-30T22:30:45.000576Z", "iopub.status.idle": "2026-06-30T22:30:45.469895Z", "shell.execute_reply": "2026-06-30T22:30:45.468981Z" } }, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "\u001b[1;36mCalculator for experiment \u001b[0m\u001b[32m'lab6'\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.98 | ✅ |
| 2 | Max deviation (%) | < 6 | 0.59 | ✅ | |
| 3 | Area ratio | 0.99 to 1.01 | 0.9956 | ✅ | |
| 4 | Shape correlation | > 0.999 | 1.0000 | ✅ |