{ "cells": [ { "cell_type": "code", "execution_count": 1, "id": "0", "metadata": { "execution": { "iopub.execute_input": "2026-06-30T22:27:04.187108Z", "iopub.status.busy": "2026-06-30T22:27:04.186895Z", "iopub.status.idle": "2026-06-30T22:27:04.191428Z", "shell.execute_reply": "2026-06-30T22:27:04.190372Z" }, "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": [ "# Calculation Without Data: LBCO, CWL\n", "\n", "This example shows how to **calculate and plot a diffraction pattern\n", "without any measured data**. Everything the calculation needs β the\n", "crystal structure, the instrument, the peak profile, and the\n", "background β is defined in code, and the pattern is computed over a\n", "calculation range instead of over loaded data points.\n", "\n", "This is useful to preview what a candidate structure should look like,\n", "to teach, or to generate a synthetic pattern before any measurement\n", "exists. No data file is downloaded or loaded.\n", "\n", "For this example, a constant-wavelength neutron powder experiment for\n", "La0.5Ba0.5CoO3 is used." ] }, { "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:27:04.192953Z", "iopub.status.busy": "2026-06-30T22:27:04.192806Z", "iopub.status.idle": "2026-06-30T22:27:07.078988Z", "shell.execute_reply": "2026-06-30T22:27:07.078088Z" } }, "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:27:07.080915Z", "iopub.status.busy": "2026-06-30T22:27:07.080623Z", "iopub.status.idle": "2026-06-30T22:27:07.575025Z", "shell.execute_reply": "2026-06-30T22:27:07.573951Z" } }, "outputs": [], "source": [ "project = edi.Project(name='lbco_simulation')" ] }, { "cell_type": "markdown", "id": "6", "metadata": {}, "source": [ "## π§© Define Structure" ] }, { "cell_type": "markdown", "id": "7", "metadata": {}, "source": [ "### Download CIF file" ] }, { "cell_type": "code", "execution_count": 4, "id": "8", "metadata": { "execution": { "iopub.execute_input": "2026-06-30T22:27:07.576791Z", "iopub.status.busy": "2026-06-30T22:27:07.576595Z", "iopub.status.idle": "2026-06-30T22:27:08.035155Z", "shell.execute_reply": "2026-06-30T22:27:08.034215Z" } }, "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-lbco'\u001b[0m: La0.5Ba0.5CoO3 \u001b[1m(\u001b[0mcrystal structure\u001b[1m)\u001b[0m\n" ] }, { "name": "stdout", "output_type": "stream", "text": [ "β Data \u001b[32m'struct-lbco'\u001b[0m downloaded to \u001b[32m'../../../data/struct-lbco.cif'\u001b[0m\n" ] } ], "source": [ "structure_path = edi.download_data('struct-lbco', destination='data')" ] }, { "cell_type": "markdown", "id": "9", "metadata": {}, "source": [ "### Add Structure from CIF" ] }, { "cell_type": "code", "execution_count": 5, "id": "10", "metadata": { "execution": { "iopub.execute_input": "2026-06-30T22:27:08.036867Z", "iopub.status.busy": "2026-06-30T22:27:08.036709Z", "iopub.status.idle": "2026-06-30T22:27:08.048568Z", "shell.execute_reply": "2026-06-30T22:27:08.047761Z" } }, "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'lbco'\u001b[0m\u001b[1m]\u001b[0m\n" ] } ], "source": [ "project.structures.add_from_cif_path(structure_path)\n", "project.structures.show_names()\n", "\n", "structure = project.structures['lbco']" ] }, { "cell_type": "markdown", "id": "11", "metadata": {}, "source": [ "### Plot Structure" ] }, { "cell_type": "code", "execution_count": 6, "id": "12", "metadata": { "execution": { "iopub.execute_input": "2026-06-30T22:27:08.050198Z", "iopub.status.busy": "2026-06-30T22:27:08.050034Z", "iopub.status.idle": "2026-06-30T22:27:08.100983Z", "shell.execute_reply": "2026-06-30T22:27:08.100016Z" } }, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "\u001b[1;36mStructure π§© \u001b[0m\u001b[32m'lbco'\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": [ "