{ "cells": [ { "cell_type": "code", "execution_count": 1, "id": "0", "metadata": { "execution": { "iopub.execute_input": "2026-09-22T21:04:18.540563Z", "iopub.status.busy": "2026-09-22T21:04:18.540394Z", "iopub.status.idle": "2026-09-22T21:04:18.545437Z", "shell.execute_reply": "2026-09-22T21:04:18.544364Z" }, "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.21.1" ] }, { "cell_type": "markdown", "id": "1", "metadata": {}, "source": [ "# Structure Refinement: YAlO3+Al2O3, SPODI\n", "\n", "This example demonstrates a staged two-phase Rietveld refinement of\n", "yttrium aluminium perovskite YAlO3 (or YAP) with a small Al2O3\n", "impurity using constant wavelength neutron powder diffraction data\n", "measured at 3 K on SPODI at MLZ.\n", "\n", "The workflow defines both structures, configures the experiment, and\n", "refines the cell, scale, profile, background, and atom parameters of\n", "both phases in stages." ] }, { "cell_type": "markdown", "id": "2", "metadata": {}, "source": [ "## πŸ› οΈ Import Library" ] }, { "cell_type": "code", "execution_count": 2, "id": "3", "metadata": { "execution": { "iopub.execute_input": "2026-09-22T21:04:18.546933Z", "iopub.status.busy": "2026-09-22T21:04:18.546760Z", "iopub.status.idle": "2026-09-22T21:04:21.437703Z", "shell.execute_reply": "2026-09-22T21:04:21.436331Z" } }, "outputs": [], "source": [ "import easydiffraction as edi" ] }, { "cell_type": "markdown", "id": "4", "metadata": {}, "source": [ "## πŸ“¦ Define Project\n", "\n", "### Create Project" ] }, { "cell_type": "code", "execution_count": 3, "id": "5", "metadata": { "execution": { "iopub.execute_input": "2026-09-22T21:04:21.439655Z", "iopub.status.busy": "2026-09-22T21:04:21.439330Z", "iopub.status.idle": "2026-09-22T21:04:21.644409Z", "shell.execute_reply": "2026-09-22T21:04:21.643377Z" } }, "outputs": [], "source": [ "project = edi.Project(\n", " name='yap_3k',\n", " description='Two-phase YAlO3 and Al2O3 refinement using 3 K data from SPODI at MLZ.',\n", ")" ] }, { "cell_type": "markdown", "id": "6", "metadata": {}, "source": [ "### Save Initial Project" ] }, { "cell_type": "code", "execution_count": 4, "id": "7", "metadata": { "execution": { "iopub.execute_input": "2026-09-22T21:04:21.646295Z", "iopub.status.busy": "2026-09-22T21:04:21.646066Z", "iopub.status.idle": "2026-09-22T21:04:21.703505Z", "shell.execute_reply": "2026-09-22T21:04:21.702758Z" } }, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "\u001b[1;36mSaving project πŸ“¦ \u001b[0m\u001b[32m'yap_3k'\u001b[0m\u001b[1;36m to \u001b[0m\u001b[32m'../../../projects/refine-yap-3k'\u001b[0m\n" ] }, { "name": "stdout", "output_type": "stream", "text": [ "β”œβ”€β”€ πŸ“„ project.edi\n", "β”œβ”€β”€ πŸ“ structures/\n", "β”œβ”€β”€ πŸ“ experiments/\n", "β”œβ”€β”€ πŸ“ analysis/\n", "β”‚ └── πŸ“„ analysis.edi\n", "└── πŸ“ reports/\n", " └── πŸ“„ yap_3k.html\n" ] } ], "source": [ "project.save_as(dir_path='projects/refine-yap-3k')" ] }, { "cell_type": "markdown", "id": "8", "metadata": {}, "source": [ "## 🧩 Define Structures\n", "\n", "### Create Structure 1: YAlO3\n", "\n", "Preserve the orthorhombic Pbnm setting used in FullProf. In\n", "EasyDiffraction this is represented by the standard space-group\n", "symbol `P n m a` with coordinate-system code `cab`. The cell axes and\n", "atom coordinates below therefore stay in the original Pbnm setting.\n", "\n", "FullProf's PCR occupancies include the site multiplicity divided by\n", "the general-position multiplicity. Here each atom site is fully\n", "occupied: the PCR values 0.5 for Y, Al, and O1, and 1.0 for O2, all\n", "become an occupancy of 1.0. Displacement parameters are entered as\n", "Biso, matching the PCR file." ] }, { "cell_type": "code", "execution_count": 5, "id": "9", "metadata": { "execution": { "iopub.execute_input": "2026-09-22T21:04:21.705681Z", "iopub.status.busy": "2026-09-22T21:04:21.705482Z", "iopub.status.idle": "2026-09-22T21:04:21.708687Z", "shell.execute_reply": "2026-09-22T21:04:21.707775Z" } }, "outputs": [], "source": [ "yap_cif = \"\"\"\n", "data_yap\n", "\n", "_cell.length_a 5.18\n", "_cell.length_b 5.33\n", "_cell.length_c 7.37\n", "_cell.angle_alpha 90.\n", "_cell.angle_beta 90.\n", "_cell.angle_gamma 90.\n", "\n", "_space_group.name_h_m \"P n m a\"\n", "_space_group.coord_system_code cab\n", "\n", "loop_\n", "_atom_site.id\n", "_atom_site.type_symbol\n", "_atom_site.fract_x\n", "_atom_site.fract_y\n", "_atom_site.fract_z\n", "_atom_site.occupancy\n", "_atom_site.adp_iso\n", "_atom_site.adp_type\n", "Y Y 0.0100 0.5500 0.2500 1.0 0.12 Biso\n", "Al Al 0.0000 0.0000 0.0000 1.0 0.13 Biso\n", "O1 O -0.0800 -0.0200 0.2500 1.0 0.06 Biso\n", "O2 O 0.2000 0.2900 0.0400 1.0 0.14 Biso\n", "\"\"\"" ] }, { "cell_type": "code", "execution_count": 6, "id": "10", "metadata": { "execution": { "iopub.execute_input": "2026-09-22T21:04:21.710141Z", "iopub.status.busy": "2026-09-22T21:04:21.709974Z", "iopub.status.idle": "2026-09-22T21:04:21.726654Z", "shell.execute_reply": "2026-09-22T21:04:21.725787Z" } }, "outputs": [], "source": [ "project.structures.add_from_cif_str(yap_cif)" ] }, { "cell_type": "code", "execution_count": 7, "id": "11", "metadata": { "execution": { "iopub.execute_input": "2026-09-22T21:04:21.728211Z", "iopub.status.busy": "2026-09-22T21:04:21.728020Z", "iopub.status.idle": "2026-09-22T21:04:21.730903Z", "shell.execute_reply": "2026-09-22T21:04:21.730085Z" } }, "outputs": [], "source": [ "yap = project.structures['yap']" ] }, { "cell_type": "markdown", "id": "12", "metadata": {}, "source": [ "### Display Structure 1: YAlO3" ] }, { "cell_type": "code", "execution_count": 8, "id": "13", "metadata": { "execution": { "iopub.execute_input": "2026-09-22T21:04:21.732781Z", "iopub.status.busy": "2026-09-22T21:04:21.732624Z", "iopub.status.idle": "2026-09-22T21:04:21.780394Z", "shell.execute_reply": "2026-09-22T21:04:21.779448Z" } }, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "\u001b[1;36mStructure 🧩 \u001b[0m\u001b[32m'yap'\u001b[0m\u001b[1;36m as text\u001b[0m\n" ] }, { "data": { "text/html": [ "
Edi
1data_yap
2
3_cell.length_a 5.18
4_cell.length_b 5.33
5_cell.length_c 7.37
6_cell.angle_alpha 90.
7_cell.angle_beta 90.
8_cell.angle_gamma 90.
9
10_space_group.name_h_m "P n m a"
11_space_group.coord_system_code cab
12
13_geom.min_bond_distance_cutoff 0.
14_geom.bond_distance_inc 0.25
15
16loop_
17_atom_site.id
18_atom_site.type_symbol
19_atom_site.fract_x
20_atom_site.fract_y
21_atom_site.fract_z
22_atom_site.wyckoff_letter
23_atom_site.multiplicity
24_atom_site.occupancy
25_atom_site.adp_iso
26_atom_site.adp_type
27Y Y 0.01 0.55 0.25 c 4 1. 0.12 Biso
28Al Al 0. 0. 0. a 4 1. 0.13 Biso
29O1 O -0.08 -0.02 0.25 c 4 1. 0.06 Biso
30O2 O 0.2 0.29 0.04 d 8 1. 0.14 Biso
" ], "text/plain": [ "" ] }, "metadata": {}, "output_type": "display_data" } ], "source": [ "yap.show_as_text()" ] }, { "cell_type": "code", "execution_count": 9, "id": "14", "metadata": { "execution": { "iopub.execute_input": "2026-09-22T21:04:21.781984Z", "iopub.status.busy": "2026-09-22T21:04:21.781784Z", "iopub.status.idle": "2026-09-22T21:04:21.800919Z", "shell.execute_reply": "2026-09-22T21:04:21.800208Z" } }, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "\u001b[1;36mStructure 🧩 \u001b[0m\u001b[32m'yap'\u001b[0m\u001b[1;36m \u001b[0m\u001b[1;36m(\u001b[0m\u001b[1;36mAtom view type: \u001b[0m\u001b[32m'covalent'\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.display.structure(struct_name='yap')" ] }, { "cell_type": "markdown", "id": "15", "metadata": {}, "source": [ "### Create Structure 2: Al2O3\n", "\n", "Define the corundum impurity in the hexagonal setting of R-3c. The\n", "FullProf PCR occupancies of 2/3 for Al and 1 for O also describe fully\n", "occupied sites. Refine its two independent cell lengths, Al z and O x\n", "coordinates, and both Biso values, as specified by the PCR codewords.\n", "The PCR contains a negative Al Biso. EasyDiffraction requires a\n", "nonnegative input value, so start this parameter at 0.1 Γ…Β² and refine\n", "it alongside O Biso." ] }, { "cell_type": "code", "execution_count": 10, "id": "16", "metadata": { "execution": { "iopub.execute_input": "2026-09-22T21:04:21.802499Z", "iopub.status.busy": "2026-09-22T21:04:21.802317Z", "iopub.status.idle": "2026-09-22T21:04:21.805520Z", "shell.execute_reply": "2026-09-22T21:04:21.804766Z" } }, "outputs": [], "source": [ "alumina = edi.StructureFactory.from_scratch(name='alumina')" ] }, { "cell_type": "markdown", "id": "17", "metadata": {}, "source": [ "#### Set Space Group" ] }, { "cell_type": "code", "execution_count": 11, "id": "18", "metadata": { "execution": { "iopub.execute_input": "2026-09-22T21:04:21.807392Z", "iopub.status.busy": "2026-09-22T21:04:21.807188Z", "iopub.status.idle": "2026-09-22T21:04:21.810352Z", "shell.execute_reply": "2026-09-22T21:04:21.809523Z" } }, "outputs": [], "source": [ "alumina.space_group.name_h_m = 'R -3 c'\n", "alumina.space_group.coord_system_code = 'h'" ] }, { "cell_type": "markdown", "id": "19", "metadata": {}, "source": [ "#### Set Unit Cell" ] }, { "cell_type": "code", "execution_count": 12, "id": "20", "metadata": { "execution": { "iopub.execute_input": "2026-09-22T21:04:21.811965Z", "iopub.status.busy": "2026-09-22T21:04:21.811771Z", "iopub.status.idle": "2026-09-22T21:04:21.814934Z", "shell.execute_reply": "2026-09-22T21:04:21.814277Z" } }, "outputs": [], "source": [ "alumina.cell.length_a = 4.75\n", "alumina.cell.length_c = 12.95" ] }, { "cell_type": "markdown", "id": "21", "metadata": {}, "source": [ "#### Set Atom Sites" ] }, { "cell_type": "code", "execution_count": 13, "id": "22", "metadata": { "execution": { "iopub.execute_input": "2026-09-22T21:04:21.816681Z", "iopub.status.busy": "2026-09-22T21:04:21.816510Z", "iopub.status.idle": "2026-09-22T21:04:21.860382Z", "shell.execute_reply": "2026-09-22T21:04:21.857275Z" } }, "outputs": [], "source": [ "alumina.atom_sites.create(\n", " id='Al1',\n", " type_symbol='Al',\n", " fract_x=0.0,\n", " fract_y=0.0,\n", " fract_z=0.33351,\n", " occupancy=1.0,\n", " adp_type='Biso',\n", " adp_iso=0.1,\n", ")\n", "alumina.atom_sites.create(\n", " id='O1',\n", " type_symbol='O',\n", " fract_x=0.3503,\n", " fract_y=0.0,\n", " fract_z=0.25,\n", " occupancy=1.0,\n", " adp_type='Biso',\n", " adp_iso=1.22884,\n", ")" ] }, { "cell_type": "code", "execution_count": 14, "id": "23", "metadata": { "execution": { "iopub.execute_input": "2026-09-22T21:04:21.863998Z", "iopub.status.busy": "2026-09-22T21:04:21.863751Z", "iopub.status.idle": "2026-09-22T21:04:21.866575Z", "shell.execute_reply": "2026-09-22T21:04:21.866136Z" } }, "outputs": [], "source": [ "project.structures.add(alumina)" ] }, { "cell_type": "markdown", "id": "24", "metadata": {}, "source": [ "### Display Structure 2: Al2O3" ] }, { "cell_type": "code", "execution_count": 15, "id": "25", "metadata": { "execution": { "iopub.execute_input": "2026-09-22T21:04:21.872332Z", "iopub.status.busy": "2026-09-22T21:04:21.869844Z", "iopub.status.idle": "2026-09-22T21:04:22.012825Z", "shell.execute_reply": "2026-09-22T21:04:22.011915Z" } }, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "\u001b[1;36mStructure 🧩 \u001b[0m\u001b[32m'alumina'\u001b[0m\u001b[1;36m as text\u001b[0m\n" ] }, { "data": { "text/html": [ "
Edi
1data_alumina
2
3_cell.length_a 4.75
4_cell.length_b 4.75
5_cell.length_c 12.95
6_cell.angle_alpha 90.
7_cell.angle_beta 90.
8_cell.angle_gamma 120.
9
10_space_group.name_h_m "R -3 c"
11_space_group.coord_system_code h
12
13_geom.min_bond_distance_cutoff 0.
14_geom.bond_distance_inc 0.25
15
16loop_
17_atom_site.id
18_atom_site.type_symbol
19_atom_site.fract_x
20_atom_site.fract_y
21_atom_site.fract_z
22_atom_site.wyckoff_letter
23_atom_site.multiplicity
24_atom_site.occupancy
25_atom_site.adp_iso
26_atom_site.adp_type
27Al1 Al 0. 0. 0.33351 c 12 1. 0.1 Biso
28O1 O 0.3503 0. 0.25 e 18 1. 1.22884 Biso
" ], "text/plain": [ "" ] }, "metadata": {}, "output_type": "display_data" } ], "source": [ "alumina.show_as_text()" ] }, { "cell_type": "code", "execution_count": 16, "id": "26", "metadata": { "execution": { "iopub.execute_input": "2026-09-22T21:04:22.014368Z", "iopub.status.busy": "2026-09-22T21:04:22.014147Z", "iopub.status.idle": "2026-09-22T21:04:22.039416Z", "shell.execute_reply": "2026-09-22T21:04:22.038555Z" } }, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "\u001b[1;36mStructure 🧩 \u001b[0m\u001b[32m'alumina'\u001b[0m\u001b[1;36m \u001b[0m\u001b[1;36m(\u001b[0m\u001b[1;36mAtom view type: \u001b[0m\u001b[32m'covalent'\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.display.structure(struct_name='alumina')" ] }, { "cell_type": "markdown", "id": "27", "metadata": {}, "source": [ "## πŸ”¬ Define Experiment\n", "\n", "### Download Measured Data\n", "\n", "Download the YAlO3 + Al2O3 pattern from the EasyDiffraction online\n", "data repository. The three columns contain 2-theta in degrees,\n", "intensity, and its standard uncertainty. They are copied from the\n", "original SPODI dataset without changing the measured values." ] }, { "cell_type": "code", "execution_count": 17, "id": "28", "metadata": { "execution": { "iopub.execute_input": "2026-09-22T21:04:22.041189Z", "iopub.status.busy": "2026-09-22T21:04:22.040968Z", "iopub.status.idle": "2026-09-22T21:04:22.238616Z", "shell.execute_reply": "2026-09-22T21:04:22.237628Z" } }, "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-yap-spodi'\u001b[0m: YAlO3 + Al2O3, SPODI \u001b[1m(\u001b[0mMLZ\u001b[1m)\u001b[0m, \u001b[1;36m3\u001b[0m K\n" ] }, { "name": "stdout", "output_type": "stream", "text": [ "βœ… Data \u001b[32m'meas-yap-spodi'\u001b[0m downloaded to \u001b[32m'../../../data/meas-yap-spodi.xye'\u001b[0m\n" ] } ], "source": [ "data_path = edi.download_data('meas-yap-spodi', destination='data')" ] }, { "cell_type": "code", "execution_count": 18, "id": "29", "metadata": { "execution": { "iopub.execute_input": "2026-09-22T21:04:22.240940Z", "iopub.status.busy": "2026-09-22T21:04:22.240208Z", "iopub.status.idle": "2026-09-22T21:04:22.662842Z", "shell.execute_reply": "2026-09-22T21:04:22.661919Z" } }, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "\u001b[1;36mData loaded successfully\u001b[0m\n" ] }, { "name": "stdout", "output_type": "stream", "text": [ "Experiment πŸ”¬ \u001b[32m'yap_3k'\u001b[0m. Number of data points: \u001b[1;36m3000\u001b[0m.\n" ] } ], "source": [ "project.experiments.add_from_data_path(\n", " name='yap_3k',\n", " data_path=data_path,\n", " sample_form='powder',\n", " beam_mode='constant wavelength',\n", " radiation_probe='neutron',\n", ")" ] }, { "cell_type": "code", "execution_count": 19, "id": "30", "metadata": { "execution": { "iopub.execute_input": "2026-09-22T21:04:22.664426Z", "iopub.status.busy": "2026-09-22T21:04:22.664260Z", "iopub.status.idle": "2026-09-22T21:04:22.667318Z", "shell.execute_reply": "2026-09-22T21:04:22.666675Z" } }, "outputs": [], "source": [ "expt = project.experiments['yap_3k']" ] }, { "cell_type": "markdown", "id": "31", "metadata": {}, "source": [ "### Set Instrument\n", "\n", "Use the neutron wavelength reported for the SPODI dataset and start\n", "with zero 2-theta offset." ] }, { "cell_type": "code", "execution_count": 20, "id": "32", "metadata": { "execution": { "iopub.execute_input": "2026-09-22T21:04:22.668886Z", "iopub.status.busy": "2026-09-22T21:04:22.668717Z", "iopub.status.idle": "2026-09-22T21:04:22.671703Z", "shell.execute_reply": "2026-09-22T21:04:22.670883Z" } }, "outputs": [], "source": [ "expt.instrument.setup_wavelength = 1.54816\n", "expt.instrument.calib_twotheta_offset = 0.0" ] }, { "cell_type": "markdown", "id": "33", "metadata": {}, "source": [ "### Set Peak Profile\n", "\n", "Use a pseudo-Voigt profile with BΓ©rar-Baldinozzi asymmetry." ] }, { "cell_type": "code", "execution_count": 21, "id": "34", "metadata": { "execution": { "iopub.execute_input": "2026-09-22T21:04:22.673022Z", "iopub.status.busy": "2026-09-22T21:04:22.672861Z", "iopub.status.idle": "2026-09-22T21:04:22.679511Z", "shell.execute_reply": "2026-09-22T21:04:22.678817Z" } }, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "\u001b[1;36mPeak types\u001b[0m\n" ] }, { "data": { "text/html": [ "
TypeDescription
1*pseudo-voigtCWL pseudo-Voigt profile
2pseudo-voigt + berar-baldinozzi asymmetryCWL pseudo-Voigt profile with Berar-Baldinozzi asymmetry correction.
" ], "text/plain": [ "" ] }, "metadata": {}, "output_type": "display_data" } ], "source": [ "expt.peak.show_supported()" ] }, { "cell_type": "code", "execution_count": 22, "id": "35", "metadata": { "execution": { "iopub.execute_input": "2026-09-22T21:04:22.680971Z", "iopub.status.busy": "2026-09-22T21:04:22.680814Z", "iopub.status.idle": "2026-09-22T21:04:22.687004Z", "shell.execute_reply": "2026-09-22T21:04:22.686322Z" } }, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "⚠️ Switching peak profile type adds these settings with defaults:\n", "β€’ asym_beba_a0=0.0\n", "β€’ asym_beba_a1=0.0\n", "β€’ asym_beba_b0=0.0\n", "β€’ asym_beba_b1=0.0\n" ] }, { "name": "stdout", "output_type": "stream", "text": [ "\u001b[1;36mPeak profile type for experiment \u001b[0m\u001b[32m'yap_3k'\u001b[0m\u001b[1;36m changed to\u001b[0m\n" ] }, { "name": "stdout", "output_type": "stream", "text": [ "pseudo-voigt + berar-baldinozzi asymmetry\n" ] } ], "source": [ "expt.peak.type = 'pseudo-voigt + berar-baldinozzi asymmetry'" ] }, { "cell_type": "code", "execution_count": 23, "id": "36", "metadata": { "execution": { "iopub.execute_input": "2026-09-22T21:04:22.688419Z", "iopub.status.busy": "2026-09-22T21:04:22.688262Z", "iopub.status.idle": "2026-09-22T21:04:22.691552Z", "shell.execute_reply": "2026-09-22T21:04:22.690854Z" } }, "outputs": [], "source": [ "expt.peak.broad_gauss_u = 0.04\n", "expt.peak.broad_gauss_v = -0.05\n", "expt.peak.broad_gauss_w = 0.10\n", "expt.peak.broad_lorentz_x = 0.0\n", "expt.peak.broad_lorentz_y = 0.01" ] }, { "cell_type": "code", "execution_count": 24, "id": "37", "metadata": { "execution": { "iopub.execute_input": "2026-09-22T21:04:22.692971Z", "iopub.status.busy": "2026-09-22T21:04:22.692802Z", "iopub.status.idle": "2026-09-22T21:04:22.695669Z", "shell.execute_reply": "2026-09-22T21:04:22.694958Z" } }, "outputs": [], "source": [ "expt.peak.asym_beba_a0 = 0.0\n", "expt.peak.asym_beba_b0 = 0.0\n", "expt.peak.asym_beba_a1 = 0.0\n", "expt.peak.asym_beba_b1 = 0.0" ] }, { "cell_type": "code", "execution_count": 25, "id": "38", "metadata": { "execution": { "iopub.execute_input": "2026-09-22T21:04:22.697233Z", "iopub.status.busy": "2026-09-22T21:04:22.697048Z", "iopub.status.idle": "2026-09-22T21:04:22.699737Z", "shell.execute_reply": "2026-09-22T21:04:22.699061Z" } }, "outputs": [], "source": [ "expt.peak.cutoff_fwhm = 8.0" ] }, { "cell_type": "markdown", "id": "39", "metadata": {}, "source": [ "### Set Absorption\n", "\n", "Apply the cylindrical-sample Hewat correction with the absorption\n", "radius product from FullProf." ] }, { "cell_type": "code", "execution_count": 26, "id": "40", "metadata": { "execution": { "iopub.execute_input": "2026-09-22T21:04:22.701304Z", "iopub.status.busy": "2026-09-22T21:04:22.701134Z", "iopub.status.idle": "2026-09-22T21:04:22.706084Z", "shell.execute_reply": "2026-09-22T21:04:22.705393Z" } }, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "\u001b[1;36mAbsorption type changed to\u001b[0m\n" ] }, { "name": "stdout", "output_type": "stream", "text": [ "cylinder-hewat\n" ] } ], "source": [ "expt.absorption.type = 'cylinder-hewat'\n", "expt.absorption.mu_r = 0.0221" ] }, { "cell_type": "markdown", "id": "41", "metadata": {}, "source": [ "### Set Excluded Regions" ] }, { "cell_type": "code", "execution_count": 27, "id": "42", "metadata": { "execution": { "iopub.execute_input": "2026-09-22T21:04:22.707593Z", "iopub.status.busy": "2026-09-22T21:04:22.707422Z", "iopub.status.idle": "2026-09-22T21:04:22.710721Z", "shell.execute_reply": "2026-09-22T21:04:22.710062Z" } }, "outputs": [], "source": [ "expt.excluded_regions.create(id='1', start=0.0, end=4.0)\n", "expt.excluded_regions.create(id='2', start=153.95, end=180.0)" ] }, { "cell_type": "markdown", "id": "43", "metadata": {}, "source": [ "### Set Background\n", "\n", "Estimate the initial line-segment background from the measured pattern.\n", "This first estimate does not use a calculated structural model." ] }, { "cell_type": "code", "execution_count": 28, "id": "44", "metadata": { "execution": { "iopub.execute_input": "2026-09-22T21:04:22.712210Z", "iopub.status.busy": "2026-09-22T21:04:22.712048Z", "iopub.status.idle": "2026-09-22T21:04:22.736578Z", "shell.execute_reply": "2026-09-22T21:04:22.735612Z" } }, "outputs": [], "source": [ "expt.background.auto_estimate(use_model=False)" ] }, { "cell_type": "code", "execution_count": 29, "id": "45", "metadata": { "execution": { "iopub.execute_input": "2026-09-22T21:04:22.738074Z", "iopub.status.busy": "2026-09-22T21:04:22.737877Z", "iopub.status.idle": "2026-09-22T21:04:22.744311Z", "shell.execute_reply": "2026-09-22T21:04:22.743761Z" } }, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "\u001b[1;36mLine-segment background points\u001b[0m\n" ] }, { "data": { "text/html": [ "
PositionIntensity
14.050001303.00000
25.950002193.97204
318.200001997.00000
437.350002147.12282
547.700002092.00000
659.250001977.00000
7151.950003468.48635
" ], "text/plain": [ "" ] }, "metadata": {}, "output_type": "display_data" } ], "source": [ "expt.background.show()" ] }, { "cell_type": "markdown", "id": "46", "metadata": {}, "source": [ "### Set Linked Structures\n", "\n", "Give each phase an independent scale factor. Scale factors are fitted\n", "intensity multipliers, rather than phase weight fractions." ] }, { "cell_type": "code", "execution_count": 30, "id": "47", "metadata": { "execution": { "iopub.execute_input": "2026-09-22T21:04:22.746177Z", "iopub.status.busy": "2026-09-22T21:04:22.746011Z", "iopub.status.idle": "2026-09-22T21:04:22.750075Z", "shell.execute_reply": "2026-09-22T21:04:22.749137Z" } }, "outputs": [], "source": [ "expt.linked_structures.create(structure_id='yap', scale=30)\n", "expt.linked_structures.create(structure_id='alumina', scale=0.1)" ] }, { "cell_type": "code", "execution_count": 31, "id": "48", "metadata": { "execution": { "iopub.execute_input": "2026-09-22T21:04:22.751413Z", "iopub.status.busy": "2026-09-22T21:04:22.751258Z", "iopub.status.idle": "2026-09-22T21:04:23.305590Z", "shell.execute_reply": "2026-09-22T21:04:23.304612Z" } }, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "\u001b[1;36mExperiment πŸ”¬ \u001b[0m\u001b[32m'yap_3k'\u001b[0m\u001b[1;36m as text\u001b[0m\n" ] }, { "data": { "text/html": [ "
Edi
1data_yap_3k
2
3_experiment_type.sample_form powder
4_experiment_type.beam_mode "constant wavelength"
5_experiment_type.radiation_probe neutron
6_experiment_type.scattering_type bragg
7
8_diffrn.ambient_temperature ?
9_diffrn.ambient_pressure ?
10_diffrn.ambient_magnetic_field ?
11_diffrn.ambient_electric_field ?
12
13_calculator.type cryspy
14
15_peak.asym_beba_a0 0.
16_peak.asym_beba_b0 0.
17_peak.asym_beba_a1 0.
18_peak.asym_beba_b1 0.
19_peak.broad_gauss_u 0.04
20_peak.broad_gauss_v -0.05
21_peak.broad_gauss_w 0.1
22_peak.broad_lorentz_x 0.
23_peak.broad_lorentz_y 0.01
24_peak.cutoff_fwhm 8.
25_peak.type cwl-pseudo-voigt-berar-baldinozzi-asymmetry
26
27_instrument.setup_wavelength 1.54816
28_instrument.setup_wavelength_2 0.
29_instrument.setup_wavelength_2_to_1_ratio 0.
30_instrument.calib_twotheta_offset 0.
31_instrument.calib_sample_displacement 0.
32_instrument.calib_sample_transparency 0.
33
34_absorption.type cylinder-hewat
35_absorption.mu_r 0.0221
36
37loop_
38_linked_structure.structure_id
39_linked_structure.scale
40yap 30
41alumina 0.1
42
43loop_
44_excluded_region.id
45_excluded_region.start
46_excluded_region.end
471 0. 4.
482 153.95 180.
49
50_background.type line-segment
51
52loop_
53_background.id
54_background.position
55_background.intensity
561 4.05 1303.
572 5.95 2193.97203967
583 18.2 1997.
594 37.35 2147.12281802
605 47.7 2092.
616 59.25 1977.
627 151.95 3468.48635134
63
64loop_
65_data.two_theta
66_data.id
67_data.d_spacing
68_data.intensity_meas
69_data.intensity_meas_su
70_data.intensity_calc
71_data.intensity_bkg
72_data.calc_status
732. 1 0. 0. 1. 0. 0. excl
742.05 2 0. 0. 1. 0. 0. excl
752.1 3 0. 0. 1. 0. 0. excl
762.15 4 0. 0. 1. 0. 0. excl
772.2 5 0. 0. 1. 0. 0. excl
782.25 6 0. 0. 1. 0. 0. excl
792.3 7 0. 0. 1. 0. 0. excl
802.35 8 0. 0. 1. 0. 0. excl
812.4 9 0. 0. 1. 0. 0. excl
822.45 10 0. 0. 1. 0. 0. excl
83...
84151.5 2991 0.79865385 3354. 57. 4902.79239884 3461.24612633 incl
85151.55 2992 0.79856544 3438. 58. 4938.57755495 3462.05059578 incl
86151.6 2993 0.79847719 3441. 58. 4948.05195479 3462.85506522 incl
87151.65 2994 0.79838912 3396. 58. 4927.349773 3463.65953467 incl
88151.7 2995 0.79830122 3429. 58. 4876.02736329 3464.46400411 incl
89151.75 2996 0.79821349 3448. 58. 4796.74526503 3465.26847356 incl
90151.8 2997 0.79812593 3532. 59. 4694.51730196 3466.072943 incl
91151.85 2998 0.79803854 3693. 60. 4575.78062248 3466.87741245 incl
92151.9 2999 0.79795132 3780. 61. 4447.50441615 3467.68188189 incl
93151.95 3000 0.79786427 3784. 61. 4316.44341414 3468.48635134 incl
94
95loop_
96_refln.id
97_refln.structure_id
98_refln.d_spacing
99_refln.sin_theta_over_lambda
100_refln.index_h
101_refln.index_k
102_refln.index_l
103_refln.f_calc
104_refln.f_squared_calc
105_refln.two_theta
1061 yap 7.37 0.06784261 0 0 1 0. 0. 12.05792913
1072 yap 5.33 0.09380863 0 1 0 0. 0. 16.7012855
1083 yap 5.18 0.0965251 1 0 0 0. 0. 17.18852072
1094 yap 4.31891055 0.11576994 0 1 1 0. 0. 20.64987025
1105 yap 4.23794054 0.11798183 1 0 1 0.17288679 0.02988984 21.0488605
1116 yap 3.71471093 0.13459998 1 1 0 0.10027655 0.01005539 24.05513521
1127 yap 3.685 0.13568521 0 0 2 0.02219992 0.00049284 24.25201992
1138 yap 3.31717219 0.15073079 1 1 1 0.86359044 0.74578846 26.98939657
1149 yap 3.03110835 0.16495616 0 1 2 0. 0. 29.5920322
11510 yap 3.00271487 0.16651598 1 0 2 0. 0. 29.878338
116...
117365 alumina 0.81930006 0.61027702 4 -1 11 1.19108015 1.41867193 141.75014806
118366 alumina 0.81616218 0.61262334 5 0 2 4.22226892 17.82755481 143.04165903
119367 alumina 0.81529214 0.6132771 5 -2 -8 0.52947251 0.28034113 143.40934214
120368 alumina 0.81138823 0.61622782 2 -1 15 5.6072072 31.44077264 145.11538603
121369 alumina 0.80534833 0.62084936 4 0 10 0.67018386 0.44914641 147.96362502
122370 alumina 0.79864545 0.62606004 4 -2 12 0.91581608 0.8387191 151.50474768
123371 alumina 0.79738004 0.62705357 5 0 -4 0.18323927 0.03357663 152.22995668
124372 alumina 0.79495324 0.62896781 3 -1 -14 2.05217352 4.21141616 153.68237943
125373 alumina 0.79414921 0.6296046 1 0 16 2.43194259 5.91434477 154.18330783
126374 alumina 0.79166667 0.63157895 6 -3 0 9.73709759 94.8110695 155.80110779
" ], "text/plain": [ "" ] }, "metadata": {}, "output_type": "display_data" } ], "source": [ "expt.show_as_text()" ] }, { "cell_type": "markdown", "id": "49", "metadata": {}, "source": [ "## πŸš€ Perform Analysis\n", "\n", "### Display Initial Pattern" ] }, { "cell_type": "code", "execution_count": 32, "id": "50", "metadata": { "execution": { "iopub.execute_input": "2026-09-22T21:04:23.307308Z", "iopub.status.busy": "2026-09-22T21:04:23.307095Z", "iopub.status.idle": "2026-09-22T21:04:23.397651Z", "shell.execute_reply": "2026-09-22T21:04:23.396708Z" }, "lines_to_next_cell": 2 }, "outputs": [ { "data": { "text/html": [ "
Loading plot…
" ], "text/plain": [ "" ] }, "metadata": {}, "output_type": "display_data" } ], "source": [ "project.display.pattern(expt_name='yap_3k')" ] }, { "cell_type": "code", "execution_count": 33, "id": "51", "metadata": { "execution": { "iopub.execute_input": "2026-09-22T21:04:23.404332Z", "iopub.status.busy": "2026-09-22T21:04:23.404121Z", "iopub.status.idle": "2026-09-22T21:04:23.458457Z", "shell.execute_reply": "2026-09-22T21:04:23.457425Z" } }, "outputs": [ { "data": { "text/html": [ "
Loading plot…
" ], "text/plain": [ "" ] }, "metadata": {}, "output_type": "display_data" } ], "source": [ "project.display.pattern(expt_name='yap_3k', x_min=134, x_max=146)" ] }, { "cell_type": "markdown", "id": "52", "metadata": {}, "source": [ "### Select Calculator" ] }, { "cell_type": "code", "execution_count": 34, "id": "53", "metadata": { "execution": { "iopub.execute_input": "2026-09-22T21:04:23.460328Z", "iopub.status.busy": "2026-09-22T21:04:23.460085Z", "iopub.status.idle": "2026-09-22T21:04:23.467984Z", "shell.execute_reply": "2026-09-22T21:04:23.467056Z" } }, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "\u001b[1;36mCalculator types\u001b[0m\n" ] }, { "data": { "text/html": [ "
TypeDescription
1crysfmlCrysFML library for crystallographic calculations
2*cryspyCrysPy library for crystallographic calculations
" ], "text/plain": [ "" ] }, "metadata": {}, "output_type": "display_data" } ], "source": [ "expt.calculator.show_supported()" ] }, { "cell_type": "code", "execution_count": 35, "id": "54", "metadata": { "execution": { "iopub.execute_input": "2026-09-22T21:04:23.469943Z", "iopub.status.busy": "2026-09-22T21:04:23.469702Z", "iopub.status.idle": "2026-09-22T21:04:23.475332Z", "shell.execute_reply": "2026-09-22T21:04:23.474456Z" } }, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "\u001b[1;36mCalculator for experiment \u001b[0m\u001b[32m'yap_3k'\u001b[0m\u001b[1;36m already set to\u001b[0m\n" ] }, { "name": "stdout", "output_type": "stream", "text": [ "cryspy\n" ] } ], "source": [ "expt.calculator.type = 'cryspy'" ] }, { "cell_type": "markdown", "id": "55", "metadata": {}, "source": [ "### Select Minimizer" ] }, { "cell_type": "code", "execution_count": 36, "id": "56", "metadata": { "execution": { "iopub.execute_input": "2026-09-22T21:04:23.477098Z", "iopub.status.busy": "2026-09-22T21:04:23.476860Z", "iopub.status.idle": "2026-09-22T21:04:23.484056Z", "shell.execute_reply": "2026-09-22T21:04:23.483262Z" } }, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "\u001b[1;36mMinimizer types\u001b[0m\n" ] }, { "data": { "text/html": [ "
TypeDescription
1bumpsBUMPS library using the default Levenberg-Marquardt method
2bumps (amoeba)BUMPS library with Nelder-Mead simplex method
3bumps (de)BUMPS library with differential evolution method
4bumps (dream)BUMPS library with DREAM Bayesian sampling
5bumps (lm)BUMPS library with Levenberg-Marquardt method
6dfolsDFO-LS library for derivative-free least-squares optimization
7emceeemcee affine-invariant ensemble Bayesian sampling
8lmfitLMFIT library using the default Levenberg-Marquardt method
9lmfit (least_squares)LMFIT library with SciPy's trust region reflective algorithm
10*lmfit (leastsq)LMFIT library with Levenberg-Marquardt least squares method
" ], "text/plain": [ "" ] }, "metadata": {}, "output_type": "display_data" } ], "source": [ "project.analysis.minimizer.show_supported()" ] }, { "cell_type": "code", "execution_count": 37, "id": "57", "metadata": { "execution": { "iopub.execute_input": "2026-09-22T21:04:23.485688Z", "iopub.status.busy": "2026-09-22T21:04:23.485515Z", "iopub.status.idle": "2026-09-22T21:04:23.493099Z", "shell.execute_reply": "2026-09-22T21:04:23.492323Z" } }, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "⚠️ Switching minimizer type removes these settings:\n", "β€’ gradient_tolerance\n" ] }, { "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": [ "project.analysis.minimizer.type = 'bumps (lm)'" ] }, { "cell_type": "code", "execution_count": 38, "id": "58", "metadata": { "execution": { "iopub.execute_input": "2026-09-22T21:04:23.495115Z", "iopub.status.busy": "2026-09-22T21:04:23.494883Z", "iopub.status.idle": "2026-09-22T21:04:23.498827Z", "shell.execute_reply": "2026-09-22T21:04:23.498079Z" } }, "outputs": [], "source": [ "project.analysis.minimizer.max_iterations = 500\n", "project.analysis.minimizer.chi_square_change_tolerance = 1e-2" ] }, { "cell_type": "markdown", "id": "59", "metadata": {}, "source": [ "### Perform Fit 1/3: Cell, Scale, and Background\n", "\n", "First refine the independent cell lengths of both phases, both phase\n", "scales, the instrument zero offset, and the automatically estimated\n", "background intensities. Hexagonal symmetry couples the Al2O3 b length\n", "to a, leaving only a and c independent." ] }, { "cell_type": "code", "execution_count": 39, "id": "60", "metadata": { "execution": { "iopub.execute_input": "2026-09-22T21:04:23.500386Z", "iopub.status.busy": "2026-09-22T21:04:23.500224Z", "iopub.status.idle": "2026-09-22T21:04:23.505020Z", "shell.execute_reply": "2026-09-22T21:04:23.503997Z" } }, "outputs": [], "source": [ "yap.cell.length_a.free = True\n", "yap.cell.length_b.free = True\n", "yap.cell.length_c.free = True\n", "\n", "alumina.cell.length_a.free = True\n", "alumina.cell.length_c.free = True\n", "\n", "expt.linked_structures['yap'].scale.free = True\n", "expt.linked_structures['alumina'].scale.free = True\n", "\n", "expt.instrument.calib_twotheta_offset.free = True\n", "\n", "for point in expt.background:\n", " point.intensity.free = True" ] }, { "cell_type": "code", "execution_count": 40, "id": "61", "metadata": { "execution": { "iopub.execute_input": "2026-09-22T21:04:23.506641Z", "iopub.status.busy": "2026-09-22T21:04:23.506478Z", "iopub.status.idle": "2026-09-22T21:04:23.587450Z", "shell.execute_reply": "2026-09-22T21:04:23.586444Z" } }, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "\u001b[1;36mFree parameters for both structures \u001b[0m\u001b[1;36m(\u001b[0m\u001b[1;36m🧩 data blocks\u001b[0m\u001b[1;36m)\u001b[0m\u001b[1;36m and experiments \u001b[0m\u001b[1;36m(\u001b[0m\u001b[1;36mπŸ”¬ data blocks\u001b[0m\u001b[1;36m)\u001b[0m\n" ] }, { "data": { "text/html": [ "
datablockcategoryentryparametervalueuncertaintyminmaxunits
1yapcelllength_a5.18000-infinfΓ…
2yapcelllength_b5.33000-infinfΓ…
3yapcelllength_c7.37000-infinfΓ…
4aluminacelllength_a4.75000-infinfΓ…
5aluminacelllength_c12.95000-infinfΓ…
6yap_3klinked_structureyapscale30.00000-infinf
7yap_3klinked_structurealuminascale0.10000-infinf
8yap_3kinstrumenttwotheta_offset0.00000-infinfdeg
9yap_3kbackground1intensity1303.00000-infinf
10yap_3kbackground2intensity2193.97204-infinf
11yap_3kbackground3intensity1997.00000-infinf
12yap_3kbackground4intensity2147.12282-infinf
13yap_3kbackground5intensity2092.00000-infinf
14yap_3kbackground6intensity1977.00000-infinf
15yap_3kbackground7intensity3468.48635-infinf
" ], "text/plain": [ "" ] }, "metadata": {}, "output_type": "display_data" } ], "source": [ "project.display.parameters.free()" ] }, { "cell_type": "code", "execution_count": 41, "id": "62", "metadata": { "execution": { "iopub.execute_input": "2026-09-22T21:04:23.589030Z", "iopub.status.busy": "2026-09-22T21:04:23.588858Z", "iopub.status.idle": "2026-09-22T21:04:41.548157Z", "shell.execute_reply": "2026-09-22T21:04:41.547693Z" } }, "outputs": [ { "data": { "text/html": [], "text/plain": [ "" ] }, "metadata": {}, "output_type": "display_data" }, { "data": { "application/javascript": [ "\n", "(function() {\n", " const button = document.getElementById('ed-fit-stop-51a658c36eb246788d85164950a1aa95-button');\n", " const status = document.getElementById('ed-fit-stop-51a658c36eb246788d85164950a1aa95-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'yap_3k'\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.371170.67
2172.61266.0077.3% ↓
3334.8074.8071.9% ↓
4497.3766.3911.3% ↓
56717.8966.03
" ], "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;36m66.03\u001b[0m at iteration \u001b[1;36m67\u001b[0m\n" ] }, { "name": "stdout", "output_type": "stream", "text": [ "βœ… Fitting complete.\n" ] } ], "source": [ "project.analysis.fit()" ] }, { "cell_type": "code", "execution_count": 42, "id": "63", "metadata": { "execution": { "iopub.execute_input": "2026-09-22T21:04:41.551119Z", "iopub.status.busy": "2026-09-22T21:04:41.550882Z", "iopub.status.idle": "2026-09-22T21:04:42.512545Z", "shell.execute_reply": "2026-09-22T21:04:42.511373Z" } }, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "βš™οΈ Settings used:\n" ] }, { "data": { "text/html": [ "
NameValueDescription
1max_iterations500Maximum solver iterations.
2chi_square_change_tolerance0.01Relative change in the objective (chi-square) used to stop fitting.
3parameter_change_tolerance1e-08Relative change in fitted parameters used to stop fitting.
" ], "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)17.89
4πŸ“ Goodness-of-fit (reduced χ²)66.03
5πŸ“ R-factor (Rf, %)8.19
6πŸ“ R-factor squared (RfΒ², %)10.54
7πŸ“ Weighted R-factor (wR, %)10.63
" ], "text/plain": [ "" ] }, "metadata": {}, "output_type": "display_data" }, { "name": "stdout", "output_type": "stream", "text": [ "πŸ“ˆ Refined parameters:\n" ] }, { "data": { "text/html": [ "
datablockcategoryentryparameterunitsstartvalues.u.change
1yapcelllength_aΓ…5.18005.17360.00010.12 % ↓
2yapcelllength_bΓ…5.33005.32780.00010.04 % ↓
3yapcelllength_cΓ…7.37007.36240.00010.10 % ↓
4aluminacelllength_aΓ…4.75004.75560.00120.12 % ↑
5aluminacelllength_cΓ…12.950012.98930.00630.30 % ↑
6yap_3klinked_structureyapscale30.000027.07080.08519.76 % ↓
7yap_3klinked_structurealuminascale0.10000.19400.016693.98 % ↑
8yap_3kinstrumenttwotheta_offsetdeg0.00000.00440.0010N/A
9yap_3kbackground1intensity1303.00001364.579189.82614.73 % ↑
10yap_3kbackground2intensity2193.97202366.325642.13917.86 % ↑
11yap_3kbackground3intensity1997.00002014.475528.63200.88 % ↑
12yap_3kbackground4intensity2147.12282231.358333.24683.92 % ↑
13yap_3kbackground5intensity2092.00002238.653439.89407.01 % ↑
14yap_3kbackground6intensity1977.00002069.834021.09954.70 % ↑
15yap_3kbackground7intensity3468.48642414.262624.475730.39 % ↓
" ], "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": [ "project.display.fit.results()" ] }, { "cell_type": "markdown", "id": "64", "metadata": {}, "source": [ "### Perform Fit 2/3: Peak Profile\n", "\n", "Add the Gaussian and Lorentzian broadening and asymmetry parameters\n", "to the refinement. The background intensities remain free." ] }, { "cell_type": "code", "execution_count": 43, "id": "65", "metadata": { "execution": { "iopub.execute_input": "2026-09-22T21:04:42.514430Z", "iopub.status.busy": "2026-09-22T21:04:42.514249Z", "iopub.status.idle": "2026-09-22T21:04:42.517978Z", "shell.execute_reply": "2026-09-22T21:04:42.517023Z" } }, "outputs": [], "source": [ "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", "expt.peak.asym_beba_a0.free = True\n", "# expt.peak.asym_beba_b0.free = True\n", "# expt.peak.asym_beba_a1.free = True\n", "expt.peak.asym_beba_b1.free = True" ] }, { "cell_type": "code", "execution_count": 44, "id": "66", "metadata": { "execution": { "iopub.execute_input": "2026-09-22T21:04:42.519649Z", "iopub.status.busy": "2026-09-22T21:04:42.519479Z", "iopub.status.idle": "2026-09-22T21:04:42.718762Z", "shell.execute_reply": "2026-09-22T21:04:42.717080Z" } }, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "\u001b[1;36mFree parameters for both structures \u001b[0m\u001b[1;36m(\u001b[0m\u001b[1;36m🧩 data blocks\u001b[0m\u001b[1;36m)\u001b[0m\u001b[1;36m and experiments \u001b[0m\u001b[1;36m(\u001b[0m\u001b[1;36mπŸ”¬ data blocks\u001b[0m\u001b[1;36m)\u001b[0m\n" ] }, { "data": { "text/html": [ "
datablockcategoryentryparametervalueuncertaintyminmaxunits
1yapcelllength_a5.173640.00007-infinfΓ…
2yapcelllength_b5.327780.00007-infinfΓ…
3yapcelllength_c7.362390.00010-infinfΓ…
4aluminacelllength_a4.755600.00119-infinfΓ…
5aluminacelllength_c12.989250.00626-infinfΓ…
6yap_3klinked_structureyapscale27.070840.08509-infinf
7yap_3klinked_structurealuminascale0.193980.01660-infinf
8yap_3kpeakasym_beba_a00.00000-infinf
9yap_3kpeakasym_beba_b10.00000-infinf
10yap_3kpeakbroad_gauss_u0.04000-infinfdegΒ²
11yap_3kpeakbroad_gauss_v-0.05000-infinfdegΒ²
12yap_3kpeakbroad_gauss_w0.10000-infinfdegΒ²
13yap_3kpeakbroad_lorentz_y0.01000-infinfdeg
14yap_3kinstrumenttwotheta_offset0.004450.00096-infinfdeg
15yap_3kbackground1intensity1364.5790989.82607-infinf
16yap_3kbackground2intensity2366.3256042.13908-infinf
17yap_3kbackground3intensity2014.4754628.63205-infinf
18yap_3kbackground4intensity2231.3582733.24678-infinf
19yap_3kbackground5intensity2238.6534139.89401-infinf
20yap_3kbackground6intensity2069.8340021.09954-infinf
21yap_3kbackground7intensity2414.2625924.47574-infinf
" ], "text/plain": [ "" ] }, "metadata": {}, "output_type": "display_data" } ], "source": [ "project.display.parameters.free()" ] }, { "cell_type": "code", "execution_count": 45, "id": "67", "metadata": { "execution": { "iopub.execute_input": "2026-09-22T21:04:42.721939Z", "iopub.status.busy": "2026-09-22T21:04:42.721660Z", "iopub.status.idle": "2026-09-22T21:05:05.110761Z", "shell.execute_reply": "2026-09-22T21:05:05.109854Z" } }, "outputs": [ { "data": { "text/html": [], "text/plain": [ "" ] }, "metadata": {}, "output_type": "display_data" }, { "data": { "application/javascript": [ "\n", "(function() {\n", " const button = document.getElementById('ed-fit-stop-d1cec5444a684e82a74a360d28a74b0d-button');\n", " const status = document.getElementById('ed-fit-stop-d1cec5444a684e82a74a360d28a74b0d-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'yap_3k'\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.1566.17
2234.7759.2410.5% ↓
3459.8958.601.1% ↓
46922.2858.50
" ], "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;36m58.50\u001b[0m at iteration \u001b[1;36m69\u001b[0m\n" ] }, { "name": "stdout", "output_type": "stream", "text": [ "βœ… Fitting complete.\n" ] } ], "source": [ "project.analysis.fit()" ] }, { "cell_type": "code", "execution_count": 46, "id": "68", "metadata": { "execution": { "iopub.execute_input": "2026-09-22T21:05:05.112359Z", "iopub.status.busy": "2026-09-22T21:05:05.112151Z", "iopub.status.idle": "2026-09-22T21:05:06.162011Z", "shell.execute_reply": "2026-09-22T21:05:06.161153Z" } }, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "βš™οΈ Settings used:\n" ] }, { "data": { "text/html": [ "
NameValueDescription
1max_iterations500Maximum solver iterations.
2chi_square_change_tolerance0.01Relative change in the objective (chi-square) used to stop fitting.
3parameter_change_tolerance1e-08Relative change in fitted parameters used to stop fitting.
" ], "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)22.28
4πŸ“ Goodness-of-fit (reduced χ²)58.50
5πŸ“ R-factor (Rf, %)7.66
6πŸ“ R-factor squared (RfΒ², %)10.03
7πŸ“ Weighted R-factor (wR, %)9.99
" ], "text/plain": [ "" ] }, "metadata": {}, "output_type": "display_data" }, { "name": "stdout", "output_type": "stream", "text": [ "πŸ“ˆ Refined parameters:\n" ] }, { "data": { "text/html": [ "
datablockcategoryentryparameterunitsstartvalues.u.change
1yapcelllength_aΓ…5.17365.17280.00010.02 % ↓
2yapcelllength_bΓ…5.32785.32700.00010.01 % ↓
3yapcelllength_cΓ…7.36247.36100.00020.02 % ↓
4aluminacelllength_aΓ…4.75564.75770.00110.04 % ↑
5aluminacelllength_cΓ…12.989312.97610.00590.10 % ↓
6yap_3klinked_structureyapscale27.070828.06930.11373.69 % ↑
7yap_3klinked_structurealuminascale0.19400.19410.01610.07 % ↑
8yap_3kpeakasym_beba_a00.0000-0.18180.0152N/A
9yap_3kpeakasym_beba_b10.0000-0.06120.0050N/A
10yap_3kpeakbroad_gauss_udegΒ²0.04000.03640.00208.95 % ↓
11yap_3kpeakbroad_gauss_vdegΒ²-0.0500-0.05100.00412.07 % ↑
12yap_3kpeakbroad_gauss_wdegΒ²0.10000.09850.00221.55 % ↓
13yap_3kpeakbroad_lorentz_ydeg0.01000.02980.0019198.09 % ↑
14yap_3kinstrumenttwotheta_offsetdeg0.00440.00590.002733.39 % ↑
15yap_3kbackground1intensity1364.57911368.934784.54480.32 % ↑
16yap_3kbackground2intensity2366.32562355.854239.66960.44 % ↓
17yap_3kbackground3intensity2014.47552037.048127.00531.12 % ↑
18yap_3kbackground4intensity2231.35832140.984432.06064.05 % ↓
19yap_3kbackground5intensity2238.65342025.140641.31519.54 % ↓
20yap_3kbackground6intensity2069.83401954.560021.68745.57 % ↓
21yap_3kbackground7intensity2414.26262293.721926.68364.99 % ↓
" ], "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": [ "project.display.fit.results()" ] }, { "cell_type": "markdown", "id": "69", "metadata": {}, "source": [ "### Perform Fit 3/3: Model-Guided Background and Atom Parameters\n", "\n", "Replace the initial background with a new estimate based on the fitted\n", "peak model. Automatically generated points are fixed by default, so\n", "mark their intensities free before fitting them with the atom parameters." ] }, { "cell_type": "code", "execution_count": 47, "id": "70", "metadata": { "execution": { "iopub.execute_input": "2026-09-22T21:05:06.163936Z", "iopub.status.busy": "2026-09-22T21:05:06.163763Z", "iopub.status.idle": "2026-09-22T21:05:06.190064Z", "shell.execute_reply": "2026-09-22T21:05:06.189228Z" } }, "outputs": [], "source": [ "expt.background.auto_estimate(use_model=True)" ] }, { "cell_type": "code", "execution_count": 48, "id": "71", "metadata": { "execution": { "iopub.execute_input": "2026-09-22T21:05:06.191970Z", "iopub.status.busy": "2026-09-22T21:05:06.191771Z", "iopub.status.idle": "2026-09-22T21:05:06.199167Z", "shell.execute_reply": "2026-09-22T21:05:06.198356Z" } }, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "\u001b[1;36mLine-segment background points\u001b[0m\n" ] }, { "data": { "text/html": [ "
PositionIntensity
14.050001303.00000
25.850002173.00000
37.300002414.80830
417.850002010.28100
524.750002041.00000
635.000001968.46433
739.350001606.73948
841.450000.00000
943.950001695.97793
1044.950002367.00000
1147.650001691.86967
1248.150001321.52032
1351.600001934.23588
1474.600001881.37866
15101.100001996.38773
16122.200001525.63663
17129.650003108.73377
18142.500002493.86153
19144.750002295.53422
20151.950002451.55313
" ], "text/plain": [ "" ] }, "metadata": {}, "output_type": "display_data" } ], "source": [ "expt.background.show()" ] }, { "cell_type": "code", "execution_count": 49, "id": "72", "metadata": { "execution": { "iopub.execute_input": "2026-09-22T21:05:06.201089Z", "iopub.status.busy": "2026-09-22T21:05:06.200903Z", "iopub.status.idle": "2026-09-22T21:05:06.204490Z", "shell.execute_reply": "2026-09-22T21:05:06.203657Z" } }, "outputs": [], "source": [ "for point in expt.background:\n", " point.intensity.free = True" ] }, { "cell_type": "markdown", "id": "73", "metadata": {}, "source": [ "Refine the independent Y and O coordinates in Pbnm and the\n", "isotropic displacement parameters of both phases. Symmetry keeps Y\n", "and O1 in YAlO3 at z = 1/4 and Al at the origin. For Al2O3, refine\n", "Al1 z and O1 x. Occupancies remain fixed\n", "at 1.0, and all coordinates fixed by symmetry remain fixed." ] }, { "cell_type": "code", "execution_count": 50, "id": "74", "metadata": { "execution": { "iopub.execute_input": "2026-09-22T21:05:06.206144Z", "iopub.status.busy": "2026-09-22T21:05:06.205947Z", "iopub.status.idle": "2026-09-22T21:05:06.211425Z", "shell.execute_reply": "2026-09-22T21:05:06.210440Z" } }, "outputs": [], "source": [ "yap.atom_sites['Y'].fract_x.free = True\n", "yap.atom_sites['Y'].fract_y.free = True\n", "yap.atom_sites['O1'].fract_x.free = True\n", "yap.atom_sites['O1'].fract_y.free = True\n", "yap.atom_sites['O2'].fract_x.free = True\n", "yap.atom_sites['O2'].fract_y.free = True\n", "yap.atom_sites['O2'].fract_z.free = True\n", "\n", "alumina.atom_sites['Al1'].fract_z.free = True\n", "alumina.atom_sites['O1'].fract_x.free = True\n", "\n", "for structure in (yap, alumina):\n", " for atom in structure.atom_sites:\n", " atom.adp_iso.free = True" ] }, { "cell_type": "code", "execution_count": 51, "id": "75", "metadata": { "execution": { "iopub.execute_input": "2026-09-22T21:05:06.213064Z", "iopub.status.busy": "2026-09-22T21:05:06.212860Z", "iopub.status.idle": "2026-09-22T21:05:06.330795Z", "shell.execute_reply": "2026-09-22T21:05:06.329928Z" } }, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "\u001b[1;36mFree parameters for both structures \u001b[0m\u001b[1;36m(\u001b[0m\u001b[1;36m🧩 data blocks\u001b[0m\u001b[1;36m)\u001b[0m\u001b[1;36m and experiments \u001b[0m\u001b[1;36m(\u001b[0m\u001b[1;36mπŸ”¬ data blocks\u001b[0m\u001b[1;36m)\u001b[0m\n" ] }, { "data": { "text/html": [ "
datablockcategoryentryparametervalueuncertaintyminmaxunits
1yapcelllength_a5.172780.00012-infinfΓ…
2yapcelllength_b5.326980.00012-infinfΓ…
3yapcelllength_c7.361050.00017-infinfΓ…
4yapatom_siteYfract_x0.01000-infinf
5yapatom_siteYfract_y0.55000-infinf
6yapatom_siteYadp_iso0.12000-infinfΓ…Β²
7yapatom_siteAladp_iso0.13000-infinfΓ…Β²
8yapatom_siteO1fract_x-0.08000-infinf
9yapatom_siteO1fract_y-0.02000-infinf
10yapatom_siteO1adp_iso0.06000-infinfΓ…Β²
11yapatom_siteO2fract_x0.20000-infinf
12yapatom_siteO2fract_y0.29000-infinf
13yapatom_siteO2fract_z0.04000-infinf
14yapatom_siteO2adp_iso0.14000-infinfΓ…Β²
15aluminacelllength_a4.757710.00112-infinfΓ…
16aluminacelllength_c12.976140.00589-infinfΓ…
17aluminaatom_siteAl1fract_z0.33351-infinf
18aluminaatom_siteAl1adp_iso0.10000-infinfΓ…Β²
19aluminaatom_siteO1fract_x0.35030-infinf
20aluminaatom_siteO1adp_iso1.22884-infinfΓ…Β²
21yap_3klinked_structureyapscale28.069350.11372-infinf
22yap_3klinked_structurealuminascale0.194130.01609-infinf
23yap_3kpeakasym_beba_a0-0.181830.01524-infinf
24yap_3kpeakasym_beba_b1-0.061170.00501-infinf
25yap_3kpeakbroad_gauss_u0.036420.00197-infinfdegΒ²
26yap_3kpeakbroad_gauss_v-0.051030.00409-infinfdegΒ²
27yap_3kpeakbroad_gauss_w0.098450.00218-infinfdegΒ²
28yap_3kpeakbroad_lorentz_y0.029810.00192-infinfdeg
29yap_3kinstrumenttwotheta_offset0.005930.00268-infinfdeg
30yap_3kbackground1intensity1303.00000-infinf
31yap_3kbackground2intensity2173.00000-infinf
32yap_3kbackground3intensity2414.80830-infinf
33yap_3kbackground4intensity2010.28100-infinf
34yap_3kbackground5intensity2041.00000-infinf
35yap_3kbackground6intensity1968.46433-infinf
36yap_3kbackground7intensity1606.73948-infinf
37yap_3kbackground8intensity0.00000-infinf
38yap_3kbackground9intensity1695.97793-infinf
39yap_3kbackground10intensity2367.00000-infinf
40yap_3kbackground11intensity1691.86967-infinf
41yap_3kbackground12intensity1321.52032-infinf
42yap_3kbackground13intensity1934.23588-infinf
43yap_3kbackground14intensity1881.37866-infinf
44yap_3kbackground15intensity1996.38773-infinf
45yap_3kbackground16intensity1525.63663-infinf
46yap_3kbackground17intensity3108.73377-infinf
47yap_3kbackground18intensity2493.86153-infinf
48yap_3kbackground19intensity2295.53422-infinf
49yap_3kbackground20intensity2451.55313-infinf
" ], "text/plain": [ "" ] }, "metadata": {}, "output_type": "display_data" } ], "source": [ "project.display.parameters.free()" ] }, { "cell_type": "code", "execution_count": 52, "id": "76", "metadata": { "execution": { "iopub.execute_input": "2026-09-22T21:05:06.332520Z", "iopub.status.busy": "2026-09-22T21:05:06.332319Z", "iopub.status.idle": "2026-09-22T21:05:50.132959Z", "shell.execute_reply": "2026-09-22T21:05:50.132144Z" } }, "outputs": [ { "data": { "text/html": [], "text/plain": [ "" ] }, "metadata": {}, "output_type": "display_data" }, { "data": { "application/javascript": [ "\n", "(function() {\n", " const button = document.getElementById('ed-fit-stop-9ca8bdf908c14bd6bec8b8a6241728df-button');\n", " const status = document.getElementById('ed-fit-stop-9ca8bdf908c14bd6bec8b8a6241728df-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'yap_3k'\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.1478.60
2519.009.9387.4% ↓
310117.529.286.6% ↓
415343.739.25
" ], "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;36m9.25\u001b[0m at iteration \u001b[1;36m153\u001b[0m\n" ] }, { "name": "stdout", "output_type": "stream", "text": [ "βœ… Fitting complete.\n" ] } ], "source": [ "project.analysis.fit()" ] }, { "cell_type": "markdown", "id": "77", "metadata": {}, "source": [ "### Inspect Results\n", "\n", "Review the fit statistics, refined parameters, and correlations.\n", "Inspect the full pattern and a closer view with impurity reflections." ] }, { "cell_type": "code", "execution_count": 53, "id": "78", "metadata": { "execution": { "iopub.execute_input": "2026-09-22T21:05:50.134878Z", "iopub.status.busy": "2026-09-22T21:05:50.134670Z", "iopub.status.idle": "2026-09-22T21:05:50.799003Z", "shell.execute_reply": "2026-09-22T21:05:50.798357Z" } }, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "βš™οΈ Settings used:\n" ] }, { "data": { "text/html": [ "
NameValueDescription
1max_iterations500Maximum solver iterations.
2chi_square_change_tolerance0.01Relative change in the objective (chi-square) used to stop fitting.
3parameter_change_tolerance1e-08Relative change in fitted parameters used to stop fitting.
" ], "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)43.73
4πŸ“ Goodness-of-fit (reduced χ²)9.25
5πŸ“ R-factor (Rf, %)3.13
6πŸ“ R-factor squared (RfΒ², %)3.71
7πŸ“ Weighted R-factor (wR, %)3.96
" ], "text/plain": [ "" ] }, "metadata": {}, "output_type": "display_data" }, { "name": "stdout", "output_type": "stream", "text": [ "πŸ“ˆ Refined parameters:\n" ] }, { "data": { "text/html": [ "
datablockcategoryentryparameterunitsstartvalues.u.change
1yapcelllength_aΓ…5.17285.17280.00000.00 % ↑
2yapcelllength_bΓ…5.32705.32710.00000.00 % ↑
3yapcelllength_cΓ…7.36107.36130.00010.00 % ↑
4yapatom_siteYfract_x0.01000.01230.000122.93 % ↑
5yapatom_siteYfract_y0.55000.55410.00010.74 % ↑
6yapatom_siteYadp_isoΓ…Β²0.12000.07110.008640.77 % ↓
7yapatom_siteAladp_isoΓ…Β²0.13000.09380.014927.81 % ↓
8yapatom_siteO1fract_x-0.0800-0.08390.00014.91 % ↑
9yapatom_siteO1fract_y-0.0200-0.02190.00019.38 % ↑
10yapatom_siteO1adp_isoΓ…Β²0.06000.02800.009653.41 % ↓
11yapatom_siteO2fract_x0.20000.20470.00012.33 % ↑
12yapatom_siteO2fract_y0.29000.29480.00011.64 % ↑
13yapatom_siteO2fract_z0.04000.04420.000110.53 % ↑
14yapatom_siteO2adp_isoΓ…Β²0.14000.08940.007536.17 % ↓
15aluminacelllength_aΓ…4.75774.75800.00040.01 % ↑
16aluminacelllength_cΓ…12.976112.97480.00240.01 % ↓
17aluminaatom_siteAl1fract_z0.33350.34090.00362.22 % ↑
18aluminaatom_siteAl1adp_isoΓ…Β²0.10000.07890.326221.13 % ↓
19aluminaatom_siteO1fract_x0.35030.34020.00772.88 % ↓
20aluminaatom_siteO1adp_isoΓ…Β²1.22881.07750.256512.32 % ↓
21yap_3klinked_structureyapscale28.069328.00570.07550.23 % ↓
22yap_3klinked_structurealuminascale0.19410.18470.01234.87 % ↓
23yap_3kpeakasym_beba_a0-0.1818-0.18250.00640.35 % ↑
24yap_3kpeakasym_beba_b1-0.0612-0.05960.00212.51 % ↓
25yap_3kpeakbroad_gauss_udegΒ²0.03640.03030.000716.83 % ↓
26yap_3kpeakbroad_gauss_vdegΒ²-0.0510-0.04580.001510.26 % ↓
27yap_3kpeakbroad_gauss_wdegΒ²0.09850.09640.00092.03 % ↓
28yap_3kpeakbroad_lorentz_ydeg0.02980.03260.00099.53 % ↑
29yap_3kinstrumenttwotheta_offsetdeg0.00590.00840.001142.18 % ↑
30yap_3kbackground1intensity1303.00001389.368536.30546.63 % ↑
31yap_3kbackground2intensity2173.00002260.648532.29174.03 % ↑
32yap_3kbackground3intensity2414.80832363.875217.48372.11 % ↓
33yap_3kbackground4intensity2010.28102000.347914.06530.49 % ↓
34yap_3kbackground5intensity2041.00002093.076614.75352.55 % ↑
35yap_3kbackground6intensity1968.46432089.966818.00426.17 % ↑
36yap_3kbackground7intensity1606.73952267.807028.686541.14 % ↑
37yap_3kbackground8intensity0.00001651.210051.4432N/A
38yap_3kbackground9intensity1695.97792069.540849.665222.03 % ↑
39yap_3kbackground10intensity2367.00002093.731638.895311.54 % ↓
40yap_3kbackground11intensity1691.86972062.850334.523121.93 % ↑
41yap_3kbackground12intensity1321.52031738.020637.491731.52 % ↑
42yap_3kbackground13intensity1934.23592008.831614.06183.86 % ↑
43yap_3kbackground14intensity1881.37872028.274012.78427.81 % ↑
44yap_3kbackground15intensity1996.38772072.590113.53303.82 % ↑
45yap_3kbackground16intensity1525.63661925.430215.770326.21 % ↑
46yap_3kbackground17intensity3108.73382266.118024.463127.10 % ↓
47yap_3kbackground18intensity2493.86152561.200923.83982.70 % ↑
48yap_3kbackground19intensity2295.53422546.228428.561510.92 % ↑
49yap_3kbackground20intensity2451.55312754.924537.889812.37 % ↑
" ], "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" }, { "data": { "text/html": [ "
⚠️ Red s.u.: exceeds the refined value (consider adding constraints)
" ], "text/plain": [ "" ] }, "metadata": {}, "output_type": "display_data" } ], "source": [ "project.display.fit.results()" ] }, { "cell_type": "code", "execution_count": 54, "id": "79", "metadata": { "execution": { "iopub.execute_input": "2026-09-22T21:05:50.800718Z", "iopub.status.busy": "2026-09-22T21:05:50.800548Z", "iopub.status.idle": "2026-09-22T21:05:50.830659Z", "shell.execute_reply": "2026-09-22T21:05:50.829894Z" } }, "outputs": [ { "data": { "text/html": [ "\n", "\n", "
\n", "
Loading plot…
\n", "
" ], "text/plain": [ "" ] }, "metadata": {}, "output_type": "display_data" } ], "source": [ "project.display.fit.correlations()" ] }, { "cell_type": "code", "execution_count": 55, "id": "80", "metadata": { "execution": { "iopub.execute_input": "2026-09-22T21:05:50.832717Z", "iopub.status.busy": "2026-09-22T21:05:50.832472Z", "iopub.status.idle": "2026-09-22T21:05:50.908963Z", "shell.execute_reply": "2026-09-22T21:05:50.908086Z" } }, "outputs": [ { "data": { "text/html": [ "
Loading plot…
" ], "text/plain": [ "" ] }, "metadata": {}, "output_type": "display_data" } ], "source": [ "project.display.pattern(expt_name='yap_3k')" ] }, { "cell_type": "code", "execution_count": 56, "id": "81", "metadata": { "execution": { "iopub.execute_input": "2026-09-22T21:05:50.915454Z", "iopub.status.busy": "2026-09-22T21:05:50.915253Z", "iopub.status.idle": "2026-09-22T21:05:51.278178Z", "shell.execute_reply": "2026-09-22T21:05:51.277052Z" } }, "outputs": [ { "data": { "text/html": [ "
Loading plot…
" ], "text/plain": [ "" ] }, "metadata": {}, "output_type": "display_data" } ], "source": [ "project.display.pattern(expt_name='yap_3k', x_min=134, x_max=146)" ] }, { "cell_type": "markdown", "id": "82", "metadata": {}, "source": [ "## πŸ’Ύ Save Project\n", "\n", "Save the refined model and analysis results in the project directory." ] }, { "cell_type": "code", "execution_count": 57, "id": "83", "metadata": { "execution": { "iopub.execute_input": "2026-09-22T21:05:51.279854Z", "iopub.status.busy": "2026-09-22T21:05:51.279667Z", "iopub.status.idle": "2026-09-22T21:05:51.668554Z", "shell.execute_reply": "2026-09-22T21:05:51.667625Z" } }, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "\u001b[1;36mSaving project πŸ“¦ \u001b[0m\u001b[32m'yap_3k'\u001b[0m\u001b[1;36m to \u001b[0m\u001b[32m'../../../projects/refine-yap-3k'\u001b[0m\n" ] }, { "name": "stdout", "output_type": "stream", "text": [ "β”œβ”€β”€ πŸ“„ project.edi\n", "β”œβ”€β”€ πŸ“ structures/\n", "β”‚ └── πŸ“„ yap.edi\n", "β”‚ └── πŸ“„ alumina.edi\n", "β”œβ”€β”€ πŸ“ experiments/\n", "β”‚ └── πŸ“„ yap_3k.edi\n", "β”œβ”€β”€ πŸ“ analysis/\n", "β”‚ └── πŸ“„ analysis.edi\n", "└── πŸ“ reports/\n", " └── πŸ“„ yap_3k.html\n" ] } ], "source": [ "project.save()" ] } ], "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.6" } }, "nbformat": 4, "nbformat_minor": 5 }