{
"nbformat": 4,
"nbformat_minor": 5,
"metadata": {
"jupytext": {
"main_language": "python",
"notebook_metadata_filter": "-all",
"cell_metadata_filter": "-all",
"text_representation": {
"extension": ".py",
"format_name": "percent"
}
}
},
"cells": [
{
"cell_type": "code",
"execution_count": 1,
"metadata": {
"tags": [
"hide-in-docs"
],
"execution": {
"iopub.status.busy": "2026-11-10T22:14:27.734581Z",
"iopub.execute_input": "2026-11-10T22:14:27.734751Z",
"shell.execute_reply": "2026-11-10T22:14:27.737437Z",
"iopub.status.idle": "2026-11-10T22:14:27.737837Z"
}
},
"outputs": [],
"source": "# Check whether easydiffraction is installed; install it if needed.\n# Required for remote environments such as Google Colab.\nimport importlib.util\n\nif importlib.util.find_spec('easydiffraction') is None:\n %pip install easydiffraction==2026.11.0 --extra-index-url https://enhantica.github.io/edi-download/pypi/simple/\n",
"id": "0"
},
{
"id": "1",
"cell_type": "markdown",
"source": "# Calculation without data: La₀.₅Ba₀.₅CoO₃, HRPT\n\nCalculate a constant-wavelength neutron pattern of the cubic perovskite La₀.₅Ba₀.₅CoO₃ without\nany measured data. The structure, the HRPT instrument, the peak profile and the background are in\nthe project, and edi calculates the pattern over the project's 2θ range.\n\nThe project is the catalogue case `pd-neut-cwl_lbco_simulation`: the files the command line fits\nwith `python -m edi fit docs/user/cli/pd-neut-cwl_lbco_simulation/project` and the app opens from\nits Examples.",
"metadata": {}
},
{
"cell_type": "markdown",
"metadata": {},
"source": "
Simulation
Single pd neut cwl Bragg
Crystal structure",
"id": "2"
},
{
"id": "3",
"cell_type": "code",
"metadata": {
"execution": {
"iopub.status.busy": "2026-11-10T22:14:27.738991Z",
"iopub.execute_input": "2026-11-10T22:14:27.739155Z",
"iopub.status.idle": "2026-11-10T22:14:27.748859Z",
"shell.execute_reply": "2026-11-10T22:14:27.748331Z"
}
},
"execution_count": 2,
"source": "import easydiffraction as edi",
"outputs": []
},
{
"id": "4",
"cell_type": "markdown",
"source": "## Load the project",
"metadata": {}
},
{
"id": "5",
"cell_type": "code",
"metadata": {
"execution": {
"iopub.status.busy": "2026-11-10T22:14:27.750053Z",
"iopub.execute_input": "2026-11-10T22:14:27.750206Z",
"iopub.status.idle": "2026-11-10T22:14:28.161254Z",
"shell.execute_reply": "2026-11-10T22:14:28.160656Z"
}
},
"execution_count": 3,
"source": "project_path = edi.download_data('pd-neut-cwl_lbco_simulation', destination='data')\nproject = edi.Project.load(project_path)\nprint(project.metadata.title)\nprint('Structures:', ', '.join(structure.name for structure in project.structures))\nprint('Experiments:', ', '.join(experiment.name for experiment in project.experiments))\nprint('Fitting mode:', project.fitting_mode)",
"outputs": [
{
"output_type": "stream",
"name": "stdout",
"text": "Data 'pd-neut-cwl_lbco_simulation' is at data/pd-neut-cwl_lbco_simulation-156565971ae8/pd-neut-cwl_lbco_simulation\nLa₀.₅Ba₀.₅CoO₃ [Pm-3m] · HRPT @ PSI\nStructures: lbco\nExperiments: hrpt\nFitting mode: single\n"
}
]
},
{
"id": "6",
"cell_type": "markdown",
"source": "## Calculate\n\nThere is nothing to fit: edi calculates the pattern from the model as it is.",
"metadata": {}
},
{
"id": "7",
"cell_type": "code",
"metadata": {
"execution": {
"iopub.status.busy": "2026-11-10T22:14:28.162442Z",
"iopub.execute_input": "2026-11-10T22:14:28.162567Z",
"shell.execute_reply": "2026-11-10T22:14:28.336523Z",
"iopub.status.idle": "2026-11-10T22:14:28.336970Z"
}
},
"execution_count": 4,
"source": "project.calculate()\npattern = project.experiments[0].data\nprint(len(pattern.intensity_calc), 'points, highest', round(max(pattern.intensity_calc), 1))",
"outputs": [
{
"output_type": "stream",
"name": "stdout",
"text": "3001 points, highest 4134.2\n"
}
]
},
{
"id": "8",
"cell_type": "markdown",
"source": "## Patterns and report\n\nThe HTML report draws the measured, calculated and difference patterns with the reflection\npositions, and lists the structure and the fit. Open it in a browser.",
"metadata": {}
},
{
"id": "9",
"cell_type": "code",
"metadata": {
"execution": {
"iopub.status.busy": "2026-11-10T22:14:28.338125Z",
"iopub.execute_input": "2026-11-10T22:14:28.338302Z",
"shell.execute_reply": "2026-11-10T22:14:28.372108Z",
"iopub.status.idle": "2026-11-10T22:14:28.372513Z"
}
},
"execution_count": 5,
"source": "project.report.save_html('pd-neut-cwl_lbco_simulation.html')",
"outputs": [
{
"output_type": "stream",
"name": "stdout",
"text": "Saving report to 'pd-neut-cwl_lbco_simulation.html'\n"
}
]
},
{
"id": "10",
"cell_type": "markdown",
"source": "## Save\n\n`save_as` writes the project with its new values to a folder of its own; the catalogue's copy\nstays as it was.",
"metadata": {}
},
{
"id": "11",
"cell_type": "code",
"metadata": {
"execution": {
"iopub.status.busy": "2026-11-10T22:14:28.373705Z",
"iopub.execute_input": "2026-11-10T22:14:28.373847Z",
"shell.execute_reply": "2026-11-10T22:14:28.400929Z",
"iopub.status.idle": "2026-11-10T22:14:28.401370Z"
}
},
"execution_count": 6,
"source": "project.save_as('pd-neut-cwl_lbco_simulation')",
"outputs": [
{
"output_type": "stream",
"name": "stdout",
"text": "Saving project to 'pd-neut-cwl_lbco_simulation'\n"
}
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": "## Explore the interactive report\n\nRun the cell and trust the notebook to interact with the report. It includes Plotly plots and three.js structures where available.",
"id": "12"
},
{
"cell_type": "code",
"execution_count": 7,
"metadata": {
"execution": {
"iopub.status.busy": "2026-11-10T22:14:28.402479Z",
"iopub.execute_input": "2026-11-10T22:14:28.402603Z",
"shell.execute_reply": "2026-11-10T22:14:28.510199Z",
"iopub.status.idle": "2026-11-10T22:14:28.510645Z"
}
},
"outputs": [
{
"output_type": "execute_result",
"metadata": {},
"data": {
"text/plain": "",
"text/html": ""
},
"execution_count": 7
}
],
"source": "project.report.html_offline = True\nproject.report",
"id": "13"
}
]
}