{ "cells": [ { "cell_type": "markdown", "metadata": { "lines_to_next_cell": 0, "toc": true }, "source": [ "

Table of Contents

\n", "
" ] }, { "cell_type": "markdown", "metadata": { "lines_to_next_cell": 0 }, "source": [ "## One-dimensional steady-state finite-volume approximation - cont'd\n", "\n", "### Summary to this point\n", "\n", "We want to express the fundamental 1-D steady-state stencil for an interior gridblock C, with neighbours E, W:\n", "\\begin{align}\n", "\\left(J_{EC}+J_{WC}\\right) &= 0 \\label{eq5141}\\\\\n", "\\end{align}\n", "\n", "in terms of concentrations. We laid out a three-step program:\n", "\n", "### 1. Write the total fluxes in terms of specific fluxes:\n", "For a mesh with gridblocks of constant size $\\Delta x$, $\\Delta y$, $\\Delta z$ and fluxes along the x-coordinate direction, we can write:\n", "\n", "\n", "\n", "\\begin{align}\n", "&J_{EC}=j_{EC}(\\Delta y) (\\Delta z)\\label{eq5143}\\\\\n", "&J_{WC}=j_{WC}(\\Delta y) (\\Delta z)\\label{eq5142}\\\\\n", "\\end{align}\n", "\n", "\n", "because the area of the face orthogonal to the $x$ direction is $(\\Delta y)(\\Delta z)$.\n", "\n", "So in terms of specific fluxes the fundamental 1-D steady-state stencil becomes:\n", "\n", "\\begin{align}\n", "&\\left(j_{EC}+j_{WC}\\right) (\\Delta y) (\\Delta z) = 0 \\label{eq5144}\\\\\n", "\\end{align}\n", "\n", "\n", "### 2. Write specific fluxes in terms of Fick's law.\n", "Since both $j_{EC}$ and $j_{WC}$ are aligned with the $x$ coordinate direction, the appropriate component of the flux vector is $j_x$:\n", "\n", "\\begin{align}\n", "j_x &= - D\\theta{\\partial c \\over \\partial x} \\label{eq5145}\\\\\n", "\\end{align}\n", "\n", "\n" ] }, { "cell_type": "markdown", "metadata": { "lines_to_next_cell": 0 }, "source": [ "### 3. Discrete approximation for Fick's law\n", "\n", "Consider the stencil below\n", "\n", "\n", "\n", "\n", "\n", "To approximate specific fluxes such as $j_x = - D\\theta {\\partial c \\over \\partial x}$ in terms of concentrations at nodal values in the centre of gridblocks, we use **finite-difference approximations**, which are motivated by the definition of the derivative:\n", "\n", "\\begin{align}\n", "{\\partial c \\over \\partial x} &= \\lim_{\\Delta x \\rightarrow 0} {c(x+\\Delta x) - c(x)\\over \\Delta x} \\label{eq5146}\\\\\n", "\\end{align}\n", "\n", "where $c(x+\\Delta x)$ is notation for \"the concentration at the point $x+\\Delta x, y, z$.\"\n", "\n", "We can use this idea to approximate the component of the gradient in **Fick's law** \\ref{eq5145} and compute the fluxes $j_{EC}$ and $j_{WC}$ in terms of values of concentration located at the centers of gridblocks **E, C, W** as (here for the case where $\\Delta x$ are the same for each gridblock, so that the nodes are separated by a distance $\\Delta x$):\n", "\n", "\\begin{align}\n", "j_{EC} &\\approx D\\theta {c_E - c_C \\over \\Delta x} \\label{eq5147}\\\\\n", "\\end{align}\n", "\n", "Recall that by our convention, $J_{EC}$ and $j_{EC}$ are positive ($>0$) when mass is entering gridblock C.\n", "\n", "### Your turn\n", "Assume at some instant in time, $c_E=15~mg/L$ and $c_C=20~mg/L$." ] }, { "cell_type": "markdown", "metadata": { "lines_to_next_cell": 0 }, "source": [ "
\n", "\n", "\n", "\n", "#### Your answer here:\n", "1. Is mass diffusing into or out of the gridblock C? How do you know?\n", "2. Is the sign of the flux $j_{EC}$ computed using the finite difference approximation above, Eq (\\ref{eq5147}) consistent with our sign convention?\n", "
" ] }, { "cell_type": "markdown", "metadata": { "lines_to_next_cell": 0 }, "source": [ "### Python\n", "If $\\Delta x= 0.1 m$, $\\Delta y=0.15 m$, and $\\Delta z=0.12 m$, and the diffusion coefficient is $D=2\\times 10^{-10}~m^2/s$, and the porosity is $\\theta = 0.25$, write a short python code to compute $j_{EC}$ and $J_{EC}$" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "scrolled": true }, "outputs": [], "source": [ "\"\"\"\n", "Code fragment to compute specific and total fluxes j_ec and J_ec\n", "\"\"\"\n", "dx = 0.1\n", "dy = 0.15\n", "dz = 0.12\n", "diff_coef = 2.0e-10\n", "poros = 0.25\n", "j_ec_spec = 11111 # replace 0 with your code\n", "j_ec_tot = 99999 # replace 0 with your code\n", "units_spec = \"PUT CORRECT SPECIFIC FLUX UNITS HERE\"\n", "units_tot = \"PUT CORRECT TOTAL FLUX UNITS HERE\"\n", "output_text = f\"\"\"\n", " The specific flux j_ec is {j_ec_spec} {units_spec}\n", " and the total flux is\n", " J_ec {j_ec_tot} {units_tot}\n", " \"\"\"\n", "print(output_text)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "
\n", "\n", "#### Your turn\n", "\n", "The approximation for $j_{EC}$ is given above in equation \\ref{eq5148}.\n", "\n", "Write the corresponding discrete approximation for $j_{WC}$ in terms of $D\\theta$, $c_W$, $c_C$ and $\\Delta x$, $\\Delta y$, and $\\Delta z$.\n", "\n", "
" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "
\n", "\n", "#### Your turn\n", "\\begin{align}\n", "j_{WC} &\\approx {????} \\label{eq5148}\\\\\n", "\\end{align}\n", "\n", "1. Is the sign of the flux $j_{WC}$ computed using your expression positive for flux entering gridblock C?\n", "2. Assume values for $c_w$ and $c_C$, and show that the sign works out.\n", "
" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## 1-D steady-state diffusion stencil\n", "\n", "Bringing it all together, the 1-D steady-state diffusion stencil in terms of specific fluxes\n", "\n", "\\begin{align*}\n", "&\\left(j_{EC}+j_{WC}\\right) (\\Delta y) (\\Delta z) = 0 \\\\\n", "\\end{align*}\n", "\n", "becomes in terms of concentrations:\n", "\n" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "
\n", "\n", "#### Your turn\n", "-replace $j_{WC}$ with the correct expression in terms of concentration.\n", "\n", "\\begin{align}\n", "&\\left(D\\theta {c_E - c_C \\over \\Delta x} + j_{WC} \\right) (\\Delta y) (\\Delta z) = 0 \\label{eq5149}\\\\\n", "\\end{align}\n", "\n", "\n", "
" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "### Reflection\n", "\n", "What have you learned? What have you struggled with? Reflect on anything else you have learned or struggled with and write it here." ] } ], "metadata": { "jupytext": { "cell_metadata_filter": "all", "formats": "", "notebook_metadata_filter": "all", "text_representation": { "extension": ".py", "format_name": "percent", "format_version": "1.2", "jupytext_version": "1.0.0-rc2" } }, "kernelspec": { "display_name": "Python 3", "language": "python", "name": "python3" }, "language_info": { "codemirror_mode": { "name": "ipython", "version": 3 }, "file_extension": ".py", "mimetype": "text/x-python", "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", "version": "3.7.3" }, "toc": { "base_numbering": 1, "nav_menu": {}, "number_sections": true, "sideBar": true, "skip_h1_title": false, "title_cell": "Table of Contents", "title_sidebar": "Contents", "toc_cell": true, "toc_position": { "height": "calc(100% - 180px)", "left": "10px", "top": "150px", "width": "358.523px" }, "toc_section_display": true, "toc_window_display": true } }, "nbformat": 4, "nbformat_minor": 2 }