{ "cells": [ { "cell_type": "code", "execution_count": 1, "id": "0", "metadata": { "execution": { "iopub.execute_input": "2026-06-30T22:30:12.382785Z", "iopub.status.busy": "2026-06-30T22:30:12.382617Z", "iopub.status.idle": "2026-06-30T22:30:12.388902Z", "shell.execute_reply": "2026-06-30T22:30:12.388416Z" }, "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: Si, TOF\n", "\n", "This example shows how to **calculate and plot a time-of-flight\n", "diffraction pattern without any measured data**. As with the\n", "constant-wavelength example, the structure, instrument, peak profile,\n", "and background are defined in code, and the pattern is computed over a\n", "calculation range.\n", "\n", "For a time-of-flight instrument an absolute time window is meaningless\n", "without a calibration, so the default `data_range` is derived from the\n", "instrument's TOF calibration. No data file is downloaded or loaded.\n", "\n", "For this example, a time-of-flight neutron powder experiment for Si is\n", "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:30:12.390738Z", "iopub.status.busy": "2026-06-30T22:30:12.390554Z", "iopub.status.idle": "2026-06-30T22:30:15.512135Z", "shell.execute_reply": "2026-06-30T22:30:15.511215Z" } }, "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:30:15.513726Z", "iopub.status.busy": "2026-06-30T22:30:15.513448Z", "iopub.status.idle": "2026-06-30T22:30:15.755057Z", "shell.execute_reply": "2026-06-30T22:30:15.754209Z" } }, "outputs": [], "source": [ "project = edi.Project(name='si_simulation')" ] }, { "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:30:15.756857Z", "iopub.status.busy": "2026-06-30T22:30:15.756670Z", "iopub.status.idle": "2026-06-30T22:30:15.759832Z", "shell.execute_reply": "2026-06-30T22:30:15.759191Z" } }, "outputs": [], "source": [ "project.structures.create(name='si')" ] }, { "cell_type": "code", "execution_count": 5, "id": "8", "metadata": { "execution": { "iopub.execute_input": "2026-06-30T22:30:15.761590Z", "iopub.status.busy": "2026-06-30T22:30:15.761419Z", "iopub.status.idle": "2026-06-30T22:30:15.764563Z", "shell.execute_reply": "2026-06-30T22:30:15.763772Z" } }, "outputs": [], "source": [ "structure = project.structures['si']" ] }, { "cell_type": "code", "execution_count": 6, "id": "9", "metadata": { "execution": { "iopub.execute_input": "2026-06-30T22:30:15.765979Z", "iopub.status.busy": "2026-06-30T22:30:15.765827Z", "iopub.status.idle": "2026-06-30T22:30:15.768761Z", "shell.execute_reply": "2026-06-30T22:30:15.768060Z" } }, "outputs": [], "source": [ "structure.space_group.name_h_m = 'F d -3 m'\n", "structure.space_group.coord_system_code = '2'" ] }, { "cell_type": "code", "execution_count": 7, "id": "10", "metadata": { "execution": { "iopub.execute_input": "2026-06-30T22:30:15.770445Z", "iopub.status.busy": "2026-06-30T22:30:15.770294Z", "iopub.status.idle": "2026-06-30T22:30:15.772929Z", "shell.execute_reply": "2026-06-30T22:30:15.772297Z" } }, "outputs": [], "source": [ "structure.cell.length_a = 5.431" ] }, { "cell_type": "code", "execution_count": 8, "id": "11", "metadata": { "execution": { "iopub.execute_input": "2026-06-30T22:30:15.774544Z", "iopub.status.busy": "2026-06-30T22:30:15.774381Z", "iopub.status.idle": "2026-06-30T22:30:15.778013Z", "shell.execute_reply": "2026-06-30T22:30:15.777310Z" } }, "outputs": [], "source": [ "structure.atom_sites.create(\n", " id='Si',\n", " type_symbol='Si',\n", " fract_x=0.125,\n", " fract_y=0.125,\n", " fract_z=0.125,\n", " adp_iso=0.5,\n", ")" ] }, { "cell_type": "code", "execution_count": 9, "id": "12", "metadata": { "execution": { "iopub.execute_input": "2026-06-30T22:30:15.779650Z", "iopub.status.busy": "2026-06-30T22:30:15.779500Z", "iopub.status.idle": "2026-06-30T22:30:16.098825Z", "shell.execute_reply": "2026-06-30T22:30:16.097910Z" } }, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "\u001b[1;36mStructure π§© \u001b[0m\u001b[32m'si'\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": [ "
| Edi | |
|---|---|
| 1 | data_sim |
| 2 | |
| 3 | _experiment_type.sample_form powder |
| 4 | _experiment_type.beam_mode time-of-flight |
| 5 | _experiment_type.radiation_probe neutron |
| 6 | _experiment_type.scattering_type bragg |
| 7 | |
| 8 | _diffrn.ambient_temperature ? |
| 9 | _diffrn.ambient_pressure ? |
| 10 | _diffrn.ambient_magnetic_field ? |
| 11 | _diffrn.ambient_electric_field ? |
| 12 | |
| 13 | _calculator.type cryspy |
| 14 | |
| 15 | _data_range.time_of_flight_min 5000. |
| 16 | _data_range.time_of_flight_max 15000. |
| 17 | _data_range.time_of_flight_inc 2. |
| 18 | |
| 19 | _peak.rise_alpha_0 0. |
| 20 | _peak.rise_alpha_1 0.5971 |
| 21 | _peak.decay_beta_0 0.04221 |
| 22 | _peak.decay_beta_1 0.00946 |
| 23 | _peak.broad_gauss_sigma_0 3. |
| 24 | _peak.broad_gauss_sigma_1 40. |
| 25 | _peak.broad_gauss_sigma_2 2. |
| 26 | _peak.broad_gauss_size_g 0. |
| 27 | _peak.broad_gauss_strain_g 0. |
| 28 | _peak.cutoff_fwhm 0. |
| 29 | _peak.type tof-jorgensen |
| 30 | |
| 31 | _instrument.setup_twotheta_bank 144.845 |
| 32 | _instrument.calib_d_to_tof_offset 0. |
| 33 | _instrument.calib_d_to_tof_linear 7476.91 |
| 34 | _instrument.calib_d_to_tof_quadratic -1.54 |
| 35 | _instrument.calib_d_to_tof_reciprocal 0. |
| 36 | |
| 37 | _absorption.type none |
| 38 | |
| 39 | loop_ |
| 40 | _linked_structure.structure_id |
| 41 | _linked_structure.scale |
| 42 | si 10. |
| 43 | |
| 44 | _background.type line-segment |
| 45 | |
| 46 | loop_ |
| 47 | _background.id |
| 48 | _background.position |
| 49 | _background.intensity |
| 50 | 1 10000 500 |
| 51 | 2 40000 500 |
| 52 | |
| 53 | loop_ |
| 54 | _refln.id |
| 55 | _refln.structure_id |
| 56 | _refln.d_spacing |
| 57 | _refln.sin_theta_over_lambda |
| 58 | _refln.index_h |
| 59 | _refln.index_k |
| 60 | _refln.index_l |
| 61 | _refln.f_calc |
| 62 | _refln.f_squared_calc |
| 63 | _refln.time_of_flight |
| 64 | 1 si 1.92014846 0.26039653 2 2 0 3.20863212 10.29532007 14351.09932031 |
| 65 | 2 si 1.63750811 0.305342 3 1 1 2.24018272 5.01841861 12239.37137416 |
| 66 | 3 si 1.56779466 0.31891932 2 2 2 0. 0. 11718.47425195 |
| 67 | 4 si 1.35775 0.36825631 4 0 0 3.10167267 9.62037338 10148.9355855 |
| 68 | 5 si 1.24595685 0.40129801 3 3 1 2.16550644 4.68941815 9313.51652715 |
| 69 | 6 si 1.21440852 0.41172307 4 2 0 0. 0. 9077.75202306 |
| 70 | 7 si 1.10859823 0.45102002 4 2 2 2.99827871 8.98967524 8286.9965678 |
| 71 | 8 si 1.04519644 0.47837897 5 1 1 2.09331949 4.3819865 7813.15734337 |
| 72 | 9 si 1.04519644 0.47837897 3 3 3 2.09331949 4.3819865 7813.15734337 |
| 73 | 10 si 0.96007423 0.52079306 4 4 0 2.89833138 8.40032478 7176.96914365 |
| 74 | ... |
| 75 | 15 si 0.82821974 0.60370452 5 3 3 1.95608441 3.82626623 6191.46806257 |
| 76 | 16 si 0.81875406 0.610684 6 2 2 0. 0. 6120.71803871 |
| 77 | 17 si 0.78389733 0.63783863 4 4 4 2.70832085 7.33500184 5860.18344831 |
| 78 | 18 si 0.76049211 0.65746901 5 5 1 1.89087853 3.5754216 5685.24043305 |
| 79 | 19 si 0.76049211 0.65746901 7 1 1 1.89087853 3.5754216 5685.24043305 |
| 80 | 20 si 0.75314419 0.6638835 6 4 0 0. 0. 5630.317808 |
| 81 | 21 si 0.7257479 0.68894446 6 4 2 2.61803924 6.85412944 5425.5406156 |
| 82 | 22 si 0.70705598 0.70715759 5 5 3 1.82784627 3.34102199 5285.8240047 |
| 83 | 23 si 0.70705598 0.70715759 7 3 1 1.82784627 3.34102199 5285.8240047 |
| 84 | 24 si 0.678875 0.73651261 8 0 0 2.53076715 6.40478236 5075.1775345 |