Skip to content

Commit

Permalink
for the turorial: add preambles and rename exercise
Browse files Browse the repository at this point in the history
  • Loading branch information
ipelupessy committed Sep 8, 2022
1 parent f8d3ff7 commit a3beaf3
Show file tree
Hide file tree
Showing 11 changed files with 596 additions and 36 deletions.
112 changes: 106 additions & 6 deletions doc/interactive_tutorial/00-Welcome.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,9 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"Welcome to ***AMUSE***. You are currently viewing the AMUSE tutorial. This is a [Jupyter Notebook web-application](https://jupyter.org/ \"Jupyter\"). With this application you can create, edit and run python scripts on your local computer. We will be using it for these AMUSE tutorials, but you can use it for all your interactive explorations of Python and it's many libraries, scripts and applications. This first tutorial is for users unfamiliar with the notebook interface."
"## Welcome to ***AMUSE*** \n",
"\n",
"You are currently viewing the AMUSE tutorial. This is a [Jupyter Notebook web-application](https://jupyter.org/ \"Jupyter\"). With this application you can create, edit and run Python scripts on your local computer. We will be using it for these AMUSE tutorials, but you can use it for all your interactive explorations of Python and it's many libraries, scripts and applications. This first tutorial is for users unfamiliar with the notebook interface. We will assume some familiarity with Python, though not at very advanced level and even if you are not, you will probably be able to follow most examples and work out the exercises."
]
},
{
Expand Down Expand Up @@ -53,7 +55,7 @@
"metadata": {},
"outputs": [],
"source": [
"from amuse import l"
"from math import s"
]
},
{
Expand Down Expand Up @@ -98,13 +100,111 @@
"\n",
"pyplot.plot(numpy.arange(10))"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Most probably AMUSE will be installed in the environment where this tutorial is run. All the notebooks include a preamble cell with some code to check and optionally install the AMUSE components used in the notebook. This works on machines with a suitable developer environement installed (such as google [colab](https://colab.research.google.com/)). Such a preamble looks like:"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"# preamble to check and install AMUSE components if necessary\n",
"%%bash\n",
"# required packages for this tutorial:\n",
"PACKAGES=\"amuse-framework\"\n",
"# skip in case a full development install is present\n",
"pip show amuse-devel && exit 0\n",
"for package in ${PACKAGES} \n",
"do\n",
" pip show ${package} || pip install ${package}\n",
"done"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"You can execute the preamble to be sure that AMUSE is installed, note it may take a few minutes. The preamble cells may show up hidden, in which it shows up as three dots:"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"jupyter": {
"source_hidden": true
},
"tags": []
},
"outputs": [],
"source": [
"# preamble to check and install AMUSE components if necessary\n",
"%%bash\n",
"# required packages for this tutorial:\n",
"PACKAGES=\"amuse-framework\"\n",
"# skip in case a full development install is present\n",
"pip show amuse-devel && exit 0\n",
"for package in ${PACKAGES} \n",
"do\n",
" pip show ${package} || pip install ${package}\n",
"done"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"In addition, if codes are used the following cell implements some optional but recommended fixes:"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"tags": []
},
"outputs": [],
"source": [
"# the following fixes are highly recommended\n",
"\n",
"#allow oversubscription for openMPI\n",
"import os\n",
"os.environ[\"OMPI_MCA_rmaps_base_oversubscribe\"]=\"true\"\n",
"\n",
"# use lower cpu resources for idle codes\n",
"from amuse.support import options\n",
"options.GlobalOptions.instance().override_value_for_option(\"polling_interval_in_milliseconds\", 10)\n"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"After this, AMUSE should be present: "
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"import amuse\n",
"print(amuse.version.version)"
]
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 2",
"display_name": "Python 3 (ipykernel)",
"language": "python",
"name": "python2"
"name": "python3"
},
"language_info": {
"codemirror_mode": {
Expand All @@ -116,9 +216,9 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.8.3"
"version": "3.8.13"
}
},
"nbformat": 4,
"nbformat_minor": 1
"nbformat_minor": 4
}
52 changes: 49 additions & 3 deletions doc/interactive_tutorial/01-Loading_AMUSE.ipynb
Original file line number Diff line number Diff line change
@@ -1,5 +1,51 @@
{
"cells": [
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"jupyter": {
"source_hidden": true
},
"tags": []
},
"outputs": [],
"source": [
"%%bash\n",
"# preamble script to check and install AMUSE components if necessary\n",
"\n",
"# required packages for this tutorial:\n",
"PACKAGES=\"mpi4py amuse-framework amuse-bhtree\"\n",
"# skip in case a full development install is present\n",
"pip show amuse-devel && exit 0\n",
"for package in ${PACKAGES} \n",
"do\n",
" pip show ${package} || pip install ${package}\n",
"done"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"jupyter": {
"source_hidden": true
},
"tags": []
},
"outputs": [],
"source": [
"# the following fixes are highly recommended\n",
"\n",
"#allow oversubscription for openMPI\n",
"import os\n",
"os.environ[\"OMPI_MCA_rmaps_base_oversubscribe\"]=\"true\"\n",
"\n",
"# use lower cpu resources for idle codes\n",
"from amuse.support import options\n",
"options.GlobalOptions.instance().override_value_for_option(\"polling_interval_in_milliseconds\", 10)\n"
]
},
{
"cell_type": "markdown",
"metadata": {},
Expand Down Expand Up @@ -364,7 +410,7 @@
],
"metadata": {
"kernelspec": {
"display_name": "Python 3",
"display_name": "Python 3 (ipykernel)",
"language": "python",
"name": "python3"
},
Expand All @@ -378,9 +424,9 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.8.3"
"version": "3.8.13"
}
},
"nbformat": 4,
"nbformat_minor": 1
"nbformat_minor": 4
}
52 changes: 49 additions & 3 deletions doc/interactive_tutorial/02-Quantities_with_units.ipynb
Original file line number Diff line number Diff line change
@@ -1,5 +1,51 @@
{
"cells": [
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"jupyter": {
"source_hidden": true
},
"tags": []
},
"outputs": [],
"source": [
"%%bash\n",
"# preamble script to check and install AMUSE components if necessary\n",
"\n",
"# required packages for this tutorial:\n",
"PACKAGES=\"amuse-framework\"\n",
"# skip in case a full development install is present\n",
"pip show amuse-devel && exit 0\n",
"for package in ${PACKAGES} \n",
"do\n",
" pip show ${package} || pip install ${package}\n",
"done"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"jupyter": {
"source_hidden": true
},
"tags": []
},
"outputs": [],
"source": [
"# the following fixes are highly recommended\n",
"\n",
"#allow oversubscription for openMPI\n",
"import os\n",
"os.environ[\"OMPI_MCA_rmaps_base_oversubscribe\"]=\"true\"\n",
"\n",
"# use lower cpu resources for idle codes\n",
"from amuse.support import options\n",
"options.GlobalOptions.instance().override_value_for_option(\"polling_interval_in_milliseconds\", 10)\n"
]
},
{
"cell_type": "code",
"execution_count": null,
Expand Down Expand Up @@ -263,7 +309,7 @@
],
"metadata": {
"kernelspec": {
"display_name": "Python 3",
"display_name": "Python 3 (ipykernel)",
"language": "python",
"name": "python3"
},
Expand All @@ -277,9 +323,9 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.8.3"
"version": "3.8.13"
}
},
"nbformat": 4,
"nbformat_minor": 1
"nbformat_minor": 4
}
52 changes: 49 additions & 3 deletions doc/interactive_tutorial/03-Generic_units.ipynb
Original file line number Diff line number Diff line change
@@ -1,5 +1,51 @@
{
"cells": [
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"jupyter": {
"source_hidden": true
},
"tags": []
},
"outputs": [],
"source": [
"%%bash\n",
"# preamble script to check and install AMUSE components if necessary\n",
"\n",
"# required packages for this tutorial:\n",
"PACKAGES=\"amuse-framework\"\n",
"# skip in case a full development install is present\n",
"pip show amuse-devel && exit 0\n",
"for package in ${PACKAGES} \n",
"do\n",
" pip show ${package} || pip install ${package}\n",
"done"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"jupyter": {
"source_hidden": true
},
"tags": []
},
"outputs": [],
"source": [
"# the following fixes are highly recommended\n",
"\n",
"#allow oversubscription for openMPI\n",
"import os\n",
"os.environ[\"OMPI_MCA_rmaps_base_oversubscribe\"]=\"true\"\n",
"\n",
"# use lower cpu resources for idle codes\n",
"from amuse.support import options\n",
"options.GlobalOptions.instance().override_value_for_option(\"polling_interval_in_milliseconds\", 10)\n"
]
},
{
"cell_type": "code",
"execution_count": null,
Expand Down Expand Up @@ -210,7 +256,7 @@
],
"metadata": {
"kernelspec": {
"display_name": "Python 3",
"display_name": "Python 3 (ipykernel)",
"language": "python",
"name": "python3"
},
Expand All @@ -224,9 +270,9 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.8.3"
"version": "3.8.13"
}
},
"nbformat": 4,
"nbformat_minor": 1
"nbformat_minor": 4
}
Loading

0 comments on commit a3beaf3

Please sign in to comment.