{ "cells": [ { "cell_type": "code", "execution_count": 1, "id": "0", "metadata": { "execution": { "iopub.execute_input": "2026-06-30T22:30:47.320391Z", "iopub.status.busy": "2026-06-30T22:30:47.320196Z", "iopub.status.idle": "2026-06-30T22:30:47.324559Z", "shell.execute_reply": "2026-06-30T22:30:47.323640Z" }, "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": [ "# Structure Refinement: Co2SiO4, D20 (T-scan)\n", "\n", "This example demonstrates a Rietveld refinement of the Co2SiO4 crystal\n", "structure using constant-wavelength neutron powder diffraction data\n", "from D20 at ILL. A sequential refinement is performed against a\n", "temperature scan using sequential fitting, which processes each data\n", "file independently without loading all datasets into memory at once." ] }, { "cell_type": "markdown", "id": "2", "metadata": {}, "source": [ "## 🛠️ Import Library" ] }, { "cell_type": "code", "execution_count": 2, "id": "3", "metadata": { "execution": { "iopub.execute_input": "2026-06-30T22:30:47.326502Z", "iopub.status.busy": "2026-06-30T22:30:47.326333Z", "iopub.status.idle": "2026-06-30T22:30:50.130965Z", "shell.execute_reply": "2026-06-30T22:30:50.130060Z" } }, "outputs": [], "source": [ "import easydiffraction as edi" ] }, { "cell_type": "markdown", "id": "4", "metadata": {}, "source": [ "## 📦 Define Project\n", "\n", "The project object manages structures, experiments, analysis, display,\n", "and other related components." ] }, { "cell_type": "code", "execution_count": 3, "id": "5", "metadata": { "execution": { "iopub.execute_input": "2026-06-30T22:30:50.132964Z", "iopub.status.busy": "2026-06-30T22:30:50.132578Z", "iopub.status.idle": "2026-06-30T22:30:50.354873Z", "shell.execute_reply": "2026-06-30T22:30:50.354060Z" } }, "outputs": [], "source": [ "project = edi.Project(name='cosio_d20_scan')\n", "analysis = project.analysis\n", "display = project.display" ] }, { "cell_type": "markdown", "id": "6", "metadata": {}, "source": [ "The project must be saved before running sequential fitting, so that\n", "results can be written to `analysis/results.csv`." ] }, { "cell_type": "code", "execution_count": 4, "id": "7", "metadata": { "execution": { "iopub.execute_input": "2026-06-30T22:30:50.356806Z", "iopub.status.busy": "2026-06-30T22:30:50.356629Z", "iopub.status.idle": "2026-06-30T22:30:50.410871Z", "shell.execute_reply": "2026-06-30T22:30:50.410131Z" } }, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "\u001b[1;36mSaving project 📦 \u001b[0m\u001b[32m'cosio_d20_scan'\u001b[0m\u001b[1;36m to \u001b[0m\u001b[32m'../../../projects/refine-cosio-d20-tscan'\u001b[0m\n" ] }, { "name": "stdout", "output_type": "stream", "text": [ "├── 📄 project.edi\n" ] }, { "name": "stdout", "output_type": "stream", "text": [ "├── 📁 structures/\n" ] }, { "name": "stdout", "output_type": "stream", "text": [ "├── 📁 experiments/\n" ] }, { "name": "stdout", "output_type": "stream", "text": [ "├── 📁 analysis/\n" ] }, { "name": "stdout", "output_type": "stream", "text": [ "│ └── 📄 analysis.edi\n" ] }, { "name": "stdout", "output_type": "stream", "text": [ "└── 📁 reports/\n" ] }, { "name": "stdout", "output_type": "stream", "text": [ " └── 📄 cosio_d20_scan.html\n" ] } ], "source": [ "project.save_as(dir_path='projects/refine-cosio-d20-tscan')" ] }, { "cell_type": "markdown", "id": "8", "metadata": {}, "source": [ "## 🧩 Define Structure\n", "\n", "This section shows how to add structures and modify their\n", "parameters.\n", "\n", "### Create Structure" ] }, { "cell_type": "code", "execution_count": 5, "id": "9", "metadata": { "execution": { "iopub.execute_input": "2026-06-30T22:30:50.412585Z", "iopub.status.busy": "2026-06-30T22:30:50.412423Z", "iopub.status.idle": "2026-06-30T22:30:50.415944Z", "shell.execute_reply": "2026-06-30T22:30:50.414963Z" } }, "outputs": [], "source": [ "project.structures.create(name='cosio')\n", "struct = project.structures['cosio']" ] }, { "cell_type": "markdown", "id": "10", "metadata": {}, "source": [ "### Set Space Group" ] }, { "cell_type": "code", "execution_count": 6, "id": "11", "metadata": { "execution": { "iopub.execute_input": "2026-06-30T22:30:50.417544Z", "iopub.status.busy": "2026-06-30T22:30:50.417391Z", "iopub.status.idle": "2026-06-30T22:30:50.420246Z", "shell.execute_reply": "2026-06-30T22:30:50.419558Z" } }, "outputs": [], "source": [ "struct.space_group.name_h_m = 'P n m a'\n", "struct.space_group.coord_system_code = 'abc'" ] }, { "cell_type": "markdown", "id": "12", "metadata": {}, "source": [ "### Set Unit Cell" ] }, { "cell_type": "code", "execution_count": 7, "id": "13", "metadata": { "execution": { "iopub.execute_input": "2026-06-30T22:30:50.421847Z", "iopub.status.busy": "2026-06-30T22:30:50.421714Z", "iopub.status.idle": "2026-06-30T22:30:50.424823Z", "shell.execute_reply": "2026-06-30T22:30:50.424065Z" } }, "outputs": [], "source": [ "struct.cell.length_a = 10.31\n", "struct.cell.length_b = 6.0\n", "struct.cell.length_c = 4.79" ] }, { "cell_type": "markdown", "id": "14", "metadata": {}, "source": [ "### Set Atom Sites" ] }, { "cell_type": "code", "execution_count": 8, "id": "15", "metadata": { "execution": { "iopub.execute_input": "2026-06-30T22:30:50.426449Z", "iopub.status.busy": "2026-06-30T22:30:50.426292Z", "iopub.status.idle": "2026-06-30T22:30:50.434273Z", "shell.execute_reply": "2026-06-30T22:30:50.433420Z" } }, "outputs": [], "source": [ "struct.atom_sites.create(\n", " id='Co1',\n", " type_symbol='Co',\n", " fract_x=0,\n", " fract_y=0,\n", " fract_z=0,\n", " adp_iso=0.3,\n", ")\n", "struct.atom_sites.create(\n", " id='Co2',\n", " type_symbol='Co',\n", " fract_x=0.279,\n", " fract_y=0.25,\n", " fract_z=0.985,\n", " adp_iso=0.3,\n", ")\n", "struct.atom_sites.create(\n", " id='Si',\n", " type_symbol='Si',\n", " fract_x=0.094,\n", " fract_y=0.25,\n", " fract_z=0.429,\n", " adp_iso=0.34,\n", ")\n", "struct.atom_sites.create(\n", " id='O1',\n", " type_symbol='O',\n", " fract_x=0.091,\n", " fract_y=0.25,\n", " fract_z=0.771,\n", " adp_iso=0.63,\n", ")\n", "struct.atom_sites.create(\n", " id='O2',\n", " type_symbol='O',\n", " fract_x=0.448,\n", " fract_y=0.25,\n", " fract_z=0.217,\n", " adp_iso=0.59,\n", ")\n", "struct.atom_sites.create(\n", " id='O3',\n", " type_symbol='O',\n", " fract_x=0.164,\n", " fract_y=0.032,\n", " fract_z=0.28,\n", " adp_iso=0.83,\n", ")" ] }, { "cell_type": "markdown", "id": "16", "metadata": {}, "source": [ "### Display Structure" ] }, { "cell_type": "code", "execution_count": 9, "id": "17", "metadata": { "execution": { "iopub.execute_input": "2026-06-30T22:30:50.435900Z", "iopub.status.busy": "2026-06-30T22:30:50.435691Z", "iopub.status.idle": "2026-06-30T22:30:50.535163Z", "shell.execute_reply": "2026-06-30T22:30:50.534367Z" } }, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "\u001b[1;36mStructure 🧩 \u001b[0m\u001b[32m'cosio'\u001b[0m\u001b[1;36m \u001b[0m\u001b[1;36m(\u001b[0m\u001b[1;36mAtom view type: \u001b[0m\u001b[32m'adp'\u001b[0m\u001b[1;36m)\u001b[0m\n" ] }, { "data": { "text/html": [ "
\n", "
\n", "
Loading plot…
\n", "
\n", "
\n", "
\n", "
drag = rotate
wheel = zoom
right-drag = pan
\n", "
\n", "
\n", "\n", "\n", "\n", "" ], "text/plain": [ "" ] }, "metadata": {}, "output_type": "display_data" } ], "source": [ "project.structure_style.atom_view = 'adp'\n", "project.display.structure(struct_name='cosio')" ] }, { "cell_type": "markdown", "id": "18", "metadata": {}, "source": [ "## 🔬 Define Experiment\n", "\n", "For sequential fitting, we create a single template experiment from\n", "the first data file. This template defines the instrument, peak\n", "profile, background, and linked structures that will be reused for every\n", "data file in the scan.\n", "\n", "### Download Data" ] }, { "cell_type": "code", "execution_count": 10, "id": "19", "metadata": { "execution": { "iopub.execute_input": "2026-06-30T22:30:50.537167Z", "iopub.status.busy": "2026-06-30T22:30:50.536928Z", "iopub.status.idle": "2026-06-30T22:30:50.695133Z", "shell.execute_reply": "2026-06-30T22:30:50.694058Z" } }, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "\u001b[1;36mGetting data\u001b[0m\u001b[1;36m...\u001b[0m\n" ] }, { "name": "stdout", "output_type": "stream", "text": [ "Data \u001b[32m'meas-cosio-d20-scan-3f'\u001b[0m: Co2SiO4, D20 \u001b[1m(\u001b[0mILL\u001b[1m)\u001b[0m, \u001b[1;36m3\u001b[0m files: ~50K, ~300K, ~500K\n" ] }, { "name": "stdout", "output_type": "stream", "text": [ "✅ Data \u001b[32m'meas-cosio-d20-scan-3f'\u001b[0m downloaded to \u001b[32m'../../../data/meas-cosio-d20-scan-3f.zip'\u001b[0m\n" ] } ], "source": [ "zip_path = edi.download_data('meas-cosio-d20-scan-3f', destination='data')" ] }, { "cell_type": "markdown", "id": "20", "metadata": {}, "source": [ "### Extract Data Files" ] }, { "cell_type": "code", "execution_count": 11, "id": "21", "metadata": { "execution": { "iopub.execute_input": "2026-06-30T22:30:50.696693Z", "iopub.status.busy": "2026-06-30T22:30:50.696529Z", "iopub.status.idle": "2026-06-30T22:30:50.701511Z", "shell.execute_reply": "2026-06-30T22:30:50.700777Z" } }, "outputs": [], "source": [ "scan_data_dir = 'experiments/d20_scan'\n", "data_paths = edi.extract_data_paths_from_zip(\n", " zip_path,\n", " destination=project.metadata.path / scan_data_dir,\n", ")" ] }, { "cell_type": "markdown", "id": "22", "metadata": {}, "source": [ "### Create Template Experiment" ] }, { "cell_type": "code", "execution_count": 12, "id": "23", "metadata": { "execution": { "iopub.execute_input": "2026-06-30T22:30:50.703156Z", "iopub.status.busy": "2026-06-30T22:30:50.702969Z", "iopub.status.idle": "2026-06-30T22:30:50.923400Z", "shell.execute_reply": "2026-06-30T22:30:50.922594Z" } }, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "\u001b[1;36mData loaded successfully\u001b[0m\n" ] }, { "name": "stdout", "output_type": "stream", "text": [ "Experiment 🔬 \u001b[32m'd20'\u001b[0m. Number of data points: \u001b[1;36m1507\u001b[0m.\n" ] } ], "source": [ "project.experiments.add_from_data_path(\n", " name='d20',\n", " data_path=data_paths[0],\n", ")\n", "expt = project.experiments['d20']" ] }, { "cell_type": "markdown", "id": "24", "metadata": {}, "source": [ "### Set Instrument" ] }, { "cell_type": "code", "execution_count": 13, "id": "25", "metadata": { "execution": { "iopub.execute_input": "2026-06-30T22:30:50.925240Z", "iopub.status.busy": "2026-06-30T22:30:50.924982Z", "iopub.status.idle": "2026-06-30T22:30:50.928749Z", "shell.execute_reply": "2026-06-30T22:30:50.927841Z" } }, "outputs": [], "source": [ "expt.instrument.setup_wavelength = 1.87\n", "expt.instrument.calib_twotheta_offset = 0.29" ] }, { "cell_type": "markdown", "id": "26", "metadata": {}, "source": [ "### Set Peak Profile" ] }, { "cell_type": "code", "execution_count": 14, "id": "27", "metadata": { "execution": { "iopub.execute_input": "2026-06-30T22:30:50.930456Z", "iopub.status.busy": "2026-06-30T22:30:50.930231Z", "iopub.status.idle": "2026-06-30T22:30:50.934780Z", "shell.execute_reply": "2026-06-30T22:30:50.933875Z" } }, "outputs": [], "source": [ "expt.peak.broad_gauss_u = 0.24\n", "expt.peak.broad_gauss_v = -0.53\n", "expt.peak.broad_gauss_w = 0.38\n", "expt.peak.broad_lorentz_y = 0.02\n", "expt.peak.cutoff_fwhm = 8" ] }, { "cell_type": "markdown", "id": "28", "metadata": {}, "source": [ "### Set Excluded Regions" ] }, { "cell_type": "code", "execution_count": 15, "id": "29", "metadata": { "execution": { "iopub.execute_input": "2026-06-30T22:30:50.936407Z", "iopub.status.busy": "2026-06-30T22:30:50.936239Z", "iopub.status.idle": "2026-06-30T22:30:50.939845Z", "shell.execute_reply": "2026-06-30T22:30:50.938983Z" } }, "outputs": [], "source": [ "expt.excluded_regions.create(id='1', start=0, end=8)\n", "expt.excluded_regions.create(id='2', start=150, end=180)" ] }, { "cell_type": "markdown", "id": "30", "metadata": {}, "source": [ "### Set Background" ] }, { "cell_type": "code", "execution_count": 16, "id": "31", "metadata": { "execution": { "iopub.execute_input": "2026-06-30T22:30:50.941506Z", "iopub.status.busy": "2026-06-30T22:30:50.941276Z", "iopub.status.idle": "2026-06-30T22:30:50.953170Z", "shell.execute_reply": "2026-06-30T22:30:50.952205Z" } }, "outputs": [], "source": [ "expt.background.create(id='1', position=8, intensity=609)\n", "expt.background.create(id='2', position=9, intensity=581)\n", "expt.background.create(id='3', position=10, intensity=563)\n", "expt.background.create(id='4', position=11, intensity=540)\n", "expt.background.create(id='5', position=12, intensity=520)\n", "expt.background.create(id='6', position=15, intensity=507)\n", "expt.background.create(id='7', position=25, intensity=463)\n", "expt.background.create(id='8', position=30, intensity=434)\n", "expt.background.create(id='9', position=50, intensity=451)\n", "expt.background.create(id='10', position=70, intensity=431)\n", "expt.background.create(id='11', position=90, intensity=414)\n", "expt.background.create(id='12', position=110, intensity=361)\n", "expt.background.create(id='13', position=130, intensity=292)\n", "expt.background.create(id='14', position=150, intensity=241)" ] }, { "cell_type": "markdown", "id": "32", "metadata": {}, "source": [ "### Set Linked Structures" ] }, { "cell_type": "code", "execution_count": 17, "id": "33", "metadata": { "execution": { "iopub.execute_input": "2026-06-30T22:30:50.954876Z", "iopub.status.busy": "2026-06-30T22:30:50.954654Z", "iopub.status.idle": "2026-06-30T22:30:50.957922Z", "shell.execute_reply": "2026-06-30T22:30:50.957115Z" } }, "outputs": [], "source": [ "expt.linked_structures.create(structure_id='cosio', scale=1.2)" ] }, { "cell_type": "markdown", "id": "34", "metadata": {}, "source": [ "## 🚀 Perform Analysis\n", "\n", "This section shows how to set free parameters, define constraints,\n", "and run the sequential refinement." ] }, { "cell_type": "markdown", "id": "35", "metadata": {}, "source": [ "### Set Free Parameters" ] }, { "cell_type": "code", "execution_count": 18, "id": "36", "metadata": { "execution": { "iopub.execute_input": "2026-06-30T22:30:50.959511Z", "iopub.status.busy": "2026-06-30T22:30:50.959341Z", "iopub.status.idle": "2026-06-30T22:30:50.964457Z", "shell.execute_reply": "2026-06-30T22:30:50.963729Z" } }, "outputs": [], "source": [ "struct.cell.length_a.free = True\n", "struct.cell.length_b.free = True\n", "struct.cell.length_c.free = True\n", "\n", "struct.atom_sites['Co2'].fract_x.free = True\n", "struct.atom_sites['Co2'].fract_z.free = True\n", "struct.atom_sites['Si'].fract_x.free = True\n", "struct.atom_sites['Si'].fract_z.free = True\n", "struct.atom_sites['O1'].fract_x.free = True\n", "struct.atom_sites['O1'].fract_z.free = True\n", "struct.atom_sites['O2'].fract_x.free = True\n", "struct.atom_sites['O2'].fract_z.free = True\n", "struct.atom_sites['O3'].fract_x.free = True\n", "struct.atom_sites['O3'].fract_y.free = True\n", "struct.atom_sites['O3'].fract_z.free = True\n", "\n", "struct.atom_sites['Co1'].adp_iso.free = True\n", "struct.atom_sites['Co2'].adp_iso.free = True\n", "struct.atom_sites['Si'].adp_iso.free = True\n", "struct.atom_sites['O1'].adp_iso.free = True\n", "struct.atom_sites['O2'].adp_iso.free = True\n", "struct.atom_sites['O3'].adp_iso.free = True" ] }, { "cell_type": "code", "execution_count": 19, "id": "37", "metadata": { "execution": { "iopub.execute_input": "2026-06-30T22:30:50.966291Z", "iopub.status.busy": "2026-06-30T22:30:50.966128Z", "iopub.status.idle": "2026-06-30T22:30:50.970436Z", "shell.execute_reply": "2026-06-30T22:30:50.969722Z" } }, "outputs": [], "source": [ "expt.linked_structures['cosio'].scale.free = True\n", "\n", "expt.instrument.calib_twotheta_offset.free = True\n", "\n", "expt.peak.broad_gauss_u.free = True\n", "expt.peak.broad_gauss_v.free = True\n", "expt.peak.broad_gauss_w.free = True\n", "expt.peak.broad_lorentz_y.free = True\n", "\n", "for point in expt.background:\n", " point.intensity.free = True" ] }, { "cell_type": "markdown", "id": "38", "metadata": {}, "source": [ "### Set Constraints\n", "\n", "Set aliases for parameters." ] }, { "cell_type": "code", "execution_count": 20, "id": "39", "metadata": { "execution": { "iopub.execute_input": "2026-06-30T22:30:50.972238Z", "iopub.status.busy": "2026-06-30T22:30:50.972077Z", "iopub.status.idle": "2026-06-30T22:30:50.975716Z", "shell.execute_reply": "2026-06-30T22:30:50.974922Z" } }, "outputs": [], "source": [ "analysis.aliases.create(\n", " id='biso_Co1',\n", " param=struct.atom_sites['Co1'].adp_iso,\n", ")\n", "analysis.aliases.create(\n", " id='biso_Co2',\n", " param=struct.atom_sites['Co2'].adp_iso,\n", ")" ] }, { "cell_type": "markdown", "id": "40", "metadata": {}, "source": [ "Set constraints." ] }, { "cell_type": "code", "execution_count": 21, "id": "41", "metadata": { "execution": { "iopub.execute_input": "2026-06-30T22:30:50.977210Z", "iopub.status.busy": "2026-06-30T22:30:50.977056Z", "iopub.status.idle": "2026-06-30T22:30:50.980698Z", "shell.execute_reply": "2026-06-30T22:30:50.979975Z" } }, "outputs": [], "source": [ "analysis.constraints.create(expression='biso_Co2 = biso_Co1')" ] }, { "cell_type": "markdown", "id": "42", "metadata": {}, "source": [ "### Set Minimizer" ] }, { "cell_type": "code", "execution_count": 22, "id": "43", "metadata": { "execution": { "iopub.execute_input": "2026-06-30T22:30:50.982407Z", "iopub.status.busy": "2026-06-30T22:30:50.982258Z", "iopub.status.idle": "2026-06-30T22:30:50.988451Z", "shell.execute_reply": "2026-06-30T22:30:50.987625Z" } }, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "\u001b[1;36mCurrent minimizer changed to\u001b[0m\n" ] }, { "name": "stdout", "output_type": "stream", "text": [ "bumps \u001b[1m(\u001b[0mlm\u001b[1m)\u001b[0m\n" ] } ], "source": [ "analysis.minimizer.type = 'bumps (lm)'" ] }, { "cell_type": "markdown", "id": "44", "metadata": {}, "source": [ "### Run Fitting\n", "\n", "This is the fitting of the first dataset to optimize the initial\n", "parameters for the sequential fitting. This step is optional but can\n", "help with convergence and speed of the sequential fitting, especially\n", "if the initial parameters are far from optimal." ] }, { "cell_type": "code", "execution_count": 23, "id": "45", "metadata": { "execution": { "iopub.execute_input": "2026-06-30T22:30:50.990226Z", "iopub.status.busy": "2026-06-30T22:30:50.990059Z", "iopub.status.idle": "2026-06-30T22:31:11.019879Z", "shell.execute_reply": "2026-06-30T22:31:11.019029Z" } }, "outputs": [ { "data": { "text/html": [], "text/plain": [ "" ] }, "metadata": {}, "output_type": "display_data" }, { "data": { "application/javascript": [ "\n", "(function() {\n", " const button = document.getElementById('ed-fit-stop-f1bee6bcbf604864b301425cb8d89a58-button');\n", " const status = document.getElementById('ed-fit-stop-f1bee6bcbf604864b301425cb8d89a58-status');\n", " const kernelId = '';\n", " if (!button) {\n", " return;\n", " }\n", "\n", " function setStatus(text) {\n", " if (status) {\n", " status.textContent = text;\n", " }\n", " }\n", "\n", " function pageConfig() {\n", " const element = document.getElementById('jupyter-config-data');\n", " if (!element || !element.textContent) {\n", " return {};\n", " }\n", " try {\n", " return JSON.parse(element.textContent);\n", " } catch (error) {\n", " return {};\n", " }\n", " }\n", "\n", " function baseUrl(config) {\n", " const configured = config.baseUrl || config.base_url ||\n", " (window.Jupyter && Jupyter.notebook && Jupyter.notebook.base_url);\n", " if (configured) {\n", " return configured.endsWith('/') ? configured : configured + '/';\n", " }\n", " const markers = ['/lab/', '/notebooks/', '/tree/'];\n", " for (const marker of markers) {\n", " const index = window.location.pathname.indexOf(marker);\n", " if (index >= 0) {\n", " return window.location.pathname.slice(0, index + 1);\n", " }\n", " }\n", " return '/';\n", " }\n", "\n", " function token(config) {\n", " return config.token || new URLSearchParams(window.location.search).get('token') || '';\n", " }\n", "\n", " function cookie(name) {\n", " const prefix = name + '=';\n", " for (const part of document.cookie.split(';')) {\n", " const trimmed = part.trim();\n", " if (trimmed.startsWith(prefix)) {\n", " return decodeURIComponent(trimmed.slice(prefix.length));\n", " }\n", " }\n", " return '';\n", " }\n", "\n", " function notebookPath() {\n", " const decoded = decodeURIComponent(window.location.pathname);\n", " const markers = ['/lab/tree/', '/notebooks/', '/tree/'];\n", " for (const marker of markers) {\n", " const index = decoded.indexOf(marker);\n", " if (index >= 0) {\n", " return decoded.slice(index + marker.length);\n", " }\n", " }\n", " return '';\n", " }\n", "\n", " async function kernelFromSessions(config) {\n", " const url = new URL(baseUrl(config) + 'api/sessions', window.location.origin);\n", " const authToken = token(config);\n", " if (authToken) {\n", " url.searchParams.set('token', authToken);\n", " }\n", " const response = await fetch(url, {credentials: 'same-origin'});\n", " if (!response.ok) {\n", " return '';\n", " }\n", " const sessions = await response.json();\n", " const path = notebookPath();\n", " const session = sessions.find((item) => item.path === path) || sessions[0];\n", " return session && session.kernel ? session.kernel.id : '';\n", " }\n", "\n", " async function interruptKernel(config, resolvedKernelId) {\n", " const url = new URL(\n", " baseUrl(config) + 'api/kernels/' + resolvedKernelId + '/interrupt',\n", " window.location.origin\n", " );\n", " const authToken = token(config);\n", " if (authToken) {\n", " url.searchParams.set('token', authToken);\n", " }\n", " const xsrfToken = cookie('_xsrf');\n", " const headers = {};\n", " if (xsrfToken) {\n", " headers['X-XSRFToken'] = xsrfToken;\n", " }\n", " const response = await fetch(url, {\n", " method: 'POST',\n", " credentials: 'same-origin',\n", " headers: headers\n", " });\n", " return response.ok;\n", " }\n", "\n", " button.addEventListener('click', async function() {\n", " button.disabled = true;\n", " setStatus('Stopping...');\n", " const config = pageConfig();\n", " try {\n", " const resolvedKernelId = kernelId || await kernelFromSessions(config);\n", " if (!resolvedKernelId) {\n", " throw new Error('Could not resolve the current kernel id.');\n", " }\n", " const interrupted = await interruptKernel(config, resolvedKernelId);\n", " if (!interrupted) {\n", " throw new Error('Jupyter Server rejected the interrupt request.');\n", " }\n", " setStatus('Interrupt sent...');\n", " } catch (error) {\n", " button.disabled = false;\n", " setStatus('Use Kernel > Interrupt to stop this fit.');\n", " }\n", " });\n", "})();\n" ], "text/plain": [ "" ] }, "metadata": {}, "output_type": "display_data" }, { "name": "stdout", "output_type": "stream", "text": [ "\u001b[1;36mStandard fitting\u001b[0m\n" ] }, { "name": "stdout", "output_type": "stream", "text": [ "📋 Using experiment 🔬 \u001b[32m'd20'\u001b[0m for \u001b[32m'single'\u001b[0m fitting\n" ] }, { "name": "stdout", "output_type": "stream", "text": [ "🚀 Starting fit process with \u001b[32m'bumps \u001b[0m\u001b[32m(\u001b[0m\u001b[32mlm\u001b[0m\u001b[32m)\u001b[0m\u001b[32m'\u001b[0m\u001b[33m...\u001b[0m\n" ] }, { "name": "stdout", "output_type": "stream", "text": [ "📈 Goodness-of-fit progress:\n" ] }, { "data": { "text/html": [ "
iterationtime (s)χ²change / status
110.0612.77
2412.835.1160.0% ↓
3815.834.825.6% ↓
416111.954.82
520819.634.82
" ], "text/plain": [ "" ] }, "metadata": {}, "output_type": "display_data" }, { "name": "stdout", "output_type": "stream", "text": [ "🏆 Best goodness-of-fit \u001b[1m(\u001b[0mreduced χ²\u001b[1m)\u001b[0m is \u001b[1;36m4.82\u001b[0m at iteration \u001b[1;36m161\u001b[0m\n" ] }, { "name": "stdout", "output_type": "stream", "text": [ "✅ Fitting complete.\n" ] }, { "name": "stdout", "output_type": "stream", "text": [ "\u001b[1;36mSaving project 📦 \u001b[0m\u001b[32m'cosio_d20_scan'\u001b[0m\u001b[1;36m to \u001b[0m\u001b[32m'../../../projects/refine-cosio-d20-tscan'\u001b[0m\n" ] }, { "name": "stdout", "output_type": "stream", "text": [ "├── 📄 project.edi\n" ] }, { "name": "stdout", "output_type": "stream", "text": [ "├── 📁 structures/\n" ] }, { "name": "stdout", "output_type": "stream", "text": [ "│ └── 📄 cosio.edi\n" ] }, { "name": "stdout", "output_type": "stream", "text": [ "├── 📁 experiments/\n" ] }, { "name": "stdout", "output_type": "stream", "text": [ "│ └── 📄 d20.edi\n" ] }, { "name": "stdout", "output_type": "stream", "text": [ "├── 📁 analysis/\n" ] }, { "name": "stdout", "output_type": "stream", "text": [ "│ └── 📄 analysis.edi\n" ] }, { "name": "stdout", "output_type": "stream", "text": [ "└── 📁 reports/\n" ] }, { "name": "stdout", "output_type": "stream", "text": [ " └── 📄 cosio_d20_scan.html\n" ] } ], "source": [ "analysis.fit()" ] }, { "cell_type": "code", "execution_count": 24, "id": "46", "metadata": { "execution": { "iopub.execute_input": "2026-06-30T22:31:11.022001Z", "iopub.status.busy": "2026-06-30T22:31:11.021755Z", "iopub.status.idle": "2026-06-30T22:31:11.659782Z", "shell.execute_reply": "2026-06-30T22:31:11.659080Z" } }, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "⚙️ Settings used:\n" ] }, { "data": { "text/html": [ "
NameValueDescription
1max_iterations1000Maximum solver iterations.
" ], "text/plain": [ "" ] }, "metadata": {}, "output_type": "display_data" }, { "name": "stdout", "output_type": "stream", "text": [ "📋 Least-squares fit results:\n" ] }, { "data": { "text/html": [ "
MetricValue
1🧪 Minimizerbumps (lm)
2✅ Overall statussuccess
3⏱️ Fitting time (seconds)19.63
4📏 Goodness-of-fit (reduced χ²)4.82
5📏 R-factor (Rf, %)3.16
6📏 R-factor squared (Rf², %)4.68
7📏 Weighted R-factor (wR, %)5.02
" ], "text/plain": [ "" ] }, "metadata": {}, "output_type": "display_data" }, { "name": "stdout", "output_type": "stream", "text": [ "📈 Refined parameters:\n" ] }, { "data": { "text/html": [ "
datablockcategoryentryparameterunitsstartvalues.u.change
1cosiocelllength_aÅ10.310010.30710.00030.03 % ↓
2cosiocelllength_bÅ6.00006.00300.00020.05 % ↑
3cosiocelllength_cÅ4.79004.78650.00010.07 % ↓
4cosioatom_siteCo1adp_isoŲ0.30000.16020.080746.59 % ↓
5cosioatom_siteCo2fract_x0.27900.27840.00070.21 % ↓
6cosioatom_siteCo2fract_z0.98500.98090.00150.41 % ↓
7cosioatom_siteSifract_x0.09400.09340.00040.63 % ↓
8cosioatom_siteSifract_z0.42900.42850.00090.12 % ↓
9cosioatom_siteSiadp_isoŲ0.34000.38500.065013.23 % ↑
10cosioatom_siteO1fract_x0.09100.09070.00030.38 % ↓
11cosioatom_siteO1fract_z0.77100.77180.00070.10 % ↑
12cosioatom_siteO1adp_isoŲ0.63000.64940.06013.08 % ↑
13cosioatom_siteO2fract_x0.44800.44840.00030.08 % ↑
14cosioatom_siteO2fract_z0.21700.21660.00070.19 % ↓
15cosioatom_siteO2adp_isoŲ0.59000.47830.059518.93 % ↓
16cosioatom_siteO3fract_x0.16400.16330.00020.44 % ↓
17cosioatom_siteO3fract_y0.03200.03110.00032.80 % ↓
18cosioatom_siteO3fract_z0.28000.27960.00050.15 % ↓
19cosioatom_siteO3adp_isoŲ0.83000.85880.05033.47 % ↑
20d20linked_structurecosioscale1.20001.19890.01090.09 % ↓
21d20peakbroad_gauss_udeg²0.24000.24330.00711.40 % ↑
22d20peakbroad_gauss_vdeg²-0.5300-0.53150.01510.28 % ↑
23d20peakbroad_gauss_wdeg²0.38000.38290.00930.76 % ↑
24d20peakbroad_lorentz_ydeg0.02000.02130.00456.51 % ↑
25d20instrumenttwotheta_offsetdeg0.29000.28700.00211.03 % ↓
26d20background1intensity609.0000610.922715.10350.32 % ↑
27d20background2intensity581.0000605.202210.22084.17 % ↑
28d20background3intensity563.0000592.42069.75305.23 % ↑
29d20background4intensity540.0000576.94399.28956.84 % ↑
30d20background5intensity520.0000528.19436.28051.58 % ↑
31d20background6intensity507.0000505.42443.58090.31 % ↓
32d20background7intensity463.0000484.40343.31964.62 % ↑
33d20background8intensity434.0000419.41652.44733.36 % ↓
34d20background9intensity451.0000457.04052.29331.34 % ↑
35d20background10intensity431.0000424.80512.05941.44 % ↓
36d20background11intensity414.0000413.89282.24580.03 % ↓
37d20background12intensity361.0000358.52222.11780.69 % ↓
38d20background13intensity292.0000287.01931.99641.71 % ↓
39d20background14intensity241.0000238.71723.07080.95 % ↓
" ], "text/plain": [ "" ] }, "metadata": {}, "output_type": "display_data" }, { "data": { "text/html": [ "
• start = parameter value before refinement
• value = refined value from least-squares minimization
• s.u. = standard uncertainty (one sigma), from the covariance matrix
• change = relative change from start, in %; ↑ = increase, ↓ = decrease
" ], "text/plain": [ "" ] }, "metadata": {}, "output_type": "display_data" } ], "source": [ "display.fit.results()" ] }, { "cell_type": "markdown", "id": "47", "metadata": {}, "source": [ "### Display Correlations" ] }, { "cell_type": "code", "execution_count": 25, "id": "48", "metadata": { "execution": { "iopub.execute_input": "2026-06-30T22:31:11.661912Z", "iopub.status.busy": "2026-06-30T22:31:11.661738Z", "iopub.status.idle": "2026-06-30T22:31:11.694931Z", "shell.execute_reply": "2026-06-30T22:31:11.694085Z" } }, "outputs": [ { "data": { "text/html": [ "\n", "\n", "
\n", "
Loading plot…
\n", "
" ], "text/plain": [ "" ] }, "metadata": {}, "output_type": "display_data" } ], "source": [ "display.fit.correlations()" ] }, { "cell_type": "markdown", "id": "49", "metadata": {}, "source": [ "### Display Pattern" ] }, { "cell_type": "code", "execution_count": 26, "id": "50", "metadata": { "execution": { "iopub.execute_input": "2026-06-30T22:31:11.696671Z", "iopub.status.busy": "2026-06-30T22:31:11.696453Z", "iopub.status.idle": "2026-06-30T22:31:11.789767Z", "shell.execute_reply": "2026-06-30T22:31:11.788498Z" } }, "outputs": [ { "data": { "text/html": [ "
Loading plot…
" ], "text/plain": [ "" ] }, "metadata": {}, "output_type": "display_data" } ], "source": [ "display.pattern(expt_name='d20')" ] }, { "cell_type": "markdown", "id": "51", "metadata": {}, "source": [ "### Display Structure" ] }, { "cell_type": "code", "execution_count": 27, "id": "52", "metadata": { "execution": { "iopub.execute_input": "2026-06-30T22:31:11.791851Z", "iopub.status.busy": "2026-06-30T22:31:11.791630Z", "iopub.status.idle": "2026-06-30T22:31:11.855959Z", "shell.execute_reply": "2026-06-30T22:31:11.855128Z" } }, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "\u001b[1;36mStructure 🧩 \u001b[0m\u001b[32m'cosio'\u001b[0m\u001b[1;36m \u001b[0m\u001b[1;36m(\u001b[0m\u001b[1;36mAtom view type: \u001b[0m\u001b[32m'adp'\u001b[0m\u001b[1;36m)\u001b[0m\n" ] }, { "data": { "text/html": [ "
\n", "
\n", "
Loading plot…
\n", "
\n", "
\n", "
\n", "
drag = rotate
wheel = zoom
right-drag = pan
\n", "
\n", "
\n", "\n", "\n", "\n", "" ], "text/plain": [ "" ] }, "metadata": {}, "output_type": "display_data" } ], "source": [ "project.structure_style.atom_view = 'adp'\n", "project.display.structure(struct_name='cosio')" ] }, { "cell_type": "markdown", "id": "53", "metadata": {}, "source": [ "### Run Sequential Fitting\n", "\n", "Set output verbosity level to \"short\" to show only one-line status\n", "messages during the analysis process." ] }, { "cell_type": "code", "execution_count": 28, "id": "54", "metadata": { "execution": { "iopub.execute_input": "2026-06-30T22:31:11.857496Z", "iopub.status.busy": "2026-06-30T22:31:11.857337Z", "iopub.status.idle": "2026-06-30T22:31:11.860981Z", "shell.execute_reply": "2026-06-30T22:31:11.859540Z" } }, "outputs": [], "source": [ "project.verbosity = 'short'" ] }, { "cell_type": "markdown", "id": "55", "metadata": { "lines_to_next_cell": 2 }, "source": [ "\n", "Create a persisted extract rule that reads the temperature from each\n", "data file." ] }, { "cell_type": "code", "execution_count": 29, "id": "56", "metadata": { "execution": { "iopub.execute_input": "2026-06-30T22:31:11.862794Z", "iopub.status.busy": "2026-06-30T22:31:11.862628Z", "iopub.status.idle": "2026-06-30T22:31:11.865935Z", "shell.execute_reply": "2026-06-30T22:31:11.865028Z" } }, "outputs": [], "source": [ "temperature = 'diffrn.ambient_temperature'" ] }, { "cell_type": "code", "execution_count": 30, "id": "57", "metadata": { "execution": { "iopub.execute_input": "2026-06-30T22:31:11.867872Z", "iopub.status.busy": "2026-06-30T22:31:11.867566Z", "iopub.status.idle": "2026-06-30T22:31:11.872454Z", "shell.execute_reply": "2026-06-30T22:31:11.871576Z" } }, "outputs": [], "source": [ "analysis.sequential_fit_extract.create(\n", " id='temperature',\n", " target=temperature,\n", " pattern=r'^TEMP\\s+([0-9.]+)',\n", " required=True,\n", ")" ] }, { "cell_type": "markdown", "id": "58", "metadata": {}, "source": [ "Set the sequential fitting parameters." ] }, { "cell_type": "code", "execution_count": 31, "id": "59", "metadata": { "execution": { "iopub.execute_input": "2026-06-30T22:31:11.874124Z", "iopub.status.busy": "2026-06-30T22:31:11.873930Z", "iopub.status.idle": "2026-06-30T22:31:11.879223Z", "shell.execute_reply": "2026-06-30T22:31:11.878478Z" } }, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "\u001b[1;36mFitting mode changed to\u001b[0m\n" ] }, { "name": "stdout", "output_type": "stream", "text": [ "sequential\n" ] } ], "source": [ "analysis.fitting_mode.type = 'sequential'\n", "analysis.sequential_fit.data_dir = scan_data_dir\n", "analysis.sequential_fit.max_workers = 'auto'\n", "analysis.sequential_fit.reverse = True" ] }, { "cell_type": "markdown", "id": "60", "metadata": {}, "source": [ "Run the sequential fit over all data files in the scan directory." ] }, { "cell_type": "code", "execution_count": 32, "id": "61", "metadata": { "execution": { "iopub.execute_input": "2026-06-30T22:31:11.880980Z", "iopub.status.busy": "2026-06-30T22:31:11.880808Z", "iopub.status.idle": "2026-06-30T22:32:18.197359Z", "shell.execute_reply": "2026-06-30T22:32:18.196558Z" } }, "outputs": [ { "data": { "text/html": [], "text/plain": [ "" ] }, "metadata": {}, "output_type": "display_data" }, { "data": { "application/javascript": [ "\n", "(function() {\n", " const button = document.getElementById('ed-fit-stop-c37cd7f7f5524de6bf532d2c5351bafc-button');\n", " const status = document.getElementById('ed-fit-stop-c37cd7f7f5524de6bf532d2c5351bafc-status');\n", " const kernelId = '';\n", " if (!button) {\n", " return;\n", " }\n", "\n", " function setStatus(text) {\n", " if (status) {\n", " status.textContent = text;\n", " }\n", " }\n", "\n", " function pageConfig() {\n", " const element = document.getElementById('jupyter-config-data');\n", " if (!element || !element.textContent) {\n", " return {};\n", " }\n", " try {\n", " return JSON.parse(element.textContent);\n", " } catch (error) {\n", " return {};\n", " }\n", " }\n", "\n", " function baseUrl(config) {\n", " const configured = config.baseUrl || config.base_url ||\n", " (window.Jupyter && Jupyter.notebook && Jupyter.notebook.base_url);\n", " if (configured) {\n", " return configured.endsWith('/') ? configured : configured + '/';\n", " }\n", " const markers = ['/lab/', '/notebooks/', '/tree/'];\n", " for (const marker of markers) {\n", " const index = window.location.pathname.indexOf(marker);\n", " if (index >= 0) {\n", " return window.location.pathname.slice(0, index + 1);\n", " }\n", " }\n", " return '/';\n", " }\n", "\n", " function token(config) {\n", " return config.token || new URLSearchParams(window.location.search).get('token') || '';\n", " }\n", "\n", " function cookie(name) {\n", " const prefix = name + '=';\n", " for (const part of document.cookie.split(';')) {\n", " const trimmed = part.trim();\n", " if (trimmed.startsWith(prefix)) {\n", " return decodeURIComponent(trimmed.slice(prefix.length));\n", " }\n", " }\n", " return '';\n", " }\n", "\n", " function notebookPath() {\n", " const decoded = decodeURIComponent(window.location.pathname);\n", " const markers = ['/lab/tree/', '/notebooks/', '/tree/'];\n", " for (const marker of markers) {\n", " const index = decoded.indexOf(marker);\n", " if (index >= 0) {\n", " return decoded.slice(index + marker.length);\n", " }\n", " }\n", " return '';\n", " }\n", "\n", " async function kernelFromSessions(config) {\n", " const url = new URL(baseUrl(config) + 'api/sessions', window.location.origin);\n", " const authToken = token(config);\n", " if (authToken) {\n", " url.searchParams.set('token', authToken);\n", " }\n", " const response = await fetch(url, {credentials: 'same-origin'});\n", " if (!response.ok) {\n", " return '';\n", " }\n", " const sessions = await response.json();\n", " const path = notebookPath();\n", " const session = sessions.find((item) => item.path === path) || sessions[0];\n", " return session && session.kernel ? session.kernel.id : '';\n", " }\n", "\n", " async function interruptKernel(config, resolvedKernelId) {\n", " const url = new URL(\n", " baseUrl(config) + 'api/kernels/' + resolvedKernelId + '/interrupt',\n", " window.location.origin\n", " );\n", " const authToken = token(config);\n", " if (authToken) {\n", " url.searchParams.set('token', authToken);\n", " }\n", " const xsrfToken = cookie('_xsrf');\n", " const headers = {};\n", " if (xsrfToken) {\n", " headers['X-XSRFToken'] = xsrfToken;\n", " }\n", " const response = await fetch(url, {\n", " method: 'POST',\n", " credentials: 'same-origin',\n", " headers: headers\n", " });\n", " return response.ok;\n", " }\n", "\n", " button.addEventListener('click', async function() {\n", " button.disabled = true;\n", " setStatus('Stopping...');\n", " const config = pageConfig();\n", " try {\n", " const resolvedKernelId = kernelId || await kernelFromSessions(config);\n", " if (!resolvedKernelId) {\n", " throw new Error('Could not resolve the current kernel id.');\n", " }\n", " const interrupted = await interruptKernel(config, resolvedKernelId);\n", " if (!interrupted) {\n", " throw new Error('Jupyter Server rejected the interrupt request.');\n", " }\n", " setStatus('Interrupt sent...');\n", " } catch (error) {\n", " button.disabled = false;\n", " setStatus('Use Kernel > Interrupt to stop this fit.');\n", " }\n", " });\n", "})();\n" ], "text/plain": [ "" ] }, "metadata": {}, "output_type": "display_data" }, { "name": "stdout", "output_type": "stream", "text": [ "\u001b[1;36mSequential fitting\u001b[0m\n" ] }, { "name": "stdout", "output_type": "stream", "text": [ "🚀 Starting fit process with \u001b[32m'bumps \u001b[0m\u001b[32m(\u001b[0m\u001b[32mlm\u001b[0m\u001b[32m)\u001b[0m\u001b[32m'\u001b[0m\u001b[33m...\u001b[0m\n" ] }, { "name": "stdout", "output_type": "stream", "text": [ "📋 \u001b[1;36m3\u001b[0m files in \u001b[1;36m1\u001b[0m chunks \u001b[1m(\u001b[0m\u001b[33mmax_workers\u001b[0m=\u001b[1;36m4\u001b[0m\u001b[1m)\u001b[0m\n" ] }, { "name": "stdout", "output_type": "stream", "text": [ "📈 Goodness-of-fit progress:\n" ] }, { "data": { "text/html": [ "
chunkprogresstime (s)filescountaverage χ²status
11/1100.0%64.82all594842.dat - all594687.dat34.37
" ], "text/plain": [ "" ] }, "metadata": {}, "output_type": "display_data" }, { "name": "stdout", "output_type": "stream", "text": [ "✅ Sequential fitting complete: \u001b[1;36m3\u001b[0m files processed.\n" ] }, { "name": "stdout", "output_type": "stream", "text": [ "📄 Results saved to \u001b[32m'../../../projects/refine-cosio-d20-tscan/analysis/results.csv'\u001b[0m\n" ] }, { "name": "stdout", "output_type": "stream", "text": [ "\u001b[1;36mSaving project 📦 \u001b[0m\u001b[32m'cosio_d20_scan'\u001b[0m\u001b[1;36m to \u001b[0m\u001b[32m'../../../projects/refine-cosio-d20-tscan'\u001b[0m\n" ] }, { "name": "stdout", "output_type": "stream", "text": [ "├── 📄 project.edi\n" ] }, { "name": "stdout", "output_type": "stream", "text": [ "├── 📁 structures/\n" ] }, { "name": "stdout", "output_type": "stream", "text": [ "│ └── 📄 cosio.edi\n" ] }, { "name": "stdout", "output_type": "stream", "text": [ "├── 📁 experiments/\n" ] }, { "name": "stdout", "output_type": "stream", "text": [ "│ └── 📄 d20.edi\n" ] }, { "name": "stdout", "output_type": "stream", "text": [ "├── 📁 analysis/\n" ] }, { "name": "stdout", "output_type": "stream", "text": [ "│ ├── 📄 analysis.edi\n" ] }, { "name": "stdout", "output_type": "stream", "text": [ "│ └── 📄 results.csv\n" ] }, { "name": "stdout", "output_type": "stream", "text": [ "└── 📁 reports/\n" ] }, { "name": "stdout", "output_type": "stream", "text": [ " └── 📄 cosio_d20_scan.html\n" ] } ], "source": [ "analysis.fit()" ] }, { "cell_type": "markdown", "id": "62", "metadata": {}, "source": [ "### Replay a Dataset\n", "\n", "Apply fitted parameters from the first CSV row and plot the result." ] }, { "cell_type": "code", "execution_count": 33, "id": "63", "metadata": { "execution": { "iopub.execute_input": "2026-06-30T22:32:18.199228Z", "iopub.status.busy": "2026-06-30T22:32:18.199056Z", "iopub.status.idle": "2026-06-30T22:32:18.753749Z", "shell.execute_reply": "2026-06-30T22:32:18.752949Z" } }, "outputs": [ { "data": { "text/html": [ "
Loading plot…
" ], "text/plain": [ "" ] }, "metadata": {}, "output_type": "display_data" } ], "source": [ "project.apply_params_from_csv(row_index=0)\n", "display.pattern(expt_name='d20')" ] }, { "cell_type": "markdown", "id": "64", "metadata": {}, "source": [ "\n", "Apply fitted parameters from the last CSV row and plot the result." ] }, { "cell_type": "code", "execution_count": 34, "id": "65", "metadata": { "execution": { "iopub.execute_input": "2026-06-30T22:32:18.755418Z", "iopub.status.busy": "2026-06-30T22:32:18.755247Z", "iopub.status.idle": "2026-06-30T22:32:19.602036Z", "shell.execute_reply": "2026-06-30T22:32:19.601203Z" } }, "outputs": [ { "data": { "text/html": [ "
Loading plot…
" ], "text/plain": [ "" ] }, "metadata": {}, "output_type": "display_data" } ], "source": [ "project.apply_params_from_csv(row_index=-1)\n", "display.pattern(expt_name='d20')" ] }, { "cell_type": "markdown", "id": "66", "metadata": {}, "source": [ "### Display Parameter Evolution\n", "\n", "Reuse the extracted diffrn path as the x-axis in the following plots." ] }, { "cell_type": "markdown", "id": "67", "metadata": {}, "source": [ "Plot fit quality metrics vs. temperature." ] }, { "cell_type": "code", "execution_count": 35, "id": "68", "metadata": { "execution": { "iopub.execute_input": "2026-06-30T22:32:19.604700Z", "iopub.status.busy": "2026-06-30T22:32:19.604542Z", "iopub.status.idle": "2026-06-30T22:32:19.654642Z", "shell.execute_reply": "2026-06-30T22:32:19.653920Z" } }, "outputs": [ { "data": { "text/html": [ "
Loading plot…
" ], "text/plain": [ "" ] }, "metadata": {}, "output_type": "display_data" }, { "data": { "text/html": [ "
Loading plot…
" ], "text/plain": [ "" ] }, "metadata": {}, "output_type": "display_data" }, { "data": { "text/html": [ "
Loading plot…
" ], "text/plain": [ "" ] }, "metadata": {}, "output_type": "display_data" } ], "source": [ "display.fit.series(analysis.fit_result.success, versus=temperature)\n", "display.fit.series(analysis.fit_result.reduced_chi_square, versus=temperature)\n", "display.fit.series(analysis.fit_result.iterations, versus=temperature)" ] }, { "cell_type": "markdown", "id": "69", "metadata": {}, "source": [ "Plot unit cell parameters vs. temperature." ] }, { "cell_type": "code", "execution_count": 36, "id": "70", "metadata": { "execution": { "iopub.execute_input": "2026-06-30T22:32:19.656682Z", "iopub.status.busy": "2026-06-30T22:32:19.656500Z", "iopub.status.idle": "2026-06-30T22:32:19.716542Z", "shell.execute_reply": "2026-06-30T22:32:19.715542Z" } }, "outputs": [ { "data": { "text/html": [ "
Loading plot…
" ], "text/plain": [ "" ] }, "metadata": {}, "output_type": "display_data" }, { "data": { "text/html": [ "
Loading plot…
" ], "text/plain": [ "" ] }, "metadata": {}, "output_type": "display_data" }, { "data": { "text/html": [ "
Loading plot…
" ], "text/plain": [ "" ] }, "metadata": {}, "output_type": "display_data" } ], "source": [ "display.fit.series(struct.cell.length_a, versus=temperature)\n", "display.fit.series(struct.cell.length_b, versus=temperature)\n", "display.fit.series(struct.cell.length_c, versus=temperature)" ] }, { "cell_type": "markdown", "id": "71", "metadata": {}, "source": [ "Plot isotropic displacement parameters vs. temperature." ] }, { "cell_type": "code", "execution_count": 37, "id": "72", "metadata": { "execution": { "iopub.execute_input": "2026-06-30T22:32:19.718110Z", "iopub.status.busy": "2026-06-30T22:32:19.717926Z", "iopub.status.idle": "2026-06-30T22:32:19.783627Z", "shell.execute_reply": "2026-06-30T22:32:19.782735Z" } }, "outputs": [ { "data": { "text/html": [ "
Loading plot…
" ], "text/plain": [ "" ] }, "metadata": {}, "output_type": "display_data" }, { "data": { "text/html": [ "
Loading plot…
" ], "text/plain": [ "" ] }, "metadata": {}, "output_type": "display_data" }, { "data": { "text/html": [ "
Loading plot…
" ], "text/plain": [ "" ] }, "metadata": {}, "output_type": "display_data" }, { "data": { "text/html": [ "
Loading plot…
" ], "text/plain": [ "" ] }, "metadata": {}, "output_type": "display_data" }, { "data": { "text/html": [ "
Loading plot…
" ], "text/plain": [ "" ] }, "metadata": {}, "output_type": "display_data" } ], "source": [ "display.fit.series(struct.atom_sites['Co1'].adp_iso, versus=temperature)\n", "display.fit.series(struct.atom_sites['Si'].adp_iso, versus=temperature)\n", "display.fit.series(struct.atom_sites['O1'].adp_iso, versus=temperature)\n", "display.fit.series(struct.atom_sites['O2'].adp_iso, versus=temperature)\n", "display.fit.series(struct.atom_sites['O3'].adp_iso, versus=temperature)" ] }, { "cell_type": "markdown", "id": "73", "metadata": {}, "source": [ "Plot selected fractional coordinates vs. temperature." ] }, { "cell_type": "code", "execution_count": 38, "id": "74", "metadata": { "execution": { "iopub.execute_input": "2026-06-30T22:32:19.785366Z", "iopub.status.busy": "2026-06-30T22:32:19.785137Z", "iopub.status.idle": "2026-06-30T22:32:19.855874Z", "shell.execute_reply": "2026-06-30T22:32:19.854980Z" } }, "outputs": [ { "data": { "text/html": [ "
Loading plot…
" ], "text/plain": [ "" ] }, "metadata": {}, "output_type": "display_data" }, { "data": { "text/html": [ "
Loading plot…
" ], "text/plain": [ "" ] }, "metadata": {}, "output_type": "display_data" }, { "data": { "text/html": [ "
Loading plot…
" ], "text/plain": [ "" ] }, "metadata": {}, "output_type": "display_data" }, { "data": { "text/html": [ "
Loading plot…
" ], "text/plain": [ "" ] }, "metadata": {}, "output_type": "display_data" }, { "data": { "text/html": [ "
Loading plot…
" ], "text/plain": [ "" ] }, "metadata": {}, "output_type": "display_data" } ], "source": [ "display.fit.series(struct.atom_sites['Co2'].fract_x, versus=temperature)\n", "display.fit.series(struct.atom_sites['Co2'].fract_z, versus=temperature)\n", "display.fit.series(struct.atom_sites['O1'].fract_z, versus=temperature)\n", "display.fit.series(struct.atom_sites['O2'].fract_z, versus=temperature)\n", "display.fit.series(struct.atom_sites['O3'].fract_z, versus=temperature)" ] } ], "metadata": { "jupytext": { "cell_metadata_filter": "-all", "main_language": "python", "notebook_metadata_filter": "-all" }, "language_info": { "codemirror_mode": { "name": "ipython", "version": 3 }, "file_extension": ".py", "mimetype": "text/x-python", "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", "version": "3.14.5" } }, "nbformat": 4, "nbformat_minor": 5 }