{ "cells": [ { "cell_type": "code", "execution_count": 1, "id": "0", "metadata": { "execution": { "iopub.execute_input": "2026-04-14T14:54:39.089208Z", "iopub.status.busy": "2026-04-14T14:54:39.088968Z", "iopub.status.idle": "2026-04-14T14:54:39.093487Z", "shell.execute_reply": "2026-04-14T14:54:39.092538Z" }, "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.13.1" ] }, { "cell_type": "markdown", "id": "1", "metadata": {}, "source": [ "# Pair Distribution Function: NaCl, XRD\n", "\n", "This example demonstrates a pair distribution function (PDF) analysis\n", "of NaCl, based on data collected from an X-ray powder diffraction\n", "experiment.\n", "\n", "The dataset is taken from:\n", "https://github.com/diffpy/add2019-diffpy-cmi/tree/master" ] }, { "cell_type": "markdown", "id": "2", "metadata": {}, "source": [ "## Import Library" ] }, { "cell_type": "code", "execution_count": 2, "id": "3", "metadata": { "execution": { "iopub.execute_input": "2026-04-14T14:54:39.095216Z", "iopub.status.busy": "2026-04-14T14:54:39.094885Z", "iopub.status.idle": "2026-04-14T14:54:41.693972Z", "shell.execute_reply": "2026-04-14T14:54:41.693006Z" } }, "outputs": [], "source": [ "import easydiffraction as ed" ] }, { "cell_type": "markdown", "id": "4", "metadata": {}, "source": [ "## Create Project" ] }, { "cell_type": "code", "execution_count": 3, "id": "5", "metadata": { "execution": { "iopub.execute_input": "2026-04-14T14:54:41.696031Z", "iopub.status.busy": "2026-04-14T14:54:41.695655Z", "iopub.status.idle": "2026-04-14T14:54:42.194730Z", "shell.execute_reply": "2026-04-14T14:54:42.193939Z" } }, "outputs": [ { "data": { "application/javascript": [ "\n", " (function() {\n", " var isDark = false;\n", "\n", " // Check JupyterLab theme\n", " if (document.body.classList.contains('jp-mod-dark') || \n", " document.body.classList.contains('theme-dark') ||\n", " document.body.classList.contains('vscode-dark')) {\n", " isDark = true;\n", " }\n", "\n", " // Check theme attribute\n", " var themeAttr = document.body.getAttribute('data-jp-theme-name');\n", " if (themeAttr && themeAttr.includes('dark')) {\n", " isDark = true;\n", " }\n", "\n", " // Check computed background color\n", " var notebookEl = document.querySelector('.jp-Notebook') || \n", " document.querySelector('.notebook_app') ||\n", " document.body;\n", " if (notebookEl) {\n", " var bgColor = window.getComputedStyle(notebookEl).backgroundColor;\n", " var rgb = bgColor.match(/\\d+/g);\n", " if (rgb && rgb.length >= 3) {\n", " var brightness = (parseInt(rgb[0]) + parseInt(rgb[1]) + parseInt(rgb[2])) / 3;\n", " if (brightness < 128) {\n", " isDark = true;\n", " }\n", " }\n", " }\n", "\n", " // Store result\n", " if (typeof IPython !== 'undefined' && IPython.notebook && IPython.notebook.kernel) {\n", " IPython.notebook.kernel.execute('_jupyter_dark_detect_result = ' + isDark);\n", " }\n", " })();\n", " " ], "text/plain": [ "" ] }, "metadata": {}, "output_type": "display_data" }, { "data": { "application/javascript": [ "\n", " if (typeof IPython !== 'undefined' && IPython.notebook) {\n", " IPython.notebook.kernel.execute(\"_jupyter_dark_detect_result = \" + \n", " (document.body.classList.contains('theme-dark') || \n", " document.body.classList.contains('jp-mod-dark') ||\n", " (document.body.getAttribute('data-jp-theme-name') && \n", " document.body.getAttribute('data-jp-theme-name').includes('dark'))));\n", " }\n", " " ], "text/plain": [ "" ] }, "metadata": {}, "output_type": "display_data" } ], "source": [ "project = ed.Project()" ] }, { "cell_type": "markdown", "id": "6", "metadata": {}, "source": [ "## Set Plotting Engine" ] }, { "cell_type": "code", "execution_count": 4, "id": "7", "metadata": { "execution": { "iopub.execute_input": "2026-04-14T14:54:42.196892Z", "iopub.status.busy": "2026-04-14T14:54:42.196540Z", "iopub.status.idle": "2026-04-14T14:54:42.199434Z", "shell.execute_reply": "2026-04-14T14:54:42.198648Z" } }, "outputs": [], "source": [ "# Keep the auto-selected engine. Alternatively, you can uncomment the\n", "# line below to explicitly set the engine to the required one.\n", "# project.plotter.engine = 'plotly'" ] }, { "cell_type": "code", "execution_count": 5, "id": "8", "metadata": { "execution": { "iopub.execute_input": "2026-04-14T14:54:42.200855Z", "iopub.status.busy": "2026-04-14T14:54:42.200680Z", "iopub.status.idle": "2026-04-14T14:54:42.203514Z", "shell.execute_reply": "2026-04-14T14:54:42.202832Z" } }, "outputs": [], "source": [ "# Set global plot range for plots\n", "project.plotter.x_min = 2.0\n", "project.plotter.x_max = 30.0" ] }, { "cell_type": "markdown", "id": "9", "metadata": {}, "source": [ "## Add Structure" ] }, { "cell_type": "code", "execution_count": 6, "id": "10", "metadata": { "execution": { "iopub.execute_input": "2026-04-14T14:54:42.205224Z", "iopub.status.busy": "2026-04-14T14:54:42.205036Z", "iopub.status.idle": "2026-04-14T14:54:42.208586Z", "shell.execute_reply": "2026-04-14T14:54:42.207843Z" } }, "outputs": [], "source": [ "project.structures.create(name='nacl')" ] }, { "cell_type": "code", "execution_count": 7, "id": "11", "metadata": { "execution": { "iopub.execute_input": "2026-04-14T14:54:42.210160Z", "iopub.status.busy": "2026-04-14T14:54:42.209973Z", "iopub.status.idle": "2026-04-14T14:54:42.215979Z", "shell.execute_reply": "2026-04-14T14:54:42.215125Z" } }, "outputs": [], "source": [ "project.structures['nacl'].space_group.name_h_m = 'F m -3 m'\n", "project.structures['nacl'].space_group.it_coordinate_system_code = '1'\n", "project.structures['nacl'].cell.length_a = 5.62\n", "project.structures['nacl'].atom_sites.create(\n", " label='Na',\n", " type_symbol='Na',\n", " fract_x=0,\n", " fract_y=0,\n", " fract_z=0,\n", " wyckoff_letter='a',\n", " adp_iso=1.0,\n", ")\n", "project.structures['nacl'].atom_sites.create(\n", " label='Cl',\n", " type_symbol='Cl',\n", " fract_x=0.5,\n", " fract_y=0.5,\n", " fract_z=0.5,\n", " wyckoff_letter='b',\n", " adp_iso=1.0,\n", ")" ] }, { "cell_type": "markdown", "id": "12", "metadata": {}, "source": [ "## Add Experiment" ] }, { "cell_type": "code", "execution_count": 8, "id": "13", "metadata": { "execution": { "iopub.execute_input": "2026-04-14T14:54:42.217589Z", "iopub.status.busy": "2026-04-14T14:54:42.217411Z", "iopub.status.idle": "2026-04-14T14:54:42.519911Z", "shell.execute_reply": "2026-04-14T14:54:42.519168Z" } }, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "\u001b[1;34mGetting data\u001b[0m\u001b[1;34m...\u001b[0m\n" ] }, { "name": "stdout", "output_type": "stream", "text": [ "Data #\u001b[1;36m4\u001b[0m: NaCl.gr\n" ] }, { "name": "stdout", "output_type": "stream", "text": [ "โœ… Data #\u001b[1;36m4\u001b[0m downloaded to \u001b[32m'data/ed-4.gr'\u001b[0m\n" ] } ], "source": [ "data_path = ed.download_data(id=4, destination='data')" ] }, { "cell_type": "code", "execution_count": 9, "id": "14", "metadata": { "execution": { "iopub.execute_input": "2026-04-14T14:54:42.521775Z", "iopub.status.busy": "2026-04-14T14:54:42.521549Z", "iopub.status.idle": "2026-04-14T14:54:42.814307Z", "shell.execute_reply": "2026-04-14T14:54:42.813591Z" } }, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "โš ๏ธ No uncertainty (sy) column provided. Defaulting to 0.03. \n" ] }, { "name": "stdout", "output_type": "stream", "text": [ "\u001b[1;34mData loaded successfully\u001b[0m\n" ] }, { "name": "stdout", "output_type": "stream", "text": [ "Experiment ๐Ÿ”ฌ \u001b[32m'xray_pdf'\u001b[0m. Number of data points: \u001b[1;36m5000\u001b[0m.\n" ] } ], "source": [ "project.experiments.add_from_data_path(\n", " name='xray_pdf',\n", " data_path=data_path,\n", " sample_form='powder',\n", " beam_mode='constant wavelength',\n", " radiation_probe='xray',\n", " scattering_type='total',\n", ")" ] }, { "cell_type": "code", "execution_count": 10, "id": "15", "metadata": { "execution": { "iopub.execute_input": "2026-04-14T14:54:42.816300Z", "iopub.status.busy": "2026-04-14T14:54:42.816092Z", "iopub.status.idle": "2026-04-14T14:54:43.094554Z", "shell.execute_reply": "2026-04-14T14:54:43.093641Z" } }, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "\u001b[1;34mSupported types\u001b[0m\n" ] }, { "data": { "application/javascript": [ "\n", " (function() {\n", " var isDark = false;\n", "\n", " // Check JupyterLab theme\n", " if (document.body.classList.contains('jp-mod-dark') || \n", " document.body.classList.contains('theme-dark') ||\n", " document.body.classList.contains('vscode-dark')) {\n", " isDark = true;\n", " }\n", "\n", " // Check theme attribute\n", " var themeAttr = document.body.getAttribute('data-jp-theme-name');\n", " if (themeAttr && themeAttr.includes('dark')) {\n", " isDark = true;\n", " }\n", "\n", " // Check computed background color\n", " var notebookEl = document.querySelector('.jp-Notebook') || \n", " document.querySelector('.notebook_app') ||\n", " document.body;\n", " if (notebookEl) {\n", " var bgColor = window.getComputedStyle(notebookEl).backgroundColor;\n", " var rgb = bgColor.match(/\\d+/g);\n", " if (rgb && rgb.length >= 3) {\n", " var brightness = (parseInt(rgb[0]) + parseInt(rgb[1]) + parseInt(rgb[2])) / 3;\n", " if (brightness < 128) {\n", " isDark = true;\n", " }\n", " }\n", " }\n", "\n", " // Store result\n", " if (typeof IPython !== 'undefined' && IPython.notebook && IPython.notebook.kernel) {\n", " IPython.notebook.kernel.execute('_jupyter_dark_detect_result = ' + isDark);\n", " }\n", " })();\n", " " ], "text/plain": [ "" ] }, "metadata": {}, "output_type": "display_data" }, { "data": { "application/javascript": [ "\n", " if (typeof IPython !== 'undefined' && IPython.notebook) {\n", " IPython.notebook.kernel.execute(\"_jupyter_dark_detect_result = \" + \n", " (document.body.classList.contains('theme-dark') || \n", " document.body.classList.contains('jp-mod-dark') ||\n", " (document.body.getAttribute('data-jp-theme-name') && \n", " document.body.getAttribute('data-jp-theme-name').includes('dark'))));\n", " }\n", " " ], "text/plain": [ "" ] }, "metadata": {}, "output_type": "display_data" }, { "data": { "text/html": [ "\n", "\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", "
 TypeDescription
1gaussian-damped-sincGaussian-damped sinc for pair distribution function analysis
\n" ], "text/plain": [ "" ] }, "metadata": {}, "output_type": "display_data" } ], "source": [ "project.experiments['xray_pdf'].show_supported_peak_profile_types()" ] }, { "cell_type": "code", "execution_count": 11, "id": "16", "metadata": { "execution": { "iopub.execute_input": "2026-04-14T14:54:43.096715Z", "iopub.status.busy": "2026-04-14T14:54:43.096529Z", "iopub.status.idle": "2026-04-14T14:54:43.103319Z", "shell.execute_reply": "2026-04-14T14:54:43.102356Z" } }, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "\u001b[1;34mCurrent peak profile type\u001b[0m\n" ] }, { "name": "stdout", "output_type": "stream", "text": [ "gaussian-damped-sinc\n" ] } ], "source": [ "project.experiments['xray_pdf'].show_current_peak_profile_type()" ] }, { "cell_type": "code", "execution_count": 12, "id": "17", "metadata": { "execution": { "iopub.execute_input": "2026-04-14T14:54:43.104928Z", "iopub.status.busy": "2026-04-14T14:54:43.104757Z", "iopub.status.idle": "2026-04-14T14:54:43.112213Z", "shell.execute_reply": "2026-04-14T14:54:43.111335Z" } }, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "โš ๏ธ Switching peak profile type discards existing peak parameters. \n" ] }, { "name": "stdout", "output_type": "stream", "text": [ "\u001b[1;34mPeak profile type for experiment \u001b[0m\u001b[32m'xray_pdf'\u001b[0m\u001b[1;34m changed to\u001b[0m\n" ] }, { "name": "stdout", "output_type": "stream", "text": [ "gaussian-damped-sinc\n" ] } ], "source": [ "project.experiments['xray_pdf'].peak_profile_type = 'gaussian-damped-sinc'" ] }, { "cell_type": "code", "execution_count": 13, "id": "18", "metadata": { "execution": { "iopub.execute_input": "2026-04-14T14:54:43.114044Z", "iopub.status.busy": "2026-04-14T14:54:43.113863Z", "iopub.status.idle": "2026-04-14T14:54:43.118050Z", "shell.execute_reply": "2026-04-14T14:54:43.117104Z" } }, "outputs": [], "source": [ "project.experiments['xray_pdf'].peak.damp_q = 0.03\n", "project.experiments['xray_pdf'].peak.broad_q = 0\n", "project.experiments['xray_pdf'].peak.cutoff_q = 21\n", "project.experiments['xray_pdf'].peak.sharp_delta_1 = 0\n", "project.experiments['xray_pdf'].peak.sharp_delta_2 = 5\n", "project.experiments['xray_pdf'].peak.damp_particle_diameter = 0" ] }, { "cell_type": "code", "execution_count": 14, "id": "19", "metadata": { "execution": { "iopub.execute_input": "2026-04-14T14:54:43.119731Z", "iopub.status.busy": "2026-04-14T14:54:43.119547Z", "iopub.status.idle": "2026-04-14T14:54:43.123439Z", "shell.execute_reply": "2026-04-14T14:54:43.122175Z" } }, "outputs": [], "source": [ "project.experiments['xray_pdf'].linked_phases.create(id='nacl', scale=0.5)" ] }, { "cell_type": "markdown", "id": "20", "metadata": {}, "source": [ "## Select Fitting Parameters" ] }, { "cell_type": "code", "execution_count": 15, "id": "21", "metadata": { "execution": { "iopub.execute_input": "2026-04-14T14:54:43.125368Z", "iopub.status.busy": "2026-04-14T14:54:43.125199Z", "iopub.status.idle": "2026-04-14T14:54:43.128788Z", "shell.execute_reply": "2026-04-14T14:54:43.127844Z" } }, "outputs": [], "source": [ "project.structures['nacl'].cell.length_a.free = True\n", "project.structures['nacl'].atom_sites['Na'].adp_iso.free = True\n", "project.structures['nacl'].atom_sites['Cl'].adp_iso.free = True" ] }, { "cell_type": "code", "execution_count": 16, "id": "22", "metadata": { "execution": { "iopub.execute_input": "2026-04-14T14:54:43.130432Z", "iopub.status.busy": "2026-04-14T14:54:43.130250Z", "iopub.status.idle": "2026-04-14T14:54:43.133470Z", "shell.execute_reply": "2026-04-14T14:54:43.132620Z" } }, "outputs": [], "source": [ "project.experiments['xray_pdf'].linked_phases['nacl'].scale.free = True\n", "project.experiments['xray_pdf'].peak.damp_q.free = True\n", "project.experiments['xray_pdf'].peak.sharp_delta_2.free = True" ] }, { "cell_type": "markdown", "id": "23", "metadata": {}, "source": [ "## Run Fitting" ] }, { "cell_type": "code", "execution_count": 17, "id": "24", "metadata": { "execution": { "iopub.execute_input": "2026-04-14T14:54:43.135069Z", "iopub.status.busy": "2026-04-14T14:54:43.134903Z", "iopub.status.idle": "2026-04-14T14:54:56.234995Z", "shell.execute_reply": "2026-04-14T14:54:56.234215Z" } }, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "\u001b[1;34mStandard fitting\u001b[0m\n" ] }, { "name": "stdout", "output_type": "stream", "text": [ "๐Ÿ“‹ Using experiment ๐Ÿ”ฌ \u001b[32m'xray_pdf'\u001b[0m for \u001b[32m'single'\u001b[0m fitting\n" ] }, { "name": "stdout", "output_type": "stream", "text": [ "๐Ÿš€ Starting fit process with \u001b[32m'lmfit \u001b[0m\u001b[32m(\u001b[0m\u001b[32mleastsq\u001b[0m\u001b[32m)\u001b[0m\u001b[32m'\u001b[0m\u001b[33m...\u001b[0m\n" ] }, { "name": "stdout", "output_type": "stream", "text": [ "๐Ÿ“ˆ Goodness-of-fit \u001b[1m(\u001b[0mreduced ฯ‡ยฒ\u001b[1m)\u001b[0m change:\n" ] }, { "data": { "text/html": [ "\n", "\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", "
 iterationฯ‡ยฒimprovement [%]
11163.09
21017.0689.5% โ†“
3172.2786.7% โ†“
4241.4834.6% โ†“
5531.48
\n" ], "text/plain": [ "" ] }, "metadata": {}, "output_type": "display_data" }, { "data": { "application/javascript": [ "\n", " (function() {\n", " var isDark = false;\n", "\n", " // Check JupyterLab theme\n", " if (document.body.classList.contains('jp-mod-dark') || \n", " document.body.classList.contains('theme-dark') ||\n", " document.body.classList.contains('vscode-dark')) {\n", " isDark = true;\n", " }\n", "\n", " // Check theme attribute\n", " var themeAttr = document.body.getAttribute('data-jp-theme-name');\n", " if (themeAttr && themeAttr.includes('dark')) {\n", " isDark = true;\n", " }\n", "\n", " // Check computed background color\n", " var notebookEl = document.querySelector('.jp-Notebook') || \n", " document.querySelector('.notebook_app') ||\n", " document.body;\n", " if (notebookEl) {\n", " var bgColor = window.getComputedStyle(notebookEl).backgroundColor;\n", " var rgb = bgColor.match(/\\d+/g);\n", " if (rgb && rgb.length >= 3) {\n", " var brightness = (parseInt(rgb[0]) + parseInt(rgb[1]) + parseInt(rgb[2])) / 3;\n", " if (brightness < 128) {\n", " isDark = true;\n", " }\n", " }\n", " }\n", "\n", " // Store result\n", " if (typeof IPython !== 'undefined' && IPython.notebook && IPython.notebook.kernel) {\n", " IPython.notebook.kernel.execute('_jupyter_dark_detect_result = ' + isDark);\n", " }\n", " })();\n", " " ], "text/plain": [ "" ] }, "metadata": {}, "output_type": "display_data" }, { "data": { "application/javascript": [ "\n", " if (typeof IPython !== 'undefined' && IPython.notebook) {\n", " IPython.notebook.kernel.execute(\"_jupyter_dark_detect_result = \" + \n", " (document.body.classList.contains('theme-dark') || \n", " document.body.classList.contains('jp-mod-dark') ||\n", " (document.body.getAttribute('data-jp-theme-name') && \n", " document.body.getAttribute('data-jp-theme-name').includes('dark'))));\n", " }\n", " " ], "text/plain": [ "" ] }, "metadata": {}, "output_type": "display_data" }, { "data": { "application/javascript": [ "\n", " (function() {\n", " var isDark = false;\n", "\n", " // Check JupyterLab theme\n", " if (document.body.classList.contains('jp-mod-dark') || \n", " document.body.classList.contains('theme-dark') ||\n", " document.body.classList.contains('vscode-dark')) {\n", " isDark = true;\n", " }\n", "\n", " // Check theme attribute\n", " var themeAttr = document.body.getAttribute('data-jp-theme-name');\n", " if (themeAttr && themeAttr.includes('dark')) {\n", " isDark = true;\n", " }\n", "\n", " // Check computed background color\n", " var notebookEl = document.querySelector('.jp-Notebook') || \n", " document.querySelector('.notebook_app') ||\n", " document.body;\n", " if (notebookEl) {\n", " var bgColor = window.getComputedStyle(notebookEl).backgroundColor;\n", " var rgb = bgColor.match(/\\d+/g);\n", " if (rgb && rgb.length >= 3) {\n", " var brightness = (parseInt(rgb[0]) + parseInt(rgb[1]) + parseInt(rgb[2])) / 3;\n", " if (brightness < 128) {\n", " isDark = true;\n", " }\n", " }\n", " }\n", "\n", " // Store result\n", " if (typeof IPython !== 'undefined' && IPython.notebook && IPython.notebook.kernel) {\n", " IPython.notebook.kernel.execute('_jupyter_dark_detect_result = ' + isDark);\n", " }\n", " })();\n", " " ], "text/plain": [ "" ] }, "metadata": {}, "output_type": "display_data" }, { "data": { "application/javascript": [ "\n", " if (typeof IPython !== 'undefined' && IPython.notebook) {\n", " IPython.notebook.kernel.execute(\"_jupyter_dark_detect_result = \" + \n", " (document.body.classList.contains('theme-dark') || \n", " document.body.classList.contains('jp-mod-dark') ||\n", " (document.body.getAttribute('data-jp-theme-name') && \n", " document.body.getAttribute('data-jp-theme-name').includes('dark'))));\n", " }\n", " " ], "text/plain": [ "" ] }, "metadata": {}, "output_type": "display_data" }, { "data": { "application/javascript": [ "\n", " (function() {\n", " var isDark = false;\n", "\n", " // Check JupyterLab theme\n", " if (document.body.classList.contains('jp-mod-dark') || \n", " document.body.classList.contains('theme-dark') ||\n", " document.body.classList.contains('vscode-dark')) {\n", " isDark = true;\n", " }\n", "\n", " // Check theme attribute\n", " var themeAttr = document.body.getAttribute('data-jp-theme-name');\n", " if (themeAttr && themeAttr.includes('dark')) {\n", " isDark = true;\n", " }\n", "\n", " // Check computed background color\n", " var notebookEl = document.querySelector('.jp-Notebook') || \n", " document.querySelector('.notebook_app') ||\n", " document.body;\n", " if (notebookEl) {\n", " var bgColor = window.getComputedStyle(notebookEl).backgroundColor;\n", " var rgb = bgColor.match(/\\d+/g);\n", " if (rgb && rgb.length >= 3) {\n", " var brightness = (parseInt(rgb[0]) + parseInt(rgb[1]) + parseInt(rgb[2])) / 3;\n", " if (brightness < 128) {\n", " isDark = true;\n", " }\n", " }\n", " }\n", "\n", " // Store result\n", " if (typeof IPython !== 'undefined' && IPython.notebook && IPython.notebook.kernel) {\n", " IPython.notebook.kernel.execute('_jupyter_dark_detect_result = ' + isDark);\n", " }\n", " })();\n", " " ], "text/plain": [ "" ] }, "metadata": {}, "output_type": "display_data" }, { "data": { "application/javascript": [ "\n", " if (typeof IPython !== 'undefined' && IPython.notebook) {\n", " IPython.notebook.kernel.execute(\"_jupyter_dark_detect_result = \" + \n", " (document.body.classList.contains('theme-dark') || \n", " document.body.classList.contains('jp-mod-dark') ||\n", " (document.body.getAttribute('data-jp-theme-name') && \n", " document.body.getAttribute('data-jp-theme-name').includes('dark'))));\n", " }\n", " " ], "text/plain": [ "" ] }, "metadata": {}, "output_type": "display_data" }, { "data": { "application/javascript": [ "\n", " (function() {\n", " var isDark = false;\n", "\n", " // Check JupyterLab theme\n", " if (document.body.classList.contains('jp-mod-dark') || \n", " document.body.classList.contains('theme-dark') ||\n", " document.body.classList.contains('vscode-dark')) {\n", " isDark = true;\n", " }\n", "\n", " // Check theme attribute\n", " var themeAttr = document.body.getAttribute('data-jp-theme-name');\n", " if (themeAttr && themeAttr.includes('dark')) {\n", " isDark = true;\n", " }\n", "\n", " // Check computed background color\n", " var notebookEl = document.querySelector('.jp-Notebook') || \n", " document.querySelector('.notebook_app') ||\n", " document.body;\n", " if (notebookEl) {\n", " var bgColor = window.getComputedStyle(notebookEl).backgroundColor;\n", " var rgb = bgColor.match(/\\d+/g);\n", " if (rgb && rgb.length >= 3) {\n", " var brightness = (parseInt(rgb[0]) + parseInt(rgb[1]) + parseInt(rgb[2])) / 3;\n", " if (brightness < 128) {\n", " isDark = true;\n", " }\n", " }\n", " }\n", "\n", " // Store result\n", " if (typeof IPython !== 'undefined' && IPython.notebook && IPython.notebook.kernel) {\n", " IPython.notebook.kernel.execute('_jupyter_dark_detect_result = ' + isDark);\n", " }\n", " })();\n", " " ], "text/plain": [ "" ] }, "metadata": {}, "output_type": "display_data" }, { "data": { "application/javascript": [ "\n", " if (typeof IPython !== 'undefined' && IPython.notebook) {\n", " IPython.notebook.kernel.execute(\"_jupyter_dark_detect_result = \" + \n", " (document.body.classList.contains('theme-dark') || \n", " document.body.classList.contains('jp-mod-dark') ||\n", " (document.body.getAttribute('data-jp-theme-name') && \n", " document.body.getAttribute('data-jp-theme-name').includes('dark'))));\n", " }\n", " " ], "text/plain": [ "" ] }, "metadata": {}, "output_type": "display_data" }, { "data": { "application/javascript": [ "\n", " (function() {\n", " var isDark = false;\n", "\n", " // Check JupyterLab theme\n", " if (document.body.classList.contains('jp-mod-dark') || \n", " document.body.classList.contains('theme-dark') ||\n", " document.body.classList.contains('vscode-dark')) {\n", " isDark = true;\n", " }\n", "\n", " // Check theme attribute\n", " var themeAttr = document.body.getAttribute('data-jp-theme-name');\n", " if (themeAttr && themeAttr.includes('dark')) {\n", " isDark = true;\n", " }\n", "\n", " // Check computed background color\n", " var notebookEl = document.querySelector('.jp-Notebook') || \n", " document.querySelector('.notebook_app') ||\n", " document.body;\n", " if (notebookEl) {\n", " var bgColor = window.getComputedStyle(notebookEl).backgroundColor;\n", " var rgb = bgColor.match(/\\d+/g);\n", " if (rgb && rgb.length >= 3) {\n", " var brightness = (parseInt(rgb[0]) + parseInt(rgb[1]) + parseInt(rgb[2])) / 3;\n", " if (brightness < 128) {\n", " isDark = true;\n", " }\n", " }\n", " }\n", "\n", " // Store result\n", " if (typeof IPython !== 'undefined' && IPython.notebook && IPython.notebook.kernel) {\n", " IPython.notebook.kernel.execute('_jupyter_dark_detect_result = ' + isDark);\n", " }\n", " })();\n", " " ], "text/plain": [ "" ] }, "metadata": {}, "output_type": "display_data" }, { "data": { "application/javascript": [ "\n", " if (typeof IPython !== 'undefined' && IPython.notebook) {\n", " IPython.notebook.kernel.execute(\"_jupyter_dark_detect_result = \" + \n", " (document.body.classList.contains('theme-dark') || \n", " document.body.classList.contains('jp-mod-dark') ||\n", " (document.body.getAttribute('data-jp-theme-name') && \n", " document.body.getAttribute('data-jp-theme-name').includes('dark'))));\n", " }\n", " " ], "text/plain": [ "" ] }, "metadata": {}, "output_type": "display_data" }, { "data": { "application/javascript": [ "\n", " (function() {\n", " var isDark = false;\n", "\n", " // Check JupyterLab theme\n", " if (document.body.classList.contains('jp-mod-dark') || \n", " document.body.classList.contains('theme-dark') ||\n", " document.body.classList.contains('vscode-dark')) {\n", " isDark = true;\n", " }\n", "\n", " // Check theme attribute\n", " var themeAttr = document.body.getAttribute('data-jp-theme-name');\n", " if (themeAttr && themeAttr.includes('dark')) {\n", " isDark = true;\n", " }\n", "\n", " // Check computed background color\n", " var notebookEl = document.querySelector('.jp-Notebook') || \n", " document.querySelector('.notebook_app') ||\n", " document.body;\n", " if (notebookEl) {\n", " var bgColor = window.getComputedStyle(notebookEl).backgroundColor;\n", " var rgb = bgColor.match(/\\d+/g);\n", " if (rgb && rgb.length >= 3) {\n", " var brightness = (parseInt(rgb[0]) + parseInt(rgb[1]) + parseInt(rgb[2])) / 3;\n", " if (brightness < 128) {\n", " isDark = true;\n", " }\n", " }\n", " }\n", "\n", " // Store result\n", " if (typeof IPython !== 'undefined' && IPython.notebook && IPython.notebook.kernel) {\n", " IPython.notebook.kernel.execute('_jupyter_dark_detect_result = ' + isDark);\n", " }\n", " })();\n", " " ], "text/plain": [ "" ] }, "metadata": {}, "output_type": "display_data" }, { "data": { "application/javascript": [ "\n", " if (typeof IPython !== 'undefined' && IPython.notebook) {\n", " IPython.notebook.kernel.execute(\"_jupyter_dark_detect_result = \" + \n", " (document.body.classList.contains('theme-dark') || \n", " document.body.classList.contains('jp-mod-dark') ||\n", " (document.body.getAttribute('data-jp-theme-name') && \n", " document.body.getAttribute('data-jp-theme-name').includes('dark'))));\n", " }\n", " " ], "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;36m1.48\u001b[0m at iteration \u001b[1;36m52\u001b[0m\n" ] }, { "name": "stdout", "output_type": "stream", "text": [ "โœ… Fitting complete.\n" ] }, { "name": "stdout", "output_type": "stream", "text": [ "\u001b[1;34mFit results\u001b[0m\n" ] }, { "name": "stdout", "output_type": "stream", "text": [ "โœ… Success: \u001b[3;92mTrue\u001b[0m\n" ] }, { "name": "stdout", "output_type": "stream", "text": [ "โฑ๏ธ Fitting time: \u001b[1;36m12.19\u001b[0m seconds\n" ] }, { "name": "stdout", "output_type": "stream", "text": [ "๐Ÿ“ Goodness-of-fit \u001b[1m(\u001b[0mreduced ฯ‡ยฒ\u001b[1m)\u001b[0m: \u001b[1;36m1.48\u001b[0m\n" ] }, { "name": "stdout", "output_type": "stream", "text": [ "๐Ÿ“ R-factor \u001b[1m(\u001b[0mRf\u001b[1m)\u001b[0m: \u001b[1;36m11.02\u001b[0m%\n" ] }, { "name": "stdout", "output_type": "stream", "text": [ "๐Ÿ“ R-factor squared \u001b[1m(\u001b[0mRfยฒ\u001b[1m)\u001b[0m: \u001b[1;36m11.38\u001b[0m%\n" ] }, { "name": "stdout", "output_type": "stream", "text": [ "๐Ÿ“ Weighted R-factor \u001b[1m(\u001b[0mwR\u001b[1m)\u001b[0m: \u001b[1;36m11.38\u001b[0m%\n" ] }, { "name": "stdout", "output_type": "stream", "text": [ "๐Ÿ“ˆ Fitted parameters:\n" ] }, { "data": { "application/javascript": [ "\n", " (function() {\n", " var isDark = false;\n", "\n", " // Check JupyterLab theme\n", " if (document.body.classList.contains('jp-mod-dark') || \n", " document.body.classList.contains('theme-dark') ||\n", " document.body.classList.contains('vscode-dark')) {\n", " isDark = true;\n", " }\n", "\n", " // Check theme attribute\n", " var themeAttr = document.body.getAttribute('data-jp-theme-name');\n", " if (themeAttr && themeAttr.includes('dark')) {\n", " isDark = true;\n", " }\n", "\n", " // Check computed background color\n", " var notebookEl = document.querySelector('.jp-Notebook') || \n", " document.querySelector('.notebook_app') ||\n", " document.body;\n", " if (notebookEl) {\n", " var bgColor = window.getComputedStyle(notebookEl).backgroundColor;\n", " var rgb = bgColor.match(/\\d+/g);\n", " if (rgb && rgb.length >= 3) {\n", " var brightness = (parseInt(rgb[0]) + parseInt(rgb[1]) + parseInt(rgb[2])) / 3;\n", " if (brightness < 128) {\n", " isDark = true;\n", " }\n", " }\n", " }\n", "\n", " // Store result\n", " if (typeof IPython !== 'undefined' && IPython.notebook && IPython.notebook.kernel) {\n", " IPython.notebook.kernel.execute('_jupyter_dark_detect_result = ' + isDark);\n", " }\n", " })();\n", " " ], "text/plain": [ "" ] }, "metadata": {}, "output_type": "display_data" }, { "data": { "application/javascript": [ "\n", " if (typeof IPython !== 'undefined' && IPython.notebook) {\n", " IPython.notebook.kernel.execute(\"_jupyter_dark_detect_result = \" + \n", " (document.body.classList.contains('theme-dark') || \n", " document.body.classList.contains('jp-mod-dark') ||\n", " (document.body.getAttribute('data-jp-theme-name') && \n", " document.body.getAttribute('data-jp-theme-name').includes('dark'))));\n", " }\n", " " ], "text/plain": [ "" ] }, "metadata": {}, "output_type": "display_data" }, { "data": { "text/html": [ "\n", "\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", "
 datablockcategoryentryparameterstartfitteduncertaintyunitschange
1naclcelllength_a5.62005.60180.0001ร…0.32 % โ†“
2naclatom_siteNaadp_iso1.00001.10530.0077ร…ยฒ10.53 % โ†‘
3naclatom_siteCladp_iso1.00000.57070.0028ร…ยฒ42.93 % โ†“
4xray_pdflinked_phasesnaclscale0.50000.42540.000614.93 % โ†“
5xray_pdfpeakdamp_q0.03000.06060.0001ร…โปยน102.13 % โ†‘
6xray_pdfpeaksharp_delta_25.00003.50410.0667ร…ยฒ29.92 % โ†“
\n" ], "text/plain": [ "" ] }, "metadata": {}, "output_type": "display_data" }, { "name": "stdout", "output_type": "stream", "text": [ "โš ๏ธ No parameter pairs with |correlation| >= 0.70 were found. \n" ] } ], "source": [ "project.analysis.fit()\n", "project.analysis.display.fit_results()\n", "project.plotter.plot_param_correlations()" ] }, { "cell_type": "markdown", "id": "25", "metadata": {}, "source": [ "## Plot Measured vs Calculated" ] }, { "cell_type": "code", "execution_count": 18, "id": "26", "metadata": { "execution": { "iopub.execute_input": "2026-04-14T14:54:56.236913Z", "iopub.status.busy": "2026-04-14T14:54:56.236744Z", "iopub.status.idle": "2026-04-14T14:54:56.296276Z", "shell.execute_reply": "2026-04-14T14:54:56.295404Z" } }, "outputs": [ { "data": { "text/html": [ "
\n", "
" ], "text/plain": [ "" ] }, "metadata": {}, "output_type": "display_data" } ], "source": [ "project.plotter.plot_meas_vs_calc(expt_name='xray_pdf')" ] } ], "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.4" } }, "nbformat": 4, "nbformat_minor": 5 }