-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 8fe7187
Showing
256 changed files
with
63,666 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
# Sphinx build info version 1 | ||
# This file hashes the configuration used when building these files. When it is not found, a full rebuild will be done. | ||
config: 87c4fbe0b5f1e22af8a4360697a7e593 | ||
tags: 645f666f9bcd5a90fca523b33c5a78b7 |
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file added
BIN
+34.6 KB
.doctrees/examples/co2_leakage_along_a_fault/1_generate_mesh_in_python_with_gmsh.doctree
Binary file not shown.
Binary file added
BIN
+28.6 KB
.doctrees/examples/co2_leakage_along_a_fault/2_generate_mesh_and_incon_files.doctree
Binary file not shown.
Binary file added
BIN
+24.5 KB
.doctrees/examples/co2_leakage_along_a_fault/3_generate_model_parameters_input_file.doctree
Binary file not shown.
Binary file added
BIN
+20.2 KB
...es/co2_leakage_along_a_fault/4_import_and_visualize_simulation_outputs_in_pyvista.doctree
Binary file not shown.
Binary file not shown.
Binary file added
BIN
+13.3 KB
.doctrees/examples/co2_leakage_along_a_fault/sg_execution_times.doctree
Binary file not shown.
Binary file added
BIN
+33.5 KB
.doctrees/examples/heat_pipe_in_cylindrical_geometry/1_preprocessing.doctree
Binary file not shown.
Binary file added
BIN
+16.7 KB
.doctrees/examples/heat_pipe_in_cylindrical_geometry/2_postprocessing.doctree
Binary file not shown.
Binary file not shown.
Binary file added
BIN
+9.86 KB
.doctrees/examples/heat_pipe_in_cylindrical_geometry/sg_execution_times.doctree
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Empty file.
97 changes: 97 additions & 0 deletions
97
_downloads/1ce45cd6327683a313eacb9cc8351140/2_postprocessing.ipynb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,97 @@ | ||
{ | ||
"cells": [ | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"metadata": { | ||
"collapsed": false | ||
}, | ||
"outputs": [], | ||
"source": [ | ||
"%matplotlib inline" | ||
] | ||
}, | ||
{ | ||
"cell_type": "markdown", | ||
"metadata": {}, | ||
"source": [ | ||
"\n# Plot profiles\n\nThe objective of this example is to import the output results and plot the profiles of temperature, pressure, liquid saturation and air mass fraction.\n" | ||
] | ||
}, | ||
{ | ||
"cell_type": "markdown", | ||
"metadata": {}, | ||
"source": [ | ||
"Here, we assume that the simulation's output have been written in the file \"OUTPUT\". To import the results, we use the function :func:`toughio.read_output`. The variable `outputs` is a list with three :class:`toughio.Output` corresponding to the three time steps requested in the preprocessing example. In this example, we want to look at the last time step (index -1).\n\n" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"metadata": { | ||
"collapsed": false | ||
}, | ||
"outputs": [], | ||
"source": [ | ||
"import numpy as np\nimport toughio\n\noutputs = toughio.read_output(\"OUTPUT\")\noutput = outputs[-1]\n\nt = output.data[\"T\"]\np = output.data[\"P\"]\nsl = output.data[\"SL\"]\nxm = output.data[\"XAIRG\"]" | ||
] | ||
}, | ||
{ | ||
"cell_type": "markdown", | ||
"metadata": {}, | ||
"source": [ | ||
"It is well known that for the stated conditions (1-D radial geometry, homogeneous medium, uniform initial conditions, and a constant-rate line source) the problem has a similarity solution: The partial differential equations for this complex two-phase flow problem can be rigorously transformed into a set of ordinary differential equations in the variable $Z = R/\\sqrt{t}$, which can be easily solved to any degree of accuracy desired by means of one-dimensional numerical integration (O'Sullivan, 1981). Comparison of TOUGH2 simulations with the semi-analytical similarity solution has shown excellent agreement (Doughty and Pruess, 1992). To define such variable, we first need to import the mesh \n\n" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"metadata": { | ||
"collapsed": false | ||
}, | ||
"outputs": [], | ||
"source": [ | ||
"mesh = toughio.read_mesh(\"mesh.pickle\")\nR = np.log(mesh.centers[:, 0] / (output.time) ** 0.5)" | ||
] | ||
}, | ||
{ | ||
"cell_type": "markdown", | ||
"metadata": {}, | ||
"source": [ | ||
"Now that the required data have been imported, we can plot the results using :mod:`matplotlib`.\n\n" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"metadata": { | ||
"collapsed": false | ||
}, | ||
"outputs": [], | ||
"source": [ | ||
"import matplotlib.pyplot as plt\nplt.rc(\"font\", size=12)\n\nfig, ax1 = plt.subplots(figsize=(8, 5))\nax2 = ax1.twinx()\n\nax1.plot(R, t, color=\"black\", linestyle=\"--\", label=\"Temperature\")\nax1.set_ylim(0.0, 260.0)\nax1.set_ylabel(\"Temperature ($\\degree$C)\")\n\nax2.plot(R, sl, label=\"Liquid saturation\")\nax2.plot(R, xm, label=\"Air mass fraction\")\nax2.plot(R, p * 1.0e-5, label=\"Pressure (bar)\")\nax2.set_ylim(0.0, 1.3)\nax2.set_ylabel(\"Liquid saturation, air mass fraction, pressure\")\n\nax1.set_xlim(R.min(), -4.0)\nax1.set_xlabel(\"$ln(R/\\sqrt{t})$\")\n\nfig.legend(\n loc=\"lower left\",\n bbox_to_anchor=(0.0, 0.0),\n bbox_transform=ax1.transAxes,\n frameon=False,\n)" | ||
] | ||
} | ||
], | ||
"metadata": { | ||
"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.9.19" | ||
} | ||
}, | ||
"nbformat": 4, | ||
"nbformat_minor": 0 | ||
} |
212 changes: 212 additions & 0 deletions
212
_downloads/4790b1dc53fd45ecd00f717e3df347da/3_generate_model_parameters_input_file.ipynb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,212 @@ | ||
{ | ||
"cells": [ | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"metadata": { | ||
"collapsed": false | ||
}, | ||
"outputs": [], | ||
"source": [ | ||
"%matplotlib inline" | ||
] | ||
}, | ||
{ | ||
"cell_type": "markdown", | ||
"metadata": {}, | ||
"source": [ | ||
"\n# Generate model parameters input file\n\nNow that the mesh has been pre-processed, we can define the TOUGH simulation parameters.\n" | ||
] | ||
}, | ||
{ | ||
"cell_type": "markdown", | ||
"metadata": {}, | ||
"source": [ | ||
"As always, we first import the required modules for this example.\n\n" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"metadata": { | ||
"collapsed": false | ||
}, | ||
"outputs": [], | ||
"source": [ | ||
"import numpy as np\nimport toughio" | ||
] | ||
}, | ||
{ | ||
"cell_type": "markdown", | ||
"metadata": {}, | ||
"source": [ | ||
"A :mod:`toughio` input file is defined as a nested dictionary with meaningful keywords.\nLet's initialize our parameter dictionary by giving the simulation a title and defining the equation-of-state. This example will also be run isothermally.\n\n" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"metadata": { | ||
"collapsed": false | ||
}, | ||
"outputs": [], | ||
"source": [ | ||
"parameters = {\n \"title\": \"Simulation of CO2 leak along a fault\",\n \"eos\": \"eco2n\",\n \"isothermal\": True,\n \"start\": True,\n}" | ||
] | ||
}, | ||
{ | ||
"cell_type": "markdown", | ||
"metadata": {}, | ||
"source": [ | ||
"We can also define some default values that are shared by the different materials.\n\n" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"metadata": { | ||
"collapsed": false | ||
}, | ||
"outputs": [], | ||
"source": [ | ||
"parameters[\"default\"] = {\n \"density\": 2260.0,\n \"conductivity\": 1.8,\n \"specific_heat\": 1500.0,\n \"compressibility\": 8.33e-10,\n \"conductivity_dry\": 1.8,\n \"tortuosity\": 0.7,\n \"relative_permeability\": {\n \"id\": 3,\n \"parameters\": [0.3, 0.05],\n },\n \"capillarity\": {\n \"id\": 7,\n \"parameters\": [0.457, 0.0, 5.03e-5, 5.0e7, 0.99],\n },\n}" | ||
] | ||
}, | ||
{ | ||
"cell_type": "markdown", | ||
"metadata": {}, | ||
"source": [ | ||
"Now, we define specific material properties (different than the default ones previously defined) for each material in the mesh (i.e., we write the block `ROCKS`).\n\n" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"metadata": { | ||
"collapsed": false | ||
}, | ||
"outputs": [], | ||
"source": [ | ||
"parameters[\"rocks\"] = {\n \"UPPAQ\": {\n \"porosity\": 0.10,\n \"permeability\": 1.0e-14,\n },\n \"CENAQ\": {\n \"porosity\": 0.10,\n \"permeability\": 1.0e-13,\n },\n \"BASAQ\": {\n \"porosity\": 0.01,\n \"permeability\": 1.0e-16,\n \"relative_permeability\": {\n \"id\": 3,\n \"parameters\": [0.3, 0.05],\n },\n \"capillarity\": {\n \"id\": 7,\n \"parameters\": [0.457, 0.0, 1.61e-6, 5.0e7, 0.99],\n },\n },\n \"CAPRO\": {\n \"porosity\": 0.01,\n \"permeability\": 1.0e-19,\n \"relative_permeability\": {\n \"id\": 3,\n \"parameters\": [0.3, 0.05],\n },\n \"capillarity\": {\n \"id\": 7,\n \"parameters\": [0.457, 0.0, 1.61e-6, 5.0e7, 0.99],\n },\n },\n \"FAULT\": {\n \"porosity\": 0.10,\n \"permeability\": 1.0e-13,\n },\n \"BOUND\": {\n \"specific_heat\": 1.0e55,\n \"porosity\": 0.10,\n \"permeability\": 1.0e-13,\n },\n}" | ||
] | ||
}, | ||
{ | ||
"cell_type": "markdown", | ||
"metadata": {}, | ||
"source": [ | ||
"We can specify some simulation parameters (block `PARAM`), options (`MOP`) and selections (block `SELEC`).\n\n" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"metadata": { | ||
"collapsed": false | ||
}, | ||
"outputs": [], | ||
"source": [ | ||
"parameters[\"options\"] = {\n \"n_cycle\": 9999,\n \"n_cycle_print\": 9999,\n \"t_ini\": 0.0,\n \"t_max\": 3.0 * 365.25 * 24.0 * 3600.0,\n \"t_steps\": 24.0 * 3600.0,\n \"t_step_max\": 1.0e8,\n \"t_reduce_factor\": 4,\n \"eps1\": 1.0e-4,\n \"eps2\": 1.0,\n \"gravity\": 9.81,\n}\nparameters[\"extra_options\"] = {\n 16: 4,\n 21: 8,\n}\nparameters[\"selections\"] = {\n \"integers\": {\n 1: 1,\n 13: 2,\n 16: 2,\n },\n \"floats\": [0.8, 0.8],\n}" | ||
] | ||
}, | ||
{ | ||
"cell_type": "markdown", | ||
"metadata": {}, | ||
"source": [ | ||
"We also have to define the generator (i.e., the source).\nHowever, we first need to know the name of the cell in which the CO2 is injected. Let's unpickle the mesh back and use the method :meth:`toughio.Mesh.near` to get the name of the injection element.\n\n" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"metadata": { | ||
"collapsed": false | ||
}, | ||
"outputs": [], | ||
"source": [ | ||
"mesh = toughio.read_mesh(\"mesh.pickle\")\nlabel = mesh.labels[mesh.near((0.0, 0.0, -1500.0))]" | ||
] | ||
}, | ||
{ | ||
"cell_type": "markdown", | ||
"metadata": {}, | ||
"source": [ | ||
"Now we can add the generator to the parameters by specifying the type and injection rate (block `GENER`).\n\n" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"metadata": { | ||
"collapsed": false | ||
}, | ||
"outputs": [], | ||
"source": [ | ||
"parameters[\"generators\"] = [\n {\n \"label\": label,\n \"type\": \"COM3\",\n \"rates\": 0.02,\n },\n]" | ||
] | ||
}, | ||
{ | ||
"cell_type": "markdown", | ||
"metadata": {}, | ||
"source": [ | ||
"Let's customize the outputs.\nFor this example, we want TOUGH to save the output every three months (i.e., 4 outputs per year). To reduce the size of the output file, we also want TOUGH to only save the saturation of phase 1 (gas) in addition to the cell coordinates. Note that this option is only available in TOUGH3.\n\n" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"metadata": { | ||
"collapsed": false | ||
}, | ||
"outputs": [], | ||
"source": [ | ||
"parameters[\"times\"] = np.arange(1, 13) * 90.0 * 24.0 * 3600.0\nparameters[\"output\"] = {\n \"variables\": [\n {\"name\": \"saturation\", \"options\": 1},\n {\"name\": \"coordinate\"},\n ],\n}" | ||
] | ||
}, | ||
{ | ||
"cell_type": "markdown", | ||
"metadata": {}, | ||
"source": [ | ||
"Finally, we can export the model parameters input file by using the function :func:`toughio.write_input`.\n\n" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"metadata": { | ||
"collapsed": false | ||
}, | ||
"outputs": [], | ||
"source": [ | ||
"toughio.write_input(\"INFILE\", parameters)" | ||
] | ||
}, | ||
{ | ||
"cell_type": "markdown", | ||
"metadata": {}, | ||
"source": [ | ||
"At this stage, all the input files required to run the simulation have been generated. We can now simply call TOUGH using EOS ECO2n (e.g., :code:`tough3-eco2n` for TOUGH3).\n\n" | ||
] | ||
} | ||
], | ||
"metadata": { | ||
"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.9.19" | ||
} | ||
}, | ||
"nbformat": 4, | ||
"nbformat_minor": 0 | ||
} |
Oops, something went wrong.