Skip to content

Commit

Permalink
Adds an updated version of the Jupyter notebook tutorial for the onse…
Browse files Browse the repository at this point in the history
…t of convection
  • Loading branch information
ljhwang committed Jan 19, 2024
1 parent d34caed commit d77075c
Show file tree
Hide file tree
Showing 30 changed files with 14,179 additions and 0 deletions.
86 changes: 86 additions & 0 deletions cookbooks/convection-box/tutorial-onset-of-convection/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
Author: Lorraine J. Hwang, Ian Rose, Juliane Dannberg and the ASPECT development community

# Introduction to ASPECT

This notebook is based on tutorials by J. Dannberg that provide a basic introduction to ASPECT.
This notebook demonstrates the onset of convection and the Nusselt-Rayleigh number relationship.

To run, copy the contents of this directory to your workspace.


## Running using ASPECT Jupyter Notebooks tool

The current version is verified to run within the ASPECT Jupyter Notebooks tool which can be launched from the CIG website:

https://geodynamics.org/resources/aspectnotebook


## Running on your desktop

If you run in your local JupyterLab environment, note the following dependencies:

* Python 3.8.5
* IPython 7.19.0
* Jupyterlab 3.2.1
* Jupyter widget extension 1.0.0 (see Appendix B)
* matplotlib 3.3.2
* numpy 1.19.2
* tables
* ipympl
* scipy
* glob


## Running using Docker
The current version of the docker container supports an older version of ASPECT. The model_input directory contains two files with `_old` in its name which will work with this container.

Use at your own risk.

Here are the old instructions

A. Install Docker

B. Download the docker image
> docker pull tjhei/aspect-jupyter
1. Start Docker
2. In a terminal window, navigate to directory where your model input is located:
> cd my_directory/ModelInput
3. Load the Jupyter extension for widgets:
>jupyter nbextension enable widgetsnbextension --py --sys-prefix
4. Spin up Timo’s container with Jupyter notebooks and map your current working directory as input:
> docker run -it -v "$(pwd):/home/dealii/aspect/model_input:ro" -d -p 8888:8888 --name tmpnb-aspect-jupyter tjhei/aspect-jupyter start-notebook.sh --NotebookApp.token=' '
5. In a browser, type:
> http://localhost:8888/tree?
6. Upload this notebook and the image files.

Remember you are now running in a Docker container and NOT your desktop.

**Common problems:**

unexpected error address already in use.
change your local host address 8887:8888
change this to 8887 in step 5

You have to remove (or rename) that container to be able to reuse that name.
Easiest solution (somewhat heavy handed) stop your container, prune, and check.

> docker stop CONTAINER_ID
> docker container prune
> docker ps -a
## Packages install

The heat flux slider requires the installation of two additional packages.

**Adding Jupyter widgets**

You should have added this in Step 3 above:
> jupyter nbextension enable widgetsnbextension --py --sys-prefix
**Installing tables**
> conda install tables

Original file line number Diff line number Diff line change
@@ -0,0 +1,161 @@
# A description of convection in a 2d box. See the manual for more information.


# At the top, we define the number of space dimensions we would like to
# work in:
set Dimension = 2

# There are several global variables that have to do with what
# time system we want to work in and what the end time is. We
# also designate an output directory.
set Use years in output instead of seconds = false
set End time = 0.1
set Output directory = output-convection-box2

# Then there are variables that describe the tolerance of
# the linear solver as well as how the pressure should
# be normalized. Here, we choose a zero average pressure
# at the surface of the domain (for the current geometry, the
# surface is defined as the top boundary).
set Linear solver tolerance = 1e-7
set Temperature solver tolerance = 1e-10

set Pressure normalization = surface
set Surface pressure = 0


# Then come a number of sections that deal with the setup
# of the problem to solve. The first one deals with the
# geometry of the domain within which we want to solve.
# The sections that follow all have the same basic setup
# where we select the name of a particular model (here,
# the box geometry) and then, in a further subsection,
# set the parameters that are specific to this particular
# model.
subsection Geometry model
set Model name = box

subsection Box
set X extent = 1
set Y extent = 1
end
end


# The next section deals with the initial conditions for the
# temperature (there are no initial conditions for the
# velocity variable since the velocity is assumed to always
# be in a static equilibrium with the temperature field).
# There are a number of models with the 'function' model
# a generic one that allows us to enter the actual initial
# conditions in the form of a formula that can contain
# constants. We choose a linear temperature profile that
# matches the boundary conditions defined below plus
# a small perturbation:
subsection Initial temperature model
set Model name = function

subsection Function
set Variable names = x,z
set Function constants = p=0.01, L=1, pi=3.1415926536, k=1
set Function expression = (1.0-z) - p*cos(k*pi*x/L)*sin(pi*z)
end
end


# Then follows a section that describes the boundary conditions
# for the temperature. The model we choose is called 'box' and
# allows to set a constant temperature on each of the four sides
# of the box geometry. In our case, we choose something that is
# heated from below and cooled from above. (As will be seen
# in the next section, the actual temperature prescribed here
# at the left and right does not matter.)
subsection Boundary temperature model
set Model name = box

subsection Box
set Bottom temperature = 1
set Left temperature = 0
set Right temperature = 0
set Top temperature = 0
end
end


# We then also have to prescribe several other parts of the model such as
# which boundaries actually carry a prescribed boundary temperature, whereas
# all other parts of the boundary are insulated (i.e., no heat flux through
# these boundaries; this is also often used to specify symmetry boundaries).
subsection Model settings
set Fixed temperature boundary indicators = bottom, top

# The next parameters then describe on which parts of the
# boundary we prescribe a zero or nonzero velocity and
# on which parts the flow is allowed to be tangential.
# Here, all four sides of the box allow tangential
# unrestricted flow but with a zero normal component:
set Zero velocity boundary indicators =
set Prescribed velocity boundary indicators =
set Tangential velocity boundary indicators = left, right, bottom, top
end

# The following two sections describe first the
# direction (vertical) and magnitude of gravity and the
# material model (i.e., density, viscosity, etc). We have
# discussed the settings used here in the introduction to
# this cookbook in the manual already.
subsection Gravity model
set Model name = vertical

subsection Vertical
set Magnitude = 1e4 # = Ra / Thermal expansion coefficient
end
end


subsection Material model
set Model name = simple # default:

subsection Simple model
set Reference density = 1
set Reference specific heat = 1
set Reference temperature = 0
set Thermal conductivity = 1
set Thermal expansion coefficient = 1
set Viscosity = 1
end
end


# The settings above all pertain to the description of the
# continuous partial differential equations we want to solve.
# The following section deals with the discretization of
# this problem, namely the kind of mesh we want to compute
# on. We here use a globally refined mesh without
# adaptive mesh refinement.
subsection Mesh refinement
set Initial global refinement = 5
set Initial adaptive refinement = 0
set Time steps between mesh refinement = 0
end


# The final part is to specify what ASPECT should do with the
# solution once computed at the end of every time step. The
# process of evaluating the solution is called `postprocessing'
# and we choose to compute velocity and temperature statistics,
# statistics about the heat flux through the boundaries of the
# domain, and to generate graphical output files for later
# visualization. These output files are created every time
# a time step crosses time points separated by 0.01. Given
# our start time (zero) and final time (0.5) this means that
# we will obtain 50 output files.
subsection Postprocess
set List of postprocessors = velocity statistics, temperature statistics, heat flux statistics, visualization, heat flux map

subsection Visualization
set Time between graphical output = 0.00
set Output format = hdf5
end
end

Loading

0 comments on commit d77075c

Please sign in to comment.