Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Last mcstas changes #84

Merged
merged 2 commits into from
Aug 29, 2024
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
45 changes: 33 additions & 12 deletions 3-mcstas/Simulation.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,13 @@
{
"cell_type": "markdown",
"id": "polyphonic-waste",
"metadata": {},
"metadata": {
"editable": true,
"slideshow": {
"slide_type": ""
},
"tags": []
},
"source": [
"# Simulation\n",
"At the ESS we have used simulations extensively to design and optimize the facility.\n",
Expand All @@ -30,10 +36,16 @@
{
"cell_type": "markdown",
"id": "adequate-delay",
"metadata": {},
"metadata": {
"editable": true,
"slideshow": {
"slide_type": ""
},
"tags": []
},
"source": [
"### Ray-tracing\n",
"The ray-tracing part of the simulation deals with the paths of the neutrons through space. Thus the geometric effects in the optics can be understood, as they path of the neutrons are traced through the known guide system.\n",
"The ray-tracing part of the simulation deals with the paths of the neutrons through space. Thus the geometric effects in the optics can be understood, as the path of the neutrons are traced through the known guide system.\n",
"\n",
"## Monte Carlo ray-tracing\n",
"Combining these techniques one can start the rays with random velocities drawn from a distribution that resembles the real source, trace the path of the neutrons through the instrument, and at each interaction, random numbers will be used to sample the behavior using the known probability distributions. Repeating this with many rays allow us to estimate for example the flux at the detector, or even the distribution of flux on the detector.\n",
Expand All @@ -53,9 +65,8 @@
"### Simulation\n",
"Often the simulation will run to estimate a intensity, meaning neutrons per second, and will give this result with an error. This error can be reduced by using more rays for the simulation, corresponding to more Monte Carlo samples. To get the expected count from an experiment, one would have to multiply the intensity with the experiment time. It is also important to understand that the error reported by McStas has nothing to do with the expected error in an experiment, that would be calculated from the square root of the number of counts, the McStas error instead measures the quality of the intensity estimate.\n",
"\n",
"\n",
"## Quick tutorial\n",
"Thorough Python McStas tutorials can be found with the documentation for McStasScript [https://mads-bertelsen.github.io](https://mads-bertelsen.github.io), and for examples in the C syntax one can look in the McStas package or on [https://www.mcstas.org](https://www.mcstas.org).\n",
"Thorough Python McStas tutorials can be found with the documentation for McStasScript [here](https://mads-bertelsen.github.io), and for examples in the C syntax one can look in the McStas package or on the package [website](https://www.mcstas.org).\n",
"\n",
"### Import the package\n",
"First the package needs to be installed, then it can be imported. McStasScript also needs to be configured to access the local McStas installation, this is covered in the documentation. It is common to define a shorter name when importing to save some keystrokes, here ms is chosen."
Expand All @@ -65,7 +76,13 @@
"cell_type": "code",
"execution_count": null,
"id": "foster-union",
"metadata": {},
"metadata": {
"editable": true,
"slideshow": {
"slide_type": ""
},
"tags": []
},
"outputs": [],
"source": [
"import mcstasscript as ms"
Expand Down Expand Up @@ -418,7 +435,13 @@
{
"cell_type": "markdown",
"id": "portuguese-supervision",
"metadata": {},
"metadata": {
"editable": true,
"slideshow": {
"slide_type": ""
},
"tags": []
},
"source": [
"And we an see how that modified the value by calling *show_parameters* again"
]
Expand Down Expand Up @@ -486,9 +509,7 @@
"cell_type": "code",
"execution_count": null,
"id": "mediterranean-pricing",
"metadata": {
"scrolled": false
},
"metadata": {},
"outputs": [],
"source": [
"ms.make_sub_plot(data)"
Expand Down Expand Up @@ -547,7 +568,7 @@
"metadata": {
"celltoolbar": "Tags",
"kernelspec": {
"display_name": "Python 3",
"display_name": "Python 3 (ipykernel)",
"language": "python",
"name": "python3"
},
Expand All @@ -561,7 +582,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.8.8"
"version": "3.10.14"
}
},
"nbformat": 4,
Expand Down
Loading