{
"cells": [
{
"cell_type": "code",
"execution_count": 1,
"id": "0",
"metadata": {
"execution": {
"iopub.execute_input": "2026-08-18T18:26:46.994062Z",
"iopub.status.busy": "2026-08-18T18:26:46.993880Z",
"iopub.status.idle": "2026-08-18T18:26:46.998189Z",
"shell.execute_reply": "2026-08-18T18:26:46.997437Z"
},
"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.20.1"
]
},
{
"cell_type": "markdown",
"id": "1",
"metadata": {},
"source": [
"# Structure Refinement: LMO, ECHIDNA\n",
"\n",
"This example refines an LMO structure with Li/Ni site mixing against\n",
"constant-wavelength neutron powder diffraction data collected on the\n",
"ECHIDNA diffractometer at ANSTO. The workflow starts from approximate\n",
"structural and profile parameters, constrains the coupled site\n",
"occupancies, and performs a Rietveld refinement."
]
},
{
"cell_type": "markdown",
"id": "2",
"metadata": {},
"source": [
"## π οΈ Import Library"
]
},
{
"cell_type": "code",
"execution_count": 2,
"id": "3",
"metadata": {
"execution": {
"iopub.execute_input": "2026-08-18T18:26:46.999617Z",
"iopub.status.busy": "2026-08-18T18:26:46.999422Z",
"iopub.status.idle": "2026-08-18T18:26:49.772617Z",
"shell.execute_reply": "2026-08-18T18:26:49.771888Z"
}
},
"outputs": [],
"source": [
"import easydiffraction as edi"
]
},
{
"cell_type": "markdown",
"id": "4",
"metadata": {},
"source": [
"## π¦ Define Project\n",
"\n",
"The project manages the structure, experiment, analysis, and saved\n",
"results used throughout the tutorial.\n",
"\n",
"### Create Project"
]
},
{
"cell_type": "code",
"execution_count": 3,
"id": "5",
"metadata": {
"execution": {
"iopub.execute_input": "2026-08-18T18:26:49.774962Z",
"iopub.status.busy": "2026-08-18T18:26:49.774640Z",
"iopub.status.idle": "2026-08-18T18:26:50.068800Z",
"shell.execute_reply": "2026-08-18T18:26:50.067995Z"
}
},
"outputs": [],
"source": [
"project = edi.Project(\n",
" name='lmo_echidna',\n",
" description='LMO refinement using ECHIDNA neutron powder diffraction data.',\n",
")"
]
},
{
"cell_type": "markdown",
"id": "6",
"metadata": {},
"source": [
"### Save Initial Project\n",
"\n",
"Create the project directory before fitting so that analysis results\n",
"can be written as they are produced."
]
},
{
"cell_type": "code",
"execution_count": 4,
"id": "7",
"metadata": {
"execution": {
"iopub.execute_input": "2026-08-18T18:26:50.071199Z",
"iopub.status.busy": "2026-08-18T18:26:50.071004Z",
"iopub.status.idle": "2026-08-18T18:26:50.124784Z",
"shell.execute_reply": "2026-08-18T18:26:50.124044Z"
}
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"\u001b[1;36mSaving project π¦ \u001b[0m\u001b[32m'lmo_echidna'\u001b[0m\u001b[1;36m to \u001b[0m\u001b[32m'../../../projects/refine-lmo-echidna'\u001b[0m\n"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"βββ π project.edi\n",
"βββ π structures/\n",
"βββ π experiments/\n",
"βββ π analysis/\n",
"β βββ π analysis.edi\n",
"βββ π reports/\n",
" βββ π lmo_echidna.html\n"
]
}
],
"source": [
"project.save_as(dir_path='projects/refine-lmo-echidna')"
]
},
{
"cell_type": "markdown",
"id": "8",
"metadata": {},
"source": [
"## π§© Define Structure\n",
"\n",
"The rhombohedral LMO model contains two crystallographic cation sites.\n",
"Li1 and Ni1 share the site at z = 1/2, while Li2 and Ni2 share the site\n",
"at z = 0. Their starting occupancies describe a small amount of Li/Ni\n",
"site mixing.\n",
"\n",
"### Create Structure from CIF\n",
"\n",
"Define the complete starting structure in a compact inline CIF. The\n",
"hexagonal setting of space group R-3m is used, with approximate cell\n",
"dimensions and oxygen z coordinate."
]
},
{
"cell_type": "code",
"execution_count": 5,
"id": "9",
"metadata": {
"execution": {
"iopub.execute_input": "2026-08-18T18:26:50.126837Z",
"iopub.status.busy": "2026-08-18T18:26:50.126658Z",
"iopub.status.idle": "2026-08-18T18:26:50.129522Z",
"shell.execute_reply": "2026-08-18T18:26:50.128839Z"
}
},
"outputs": [],
"source": [
"structure_cif = \"\"\"\n",
"data_lmo\n",
"\n",
"_cell.length_a 2.88\n",
"_cell.length_b 2.88\n",
"_cell.length_c 14.18\n",
"_cell.angle_alpha 90.\n",
"_cell.angle_beta 90.\n",
"_cell.angle_gamma 120.\n",
"\n",
"_space_group.name_h_m \"R -3 m\"\n",
"_space_group.coord_system_code h\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",
"O O 0. 0. 0.26 1.0000 0.94645 Biso\n",
"Ni1 Ni 0. 0. 0.5 0.0184 1.00000 Biso\n",
"Li1 Li 0. 0. 0.5 0.9816 1.00000 Biso\n",
"Li2 Li 0. 0. 0.0 0.0184 1.00000 Biso\n",
"Ni2 Ni 0. 0. 0.0 0.9816 1.00000 Biso\n",
"\"\"\""
]
},
{
"cell_type": "code",
"execution_count": 6,
"id": "10",
"metadata": {
"execution": {
"iopub.execute_input": "2026-08-18T18:26:50.131297Z",
"iopub.status.busy": "2026-08-18T18:26:50.131126Z",
"iopub.status.idle": "2026-08-18T18:26:50.140675Z",
"shell.execute_reply": "2026-08-18T18:26:50.139843Z"
}
},
"outputs": [],
"source": [
"project.structures.add_from_cif_str(structure_cif)"
]
},
{
"cell_type": "code",
"execution_count": 7,
"id": "11",
"metadata": {
"execution": {
"iopub.execute_input": "2026-08-18T18:26:50.142282Z",
"iopub.status.busy": "2026-08-18T18:26:50.142091Z",
"iopub.status.idle": "2026-08-18T18:26:50.146920Z",
"shell.execute_reply": "2026-08-18T18:26:50.146159Z"
}
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"\u001b[1;36mDefined structures π§©\u001b[0m\n"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"\u001b[1m[\u001b[0m\u001b[32m'lmo'\u001b[0m\u001b[1m]\u001b[0m\n"
]
}
],
"source": [
"project.structures.show_names()"
]
},
{
"cell_type": "markdown",
"id": "12",
"metadata": {},
"source": [
"Use a short alias to access the structure parameters below."
]
},
{
"cell_type": "code",
"execution_count": 8,
"id": "13",
"metadata": {
"execution": {
"iopub.execute_input": "2026-08-18T18:26:50.148667Z",
"iopub.status.busy": "2026-08-18T18:26:50.148515Z",
"iopub.status.idle": "2026-08-18T18:26:50.151231Z",
"shell.execute_reply": "2026-08-18T18:26:50.150472Z"
}
},
"outputs": [],
"source": [
"structure = project.structures['lmo']"
]
},
{
"cell_type": "markdown",
"id": "14",
"metadata": {},
"source": [
"### Display Structure\n",
"\n",
"Inspect the structure as text and as an interactive crystal model."
]
},
{
"cell_type": "code",
"execution_count": 9,
"id": "15",
"metadata": {
"execution": {
"iopub.execute_input": "2026-08-18T18:26:50.152708Z",
"iopub.status.busy": "2026-08-18T18:26:50.152553Z",
"iopub.status.idle": "2026-08-18T18:26:50.433398Z",
"shell.execute_reply": "2026-08-18T18:26:50.432435Z"
}
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"\u001b[1;36mStructure π§© \u001b[0m\u001b[32m'lmo'\u001b[0m\u001b[1;36m as text\u001b[0m\n"
]
},
{
"data": {
"text/html": [
"
| Edi |
|---|
| 1 | data_lmo |
|---|
| 2 | |
|---|
| 3 | _cell.length_a 2.88 |
|---|
| 4 | _cell.length_b 2.88 |
|---|
| 5 | _cell.length_c 14.18 |
|---|
| 6 | _cell.angle_alpha 90. |
|---|
| 7 | _cell.angle_beta 90. |
|---|
| 8 | _cell.angle_gamma 120. |
|---|
| 9 | |
|---|
| 10 | _space_group.name_h_m "R -3 m" |
|---|
| 11 | _space_group.coord_system_code h |
|---|
| 12 | |
|---|
| 13 | _geom.min_bond_distance_cutoff 0. |
|---|
| 14 | _geom.bond_distance_inc 0.25 |
|---|
| 15 | |
|---|
| 16 | loop_ |
|---|
| 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 |
|---|
| 27 | O O 0. 0. 0.26 c 6 1. 0.94645 Biso |
|---|
| 28 | Ni1 Ni 0. 0. 0.5 b 3 0.0184 1. Biso |
|---|
| 29 | Li1 Li 0. 0. 0.5 b 3 0.9816 1. Biso |
|---|
| 30 | Li2 Li 0. 0. 0. a 3 0.0184 1. Biso |
|---|
| 31 | Ni2 Ni 0. 0. 0. a 3 0.9816 1. Biso |
|---|
"
],
"text/plain": [
""
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"structure.show_as_text()"
]
},
{
"cell_type": "code",
"execution_count": 10,
"id": "16",
"metadata": {
"execution": {
"iopub.execute_input": "2026-08-18T18:26:50.434976Z",
"iopub.status.busy": "2026-08-18T18:26:50.434793Z",
"iopub.status.idle": "2026-08-18T18:26:50.463083Z",
"shell.execute_reply": "2026-08-18T18:26:50.462170Z"
}
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"\u001b[1;36mStructure π§© \u001b[0m\u001b[32m'lmo'\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='lmo')"
]
},
{
"cell_type": "markdown",
"id": "17",
"metadata": {},
"source": [
"## π¬ Define Experiment\n",
"\n",
"Load the measured pattern, choose the calculation engine, configure\n",
"the instrument and peak profile, and link the structure to the data.\n",
"\n",
"### Download Data\n",
"\n",
"Download the LMO pattern from the EasyDiffraction online data\n",
"repository. The columns contain 2-theta, intensity, and the standard\n",
"uncertainty of the measured intensity."
]
},
{
"cell_type": "code",
"execution_count": 11,
"id": "18",
"metadata": {
"execution": {
"iopub.execute_input": "2026-08-18T18:26:50.465087Z",
"iopub.status.busy": "2026-08-18T18:26:50.464917Z",
"iopub.status.idle": "2026-08-18T18:26:50.667569Z",
"shell.execute_reply": "2026-08-18T18:26:50.666688Z"
}
},
"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-lmo-echidna'\u001b[0m: LMO, ECHIDNA \u001b[1m(\u001b[0mANSTO\u001b[1m)\u001b[0m, wavelength \u001b[1;36m1.6215\u001b[0m A\n"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"β
Data \u001b[32m'meas-lmo-echidna'\u001b[0m downloaded to \u001b[32m'../../../data/meas-lmo-echidna.dat'\u001b[0m\n"
]
}
],
"source": [
"data_path = edi.download_data('meas-lmo-echidna', destination='data')"
]
},
{
"cell_type": "markdown",
"id": "19",
"metadata": {},
"source": [
"### Create Experiment"
]
},
{
"cell_type": "code",
"execution_count": 12,
"id": "20",
"metadata": {
"execution": {
"iopub.execute_input": "2026-08-18T18:26:50.669311Z",
"iopub.status.busy": "2026-08-18T18:26:50.669006Z",
"iopub.status.idle": "2026-08-18T18:26:51.200904Z",
"shell.execute_reply": "2026-08-18T18:26:51.200204Z"
}
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"\u001b[1;36mData loaded successfully\u001b[0m\n"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"Experiment π¬ \u001b[32m'echidna'\u001b[0m. Number of data points: \u001b[1;36m3200\u001b[0m.\n"
]
}
],
"source": [
"project.experiments.add_from_data_path(\n",
" name='echidna',\n",
" data_path=data_path,\n",
" sample_form='powder',\n",
" beam_mode='constant wavelength',\n",
" radiation_probe='neutron',\n",
")"
]
},
{
"cell_type": "markdown",
"id": "21",
"metadata": {},
"source": [
"Use a short alias to access the experiment parameters below."
]
},
{
"cell_type": "code",
"execution_count": 13,
"id": "22",
"metadata": {
"execution": {
"iopub.execute_input": "2026-08-18T18:26:51.202766Z",
"iopub.status.busy": "2026-08-18T18:26:51.202601Z",
"iopub.status.idle": "2026-08-18T18:26:51.205149Z",
"shell.execute_reply": "2026-08-18T18:26:51.204532Z"
}
},
"outputs": [],
"source": [
"experiment = project.experiments['echidna']"
]
},
{
"cell_type": "markdown",
"id": "23",
"metadata": {},
"source": [
"### Select Calculator\n",
"\n",
"Use the CrysFML calculation engine for this refinement."
]
},
{
"cell_type": "code",
"execution_count": 14,
"id": "24",
"metadata": {
"execution": {
"iopub.execute_input": "2026-08-18T18:26:51.206860Z",
"iopub.status.busy": "2026-08-18T18:26:51.206701Z",
"iopub.status.idle": "2026-08-18T18:26:51.213276Z",
"shell.execute_reply": "2026-08-18T18:26:51.212418Z"
}
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"\u001b[1;36mCalculator types\u001b[0m\n"
]
},
{
"data": {
"text/html": [
" | | Type | Description |
|---|
| 1 | | crysfml | CrysFML library for crystallographic calculations |
|---|
| 2 | * | cryspy | CrysPy library for crystallographic calculations |
|---|
"
],
"text/plain": [
""
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"experiment.calculator.show_supported()"
]
},
{
"cell_type": "code",
"execution_count": 15,
"id": "25",
"metadata": {
"execution": {
"iopub.execute_input": "2026-08-18T18:26:51.214717Z",
"iopub.status.busy": "2026-08-18T18:26:51.214564Z",
"iopub.status.idle": "2026-08-18T18:26:51.219520Z",
"shell.execute_reply": "2026-08-18T18:26:51.218868Z"
}
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"\u001b[1;36mCalculator for experiment \u001b[0m\u001b[32m'echidna'\u001b[0m\u001b[1;36m changed to\u001b[0m\n"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"crysfml\n"
]
}
],
"source": [
"experiment.calculator.type = 'crysfml'"
]
},
{
"cell_type": "markdown",
"id": "26",
"metadata": {},
"source": [
"### Set Instrument\n",
"\n",
"Set the measured neutron wavelength and approximate calibration\n",
"corrections for the 2-theta zero, sample displacement, and sample\n",
"transparency."
]
},
{
"cell_type": "code",
"execution_count": 16,
"id": "27",
"metadata": {
"execution": {
"iopub.execute_input": "2026-08-18T18:26:51.221400Z",
"iopub.status.busy": "2026-08-18T18:26:51.221219Z",
"iopub.status.idle": "2026-08-18T18:26:51.224849Z",
"shell.execute_reply": "2026-08-18T18:26:51.224108Z"
}
},
"outputs": [],
"source": [
"experiment.instrument.setup_wavelength = 1.6215\n",
"experiment.instrument.calib_twotheta_offset = 0.0\n",
"experiment.instrument.calib_sample_displacement = 0.03\n",
"experiment.instrument.calib_sample_transparency = 0.02"
]
},
{
"cell_type": "markdown",
"id": "28",
"metadata": {},
"source": [
"### Set Peak Profile\n",
"\n",
"Select the Thompson-Cox-Hastings pseudo-Voigt profile. U, V, and W\n",
"define its Gaussian broadening; Y defines its Lorentzian broadening;\n",
"and the Finger-Cox-Jephcoat terms describe the low-angle asymmetry."
]
},
{
"cell_type": "code",
"execution_count": 17,
"id": "29",
"metadata": {
"execution": {
"iopub.execute_input": "2026-08-18T18:26:51.226380Z",
"iopub.status.busy": "2026-08-18T18:26:51.226215Z",
"iopub.status.idle": "2026-08-18T18:26:51.232717Z",
"shell.execute_reply": "2026-08-18T18:26:51.231864Z"
}
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"\u001b[1;36mPeak types\u001b[0m\n"
]
},
{
"data": {
"text/html": [
" | | Type | Description |
|---|
| 1 | * | pseudo-voigt | CWL pseudo-Voigt profile |
|---|
| 2 | | thompson-cox-hastings | CWL Thompson-Cox-Hastings profile with FCJ asymmetry correction. |
|---|
"
],
"text/plain": [
""
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"experiment.peak.show_supported()"
]
},
{
"cell_type": "code",
"execution_count": 18,
"id": "30",
"metadata": {
"execution": {
"iopub.execute_input": "2026-08-18T18:26:51.234184Z",
"iopub.status.busy": "2026-08-18T18:26:51.234030Z",
"iopub.status.idle": "2026-08-18T18:26:51.240441Z",
"shell.execute_reply": "2026-08-18T18:26:51.239834Z"
}
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"β οΈ Switching peak profile type adds these settings with defaults: \n",
" β’ asym_fcj_1=0.0 \n",
" β’ asym_fcj_2=0.0 \n"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"\u001b[1;36mPeak profile type for experiment \u001b[0m\u001b[32m'echidna'\u001b[0m\u001b[1;36m changed to\u001b[0m\n"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"thompson-cox-hastings\n"
]
}
],
"source": [
"experiment.peak.type = 'thompson-cox-hastings'"
]
},
{
"cell_type": "code",
"execution_count": 19,
"id": "31",
"metadata": {
"execution": {
"iopub.execute_input": "2026-08-18T18:26:51.242216Z",
"iopub.status.busy": "2026-08-18T18:26:51.242062Z",
"iopub.status.idle": "2026-08-18T18:26:51.245721Z",
"shell.execute_reply": "2026-08-18T18:26:51.244950Z"
}
},
"outputs": [],
"source": [
"experiment.peak.broad_gauss_u = 0.1\n",
"experiment.peak.broad_gauss_v = -0.3\n",
"experiment.peak.broad_gauss_w = 0.4\n",
"experiment.peak.broad_lorentz_y = 0.1\n",
"experiment.peak.asym_fcj_1 = 0.08\n",
"experiment.peak.asym_fcj_2 = 0.08"
]
},
{
"cell_type": "markdown",
"id": "32",
"metadata": {},
"source": [
"### Set Absorption\n",
"\n",
"Apply the Hewat cylindrical-sample absorption correction with an\n",
"approximate value of the dimensionless absorption-radius product."
]
},
{
"cell_type": "code",
"execution_count": 20,
"id": "33",
"metadata": {
"execution": {
"iopub.execute_input": "2026-08-18T18:26:51.247192Z",
"iopub.status.busy": "2026-08-18T18:26:51.247022Z",
"iopub.status.idle": "2026-08-18T18:26:51.252329Z",
"shell.execute_reply": "2026-08-18T18:26:51.251485Z"
}
},
"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": [
"experiment.absorption.type = 'cylinder-hewat'\n",
"experiment.absorption.mu_r = 0.3"
]
},
{
"cell_type": "markdown",
"id": "34",
"metadata": {},
"source": [
"### Set Excluded Regions\n",
"\n",
"Exclude the low- and high-angle regions outside the useful measured\n",
"range from 12 to 162 degrees."
]
},
{
"cell_type": "code",
"execution_count": 21,
"id": "35",
"metadata": {
"execution": {
"iopub.execute_input": "2026-08-18T18:26:51.253907Z",
"iopub.status.busy": "2026-08-18T18:26:51.253721Z",
"iopub.status.idle": "2026-08-18T18:26:51.257624Z",
"shell.execute_reply": "2026-08-18T18:26:51.256824Z"
}
},
"outputs": [],
"source": [
"experiment.excluded_regions.create(id='1', start=0.0, end=12.0)\n",
"experiment.excluded_regions.create(id='2', start=162.0, end=180.0)"
]
},
{
"cell_type": "markdown",
"id": "36",
"metadata": {},
"source": [
"### Set Background\n",
"\n",
"Estimate initial background points from the measured pattern."
]
},
{
"cell_type": "code",
"execution_count": 22,
"id": "37",
"metadata": {
"execution": {
"iopub.execute_input": "2026-08-18T18:26:51.259218Z",
"iopub.status.busy": "2026-08-18T18:26:51.259047Z",
"iopub.status.idle": "2026-08-18T18:26:51.266001Z",
"shell.execute_reply": "2026-08-18T18:26:51.265254Z"
}
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"\u001b[1;36mBackground types\u001b[0m\n"
]
},
{
"data": {
"text/html": [
" | | Type | Description |
|---|
| 1 | | chebyshev | Chebyshev polynomial background |
|---|
| 2 | * | line-segment | Linear interpolation between points |
|---|
"
],
"text/plain": [
""
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"experiment.background.show_supported()"
]
},
{
"cell_type": "code",
"execution_count": 23,
"id": "38",
"metadata": {
"execution": {
"iopub.execute_input": "2026-08-18T18:26:51.267858Z",
"iopub.status.busy": "2026-08-18T18:26:51.267666Z",
"iopub.status.idle": "2026-08-18T18:26:51.294701Z",
"shell.execute_reply": "2026-08-18T18:26:51.293897Z"
}
},
"outputs": [],
"source": [
"experiment.background.auto_estimate()"
]
},
{
"cell_type": "code",
"execution_count": 24,
"id": "39",
"metadata": {
"execution": {
"iopub.execute_input": "2026-08-18T18:26:51.296915Z",
"iopub.status.busy": "2026-08-18T18:26:51.296716Z",
"iopub.status.idle": "2026-08-18T18:26:51.303880Z",
"shell.execute_reply": "2026-08-18T18:26:51.303113Z"
}
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"\u001b[1;36mLine-segment background points\u001b[0m\n"
]
},
{
"data": {
"text/html": [
" | Position | Intensity |
|---|
| 1 | 12.02420 | 558.74541 |
|---|
| 2 | 20.03970 | 640.62497 |
|---|
| 3 | 32.05130 | 497.74000 |
|---|
| 4 | 39.42070 | 641.87000 |
|---|
| 5 | 58.71960 | 553.94103 |
|---|
| 6 | 93.37010 | 550.51000 |
|---|
| 7 | 149.84400 | 653.58448 |
|---|
| 8 | 161.99680 | 772.38099 |
|---|
"
],
"text/plain": [
""
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"experiment.background.show()"
]
},
{
"cell_type": "markdown",
"id": "40",
"metadata": {},
"source": [
"### Set Linked Structure\n",
"\n",
"Link the LMO model to the experiment and provide an initial estimate\n",
"for its scale factor."
]
},
{
"cell_type": "code",
"execution_count": 25,
"id": "41",
"metadata": {
"execution": {
"iopub.execute_input": "2026-08-18T18:26:51.305487Z",
"iopub.status.busy": "2026-08-18T18:26:51.305281Z",
"iopub.status.idle": "2026-08-18T18:26:51.308835Z",
"shell.execute_reply": "2026-08-18T18:26:51.308145Z"
}
},
"outputs": [],
"source": [
"experiment.linked_structures.create(structure_id='lmo', scale=10.0)"
]
},
{
"cell_type": "markdown",
"id": "42",
"metadata": {},
"source": [
"### Inspect Experiment\n",
"\n",
"Display the configured experiment as text."
]
},
{
"cell_type": "code",
"execution_count": 26,
"id": "43",
"metadata": {
"execution": {
"iopub.execute_input": "2026-08-18T18:26:51.310631Z",
"iopub.status.busy": "2026-08-18T18:26:51.310429Z",
"iopub.status.idle": "2026-08-18T18:26:51.534636Z",
"shell.execute_reply": "2026-08-18T18:26:51.533769Z"
}
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"\u001b[1;36mExperiment π¬ \u001b[0m\u001b[32m'echidna'\u001b[0m\u001b[1;36m as text\u001b[0m\n"
]
},
{
"data": {
"text/html": [
" | Edi |
|---|
| 1 | data_echidna |
|---|
| 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 crysfml |
|---|
| 14 | |
|---|
| 15 | _peak.asym_fcj_1 0.08 |
|---|
| 16 | _peak.asym_fcj_2 0.08 |
|---|
| 17 | _peak.broad_gauss_u 0.1 |
|---|
| 18 | _peak.broad_gauss_v -0.3 |
|---|
| 19 | _peak.broad_gauss_w 0.4 |
|---|
| 20 | _peak.broad_lorentz_x 0. |
|---|
| 21 | _peak.broad_lorentz_y 0.1 |
|---|
| 22 | _peak.cutoff_fwhm 0. |
|---|
| 23 | _peak.type cwl-thompson-cox-hastings |
|---|
| 24 | |
|---|
| 25 | _instrument.setup_wavelength 1.6215 |
|---|
| 26 | _instrument.setup_wavelength_2 0. |
|---|
| 27 | _instrument.setup_wavelength_2_to_1_ratio 0. |
|---|
| 28 | _instrument.calib_twotheta_offset 0. |
|---|
| 29 | _instrument.calib_sample_displacement 0.03 |
|---|
| 30 | _instrument.calib_sample_transparency 0.02 |
|---|
| 31 | |
|---|
| 32 | _absorption.type cylinder-hewat |
|---|
| 33 | _absorption.mu_r 0.3 |
|---|
| 34 | |
|---|
| 35 | loop_ |
|---|
| 36 | _linked_structure.structure_id |
|---|
| 37 | _linked_structure.scale |
|---|
| 38 | lmo 10. |
|---|
| 39 | |
|---|
| 40 | loop_ |
|---|
| 41 | _excluded_region.id |
|---|
| 42 | _excluded_region.start |
|---|
| 43 | _excluded_region.end |
|---|
| 44 | 1 0. 12. |
|---|
| 45 | 2 162. 180. |
|---|
| 46 | |
|---|
| 47 | _background.type line-segment |
|---|
| 48 | |
|---|
| 49 | loop_ |
|---|
| 50 | _background.id |
|---|
| 51 | _background.position |
|---|
| 52 | _background.intensity |
|---|
| 53 | 1 12.0242 558.74540525 |
|---|
| 54 | 2 20.0397 640.62496987 |
|---|
| 55 | 3 32.0513 497.74 |
|---|
| 56 | 4 39.4207 641.87 |
|---|
| 57 | 5 58.7196 553.94102828 |
|---|
| 58 | 6 93.3701 550.51 |
|---|
| 59 | 7 149.844 653.58448376 |
|---|
| 60 | 8 161.9968 772.38098901 |
|---|
| 61 | |
|---|
| 62 | loop_ |
|---|
| 63 | _data.two_theta |
|---|
| 64 | _data.id |
|---|
| 65 | _data.d_spacing |
|---|
| 66 | _data.intensity_meas |
|---|
| 67 | _data.intensity_meas_su |
|---|
| 68 | _data.intensity_calc |
|---|
| 69 | _data.intensity_bkg |
|---|
| 70 | _data.calc_status |
|---|
| 71 | 4.0138 1 0. 73.54 11.06927 0. 0. excl |
|---|
| 72 | 4.0639 2 0. 76.08 11.30158 0. 0. excl |
|---|
| 73 | 4.1139 3 0. 69.48 10.74801 0. 0. excl |
|---|
| 74 | 4.164 4 0. 73.23 11.00793 0. 0. excl |
|---|
| 75 | 4.2139 5 0. 87.95 12.11325 0. 0. excl |
|---|
| 76 | 4.2638 6 0. 103.51 13.09452 0. 0. excl |
|---|
| 77 | 4.3139 7 0. 134.34 14.94499 0. 0. excl |
|---|
| 78 | 4.3639 8 0. 158.84 16.27419 0. 0. excl |
|---|
| 79 | 4.4139 9 0. 157.33 16.2141 0. 0. excl |
|---|
| 80 | 4.4639 10 0. 185.27 17.68956 0. 0. excl |
|---|
| 81 | ... |
|---|
| 82 | 163.4564 3191 0. 1063.71 69.45311 0. 0. excl |
|---|
| 83 | 163.5065 3192 0. 981.95 66.61054 0. 0. excl |
|---|
| 84 | 163.5566 3193 0. 959.97 65.18457 0. 0. excl |
|---|
| 85 | 163.6065 3194 0. 1116.65 71.63894 0. 0. excl |
|---|
| 86 | 163.6565 3195 0. 1014.94 67.92402 0. 0. excl |
|---|
| 87 | 163.7066 3196 0. 1106.06 70.89243 0. 0. excl |
|---|
| 88 | 163.7566 3197 0. 1219.54 75.04669 0. 0. excl |
|---|
| 89 | 163.8065 3198 0. 1272.44 76.11867 0. 0. excl |
|---|
| 90 | 163.8565 3199 0. 1239.6 75.53265 0. 0. excl |
|---|
| 91 | 163.9066 3200 0. 1262.89 76.04648 0. 0. excl |
|---|
"
],
"text/plain": [
""
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"experiment.show_as_text()"
]
},
{
"cell_type": "markdown",
"id": "44",
"metadata": {},
"source": [
"## π Perform Analysis\n",
"\n",
"Inspect the starting calculation, constrain the coupled site-mixing\n",
"parameters, select the independent refinement parameters, and fit the\n",
"model to the measured pattern.\n",
"\n",
"### Display Initial Pattern"
]
},
{
"cell_type": "code",
"execution_count": 27,
"id": "45",
"metadata": {
"execution": {
"iopub.execute_input": "2026-08-18T18:26:51.536384Z",
"iopub.status.busy": "2026-08-18T18:26:51.536229Z",
"iopub.status.idle": "2026-08-18T18:26:51.621911Z",
"shell.execute_reply": "2026-08-18T18:26:51.621088Z"
}
},
"outputs": [
{
"data": {
"text/html": [
""
],
"text/plain": [
""
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"project.display.pattern(expt_name='echidna')"
]
},
{
"cell_type": "markdown",
"id": "46",
"metadata": {},
"source": [
"### Set Constraints\n",
"\n",
"First create readable aliases for the displacement and occupancy\n",
"parameters involved in the constraints."
]
},
{
"cell_type": "code",
"execution_count": 28,
"id": "47",
"metadata": {
"execution": {
"iopub.execute_input": "2026-08-18T18:26:51.626135Z",
"iopub.status.busy": "2026-08-18T18:26:51.625960Z",
"iopub.status.idle": "2026-08-18T18:26:51.631397Z",
"shell.execute_reply": "2026-08-18T18:26:51.630727Z"
}
},
"outputs": [],
"source": [
"project.analysis.aliases.create(\n",
" id='biso_Li1',\n",
" param=structure.atom_sites['Li1'].adp_iso,\n",
")\n",
"project.analysis.aliases.create(\n",
" id='biso_Li2',\n",
" param=structure.atom_sites['Li2'].adp_iso,\n",
")\n",
"project.analysis.aliases.create(\n",
" id='biso_Ni1',\n",
" param=structure.atom_sites['Ni1'].adp_iso,\n",
")\n",
"project.analysis.aliases.create(\n",
" id='biso_Ni2',\n",
" param=structure.atom_sites['Ni2'].adp_iso,\n",
")\n",
"\n",
"project.analysis.aliases.create(\n",
" id='occ_Li1',\n",
" param=structure.atom_sites['Li1'].occupancy,\n",
")\n",
"project.analysis.aliases.create(\n",
" id='occ_Li2',\n",
" param=structure.atom_sites['Li2'].occupancy,\n",
")\n",
"project.analysis.aliases.create(\n",
" id='occ_Ni1',\n",
" param=structure.atom_sites['Ni1'].occupancy,\n",
")\n",
"project.analysis.aliases.create(\n",
" id='occ_Ni2',\n",
" param=structure.atom_sites['Ni2'].occupancy,\n",
")"
]
},
{
"cell_type": "markdown",
"id": "48",
"metadata": {},
"source": [
"Atoms sharing a crystallographic site use the same Biso value. The\n",
"occupancy constraints keep each shared site fully occupied and couple\n",
"the same Li/Ni exchange fraction across both sites. Consequently,\n",
"`occ_Li1` is the only independent occupancy parameter."
]
},
{
"cell_type": "code",
"execution_count": 29,
"id": "49",
"metadata": {
"execution": {
"iopub.execute_input": "2026-08-18T18:26:51.632956Z",
"iopub.status.busy": "2026-08-18T18:26:51.632798Z",
"iopub.status.idle": "2026-08-18T18:26:51.636700Z",
"shell.execute_reply": "2026-08-18T18:26:51.635922Z"
}
},
"outputs": [],
"source": [
"project.analysis.constraints.create(\n",
" id='1',\n",
" expression='biso_Ni1 = biso_Li1',\n",
")\n",
"project.analysis.constraints.create(\n",
" id='2',\n",
" expression='biso_Li2 = biso_Ni2',\n",
")\n",
"project.analysis.constraints.create(\n",
" id='3',\n",
" expression='occ_Ni1 = 1 - occ_Li1',\n",
")\n",
"project.analysis.constraints.create(\n",
" id='4',\n",
" expression='occ_Li2 = 1 - occ_Li1',\n",
")\n",
"project.analysis.constraints.create(\n",
" id='5',\n",
" expression='occ_Ni2 = occ_Li1',\n",
")"
]
},
{
"cell_type": "code",
"execution_count": 30,
"id": "50",
"metadata": {
"execution": {
"iopub.execute_input": "2026-08-18T18:26:51.638181Z",
"iopub.status.busy": "2026-08-18T18:26:51.638026Z",
"iopub.status.idle": "2026-08-18T18:26:51.645091Z",
"shell.execute_reply": "2026-08-18T18:26:51.644287Z"
}
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"\u001b[1;36mUser defined constraints\u001b[0m\n"
]
},
{
"data": {
"text/html": [
" | id | expression |
|---|
| 1 | 1 | biso_Ni1 = biso_Li1 |
|---|
| 2 | 2 | biso_Li2 = biso_Ni2 |
|---|
| 3 | 3 | occ_Ni1 = 1 - occ_Li1 |
|---|
| 4 | 4 | occ_Li2 = 1 - occ_Li1 |
|---|
| 5 | 5 | occ_Ni2 = occ_Li1 |
|---|
"
],
"text/plain": [
""
]
},
"metadata": {},
"output_type": "display_data"
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"Constraints enabled: \u001b[3;92mTrue\u001b[0m\n"
]
}
],
"source": [
"project.analysis.constraints.show()"
]
},
{
"cell_type": "markdown",
"id": "51",
"metadata": {},
"source": [
"### Set Free Parameters\n",
"\n",
"Refine the two independent cell lengths, oxygen z coordinate, the two\n",
"independent cation Biso values, and the independent Li occupancy."
]
},
{
"cell_type": "code",
"execution_count": 31,
"id": "52",
"metadata": {
"execution": {
"iopub.execute_input": "2026-08-18T18:26:51.646552Z",
"iopub.status.busy": "2026-08-18T18:26:51.646365Z",
"iopub.status.idle": "2026-08-18T18:26:51.649832Z",
"shell.execute_reply": "2026-08-18T18:26:51.649160Z"
}
},
"outputs": [],
"source": [
"structure.cell.length_a.free = True\n",
"structure.cell.length_c.free = True\n",
"\n",
"structure.atom_sites['O'].fract_z.free = True\n",
"structure.atom_sites['Li1'].adp_iso.free = True\n",
"structure.atom_sites['Ni2'].adp_iso.free = True\n",
"structure.atom_sites['Li1'].occupancy.free = True"
]
},
{
"cell_type": "markdown",
"id": "53",
"metadata": {},
"source": [
"Refine the scale, instrument calibration terms, U/V/W/Y profile terms,\n",
"and active background-point intensities. The asymmetry and absorption\n",
"parameters remain fixed at their approximate values."
]
},
{
"cell_type": "code",
"execution_count": 32,
"id": "54",
"metadata": {
"execution": {
"iopub.execute_input": "2026-08-18T18:26:51.651308Z",
"iopub.status.busy": "2026-08-18T18:26:51.651140Z",
"iopub.status.idle": "2026-08-18T18:26:51.655447Z",
"shell.execute_reply": "2026-08-18T18:26:51.654724Z"
}
},
"outputs": [],
"source": [
"experiment.linked_structures['lmo'].scale.free = True\n",
"\n",
"experiment.instrument.calib_twotheta_offset.free = True\n",
"experiment.instrument.calib_sample_displacement.free = True\n",
"experiment.instrument.calib_sample_transparency.free = True\n",
"\n",
"experiment.peak.broad_gauss_u.free = True\n",
"experiment.peak.broad_gauss_v.free = True\n",
"experiment.peak.broad_gauss_w.free = True\n",
"experiment.peak.broad_lorentz_y.free = True\n",
"\n",
"for point in experiment.background:\n",
" point.intensity.free = True"
]
},
{
"cell_type": "markdown",
"id": "55",
"metadata": {},
"source": [
"Display all parameters selected for refinement."
]
},
{
"cell_type": "code",
"execution_count": 33,
"id": "56",
"metadata": {
"execution": {
"iopub.execute_input": "2026-08-18T18:26:51.657117Z",
"iopub.status.busy": "2026-08-18T18:26:51.656952Z",
"iopub.status.idle": "2026-08-18T18:26:51.736261Z",
"shell.execute_reply": "2026-08-18T18:26:51.735386Z"
}
},
"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": [
""
],
"text/plain": [
""
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"project.display.parameters.free()"
]
},
{
"cell_type": "markdown",
"id": "57",
"metadata": {},
"source": [
"### Select Minimizer\n",
"\n",
"Use the Levenberg-Marquardt optimizer provided by Bumps."
]
},
{
"cell_type": "code",
"execution_count": 34,
"id": "58",
"metadata": {
"execution": {
"iopub.execute_input": "2026-08-18T18:26:51.738006Z",
"iopub.status.busy": "2026-08-18T18:26:51.737779Z",
"iopub.status.idle": "2026-08-18T18:26:51.746070Z",
"shell.execute_reply": "2026-08-18T18:26:51.745185Z"
}
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"\u001b[1;36mMinimizer types\u001b[0m\n"
]
},
{
"data": {
"text/html": [
" | | Type | Description |
|---|
| 1 | | bumps | BUMPS library using the default Levenberg-Marquardt method |
|---|
| 2 | | bumps (amoeba) | BUMPS library with Nelder-Mead simplex method |
|---|
| 3 | | bumps (de) | BUMPS library with differential evolution method |
|---|
| 4 | | bumps (dream) | BUMPS library with DREAM Bayesian sampling |
|---|
| 5 | | bumps (lm) | BUMPS library with Levenberg-Marquardt method |
|---|
| 6 | | dfols | DFO-LS library for derivative-free least-squares optimization |
|---|
| 7 | | emcee | emcee affine-invariant ensemble Bayesian sampling |
|---|
| 8 | | lmfit | LMFIT library using the default Levenberg-Marquardt method |
|---|
| 9 | | lmfit (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": 35,
"id": "59",
"metadata": {
"execution": {
"iopub.execute_input": "2026-08-18T18:26:51.747750Z",
"iopub.status.busy": "2026-08-18T18:26:51.747540Z",
"iopub.status.idle": "2026-08-18T18:26:51.754204Z",
"shell.execute_reply": "2026-08-18T18:26:51.753518Z"
}
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"\u001b[1;36mCurrent minimizer changed to\u001b[0m\n"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"bumps \u001b[1m(\u001b[0mlm\u001b[1m)\u001b[0m\n"
]
}
],
"source": [
"project.analysis.minimizer.type = 'bumps (lm)'"
]
},
{
"cell_type": "markdown",
"id": "60",
"metadata": {},
"source": [
"### Fit Model"
]
},
{
"cell_type": "code",
"execution_count": 36,
"id": "61",
"metadata": {
"execution": {
"iopub.execute_input": "2026-08-18T18:26:51.755739Z",
"iopub.status.busy": "2026-08-18T18:26:51.755559Z",
"iopub.status.idle": "2026-08-18T18:28:21.628635Z",
"shell.execute_reply": "2026-08-18T18:28:21.625854Z"
}
},
"outputs": [
{
"data": {
"text/html": [],
"text/plain": [
""
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"application/javascript": [
"\n",
"(function() {\n",
" const button = document.getElementById('ed-fit-stop-3e7fca297e284a4b887370ae63119f2e-button');\n",
" const status = document.getElementById('ed-fit-stop-3e7fca297e284a4b887370ae63119f2e-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'echidna'\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": [
" | iteration | time (s) | ΟΒ² | change / status |
|---|
| 1 | 1 | 0.23 | 84.57 | |
|---|
| 2 | 24 | 5.07 | 57.98 | 31.4% β |
|---|
| 3 | 47 | 9.91 | 6.22 | 89.3% β |
|---|
| 4 | 70 | 14.75 | 2.89 | 53.5% β |
|---|
| 5 | 93 | 19.58 | 2.44 | 15.5% β |
|---|
| 6 | 116 | 24.44 | 2.41 | 1.2% β |
|---|
| 7 | 162 | 34.19 | 2.41 | |
|---|
| 8 | 208 | 44.88 | 2.41 | |
|---|
| 9 | 232 | 53.22 | 2.41 | |
|---|
| 10 | 255 | 60.96 | 2.41 | |
|---|
| 11 | 278 | 67.79 | 2.41 | |
|---|
| 12 | 302 | 73.11 | 2.41 | |
|---|
| 13 | 328 | 89.80 | 2.41 | |
|---|
"
],
"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;36m2.41\u001b[0m at iteration \u001b[1;36m302\u001b[0m\n"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"β
Fitting complete.\n"
]
}
],
"source": [
"project.analysis.fit()"
]
},
{
"cell_type": "markdown",
"id": "62",
"metadata": {},
"source": [
"### Inspect Results\n",
"\n",
"Review the fit statistics, refined parameters, and parameter\n",
"correlations, then compare the refined calculation with the data."
]
},
{
"cell_type": "code",
"execution_count": 37,
"id": "63",
"metadata": {
"execution": {
"iopub.execute_input": "2026-08-18T18:28:21.630600Z",
"iopub.status.busy": "2026-08-18T18:28:21.630405Z",
"iopub.status.idle": "2026-08-18T18:28:21.946671Z",
"shell.execute_reply": "2026-08-18T18:28:21.945843Z"
}
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"βοΈ Settings used:\n"
]
},
{
"data": {
"text/html": [
" | Name | Value | Description |
|---|
| 1 | max_iterations | 1000 | Maximum solver iterations. |
|---|
"
],
"text/plain": [
""
]
},
"metadata": {},
"output_type": "display_data"
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"π Least-squares fit results:\n"
]
},
{
"data": {
"text/html": [
" | Metric | Value |
|---|
| 1 | π§ͺ Minimizer | bumps (lm) |
|---|
| 2 | β
Overall status | success |
|---|
| 3 | β±οΈ Fitting time (seconds) | 89.80 |
|---|
| 4 | π Goodness-of-fit (reduced ΟΒ²) | 2.41 |
|---|
| 5 | π R-factor (Rf, %) | 3.94 |
|---|
| 6 | π R-factor squared (RfΒ², %) | 4.50 |
|---|
| 7 | π Weighted R-factor (wR, %) | 4.29 |
|---|
"
],
"text/plain": [
""
]
},
"metadata": {},
"output_type": "display_data"
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"π Refined parameters:\n"
]
},
{
"data": {
"text/html": [
" | datablock | category | entry | parameter | units | start | value | s.u. | change |
|---|
| 1 | lmo | cell | | length_a | Γ
| 2.8800 | 2.8752 | 0.0001 | 0.17 % β |
|---|
| 2 | lmo | cell | | length_c | Γ
| 14.1800 | 14.1835 | 0.0004 | 0.02 % β |
|---|
| 3 | lmo | atom_site | O | fract_z | | 0.2600 | 0.2591 | 0.0001 | 0.36 % β |
|---|
| 4 | lmo | atom_site | Li1 | occupancy | | 0.9816 | 0.9804 | 0.0018 | 0.12 % β |
|---|
| 5 | lmo | atom_site | Li1 | adp_iso | Γ
Β² | 1.0000 | 1.9540 | 0.1093 | 95.40 % β |
|---|
| 6 | lmo | atom_site | Ni2 | adp_iso | Γ
Β² | 1.0000 | 0.2274 | 0.0118 | 77.26 % β |
|---|
| 7 | echidna | linked_structure | lmo | scale | | 10.0000 | 15.9990 | 0.0841 | 59.99 % β |
|---|
| 8 | echidna | peak | | broad_gauss_u | degΒ² | 0.1000 | 0.0972 | 0.0023 | 2.84 % β |
|---|
| 9 | echidna | peak | | broad_gauss_v | degΒ² | -0.3000 | -0.2842 | 0.0066 | 5.26 % β |
|---|
| 10 | echidna | peak | | broad_gauss_w | degΒ² | 0.4000 | 0.4036 | 0.0052 | 0.91 % β |
|---|
| 11 | echidna | peak | | broad_lorentz_y | deg | 0.1000 | 0.0806 | 0.0021 | 19.35 % β |
|---|
| 12 | echidna | instrument | | twotheta_offset | deg | 0.0000 | -0.0640 | 0.0072 | N/A |
|---|
| 13 | echidna | instrument | | sample_displacement | deg | 0.0300 | 0.0270 | 0.0042 | 10.07 % β |
|---|
| 14 | echidna | instrument | | sample_transparency | deg | 0.0200 | 0.0176 | 0.0054 | 12.24 % β |
|---|
| 15 | echidna | background | 1 | intensity | | 558.7454 | 548.6774 | 5.5305 | 1.80 % β |
|---|
| 16 | echidna | background | 2 | intensity | | 640.6250 | 564.8788 | 4.4804 | 11.82 % β |
|---|
| 17 | echidna | background | 3 | intensity | | 497.7400 | 528.5260 | 3.8135 | 6.19 % β |
|---|
| 18 | echidna | background | 4 | intensity | | 641.8700 | 584.0418 | 3.5967 | 9.01 % β |
|---|
| 19 | echidna | background | 5 | intensity | | 553.9410 | 568.5889 | 2.4646 | 2.64 % β |
|---|
| 20 | echidna | background | 6 | intensity | | 550.5100 | 574.2245 | 1.9936 | 4.31 % β |
|---|
| 21 | echidna | background | 7 | intensity | | 653.5845 | 644.2330 | 2.7590 | 1.43 % β |
|---|
| 22 | echidna | background | 8 | intensity | | 772.3810 | 631.4711 | 6.2037 | 18.24 % β |
|---|
"
],
"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": "code",
"execution_count": 38,
"id": "64",
"metadata": {
"execution": {
"iopub.execute_input": "2026-08-18T18:28:21.948475Z",
"iopub.status.busy": "2026-08-18T18:28:21.948270Z",
"iopub.status.idle": "2026-08-18T18:28:21.972539Z",
"shell.execute_reply": "2026-08-18T18:28:21.971749Z"
}
},
"outputs": [
{
"data": {
"text/html": [
"\n",
"\n",
""
],
"text/plain": [
""
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"project.display.fit.correlations()"
]
},
{
"cell_type": "code",
"execution_count": 39,
"id": "65",
"metadata": {
"execution": {
"iopub.execute_input": "2026-08-18T18:28:21.974007Z",
"iopub.status.busy": "2026-08-18T18:28:21.973841Z",
"iopub.status.idle": "2026-08-18T18:28:22.087491Z",
"shell.execute_reply": "2026-08-18T18:28:22.083210Z"
}
},
"outputs": [
{
"data": {
"text/html": [
""
],
"text/plain": [
""
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"project.display.pattern(expt_name='echidna')"
]
},
{
"cell_type": "markdown",
"id": "66",
"metadata": {},
"source": [
"## πΎ Save Project\n",
"\n",
"Save the refined parameters and analysis results in the project\n",
"directory created near the beginning of the tutorial."
]
},
{
"cell_type": "code",
"execution_count": 40,
"id": "67",
"metadata": {
"execution": {
"iopub.execute_input": "2026-08-18T18:28:22.098570Z",
"iopub.status.busy": "2026-08-18T18:28:22.098343Z",
"iopub.status.idle": "2026-08-18T18:28:22.445248Z",
"shell.execute_reply": "2026-08-18T18:28:22.444483Z"
}
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"\u001b[1;36mSaving project π¦ \u001b[0m\u001b[32m'lmo_echidna'\u001b[0m\u001b[1;36m to \u001b[0m\u001b[32m'../../../projects/refine-lmo-echidna'\u001b[0m\n"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"βββ π project.edi\n",
"βββ π structures/\n",
"β βββ π lmo.edi\n",
"βββ π experiments/\n",
"β βββ π echidna.edi\n",
"βββ π analysis/\n",
"β βββ π analysis.edi\n",
"βββ π reports/\n",
" βββ π lmo_echidna.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
}