Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
157 changes: 22 additions & 135 deletions docs/ess/dream.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,7 @@
"source": [
"import scipp as sc\n",
"import plopp as pp\n",
"import tof\n",
"\n",
"Hz = sc.Unit('Hz')\n",
"deg = sc.Unit('deg')\n",
"meter = sc.Unit('m')\n",
"AA = sc.Unit('angstrom')"
"import tof"
]
},
{
Expand Down Expand Up @@ -56,144 +51,35 @@
"source": [
"## Component set-up\n",
"\n",
"## Choppers\n",
"\n",
"The DREAM chopper cascade consists of:\n",
"\n",
"- Two counter-rotating pulse-shaping choppers (PSC) that are very close to each other, located ~6m from the source\n",
"- An overlap chopper placed right after the two PSCs\n",
"- A band control chopper\n",
"- A T0 chopper"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "5",
"metadata": {},
"outputs": [],
"source": [
"choppers = [\n",
" tof.Chopper(\n",
" frequency=14 * Hz,\n",
" direction=tof.AntiClockwise,\n",
" centers=sc.array(\n",
" dims=['cutout'],\n",
" values=[0, 72, 86.4, 115.2, 172.8, 273.6, 288.0, 302.4],\n",
" unit='deg',\n",
" ),\n",
" widths=sc.array(\n",
" dims=['cutout'],\n",
" values=[2.46, 3.02, 3.27, 3.27, 5.02, 3.93, 3.93, 2.46],\n",
" unit='deg',\n",
" ),\n",
" phase=(286 - 180) * deg,\n",
" distance=6.145 * meter,\n",
" name=\"PSC1\",\n",
" ),\n",
" tof.Chopper(\n",
" frequency=14 * Hz,\n",
" direction=tof.Clockwise,\n",
" centers=sc.array(\n",
" dims=['cutout'],\n",
" values=[0, 28.8, 57.6, 144, 158.4, 216, 259.2, 316.8],\n",
" unit='deg',\n",
" ),\n",
" widths=sc.array(\n",
" dims=['cutout'],\n",
" values=[2.46, 3.60, 3.60, 3.23, 3.27, 3.77, 3.94, 2.62],\n",
" unit='deg',\n",
" ),\n",
" phase=236 * deg,\n",
" distance=6.155 * meter,\n",
" name=\"PSC2\",\n",
" ),\n",
" tof.Chopper(\n",
" frequency=14 * Hz,\n",
" direction=tof.AntiClockwise,\n",
" centers=sc.array(\n",
" dims=['cutout'],\n",
" values=[0.0],\n",
" unit='deg',\n",
" ),\n",
" widths=sc.array(\n",
" dims=['cutout'],\n",
" values=[27.6],\n",
" unit='deg',\n",
" ),\n",
" phase=(297 - 180 - 90) * deg,\n",
" distance=6.174 * meter,\n",
" name=\"OC\",\n",
" ),\n",
" tof.Chopper(\n",
" frequency=112 * Hz,\n",
" direction=tof.AntiClockwise,\n",
" centers=sc.array(\n",
" dims=['cutout'],\n",
" values=[0.0, 180.0],\n",
" unit='deg',\n",
" ),\n",
" widths=sc.array(\n",
" dims=['cutout'],\n",
" values=[73.75, 73.75],\n",
" unit='deg',\n",
" ),\n",
" phase=(240 - 180) * deg,\n",
" distance=9.78 * meter,\n",
" name=\"BC\",\n",
" ),\n",
" tof.Chopper(\n",
" frequency=28 * Hz,\n",
" direction=tof.AntiClockwise,\n",
" centers=sc.array(\n",
" dims=['cutout'],\n",
" values=[0.0],\n",
" unit='deg',\n",
" ),\n",
" widths=sc.array(\n",
" dims=['cutout'],\n",
" values=[314.9],\n",
" unit='deg',\n",
" ),\n",
" phase=(280 - 180) * deg,\n",
" distance=13.05 * meter,\n",
" name=\"T0\",\n",
" ),\n",
"]"
]
},
{
"cell_type": "markdown",
"id": "6",
"metadata": {},
"source": [
"### Detector banks and monitors\n",
"- A T0 chopper\n",
"\n",
"DREAM has 5 detector banks: the Mantle, two End-caps, a High-resolution detector and a SANS detector.\n",
"\n",
"For each detector bank, we use a single mean distance (in practice, one could have a different distance for each pixel)."
"For each detector bank, we use a single mean distance (in practice, one could have a different distance for each pixel).\n",
"\n",
"These component parameters are pre-configured in `tof.facilities.ess`.\n",
"Here we select the configuration in high-flux mode:"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "7",
"id": "5",
"metadata": {},
"outputs": [],
"source": [
"sample_position = 76.55 * meter\n",
"\n",
"detectors = [\n",
" tof.Detector(distance=sample_position + 1.125 * meter, name='mantle'),\n",
" tof.Detector(distance=sample_position + 1.125 * meter, name='end-cap'),\n",
" tof.Detector(distance=sample_position + 2.5 * meter, name='high-resolution'),\n",
" tof.Detector(distance=sample_position + 2.5 * meter, name='sans'),\n",
"]"
"dream_params = tof.facilities.ess.dream(high_flux=True)\n",
"dream_params"
]
},
{
"cell_type": "markdown",
"id": "8",
"id": "6",
"metadata": {},
"source": [
"## Run the simulation\n",
Expand All @@ -204,18 +90,18 @@
{
"cell_type": "code",
"execution_count": null,
"id": "9",
"id": "7",
"metadata": {},
"outputs": [],
"source": [
"model = tof.Model(source=source, choppers=choppers, detectors=detectors)\n",
"model = tof.Model(source=source, **dream_params)\n",
"results = model.run()\n",
"results.plot(blocked_rays=5000)"
]
},
{
"cell_type": "markdown",
"id": "10",
"id": "8",
"metadata": {},
"source": [
"## Wavelength as a function of time-of-arrival\n",
Expand All @@ -231,7 +117,7 @@
{
"cell_type": "code",
"execution_count": null,
"id": "11",
"id": "9",
"metadata": {},
"outputs": [],
"source": [
Expand All @@ -246,7 +132,7 @@
},
{
"cell_type": "markdown",
"id": "12",
"id": "10",
"metadata": {},
"source": [
"### Defining a conversion from `toa` to `wavelength`\n",
Expand All @@ -259,7 +145,7 @@
{
"cell_type": "code",
"execution_count": null,
"id": "13",
"id": "11",
"metadata": {},
"outputs": [],
"source": [
Expand All @@ -278,7 +164,7 @@
},
{
"cell_type": "markdown",
"id": "14",
"id": "12",
"metadata": {},
"source": [
"## Computing wavelengths\n",
Expand All @@ -289,7 +175,7 @@
{
"cell_type": "code",
"execution_count": null,
"id": "15",
"id": "13",
"metadata": {},
"outputs": [],
"source": [
Expand All @@ -314,7 +200,7 @@
},
{
"cell_type": "markdown",
"id": "16",
"id": "14",
"metadata": {},
"source": [
"We can now compare our computed wavelengths to the true wavelengths of the neutrons."
Expand All @@ -323,7 +209,7 @@
{
"cell_type": "code",
"execution_count": null,
"id": "17",
"id": "15",
"metadata": {},
"outputs": [],
"source": [
Expand Down Expand Up @@ -351,7 +237,8 @@
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3"
"pygments_lexer": "ipython3",
"version": "3.12.7"
}
},
"nbformat": 4,
Expand Down
Loading
Loading