{
"cells": [
{
"cell_type": "code",
"execution_count": 1,
"id": "0",
"metadata": {
"execution": {
"iopub.execute_input": "2026-06-30T22:39:04.620508Z",
"iopub.status.busy": "2026-06-30T22:39:04.620317Z",
"iopub.status.idle": "2026-06-30T22:39:04.624601Z",
"shell.execute_reply": "2026-06-30T22:39:04.623776Z"
},
"tags": [
"hide-in-docs"
]
},
"outputs": [],
"source": [
"# Check whether easydiffraction is installed; install it if needed.\n",
"# Required for remote environments such as Google Colab.\n",
"import importlib.util\n",
"\n",
"if importlib.util.find_spec('easydiffraction') is None:\n",
" %pip install easydiffraction==0.19.1"
]
},
{
"cell_type": "markdown",
"id": "1",
"metadata": {},
"source": [
"# Structure Refinement: Tb2TiO7, HEiDi\n",
"\n",
"Crystal structure refinement of Tb2TiO7 using single crystal neutron\n",
"diffraction data from HEiDi at FRM II."
]
},
{
"cell_type": "markdown",
"id": "2",
"metadata": {},
"source": [
"## π οΈ Import Library"
]
},
{
"cell_type": "code",
"execution_count": 2,
"id": "3",
"metadata": {
"execution": {
"iopub.execute_input": "2026-06-30T22:39:04.625931Z",
"iopub.status.busy": "2026-06-30T22:39:04.625784Z",
"iopub.status.idle": "2026-06-30T22:39:07.510724Z",
"shell.execute_reply": "2026-06-30T22:39:07.509688Z"
}
},
"outputs": [],
"source": [
"import easydiffraction as edi"
]
},
{
"cell_type": "markdown",
"id": "4",
"metadata": {},
"source": [
"## π¦ Define Project"
]
},
{
"cell_type": "code",
"execution_count": 3,
"id": "5",
"metadata": {
"execution": {
"iopub.execute_input": "2026-06-30T22:39:07.512545Z",
"iopub.status.busy": "2026-06-30T22:39:07.512257Z",
"iopub.status.idle": "2026-06-30T22:39:07.782364Z",
"shell.execute_reply": "2026-06-30T22:39:07.781458Z"
}
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"\u001b[1;36mSaving project π¦ \u001b[0m\u001b[32m'tbti_heidi'\u001b[0m\u001b[1;36m to \u001b[0m\u001b[32m'../../../projects/refine-tbti-heidi'\u001b[0m\n"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"βββ π project.edi\n"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"βββ π structures/\n"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"βββ π experiments/\n"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"βββ π analysis/\n"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"β βββ π analysis.edi\n"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"βββ π reports/\n"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
" βββ π tbti_heidi.html\n"
]
}
],
"source": [
"# Create a minimal project with a short name\n",
"project = edi.Project(name='tbti_heidi')\n",
"project.metadata.title = 'Tb2Ti2O7 at HEiDi@FRMII'\n",
"project.metadata.description = \"\"\"This project demonstrates a standard\n",
"refinement of the crystal structure of Tb2Ti2O7 using single crystal \n",
"neutron diffraction data from HEiDi at FRM II.\"\"\"\n",
"\n",
"project.save_as(dir_path='projects/refine-tbti-heidi')"
]
},
{
"cell_type": "markdown",
"id": "6",
"metadata": {},
"source": [
"## π§© Define Structure"
]
},
{
"cell_type": "code",
"execution_count": 4,
"id": "7",
"metadata": {
"execution": {
"iopub.execute_input": "2026-06-30T22:39:07.783885Z",
"iopub.status.busy": "2026-06-30T22:39:07.783729Z",
"iopub.status.idle": "2026-06-30T22:39:07.932593Z",
"shell.execute_reply": "2026-06-30T22:39:07.931921Z"
}
},
"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'struct-tbti'\u001b[0m: Tb2Ti2O7 \u001b[1m(\u001b[0mcrystal structure\u001b[1m)\u001b[0m\n"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"β
Data \u001b[32m'struct-tbti'\u001b[0m downloaded to \u001b[32m'../../../data/struct-tbti.cif'\u001b[0m\n"
]
}
],
"source": [
"# Download CIF file from repository\n",
"structure_path = edi.download_data('struct-tbti', destination='data')"
]
},
{
"cell_type": "code",
"execution_count": 5,
"id": "8",
"metadata": {
"execution": {
"iopub.execute_input": "2026-06-30T22:39:07.938129Z",
"iopub.status.busy": "2026-06-30T22:39:07.937868Z",
"iopub.status.idle": "2026-06-30T22:39:07.964218Z",
"shell.execute_reply": "2026-06-30T22:39:07.962921Z"
}
},
"outputs": [],
"source": [
"project.structures.add_from_cif_path(structure_path)"
]
},
{
"cell_type": "code",
"execution_count": 6,
"id": "9",
"metadata": {
"execution": {
"iopub.execute_input": "2026-06-30T22:39:07.966523Z",
"iopub.status.busy": "2026-06-30T22:39:07.965811Z",
"iopub.status.idle": "2026-06-30T22:39:07.976491Z",
"shell.execute_reply": "2026-06-30T22:39:07.975512Z"
}
},
"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'tbti'\u001b[0m\u001b[1m]\u001b[0m\n"
]
}
],
"source": [
"project.structures.show_names()"
]
},
{
"cell_type": "code",
"execution_count": 7,
"id": "10",
"metadata": {
"execution": {
"iopub.execute_input": "2026-06-30T22:39:07.978145Z",
"iopub.status.busy": "2026-06-30T22:39:07.977943Z",
"iopub.status.idle": "2026-06-30T22:39:07.983322Z",
"shell.execute_reply": "2026-06-30T22:39:07.982874Z"
}
},
"outputs": [],
"source": [
"structure = project.structures['tbti']"
]
},
{
"cell_type": "code",
"execution_count": 8,
"id": "11",
"metadata": {
"execution": {
"iopub.execute_input": "2026-06-30T22:39:07.985446Z",
"iopub.status.busy": "2026-06-30T22:39:07.985158Z",
"iopub.status.idle": "2026-06-30T22:39:08.056746Z",
"shell.execute_reply": "2026-06-30T22:39:08.055518Z"
}
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"\u001b[1;36mStructure π§© \u001b[0m\u001b[32m'tbti'\u001b[0m\u001b[1;36m as text\u001b[0m\n"
]
},
{
"data": {
"text/html": [
"
| Edi |
|---|
| 1 | data_tbti |
|---|
| 2 | |
|---|
| 3 | _cell.length_a 10.13 |
|---|
| 4 | _cell.length_b 10.13 |
|---|
| 5 | _cell.length_c 10.13 |
|---|
| 6 | _cell.angle_alpha 90. |
|---|
| 7 | _cell.angle_beta 90. |
|---|
| 8 | _cell.angle_gamma 90. |
|---|
| 9 | |
|---|
| 10 | _space_group.name_h_m "F d -3 m" |
|---|
| 11 | _space_group.coord_system_code 2 |
|---|
| 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 | Tb Tb 0.5 0.5 0.5 d 16 1. 0.530(20) Biso |
|---|
| 28 | Ti Ti 0. 0. 0. c 16 1. 0.480(30) Biso |
|---|
| 29 | O1 O 0.328040(90) 0.125 0.125 f 48 1.000(10) 0.450(20) Biso |
|---|
| 30 | O2 O 0.375 0.375 0.375 b 8 0.970(20) 0.230(40) Biso |
|---|
"
],
"text/plain": [
""
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"structure.show_as_text()"
]
},
{
"cell_type": "code",
"execution_count": 9,
"id": "12",
"metadata": {
"execution": {
"iopub.execute_input": "2026-06-30T22:39:08.058668Z",
"iopub.status.busy": "2026-06-30T22:39:08.058452Z",
"iopub.status.idle": "2026-06-30T22:39:08.063126Z",
"shell.execute_reply": "2026-06-30T22:39:08.062240Z"
}
},
"outputs": [],
"source": [
"structure.atom_sites['Tb'].adp_type = 'Uiso'\n",
"structure.atom_sites['Ti'].adp_type = 'Uiso'\n",
"structure.atom_sites['O1'].adp_type = 'Uiso'\n",
"structure.atom_sites['O2'].adp_type = 'Uiso'"
]
},
{
"cell_type": "code",
"execution_count": 10,
"id": "13",
"metadata": {
"execution": {
"iopub.execute_input": "2026-06-30T22:39:08.065507Z",
"iopub.status.busy": "2026-06-30T22:39:08.065283Z",
"iopub.status.idle": "2026-06-30T22:39:08.069981Z",
"shell.execute_reply": "2026-06-30T22:39:08.069112Z"
}
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"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.wyckoff_letter\n",
"_atom_site.multiplicity\n",
"_atom_site.occupancy\n",
"_atom_site.adp_iso\n",
"_atom_site.adp_type\n",
"Tb Tb 0.5 0.5 0.5 d 16 1. 0.007(20) Uiso\n",
"Ti Ti 0. 0. 0. c 16 1. 0.006(30) Uiso\n",
"O1 O 0.328040(90) 0.125 0.125 f 48 1.000(10) 0.006(20) Uiso\n",
"O2 O 0.375 0.375 0.375 b 8 0.970(20) 0.003(40) Uiso\n"
]
}
],
"source": [
"print(structure.atom_sites.as_cif)"
]
},
{
"cell_type": "code",
"execution_count": 11,
"id": "14",
"metadata": {
"execution": {
"iopub.execute_input": "2026-06-30T22:39:08.071973Z",
"iopub.status.busy": "2026-06-30T22:39:08.071771Z",
"iopub.status.idle": "2026-06-30T22:39:08.077317Z",
"shell.execute_reply": "2026-06-30T22:39:08.075922Z"
}
},
"outputs": [],
"source": [
"structure.atom_sites['Tb'].adp_iso = 0.0\n",
"structure.atom_sites['Ti'].adp_iso = 0.0\n",
"structure.atom_sites['O1'].adp_iso = 0.0\n",
"structure.atom_sites['O2'].adp_iso = 0.0"
]
},
{
"cell_type": "markdown",
"id": "15",
"metadata": {},
"source": [
"### Display Structure (ADP)\n",
"\n",
"Select the ADP atom view. With the starting isotropic displacements every\n",
"atom is drawn as a sphere; after the anisotropic refinement below, the same\n",
"view will draw probability ellipsoids for the anisotropic sites."
]
},
{
"cell_type": "code",
"execution_count": 12,
"id": "16",
"metadata": {
"execution": {
"iopub.execute_input": "2026-06-30T22:39:08.078854Z",
"iopub.status.busy": "2026-06-30T22:39:08.078687Z",
"iopub.status.idle": "2026-06-30T22:39:08.081986Z",
"shell.execute_reply": "2026-06-30T22:39:08.081241Z"
}
},
"outputs": [],
"source": [
"project.structure_style.atom_view = 'adp'"
]
},
{
"cell_type": "code",
"execution_count": 13,
"id": "17",
"metadata": {
"execution": {
"iopub.execute_input": "2026-06-30T22:39:08.083474Z",
"iopub.status.busy": "2026-06-30T22:39:08.083324Z",
"iopub.status.idle": "2026-06-30T22:39:08.199609Z",
"shell.execute_reply": "2026-06-30T22:39:08.199119Z"
}
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"\u001b[1;36mStructure π§© \u001b[0m\u001b[32m'tbti'\u001b[0m\u001b[1;36m \u001b[0m\u001b[1;36m(\u001b[0m\u001b[1;36mAtom view type: \u001b[0m\u001b[32m'adp'\u001b[0m\u001b[1;36m)\u001b[0m\n"
]
},
{
"data": {
"text/html": [
"\n",
"
\n",
"
Loading plotβ¦
\n",
"
\n",
"
\n",
"
\n",
"
drag = rotate
wheel = zoom
right-drag = pan
\n",
"
\n",
"
\n",
"\n",
"\n",
"\n",
""
],
"text/plain": [
""
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"project.display.structure(struct_name='tbti')"
]
},
{
"cell_type": "markdown",
"id": "18",
"metadata": {},
"source": [
"## π¬ Define Experiment"
]
},
{
"cell_type": "code",
"execution_count": 14,
"id": "19",
"metadata": {
"execution": {
"iopub.execute_input": "2026-06-30T22:39:08.202208Z",
"iopub.status.busy": "2026-06-30T22:39:08.202021Z",
"iopub.status.idle": "2026-06-30T22:39:08.322209Z",
"shell.execute_reply": "2026-06-30T22:39:08.321254Z"
}
},
"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-tbti-heidi'\u001b[0m: Tb2Ti2O7, HEiDi \u001b[1m(\u001b[0mMLZ\u001b[1m)\u001b[0m\n"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"β
Data \u001b[32m'meas-tbti-heidi'\u001b[0m downloaded to \u001b[32m'../../../data/meas-tbti-heidi.xye'\u001b[0m\n"
]
}
],
"source": [
"# Download data file from repository\n",
"data_path = edi.download_data('meas-tbti-heidi', destination='data')"
]
},
{
"cell_type": "code",
"execution_count": 15,
"id": "20",
"metadata": {
"execution": {
"iopub.execute_input": "2026-06-30T22:39:08.323977Z",
"iopub.status.busy": "2026-06-30T22:39:08.323753Z",
"iopub.status.idle": "2026-06-30T22:39:08.446994Z",
"shell.execute_reply": "2026-06-30T22:39:08.446290Z"
}
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"\u001b[1;36mData loaded successfully\u001b[0m\n"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"Experiment π¬ \u001b[32m'heidi'\u001b[0m. Number of data points: \u001b[1;36m220\u001b[0m.\n"
]
}
],
"source": [
"project.experiments.add_from_data_path(\n",
" name='heidi',\n",
" data_path=data_path,\n",
" sample_form='single crystal',\n",
" beam_mode='constant wavelength',\n",
" radiation_probe='neutron',\n",
")"
]
},
{
"cell_type": "code",
"execution_count": 16,
"id": "21",
"metadata": {
"execution": {
"iopub.execute_input": "2026-06-30T22:39:08.448629Z",
"iopub.status.busy": "2026-06-30T22:39:08.448467Z",
"iopub.status.idle": "2026-06-30T22:39:08.451052Z",
"shell.execute_reply": "2026-06-30T22:39:08.450425Z"
}
},
"outputs": [],
"source": [
"experiment = project.experiments['heidi']"
]
},
{
"cell_type": "code",
"execution_count": 17,
"id": "22",
"metadata": {
"execution": {
"iopub.execute_input": "2026-06-30T22:39:08.452479Z",
"iopub.status.busy": "2026-06-30T22:39:08.452329Z",
"iopub.status.idle": "2026-06-30T22:39:08.455087Z",
"shell.execute_reply": "2026-06-30T22:39:08.454425Z"
}
},
"outputs": [],
"source": [
"experiment.linked_structure.structure_id = 'tbti'\n",
"experiment.linked_structure.scale = 1.0"
]
},
{
"cell_type": "code",
"execution_count": 18,
"id": "23",
"metadata": {
"execution": {
"iopub.execute_input": "2026-06-30T22:39:08.456476Z",
"iopub.status.busy": "2026-06-30T22:39:08.456333Z",
"iopub.status.idle": "2026-06-30T22:39:08.458964Z",
"shell.execute_reply": "2026-06-30T22:39:08.458321Z"
}
},
"outputs": [],
"source": [
"experiment.instrument.setup_wavelength = 0.793"
]
},
{
"cell_type": "code",
"execution_count": 19,
"id": "24",
"metadata": {
"execution": {
"iopub.execute_input": "2026-06-30T22:39:08.460355Z",
"iopub.status.busy": "2026-06-30T22:39:08.460206Z",
"iopub.status.idle": "2026-06-30T22:39:08.462965Z",
"shell.execute_reply": "2026-06-30T22:39:08.462316Z"
}
},
"outputs": [],
"source": [
"experiment.extinction.mosaicity = 35000\n",
"experiment.extinction.radius = 10"
]
},
{
"cell_type": "markdown",
"id": "25",
"metadata": {},
"source": [
"## π Perform Analysis"
]
},
{
"cell_type": "markdown",
"id": "26",
"metadata": {},
"source": [
"### ADP iso"
]
},
{
"cell_type": "code",
"execution_count": 20,
"id": "27",
"metadata": {
"execution": {
"iopub.execute_input": "2026-06-30T22:39:08.464314Z",
"iopub.status.busy": "2026-06-30T22:39:08.464172Z",
"iopub.status.idle": "2026-06-30T22:39:08.759861Z",
"shell.execute_reply": "2026-06-30T22:39:08.758961Z"
}
},
"outputs": [
{
"data": {
"text/html": [
""
],
"text/plain": [
""
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"project.display.pattern(expt_name='heidi')"
]
},
{
"cell_type": "code",
"execution_count": 21,
"id": "28",
"metadata": {
"execution": {
"iopub.execute_input": "2026-06-30T22:39:08.761483Z",
"iopub.status.busy": "2026-06-30T22:39:08.761323Z",
"iopub.status.idle": "2026-06-30T22:39:08.764892Z",
"shell.execute_reply": "2026-06-30T22:39:08.764206Z"
}
},
"outputs": [],
"source": [
"structure.atom_sites['O1'].fract_x.free = True\n",
"\n",
"structure.atom_sites['Ti'].occupancy.free = True\n",
"structure.atom_sites['O1'].occupancy.free = True\n",
"structure.atom_sites['O2'].occupancy.free = True\n",
"\n",
"structure.atom_sites['Tb'].adp_iso.free = True\n",
"structure.atom_sites['Ti'].adp_iso.free = True\n",
"structure.atom_sites['O1'].adp_iso.free = True\n",
"structure.atom_sites['O2'].adp_iso.free = True"
]
},
{
"cell_type": "code",
"execution_count": 22,
"id": "29",
"metadata": {
"execution": {
"iopub.execute_input": "2026-06-30T22:39:08.766560Z",
"iopub.status.busy": "2026-06-30T22:39:08.766392Z",
"iopub.status.idle": "2026-06-30T22:39:08.769763Z",
"shell.execute_reply": "2026-06-30T22:39:08.769007Z"
}
},
"outputs": [],
"source": [
"experiment.linked_structure.scale.free = True\n",
"experiment.extinction.radius.free = True"
]
},
{
"cell_type": "code",
"execution_count": 23,
"id": "30",
"metadata": {
"execution": {
"iopub.execute_input": "2026-06-30T22:39:08.771388Z",
"iopub.status.busy": "2026-06-30T22:39:08.771230Z",
"iopub.status.idle": "2026-06-30T22:39:09.915406Z",
"shell.execute_reply": "2026-06-30T22:39:09.914403Z"
}
},
"outputs": [
{
"data": {
"text/html": [],
"text/plain": [
""
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"application/javascript": [
"\n",
"(function() {\n",
" const button = document.getElementById('ed-fit-stop-d50be21371004f919fc054a62aa6ba08-button');\n",
" const status = document.getElementById('ed-fit-stop-d50be21371004f919fc054a62aa6ba08-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'heidi'\u001b[0m for \u001b[32m'single'\u001b[0m fitting\n"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"π Starting fit process with \u001b[32m'lmfit \u001b[0m\u001b[32m(\u001b[0m\u001b[32mleastsq\u001b[0m\u001b[32m)\u001b[0m\u001b[32m'\u001b[0m\u001b[33m...\u001b[0m\n"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"π Goodness-of-fit progress:\n"
]
},
{
"data": {
"text/html": [
" | iteration | time (s) | ΟΒ² | change / status |
|---|
| 1 | 1 | 0.01 | 355.79 | |
|---|
| 2 | 14 | 0.14 | 186.41 | 47.6% β |
|---|
| 3 | 25 | 0.25 | 42.28 | 77.3% β |
|---|
| 4 | 36 | 0.35 | 12.97 | 69.3% β |
|---|
| 5 | 47 | 0.45 | 12.75 | 1.6% β |
|---|
| 6 | 81 | 0.78 | 12.75 | |
|---|
"
],
"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;36m12.75\u001b[0m at iteration \u001b[1;36m80\u001b[0m\n"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"β
Fitting complete.\n"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"\u001b[1;36mSaving project π¦ \u001b[0m\u001b[32m'tbti_heidi'\u001b[0m\u001b[1;36m to \u001b[0m\u001b[32m'../../../projects/refine-tbti-heidi'\u001b[0m\n"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"βββ π project.edi\n"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"βββ π structures/\n"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"β βββ π tbti.edi\n"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"βββ π experiments/\n"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"β βββ π heidi.edi\n"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"βββ π analysis/\n"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"β βββ π analysis.edi\n"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"βββ π reports/\n"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
" βββ π tbti_heidi.html\n"
]
}
],
"source": [
"# Start refinement. All parameters, which have standard uncertainties\n",
"# in the input CIF files, are refined by default.\n",
"project.analysis.fit()"
]
},
{
"cell_type": "code",
"execution_count": 24,
"id": "31",
"metadata": {
"execution": {
"iopub.execute_input": "2026-06-30T22:39:09.917340Z",
"iopub.status.busy": "2026-06-30T22:39:09.916981Z",
"iopub.status.idle": "2026-06-30T22:39:10.218623Z",
"shell.execute_reply": "2026-06-30T22:39:10.217763Z"
}
},
"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 | lmfit (leastsq) |
|---|
| 2 | β
Overall status | success |
|---|
| 3 | β±οΈ Fitting time (seconds) | 0.78 |
|---|
| 4 | π Iterations | 78 |
|---|
| 5 | π Goodness-of-fit (reduced ΟΒ²) | 12.75 |
|---|
| 6 | π R-factor (Rf, %) | 7.65 |
|---|
| 7 | π R-factor squared (RfΒ², %) | 8.10 |
|---|
| 8 | π Weighted R-factor (wR, %) | 8.59 |
|---|
"
],
"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 | tbti | atom_site | Tb | adp_iso | Γ
Β² | 0.0000 | 0.0068 | 0.0003 | N/A |
|---|
| 2 | tbti | atom_site | Ti | occupancy | | 1.0000 | 0.9730 | 0.0178 | 2.70 % β |
|---|
| 3 | tbti | atom_site | Ti | adp_iso | Γ
Β² | 0.0000 | 0.0054 | 0.0006 | N/A |
|---|
| 4 | tbti | atom_site | O1 | fract_x | | 0.3280 | 0.3280 | 0.0001 | 0.00 % β |
|---|
| 5 | tbti | atom_site | O1 | occupancy | | 1.0000 | 0.9989 | 0.0104 | 0.11 % β |
|---|
| 6 | tbti | atom_site | O1 | adp_iso | Γ
Β² | 0.0000 | 0.0057 | 0.0002 | N/A |
|---|
| 7 | tbti | atom_site | O2 | occupancy | | 0.9700 | 0.9688 | 0.0183 | 0.12 % β |
|---|
| 8 | tbti | atom_site | O2 | adp_iso | Γ
Β² | 0.0000 | 0.0030 | 0.0005 | N/A |
|---|
| 9 | heidi | extinction | | radius | ΞΌm | 10.0000 | 26.4348 | 1.0122 | 164.35 % β |
|---|
| 10 | heidi | linked_structure | | scale | | 1.0000 | 2.9329 | 0.0586 | 193.29 % β |
|---|
"
],
"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": [
"# Show fit results summary\n",
"project.display.fit.results()"
]
},
{
"cell_type": "code",
"execution_count": 25,
"id": "32",
"metadata": {
"execution": {
"iopub.execute_input": "2026-06-30T22:39:10.220283Z",
"iopub.status.busy": "2026-06-30T22:39:10.220040Z",
"iopub.status.idle": "2026-06-30T22:39:10.229865Z",
"shell.execute_reply": "2026-06-30T22:39:10.229062Z"
}
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"\u001b[1;36mStructure π§© \u001b[0m\u001b[32m'tbti'\u001b[0m\u001b[1;36m as text\u001b[0m\n"
]
},
{
"data": {
"text/html": [
" | Edi |
|---|
| 1 | data_tbti |
|---|
| 2 | |
|---|
| 3 | _cell.length_a 10.13 |
|---|
| 4 | _cell.length_b 10.13 |
|---|
| 5 | _cell.length_c 10.13 |
|---|
| 6 | _cell.angle_alpha 90. |
|---|
| 7 | _cell.angle_beta 90. |
|---|
| 8 | _cell.angle_gamma 90. |
|---|
| 9 | |
|---|
| 10 | _space_group.name_h_m "F d -3 m" |
|---|
| 11 | _space_group.coord_system_code 2 |
|---|
| 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 | Tb Tb 0.5 0.5 0.5 d 16 1. 0.00682(29) Uiso |
|---|
| 28 | Ti Ti 0. 0. 0. c 16 0.973(18) 0.00540(60) Uiso |
|---|
| 29 | O1 O 0.328044(94) 0.125 0.125 f 48 0.999(10) 0.00573(25) Uiso |
|---|
| 30 | O2 O 0.375 0.375 0.375 b 8 0.969(18) 0.00303(48) Uiso |
|---|
"
],
"text/plain": [
""
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"structure.show_as_text()"
]
},
{
"cell_type": "code",
"execution_count": 26,
"id": "33",
"metadata": {
"execution": {
"iopub.execute_input": "2026-06-30T22:39:10.231390Z",
"iopub.status.busy": "2026-06-30T22:39:10.231227Z",
"iopub.status.idle": "2026-06-30T22:39:10.296372Z",
"shell.execute_reply": "2026-06-30T22:39:10.295407Z"
}
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"\u001b[1;36mStructure π§© \u001b[0m\u001b[32m'tbti'\u001b[0m\u001b[1;36m \u001b[0m\u001b[1;36m(\u001b[0m\u001b[1;36mAtom view type: \u001b[0m\u001b[32m'adp'\u001b[0m\u001b[1;36m)\u001b[0m\n"
]
},
{
"data": {
"text/html": [
"\n",
"
\n",
"
Loading plotβ¦
\n",
"
\n",
"
\n",
"
\n",
"
drag = rotate
wheel = zoom
right-drag = pan
\n",
"
\n",
"
\n",
"\n",
"\n",
"\n",
""
],
"text/plain": [
""
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"project.display.structure(struct_name='tbti')"
]
},
{
"cell_type": "code",
"execution_count": 27,
"id": "34",
"metadata": {
"execution": {
"iopub.execute_input": "2026-06-30T22:39:10.298061Z",
"iopub.status.busy": "2026-06-30T22:39:10.297877Z",
"iopub.status.idle": "2026-06-30T22:39:10.302399Z",
"shell.execute_reply": "2026-06-30T22:39:10.301592Z"
}
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"\u001b[1;36mDefined experiments π¬\u001b[0m\n"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"\u001b[1m[\u001b[0m\u001b[32m'heidi'\u001b[0m\u001b[1m]\u001b[0m\n"
]
}
],
"source": [
"project.experiments.show_names()"
]
},
{
"cell_type": "code",
"execution_count": 28,
"id": "35",
"metadata": {
"execution": {
"iopub.execute_input": "2026-06-30T22:39:10.304086Z",
"iopub.status.busy": "2026-06-30T22:39:10.303917Z",
"iopub.status.idle": "2026-06-30T22:39:10.319780Z",
"shell.execute_reply": "2026-06-30T22:39:10.319144Z"
}
},
"outputs": [
{
"data": {
"text/html": [
""
],
"text/plain": [
""
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"project.display.pattern(expt_name='heidi')"
]
},
{
"cell_type": "markdown",
"id": "36",
"metadata": {},
"source": [
"### ADP aniso"
]
},
{
"cell_type": "code",
"execution_count": 29,
"id": "37",
"metadata": {
"execution": {
"iopub.execute_input": "2026-06-30T22:39:10.321694Z",
"iopub.status.busy": "2026-06-30T22:39:10.321522Z",
"iopub.status.idle": "2026-06-30T22:39:10.326964Z",
"shell.execute_reply": "2026-06-30T22:39:10.326144Z"
}
},
"outputs": [],
"source": [
"structure.atom_sites['Tb'].adp_type = 'Uani'\n",
"structure.atom_sites['Ti'].adp_type = 'Uani'\n",
"structure.atom_sites['O1'].adp_type = 'Uani'\n",
"# structure.atom_sites['O2'].adp_type = 'Uani'"
]
},
{
"cell_type": "code",
"execution_count": 30,
"id": "38",
"metadata": {
"execution": {
"iopub.execute_input": "2026-06-30T22:39:10.328716Z",
"iopub.status.busy": "2026-06-30T22:39:10.328557Z",
"iopub.status.idle": "2026-06-30T22:39:10.331918Z",
"shell.execute_reply": "2026-06-30T22:39:10.331200Z"
}
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"loop_\n",
"_atom_site_aniso.id\n",
"_atom_site_aniso.adp_11\n",
"_atom_site_aniso.adp_22\n",
"_atom_site_aniso.adp_33\n",
"_atom_site_aniso.adp_12\n",
"_atom_site_aniso.adp_13\n",
"_atom_site_aniso.adp_23\n",
"Tb 0.00681683 0.00681683 0.00681683 0. 0. 0.\n",
"Ti 0.00539742 0.00539742 0.00539742 0. 0. 0.\n",
"O1 0.00572628 0.00572628 0.00572628 0. 0. 0.\n"
]
}
],
"source": [
"print(structure.atom_site_aniso.as_cif)"
]
},
{
"cell_type": "code",
"execution_count": 31,
"id": "39",
"metadata": {
"execution": {
"iopub.execute_input": "2026-06-30T22:39:10.334153Z",
"iopub.status.busy": "2026-06-30T22:39:10.333973Z",
"iopub.status.idle": "2026-06-30T22:39:10.337433Z",
"shell.execute_reply": "2026-06-30T22:39:10.336738Z"
}
},
"outputs": [],
"source": [
"structure.atom_site_aniso['Tb'].adp_11.free = True\n",
"structure.atom_site_aniso['Tb'].adp_12.free = True\n",
"structure.atom_site_aniso['Ti'].adp_11.free = True\n",
"structure.atom_site_aniso['Ti'].adp_12.free = True\n",
"structure.atom_site_aniso['O1'].adp_11.free = True\n",
"structure.atom_site_aniso['O1'].adp_22.free = True\n",
"structure.atom_site_aniso['O1'].adp_23.free = True\n",
"# structure.atom_site_aniso['O2'].adp_11.free = True"
]
},
{
"cell_type": "code",
"execution_count": 32,
"id": "40",
"metadata": {
"execution": {
"iopub.execute_input": "2026-06-30T22:39:10.339332Z",
"iopub.status.busy": "2026-06-30T22:39:10.339079Z",
"iopub.status.idle": "2026-06-30T22:39:13.399428Z",
"shell.execute_reply": "2026-06-30T22:39:13.398500Z"
}
},
"outputs": [
{
"data": {
"text/html": [],
"text/plain": [
""
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"application/javascript": [
"\n",
"(function() {\n",
" const button = document.getElementById('ed-fit-stop-c26d39ffd386412588d0f2f557868cff-button');\n",
" const status = document.getElementById('ed-fit-stop-c26d39ffd386412588d0f2f557868cff-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'heidi'\u001b[0m for \u001b[32m'single'\u001b[0m fitting\n"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"π Starting fit process with \u001b[32m'lmfit \u001b[0m\u001b[32m(\u001b[0m\u001b[32mleastsq\u001b[0m\u001b[32m)\u001b[0m\u001b[32m'\u001b[0m\u001b[33m...\u001b[0m\n"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"π Goodness-of-fit progress:\n"
]
},
{
"data": {
"text/html": [
" | iteration | time (s) | ΟΒ² | change / status |
|---|
| 1 | 1 | 0.28 | 13.00 | |
|---|
| 2 | 18 | 0.78 | 3.02 | 76.8% β |
|---|
| 3 | 33 | 1.22 | 2.94 | 2.5% β |
|---|
| 4 | 79 | 2.67 | 2.94 | |
|---|
"
],
"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.94\u001b[0m at iteration \u001b[1;36m78\u001b[0m\n"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"β
Fitting complete.\n"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"\u001b[1;36mSaving project π¦ \u001b[0m\u001b[32m'tbti_heidi'\u001b[0m\u001b[1;36m to \u001b[0m\u001b[32m'../../../projects/refine-tbti-heidi'\u001b[0m\n"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"βββ π project.edi\n"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"βββ π structures/\n"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"β βββ π tbti.edi\n"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"βββ π experiments/\n"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"β βββ π heidi.edi\n"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"βββ π analysis/\n"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"β βββ π analysis.edi\n"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"βββ π reports/\n"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
" βββ π tbti_heidi.html\n"
]
}
],
"source": [
"project.analysis.fit()"
]
},
{
"cell_type": "code",
"execution_count": 33,
"id": "41",
"metadata": {
"execution": {
"iopub.execute_input": "2026-06-30T22:39:13.401350Z",
"iopub.status.busy": "2026-06-30T22:39:13.401043Z",
"iopub.status.idle": "2026-06-30T22:39:13.729736Z",
"shell.execute_reply": "2026-06-30T22:39:13.729020Z"
}
},
"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 | lmfit (leastsq) |
|---|
| 2 | β
Overall status | success |
|---|
| 3 | β±οΈ Fitting time (seconds) | 2.67 |
|---|
| 4 | π Iterations | 76 |
|---|
| 5 | π Goodness-of-fit (reduced ΟΒ²) | 2.94 |
|---|
| 6 | π R-factor (Rf, %) | 4.21 |
|---|
| 7 | π R-factor squared (RfΒ², %) | 6.61 |
|---|
| 8 | π Weighted R-factor (wR, %) | 13.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 | tbti | atom_site | Ti | occupancy | | 0.9730 | 0.9661 | 0.0085 | 0.71 % β |
|---|
| 2 | tbti | atom_site | O1 | fract_x | | 0.3280 | 0.3280 | 0.0000 | 0.01 % β |
|---|
| 3 | tbti | atom_site | O1 | occupancy | | 0.9989 | 0.9940 | 0.0050 | 0.50 % β |
|---|
| 4 | tbti | atom_site | O2 | occupancy | | 0.9688 | 0.9718 | 0.0088 | 0.31 % β |
|---|
| 5 | tbti | atom_site | O2 | adp_iso | Γ
Β² | 0.0030 | 0.0033 | 0.0002 | 7.87 % β |
|---|
| 6 | tbti | atom_site_aniso | Tb | adp_11 | Γ
Β² | 0.0068 | 0.0066 | 0.0001 | 3.45 % β |
|---|
| 7 | tbti | atom_site_aniso | Tb | adp_12 | Γ
Β² | 0.0000 | -0.0023 | 0.0001 | N/A |
|---|
| 8 | tbti | atom_site_aniso | Ti | adp_11 | Γ
Β² | 0.0054 | 0.0049 | 0.0003 | 9.56 % β |
|---|
| 9 | tbti | atom_site_aniso | Ti | adp_12 | Γ
Β² | 0.0000 | -0.0005 | 0.0002 | N/A |
|---|
| 10 | tbti | atom_site_aniso | O1 | adp_11 | Γ
Β² | 0.0057 | 0.0067 | 0.0002 | 17.67 % β |
|---|
| 11 | tbti | atom_site_aniso | O1 | adp_22 | Γ
Β² | 0.0057 | 0.0049 | 0.0001 | 14.61 % β |
|---|
| 12 | tbti | atom_site_aniso | O1 | adp_23 | Γ
Β² | 0.0000 | 0.0019 | 0.0001 | N/A |
|---|
| 13 | heidi | extinction | | radius | ΞΌm | 26.4348 | 24.8317 | 0.4931 | 6.06 % β |
|---|
| 14 | heidi | linked_structure | | scale | | 2.9329 | 2.8744 | 0.0274 | 1.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": "code",
"execution_count": 34,
"id": "42",
"metadata": {
"execution": {
"iopub.execute_input": "2026-06-30T22:39:13.731287Z",
"iopub.status.busy": "2026-06-30T22:39:13.731124Z",
"iopub.status.idle": "2026-06-30T22:39:13.754855Z",
"shell.execute_reply": "2026-06-30T22:39:13.754144Z"
}
},
"outputs": [
{
"data": {
"text/html": [
"\n",
"\n",
""
],
"text/plain": [
""
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"project.display.fit.correlations()"
]
},
{
"cell_type": "code",
"execution_count": 35,
"id": "43",
"metadata": {
"execution": {
"iopub.execute_input": "2026-06-30T22:39:13.756377Z",
"iopub.status.busy": "2026-06-30T22:39:13.756211Z",
"iopub.status.idle": "2026-06-30T22:39:13.771980Z",
"shell.execute_reply": "2026-06-30T22:39:13.770810Z"
}
},
"outputs": [
{
"data": {
"text/html": [
""
],
"text/plain": [
""
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"project.display.pattern(expt_name='heidi')"
]
},
{
"cell_type": "code",
"execution_count": 36,
"id": "44",
"metadata": {
"execution": {
"iopub.execute_input": "2026-06-30T22:39:13.773776Z",
"iopub.status.busy": "2026-06-30T22:39:13.773552Z",
"iopub.status.idle": "2026-06-30T22:39:13.783281Z",
"shell.execute_reply": "2026-06-30T22:39:13.782474Z"
}
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"\u001b[1;36mStructure π§© \u001b[0m\u001b[32m'tbti'\u001b[0m\u001b[1;36m as text\u001b[0m\n"
]
},
{
"data": {
"text/html": [
" | Edi |
|---|
| 1 | data_tbti |
|---|
| 2 | |
|---|
| 3 | _cell.length_a 10.13 |
|---|
| 4 | _cell.length_b 10.13 |
|---|
| 5 | _cell.length_c 10.13 |
|---|
| 6 | _cell.angle_alpha 90. |
|---|
| 7 | _cell.angle_beta 90. |
|---|
| 8 | _cell.angle_gamma 90. |
|---|
| 9 | |
|---|
| 10 | _space_group.name_h_m "F d -3 m" |
|---|
| 11 | _space_group.coord_system_code 2 |
|---|
| 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 | Tb Tb 0.5 0.5 0.5 d 16 1. 0.00658189 Uani |
|---|
| 28 | Ti Ti 0. 0. 0. c 16 0.9661(85) 0.00488144 Uani |
|---|
| 29 | O1 O 0.327996(47) 0.125 0.125 f 48 0.9940(50) 0.00550586 Uani |
|---|
| 30 | O2 O 0.375 0.375 0.375 b 8 0.9718(88) 0.00327(24) Uiso |
|---|
| 31 | |
|---|
| 32 | loop_ |
|---|
| 33 | _atom_site_aniso.id |
|---|
| 34 | _atom_site_aniso.adp_11 |
|---|
| 35 | _atom_site_aniso.adp_22 |
|---|
| 36 | _atom_site_aniso.adp_33 |
|---|
| 37 | _atom_site_aniso.adp_12 |
|---|
| 38 | _atom_site_aniso.adp_13 |
|---|
| 39 | _atom_site_aniso.adp_23 |
|---|
| 40 | Tb 0.00658(14) 0.00658189 0.00658189 -0.00228(11) -0.00228459 -0.00228459 |
|---|
| 41 | Ti 0.00488(29) 0.00488144 0.00488144 -0.00048(25) -0.00048176 -0.00048176 |
|---|
| 42 | O1 0.00674(18) 0.00489(13) 0.0048898 0. 0. 0.00189(13) |
|---|
"
],
"text/plain": [
""
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"structure.show_as_text()"
]
},
{
"cell_type": "markdown",
"id": "45",
"metadata": {},
"source": [
"### Display Structure (final)\n",
"\n",
"Tb, Ti and O1 were refined with anisotropic displacements (`Uani`), so the\n",
"ADP view now draws them as probability ellipsoids, while O2 stayed isotropic\n",
"(`Uiso`) and remains a sphere β highlighting how the view changed from the\n",
"initial spheres to ellipsoids."
]
},
{
"cell_type": "code",
"execution_count": 37,
"id": "46",
"metadata": {
"execution": {
"iopub.execute_input": "2026-06-30T22:39:13.784898Z",
"iopub.status.busy": "2026-06-30T22:39:13.784679Z",
"iopub.status.idle": "2026-06-30T22:39:13.875075Z",
"shell.execute_reply": "2026-06-30T22:39:13.874088Z"
}
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"\u001b[1;36mStructure π§© \u001b[0m\u001b[32m'tbti'\u001b[0m\u001b[1;36m \u001b[0m\u001b[1;36m(\u001b[0m\u001b[1;36mAtom view type: \u001b[0m\u001b[32m'adp'\u001b[0m\u001b[1;36m)\u001b[0m\n"
]
},
{
"data": {
"text/html": [
"\n",
"
\n",
"
Loading plotβ¦
\n",
"
\n",
"
\n",
"
\n",
"
drag = rotate
wheel = zoom
right-drag = pan
\n",
"
\n",
"
\n",
"\n",
"\n",
"\n",
""
],
"text/plain": [
""
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"project.display.structure(struct_name='tbti')"
]
},
{
"cell_type": "markdown",
"id": "47",
"metadata": {},
"source": [
"## π Report"
]
},
{
"cell_type": "code",
"execution_count": 38,
"id": "48",
"metadata": {
"execution": {
"iopub.execute_input": "2026-06-30T22:39:13.876700Z",
"iopub.status.busy": "2026-06-30T22:39:13.876542Z",
"iopub.status.idle": "2026-06-30T22:39:31.879663Z",
"shell.execute_reply": "2026-06-30T22:39:31.876499Z"
}
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"\u001b[1;36mSaving project π¦ \u001b[0m\u001b[32m'tbti_heidi'\u001b[0m\u001b[1;36m to \u001b[0m\u001b[32m'../../../projects/refine-tbti-heidi'\u001b[0m\n"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"βββ π project.edi\n"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"βββ π structures/\n"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"β βββ π tbti.edi\n"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"βββ π experiments/\n"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"β βββ π heidi.edi\n"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"βββ π analysis/\n"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"β βββ π analysis.edi\n"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"βββ π reports/\n"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
" βββ π tbti_heidi.html\n"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
" βββ π tbti_heidi.pdf\n"
]
}
],
"source": [
"# Enable PDF report generation before the last save (time consuming)\n",
"project.report.pdf = True\n",
"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.5"
}
},
"nbformat": 4,
"nbformat_minor": 5
}