{ "cells": [ { "cell_type": "markdown", "id": "worldwide-contact", "metadata": {}, "source": [ "\n", "\n", "#
From Maps to Models - Tutorials for structural geological modeling using GemPy and GemGIS
\n", "\n", "# Model 3 - Faulted Layers\n", "\n", "\n", "This third notebook in this tutorial series builds upon the [first notebook](model1_Horizontal_Layers.ipynb) ([notebook on Github](https://nbviewer.org/github/cgre-aachen/gemgis_data/blob/main/notebooks/01_basic_modeling/model1_Horizontal_Layers.ipynb)) and [second notebook](model2_Folded_Layers.ipynb) ([notebook on Github](https://nbviewer.org/github/cgre-aachen/gemgis_data/blob/main/notebooks/01_basic_modeling/model2_Folded_Layers.ipynb)) where horizontal and folded layers were modeled, respectively. This notebook illustrates how to create a simple sample model of faulted layers in `GemPy`. The model consists of three parallel layers and two faults and has an extent of 1000 m by 1000 m with a vertical extent of 600 m. \n", "\n", "If you have not gone through the introduction notebook for the course, please check it out: [Introduction Notebook](../00_introduction_to_structural_modeling.ipynb) ([notebook on Github](https://nbviewer.org/github/cgre-aachen/gemgis_data/blob/main/notebooks/00_introduction_to_structural_modeling.ipynb))\n", "\n", "\n", "\n", "
\n", "In this tutorial, you will learn the following:
\n", "- Get an understanding of how faults are modeled/displayed in GemPy
\n", "- How to build a simple model consisting of faulted layers belonging to one Series
\n", "\n", "
\n", "\n", "## Contents\n", "\n", "1. [Installing GemPy](#installing-gempy)\n", "2. [Importing Libraries](#importing-libraries)\n", "3. [Data Preparation](#data-preparation)\n", " 1. [Importing Interface Points](#importing-interface-points)\n", " 2. [Importing Orientations](#importing-orientations)\n", "4. [GemPy Model Calculation](#gempy-model-calculation)\n", " 1. [Creating the GemPy Model](#creating-the-gempy-model)\n", " 2. [Data Initiation](#data-initiation)\n", " 3. [Inspecting the Surfaces](#inspecting-the-surfaces)\n", " 4. [Inspecting the Input Data](#inspecting-the-input-data)\n", " 5. [Map Stack to Surfaces](#map-stack-to-surfaces)\n", " 6. [Setting Faults](#setting-faults)\n", " 7. [Plotting Input Data in 2D](#plotting-the-input-data-in-2d)\n", " 8. [Plotting Input Data in 3D](#plotting-the-input-data-in-3d)\n", " 9. [Setting the Interpolator](#setting-the-interpolator)\n", " 10. [Computing the Model](#computing-the-model)\n", "5. [Model Visualization and Post-Processing](#model-visualization-and-post-processing)\n", " 1. [Visualizing Cross Sections of the Computed Model](#visualizing-cross-sections-of-the-computed-model)\n", " 2. [Visualizing the computed model in 3D](#visualizing-the-computed-model-in-3d)\n", "6. [Conclusions](#conclusions)\n", "7. [Outlook](#outlook)\n", "8. [Licensing](#licensing)\n", "\n", "\n", "\n", "\n" ] }, { "cell_type": "markdown", "id": "ba7d20fc", "metadata": {}, "source": [ "In reality, most geological settings are formed by a concatenation of depositional phases partitioned by unconformity boundaries and subjected to tectonic stresses that displace and deform the layers. While the interpolation is able to represent realistic folding – given enough data – the method fails to describe discontinuities. To overcome this limitation, it is possible to combine several scalar fields to recreate the desired result. So far, the implemented discontinuities in GemPy are unconformities and infinite faults. Both types are computed by specific combinations of independent scalar fields. To display the offset of faults, a drift function is calculated. \n", "\n", "\n", "Faults require the same input data as layers, interface points and orientations. `GemPy` has to be told that faults are present in the model in order to treat them as such. This is done with the function `geo_model.set_is_fault()` where you pass the name of the faults. \n", "\n", "\n", "\n", "Source: de la Varga et al. (2019)" ] }, { "cell_type": "markdown", "id": "solid-hormone", "metadata": {}, "source": [ "\n", "\n", "# Installing GemPy\n", "\n", "If you have not installed `GemPy` yet, please follow the [installation instructions](https://docs.gempy.org/installation.html). If you encounter any issues, feel free to open a new discussion at [GemPy Discussions](https://github.com/cgre-aachen/gempy/discussions). If you encounter an error in the installation process, feel free to also open an issue at [GemPy Issues](https://github.com/cgre-aachen/gempy/issues). There, the `GemPy` development team will help you out. " ] }, { "cell_type": "markdown", "id": "artificial-customs", "metadata": {}, "source": [ "\n", "\n", "# Importing Libraries\n", "\n", "For this notebook, we need the `pandas` library for the data preparation and `matplotlib` for plotting and of course the `gempy` library. Any warnings that may appear can be ignored for now. " ] }, { "cell_type": "code", "execution_count": null, "id": "2f498618", "metadata": { "ExecuteTime": { "end_time": "2022-04-02T12:34:24.298218Z", "start_time": "2022-04-02T12:34:20.847877Z" } }, "outputs": [], "source": [ "import pandas as pd\n", "import gempy as gp\n", "import matplotlib.pyplot as plt" ] }, { "cell_type": "markdown", "id": "jewish-complex", "metadata": {}, "source": [ "\n", "# Data Preparation\n", "\n", "For this model, the only thing that needs to be done is loading the already created interface points and orientations. In the next tutorials, you will create the data yourself and process it further to make it usable for GemPy. \n", "\n", "\n", "## Importing Interface Points\n", "\n", "We are using the `pandas` library to load the interface points that were prepared beforehand and stored as CSV-file. The only information that is needed are the location of the interface point (`X`, `Y`, `Z`) and the `formation` it belongs to. You may have to adjust the `delimiter` when loading the file." ] }, { "cell_type": "code", "execution_count": null, "id": "9c8c178c", "metadata": { "ExecuteTime": { "end_time": "2022-04-02T12:34:24.334226Z", "start_time": "2022-04-02T12:34:24.300219Z" } }, "outputs": [], "source": [ "interfaces = pd.read_csv('../data/model3/model3_interfaces.csv', \n", " delimiter = ';')\n", "interfaces.head()" ] }, { "cell_type": "markdown", "id": "occupied-simulation", "metadata": {}, "source": [ "\n", "\n", "## Importing Orientations\n", "\n", "The orientations will also be loaded using `pandas`. In addition to the location and the formation the orientation belongs to, the dip value, azimuth value (dip direction) and a polarity value (mostly set to 1 by default) needs to be provided. As the model will feature faulted layers, the dip and the azimuth values may be variable. Orientations are provided for all three modeled layers. " ] }, { "cell_type": "code", "execution_count": null, "id": "bd8aa29b", "metadata": { "ExecuteTime": { "end_time": "2022-04-02T12:34:24.365234Z", "start_time": "2022-04-02T12:34:24.338228Z" } }, "outputs": [], "source": [ "orientations = pd.read_csv('../data/model3/model3_orientations.csv', \n", " delimiter=';')\n", "orientations.head()" ] }, { "cell_type": "markdown", "id": "veterinary-acceptance", "metadata": {}, "source": [ "\n", "\n", "# GemPy Model Calculation\n", "\n", "The following part presents the main steps of creating a model in `GemPy`. \n", "\n", "The creation of a `GemPy` Model follows particular steps which will be performed in the following:\n", "\n", "1. Create new model: `gp.create_model()`\n", "2. Data Initiation: `gp.init_data()`\n", "3. Map Stack to Surfaces: `gp.map_stack_to_surfaces()`\n", "4. Setting Faults: `geo_model.set_is_fault()`\n", "5. Set the Interpolator: `gp.set_interpolator()`\n", "6. Computing the Model: `gp.compute_model()`\n", "\n", "\n", "\n", "## Creating the GemPy Model\n", "\n", "The first step is to create a new empty `GemPy` model by providing a name for it. " ] }, { "cell_type": "code", "execution_count": null, "id": "eb3ec438", "metadata": { "ExecuteTime": { "end_time": "2022-04-02T12:34:25.188228Z", "start_time": "2022-04-02T12:34:24.368236Z" } }, "outputs": [], "source": [ "geo_model = gp.create_model('Model3_Faulted_Layers')\n", "geo_model" ] }, { "cell_type": "markdown", "id": "supreme-encoding", "metadata": {}, "source": [ "\n", "\n", "## Data Initiation\n", "\n", "During this step, the `extent` of the model (`xmin`, `xmax`, `ymin`, `ymax`, `zmin`, `zmax`) and the `resolution` in `X`, `Y`and `Z` direction (`res_x`, `res_y`, `res_z`, equal to the number of cells in each direction) will be set using lists of values. \n", "\n", "The interface points (`surface_points_df`) and orientations (`orientations_df`) will be passed as `pandas` `DataFrames`. " ] }, { "cell_type": "code", "execution_count": null, "id": "ae4bb825", "metadata": { "ExecuteTime": { "end_time": "2022-04-02T12:34:25.457220Z", "start_time": "2022-04-02T12:34:25.190218Z" } }, "outputs": [], "source": [ "gp.init_data(geo_model=geo_model, \n", " extent=[0, 1000, 0, 1000, -600, 0], \n", " resolution=[100, 100, 100],\n", " surface_points_df=interfaces,\n", " orientations_df=orientations,\n", " default_values=True)" ] }, { "cell_type": "markdown", "id": "armed-story", "metadata": {}, "source": [ "\n", "\n", "## Inspecting the Surfaces\n", "\n", "The model consists of three different layers or surfaces now which all belong to the `Default series`. During the next step, the proper `Series` will be assigned to the surfaces. Using the `surfaces`-attribute again, we can check which layers were loaded." ] }, { "cell_type": "code", "execution_count": null, "id": "9e8519ea", "metadata": { "ExecuteTime": { "end_time": "2022-04-02T12:34:25.536242Z", "start_time": "2022-04-02T12:34:25.459225Z" } }, "outputs": [], "source": [ "geo_model.surfaces" ] }, { "cell_type": "markdown", "id": "0670ce8e", "metadata": {}, "source": [ "\n", "\n", "## Inspecting the Input Data\n", "\n", "The loaded interface points and orientations can again be inspected using the `surface_points`- and `orientations`-attributes. Using the `df`-attribute of this object will convert the displayed table in a `pandas` `DataFrame`." ] }, { "cell_type": "code", "execution_count": null, "id": "3e9a8a8f", "metadata": {}, "outputs": [], "source": [ "geo_model.surface_points.df.head()" ] }, { "cell_type": "code", "execution_count": null, "id": "d5dd786a", "metadata": {}, "outputs": [], "source": [ "geo_model.orientations.head()" ] }, { "cell_type": "markdown", "id": "occupational-coaching", "metadata": {}, "source": [ "\n", "\n", "## Map Stack to Surfaces\n", "\n", "During this step, all three layers of the model are assigned to the `Strata1` series. We know that the layers modeled here are parallel. If the layers were not parallel as shown in the next models, multiple series would be defined. Further, we define two separate series for `Fault1` and `Fault2`. We will also add a `Basement` here (`geo_model.add_surfaces('Basement')`). The order within one series also defines the age relations within this series and has to be according to the depositional events of the layers." ] }, { "cell_type": "code", "execution_count": null, "id": "ca6dfa3e", "metadata": { "ExecuteTime": { "end_time": "2022-04-02T12:34:25.789299Z", "start_time": "2022-04-02T12:34:25.540243Z" } }, "outputs": [], "source": [ "gp.map_stack_to_surfaces(geo_model,\n", " {\n", " 'Fault1': ('Fault1'),\n", " 'Fault2': ('Fault2'),\n", " 'Strata1': ('Layer1', 'Layer2', 'Layer3'), \n", " },\n", " remove_unused_series=True)\n", "geo_model.add_surfaces('Basement')\n", "geo_model.surfaces" ] }, { "cell_type": "code", "execution_count": null, "id": "92e45187", "metadata": {}, "outputs": [], "source": [ "geo_model.stack" ] }, { "cell_type": "markdown", "id": "571d2db3", "metadata": {}, "source": [ "\n", "\n", "## Setting Faults \n", "\n", "In addition to `Series` for the layers, we defined two `Series` containing the two faults. In order for `GemPy` to recognize the faults as faults, we need to define them as faults (`geo_model.set_is_fault()`). " ] }, { "cell_type": "code", "execution_count": null, "id": "ff7d420b", "metadata": {}, "outputs": [], "source": [ "geo_model.set_is_fault(['Fault1', 'Fault2'])" ] }, { "cell_type": "markdown", "id": "directed-immigration", "metadata": {}, "source": [ "\n", "\n", "## Plotting the input data in 2D using Matplotlib\n", "\n", "The input data can now be visualized in 2D using `matplotlib`. This might for example be useful to check if all points and measurements are defined the way we want them to. Using the function `plot_2d()`, we attain a 2D projection of our data points onto a plane of chosen direction (we can choose this attribute to be either `'x'`, `'y'`, or `'z'`)." ] }, { "cell_type": "code", "execution_count": null, "id": "ee36f42b", "metadata": { "ExecuteTime": { "end_time": "2022-04-02T12:34:26.152213Z", "start_time": "2022-04-02T12:34:25.792302Z" } }, "outputs": [], "source": [ "gp.plot_2d(geo_model, \n", " direction='z', \n", " show_lith=False, \n", " show_boundaries=False)\n", "plt.grid()" ] }, { "cell_type": "markdown", "id": "objective-standard", "metadata": {}, "source": [ "\n", "\n", "## Plotting the input data in 3D using PyVista\n", "\n", "The input data can also be viszualized using the `pyvista` package. In this view, the interface points are visible as well as the orientations (marked as arrows) which indicate the normals of each orientation value. \n", "\n", "The `pyvista` package requires the Visualization Toolkit (VTK) to be installed." ] }, { "cell_type": "code", "execution_count": null, "id": "03cfc42d", "metadata": { "ExecuteTime": { "end_time": "2022-04-02T12:34:26.690389Z", "start_time": "2022-04-02T12:34:26.155214Z" } }, "outputs": [], "source": [ "gp.plot_3d(geo_model, \n", " image=False, \n", " plotter_type='basic', \n", " notebook=True)" ] }, { "cell_type": "markdown", "id": "elementary-camping", "metadata": {}, "source": [ "\n", "## Setting the interpolator\n", "\n", "Once we have made sure that we have defined all our primary information, we can continue with the next step towards creating our geological model: preparing the input data for interpolation.\n", "\n", "Setting the interpolator is necessary before computing the actual model. Here, the most important kriging parameters can be defined. " ] }, { "cell_type": "code", "execution_count": null, "id": "8e27b70d", "metadata": { "ExecuteTime": { "end_time": "2022-04-02T12:34:29.915220Z", "start_time": "2022-04-02T12:34:26.693389Z" } }, "outputs": [], "source": [ "gp.set_interpolator(geo_model,\n", " compile_theano=True,\n", " theano_optimizer='fast_compile',\n", " verbose=[],\n", " update_kriging=False\n", " )" ] }, { "cell_type": "markdown", "id": "innovative-cradle", "metadata": {}, "source": [ "\n", "\n", "## Computing the model\n", "\n", "At this point, we have all we need to compute our full model via `gp.compute_model()`. By default, this will return two separate solutions in the form of arrays. The first provides information on the lithological formations, the second on the fault network in the model, which is not present in this example. " ] }, { "cell_type": "code", "execution_count": null, "id": "5b7b2377", "metadata": { "ExecuteTime": { "end_time": "2022-04-02T12:34:48.346344Z", "start_time": "2022-04-02T12:34:29.918244Z" } }, "outputs": [], "source": [ "sol = gp.compute_model(geo_model, \n", " compute_mesh=True)" ] }, { "cell_type": "code", "execution_count": null, "id": "6a77c178", "metadata": {}, "outputs": [], "source": [ "sol" ] }, { "cell_type": "code", "execution_count": null, "id": "b5861148", "metadata": {}, "outputs": [], "source": [ "geo_model.solutions" ] }, { "cell_type": "markdown", "id": "protected-parcel", "metadata": {}, "source": [ "\n", "\n", "# Model Visualization and Post-Processing\n", "\n", "\n", "\n", "## Visulazing Cross Sections of the computed model\n", "\n", "Cross sections in different `direction`s and at different `cell_number`s can be displayed. Here, we see the horizontal layers in the one direction and the faulted layers in the other direction." ] }, { "cell_type": "code", "execution_count": null, "id": "eb54b87a", "metadata": { "ExecuteTime": { "end_time": "2022-04-02T12:34:50.135506Z", "start_time": "2022-04-02T12:34:48.349347Z" } }, "outputs": [], "source": [ "gp.plot_2d(geo_model, \n", " direction=['x', 'x', 'y', 'y'], \n", " cell_number=[25, 50, 25, 75], \n", " show_topography=False, \n", " show_data=True)" ] }, { "cell_type": "markdown", "id": "fb509999", "metadata": {}, "source": [ "Next to the lithology data, we can also plot the calculated scalar field." ] }, { "cell_type": "code", "execution_count": null, "id": "7cb1d1f0", "metadata": {}, "outputs": [], "source": [ "gp.plot_2d(geo_model, direction='y', show_data=False, show_scalar=True, show_lith=False)" ] }, { "cell_type": "markdown", "id": "several-artwork", "metadata": {}, "source": [ "\n", "\n", "# Visualizing the computed model in 3D\n", "\n", "The computed model can be visualized in 3D using the `pyvista` library. Setting `notebook=False` will open an interactive windows and the model can be rotated and zooming is possible. " ] }, { "cell_type": "code", "execution_count": null, "id": "838f0e34", "metadata": { "ExecuteTime": { "end_time": "2022-04-02T12:34:50.923082Z", "start_time": "2022-04-02T12:34:50.139508Z" } }, "outputs": [], "source": [ "gpv = gp.plot_3d(geo_model, \n", " image=False, \n", " show_topography=True,\n", " plotter_type='basic', \n", " notebook=True, \n", " show_lith=True)" ] }, { "cell_type": "markdown", "id": "ee08db71", "metadata": {}, "source": [ "\n", "# Conclusions\n", "\n", "
\n", "In this tutorial, you have learnt the following:
\n", "- Get an understanding of how faults are modeled/displayed in GemPy
\n", "- How to build a simple model consisting of faulted layers belonging to one Series
\n", "\n", "
\n", "\n", "\n", "\n", "# Outlook\n", "\n", "
\n", "In the next tutorial, you will learn the following:
\n", "- Get an understanding of how unconformities are modeled/displayed in GemPy
\n", "- How to build a simple model consisting of unconformable layers belonging to multiple Series
\n", "\n", "\n", "
\n", "\n", "[Take me to the next notebook on Github](https://nbviewer.org/github/cgre-aachen/gemgis_data/blob/main/notebooks/01_basic_modeling/model4_Truncated_Layers.ipynb)\n", "\n", "[Take me to the next notebook locally](model4_Truncated_Layers.ipynb)\n", "\n", "\n", "\n", "\n", "\n", "## Licensing\n", "\n", "Institute for Computational Geoscience, Geothermics and Reservoir Geophysics, RWTH Aachen University & Fraunhofer IEG, Fraunhofer Research Institution for Energy Infrastructures and Geothermal Systems IEG, Authors: Alexander Juestel. For more information contact: alexander.juestel(at)ieg.fraunhofer.de\n", "\n", "All notebooks are licensed under a Creative Commons Attribution 4.0 International License (CC BY 4.0, http://creativecommons.org/licenses/by/4.0/). References for each displayed map are provided. Most of the maps originate from the books of [Powell (1992)](https://link.springer.com/book/9783540586074) and [Bennison (1990)](https://link.springer.com/book/10.1007/978-1-4615-9630-1). References for maps with unknown origin will gladly be added." ] } ], "metadata": { "hide_input": false, "kernelspec": { "display_name": "Python 3 (ipykernel)", "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.15" }, "varInspector": { "cols": { "lenName": 16, "lenType": 16, "lenVar": 40 }, "kernels_config": { "python": { "delete_cmd_postfix": "", "delete_cmd_prefix": "del ", "library": "var_list.py", "varRefreshCmd": "print(var_dic_list())" }, "r": { "delete_cmd_postfix": ") ", "delete_cmd_prefix": "rm(", "library": "var_list.r", "varRefreshCmd": "cat(var_dic_list()) " } }, "types_to_exclude": [ "module", "function", "builtin_function_or_method", "instance", "_Feature" ], "window_display": false } }, "nbformat": 4, "nbformat_minor": 5 }