Skip to content

Commit

Permalink
Added some comments
Browse files Browse the repository at this point in the history
  • Loading branch information
RemDelaporteMathurin committed Jun 30, 2023
1 parent 8b23206 commit 2c77e59
Showing 1 changed file with 39 additions and 31 deletions.
70 changes: 39 additions & 31 deletions tasks/task5.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,9 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"Create a mesh with FEniCS and mark the subdomains."
"Create a mesh with FEniCS and mark the subdomains.\n",
"\n",
"For more information on FEniCS meshes, please visit [the mesh demo](https://fenicsproject.org/olddocs/dolfin/latest/python/demos/built-in-meshes/demo_built-in-meshes.py.html) and the [subdomains demo](https://fenicsproject.org/pub/tutorial/sphinx1/._ftut1005.html)."
]
},
{
Expand All @@ -39,8 +41,8 @@
{
"data": {
"text/plain": [
"[<matplotlib.lines.Line2D at 0x7fd430cac4f0>,\n",
" <matplotlib.lines.Line2D at 0x7fd430cacdc0>]"
"[<matplotlib.lines.Line2D at 0x7f7c9536b910>,\n",
" <matplotlib.lines.Line2D at 0x7f7c953ac220>]"
]
},
"execution_count": 2,
Expand Down Expand Up @@ -100,7 +102,9 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"The mesh can now be passed to a `festim.Mesh` object."
"The mesh can now be passed to a `festim.Mesh` instance.\n",
"\n",
"The volume markers and surface markers also need to be passed to the `festim.Mesh` instance."
]
},
{
Expand All @@ -109,7 +113,6 @@
"metadata": {},
"outputs": [],
"source": [
"# creating mesh with FESTIM\n",
"my_model.mesh = F.Mesh(\n",
" mesh=mesh_fenics,\n",
" volume_markers=volume_markers,\n",
Expand Down Expand Up @@ -139,7 +142,7 @@
"my_model.boundary_conditions = [\n",
" F.DirichletBC(field=0, surfaces=top_and_bottom_id, value=0),\n",
" F.DirichletBC(field=0, surfaces=left_id, value=1)\n",
" ]\n",
"]\n",
"\n",
"my_model.settings = F.Settings(\n",
" absolute_tolerance=1e-10,\n",
Expand All @@ -165,26 +168,18 @@
"name": "stdout",
"output_type": "stream",
"text": [
"Calling FFC just-in-time (JIT) compiler, this may take some time.\n",
"Calling FFC just-in-time (JIT) compiler, this may take some time.\n",
"Calling FFC just-in-time (JIT) compiler, this may take some time.\n",
"Calling FFC just-in-time (JIT) compiler, this may take some time.\n",
"Calling FFC just-in-time (JIT) compiler, this may take some time.\n",
"Calling FFC just-in-time (JIT) compiler, this may take some time.\n",
"Defining initial values\n",
"Defining variational problem\n",
"Defining source terms\n",
"Defining boundary conditions\n",
"Solving steady state problem...\n",
"Calling FFC just-in-time (JIT) compiler, this may take some time.\n",
"Calling FFC just-in-time (JIT) compiler, this may take some time.\n",
"Solved problem in 1.00 s\n"
"Solved problem in 0.00 s\n"
]
},
{
"data": {
"text/plain": [
"<matplotlib.tri._tricontour.TriContourSet at 0x7fd42b7f65c0>"
"<matplotlib.tri._tricontour.TriContourSet at 0x7f7c931f0e80>"
]
},
"execution_count": 5,
Expand Down Expand Up @@ -279,9 +274,9 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"Now that we created a FEniCS function representing the velocity, let's add an advection term.\n",
"Now that we created a FEniCS function representing the velocity, let's add an advection term to the governing equation.\n",
"\n",
"The governing equation needs to be:\n",
"The governing equation for steady state advection-diffusion is:\n",
"\n",
"$$\\nabla \\cdot (D \\nabla c) - v \\cdot \\nabla c = 0$$\n",
"\n",
Expand All @@ -297,6 +292,23 @@
"cell_type": "code",
"execution_count": 8,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"{ (grad(c)) . (grad(v_0)) } * dx(<Mesh #0>[1], {})\n"
]
}
],
"source": [
"print(my_model.h_transport_problem.F)"
]
},
{
"cell_type": "code",
"execution_count": 9,
"metadata": {},
"outputs": [
{
"name": "stdout",
Expand All @@ -305,7 +317,9 @@
"Defining initial values\n",
"Defining variational problem\n",
"Defining source terms\n",
"Defining boundary conditions\n"
"Defining boundary conditions\n",
"{ (grad(c)) . (grad(v_0)) } * dx(<Mesh #0>[1], {})\n",
" + { (conj((v_0))) * ((grad(c)) . (f_90)) } * dx(<Mesh #0>[everywhere], {})\n"
]
}
],
Expand All @@ -319,7 +333,8 @@
"\n",
"advection_term = inner(dot(grad(hydrogen_concentration), velocity), test_function_solute) * my_model.mesh.dx\n",
"\n",
"my_model.h_transport_problem.F += advection_term"
"my_model.h_transport_problem.F += advection_term\n",
"print(my_model.h_transport_problem.F)"
]
},
{
Expand All @@ -332,23 +347,15 @@
},
{
"cell_type": "code",
"execution_count": 9,
"execution_count": 10,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Solving steady state problem...\n",
"Calling FFC just-in-time (JIT) compiler, this may take some time.\n"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"Calling FFC just-in-time (JIT) compiler, this may take some time.\n",
"Solved problem in 1.20 s\n"
"Solved problem in 0.00 s\n"
]
},
{
Expand All @@ -374,7 +381,8 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"The concentration field is greatly affected as particles are now pushed towards the right hand side of the domain!\n",
"The concentration field is greatly affected as particles are now pushed towards the right hand side of the domain.\n",
"\n",
"# Task:\n",
"\n",
"Vary the velocity field to investigate its influence on the mobile concentration"
Expand Down

0 comments on commit 2c77e59

Please sign in to comment.