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

Adds an updated version of the Jupyter notebook tutorial for the onse… #5533

Merged
merged 7 commits into from
Mar 28, 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
2 changes: 2 additions & 0 deletions .typos.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ ba = "ba"

# Don't correct some other abbreviations
FOT = "FOT"
LinearNDInterpolator = "LinearNDInterpolator"
ND = "ND"

# Don't check the following files
[files]
Expand Down
45 changes: 45 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,45 @@
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.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we have a better place to put notebooks/tutorials? It seems weird to me to hide them inside the convection-box folder.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This was part of a broader discussion to keep notebooks as close as possible to the related prm's such that they stay current.

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
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is not documented here or on the page linked here: It seems that you have to add $ASPECT_DIR to the path manually before you can start "aspect". @gassmoeller is that true or am I missing something?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I believe this is in the default path for the notebook container.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@tjhei: Lorraine is correct, $ASPECT_DIR is already set inside the tool. No need for the user to set it.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If I click on https://geodynamics.org/resources/aspectnotebook, then 'launch tool', "new terminal" I get:

timoheister@geodynamics_1099_6:~$ aspect
bash: aspect: command not found

while $ASPECT_DIR/bin/aspect works.



## 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



## 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,168 @@
# 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.5
set Output directory = output-convection-box

# Then there are variables that describe 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 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. Note that 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. The variables in this equation are
# described below, and it is important to note that in many
# cases the values correspond to other model parameters
# defined elsewhere. As such, if these model parameters are
# changed, the values below will also need to be adjusted.
# L - Model length/width
# p, k - values related to the small temperature 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, 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 Boundary temperature model
set Fixed temperature boundary indicators = bottom, top
set List of model names = box

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


# 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:
subsection Boundary velocity model
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
end
end


subsection Material model
set Model name = simple

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


# We also have to specify that we want to use the Boussinesq
# approximation (assuming the density in the temperature
# equation to be constant, and incompressibility).
subsection Formulation
set Formulation = Boussinesq approximation
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 = 4
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

subsection Visualization
set Time between graphical output = 0.01
end
end

subsection Solver parameters
set Temperature solver tolerance = 1e-10
end
Original file line number Diff line number Diff line change
@@ -0,0 +1,168 @@
# 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 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 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. Note that 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. The variables in this equation are
# described below, and it is important to note that in many
# cases the values correspond to other model parameters
# defined elsewhere. As such, if these model parameters are
# changed, the values below will also need to be adjusted.
# L - Model length/width
# p, k - values related to the small temperature 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, 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 Boundary temperature model
set Fixed temperature boundary indicators = bottom, top
set List of model names = box

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


# 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:
subsection Boundary velocity model
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
end
end


subsection Material model
set Model name = simple

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


# We also have to specify that we want to use the Boussinesq
# approximation (assuming the density in the temperature
# equation to be constant, and incompressibility).
subsection Formulation
set Formulation = Boussinesq approximation
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

subsection Solver parameters
set Temperature solver tolerance = 1e-10
end
Loading