From aff7d8aa08fdc2e55be30de775e39b286d97901b Mon Sep 17 00:00:00 2001 From: vcantarella Date: Fri, 9 Feb 2024 16:08:17 +0100 Subject: [PATCH] new example notebook - Ammer valley --- examples/ammer/ammer_notebook.ipynb | 248 ++++++++++++++++++++++++++-- 1 file changed, 231 insertions(+), 17 deletions(-) diff --git a/examples/ammer/ammer_notebook.ipynb b/examples/ammer/ammer_notebook.ipynb index 5c9ff23..26bf558 100644 --- a/examples/ammer/ammer_notebook.ipynb +++ b/examples/ammer/ammer_notebook.ipynb @@ -20,7 +20,7 @@ }, { "cell_type": "code", - "execution_count": 2, + "execution_count": 1, "metadata": {}, "outputs": [], "source": [ @@ -43,7 +43,7 @@ }, { "cell_type": "code", - "execution_count": 3, + "execution_count": 2, "metadata": {}, "outputs": [], "source": [ @@ -155,7 +155,7 @@ }, { "cell_type": "code", - "execution_count": 37, + "execution_count": 3, "metadata": {}, "outputs": [ { @@ -186,7 +186,7 @@ "# The median thickness would be:\n", "print(f\"The median thickness is:{median_thickness}\")\n", "# The mean thickness would be:\n", - "print(f\"The mean thickness is:{mean_thickness}\")\n" + "print(f\"The mean thickness is:{mean_thickness}\")" ] }, { @@ -199,7 +199,7 @@ }, { "cell_type": "code", - "execution_count": 34, + "execution_count": 4, "metadata": {}, "outputs": [], "source": [ @@ -210,21 +210,21 @@ " ordered_zs = np.append(ordered_zs, simulated_thickness)\n", " ordered_zs = np.append(0, ordered_zs)\n", " thicknesses = np.diff(ordered_zs)\n", - " min_thick = np.min(thicknesses)\n" + " min_thick = np.min(thicknesses)" ] }, { "cell_type": "code", - "execution_count": 36, + "execution_count": 5, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ - "The thickness array is:[0.4732641 0.73957832 0.91983533 0.94173358 0.56025054 0.46504586\n", - " 0.33035965 1.12023074 1.04970188])\n", - "The minimum thickness is:0.33035965221052077\n", + "The thickness array is:[0.30630677 0.60042646 0.94333029 0.42944475 0.35509691 1.64104664\n", + " 0.3145945 1.47268159 0.53707209])\n", + "The minimum thickness is:0.306306769616468\n", "The total thickness is:6.6\n", "The mean thickness is:0.7333333333333333\n", "THe number of layers is:9\n" @@ -236,12 +236,12 @@ "print(f\"The minimum thickness is:{min_thick}\")\n", "print(f\"The total thickness is:{np.sum(thicknesses)}\")\n", "print(f\"The mean thickness is:{np.mean(thicknesses)}\")\n", - "print(f\"THe number of layers is:{len(thicknesses)}\")\n" + "print(f\"THe number of layers is:{len(thicknesses)}\")" ] }, { "cell_type": "code", - "execution_count": 38, + "execution_count": 6, "metadata": {}, "outputs": [ { @@ -250,14 +250,14 @@ "array([0])" ] }, - "execution_count": 38, + "execution_count": 6, "metadata": {}, "output_type": "execute_result" } ], "source": [ "testf = np.empty((nrow, ncol), dtype=np.int32)\n", - "np.unique(testf)\n" + "np.unique(testf)" ] }, { @@ -269,9 +269,127 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 7, "metadata": {}, - "outputs": [], + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "0.01036946736684171\n", + "0.01886252813203301\n", + "0.030617966991747937\n", + "0.04030476369092273\n", + "0.055384471117779444\n", + "0.06498312078019505\n", + "0.07999531132783196\n", + "0.08901162790697674\n", + "0.09743623405851463\n", + "0.10450300075018755\n", + "0.10838522130532634\n", + "0.1250356339084771\n", + "0.14187171792948236\n", + "0.15518004501125282\n", + "0.025376969242310577\n", + "0.04374093523380845\n", + "0.06602525631407852\n", + "0.0864472368092023\n", + "0.103131407851963\n", + "0.12174418604651163\n", + "0.13495998999749936\n", + "0.14524318579644913\n", + "0.16546011502875718\n", + "0.014981714178544636\n", + "0.03768520255063766\n", + "0.0517183983495874\n", + "0.062150225056264066\n", + "0.07473977869467367\n", + "0.0993754688672168\n", + "0.11707426856714179\n", + "0.12634799324831208\n", + "0.1397566579144786\n", + "0.15563531507876968\n", + "0.02475993998499625\n", + "0.035182858214553636\n", + "0.05242029257314328\n", + "0.06832708177044261\n", + "0.08422730682670668\n", + "0.10225993998499625\n", + "0.12434546136534133\n", + "0.14358870967741935\n", + "0.15640191297824457\n", + "0.011897036759189798\n", + "0.02401256564141035\n", + "0.028411477869467367\n", + "0.04182014253563391\n", + "0.052286196549137284\n", + "0.07610183795948987\n", + "0.09949643660915229\n", + "0.108728432108027\n", + "0.12242779444861215\n", + "0.1292160540135034\n", + "0.143728432108027\n", + "0.16198612153038258\n", + "0.009430091897974493\n", + "0.017765847711927983\n", + "0.020241466616654165\n", + "0.03668042010502626\n", + "0.0476115903975994\n", + "0.0520869279819955\n", + "0.057235324456114026\n", + "0.06438320517629408\n", + "0.0690179576144036\n", + "0.08087701612903225\n", + "0.08631376594148538\n", + "0.08736965491372843\n", + "0.09234081957989497\n", + "0.09685085333833458\n", + "0.10244232933233308\n", + "0.11119959677419355\n", + "0.11846867966991748\n", + "0.12797894786196548\n", + "0.13197674418604652\n", + "0.1346900787696924\n", + "0.1413407258064516\n", + "0.14803075768942237\n", + "0.15202152100525132\n", + "0.015976181545386346\n", + "0.03027569392348087\n", + "0.043502438109527385\n", + "0.062108027006751686\n", + "0.09256845461365341\n", + "0.12647599399849963\n", + "0.15015472618154538\n", + "0.007241989068695745\n", + "0.015567463294395028\n", + "0.027546618797556533\n", + "0.03522264494695102\n", + "0.0510438323866681\n", + "0.05936073304040296\n", + "0.059499249812453116\n", + "0.06702363090772694\n", + "0.0762396849212303\n", + "0.08431813310470475\n", + "0.09407271460722323\n", + "0.10386882434894439\n", + "0.11183206515914693\n", + "0.12274863358696816\n", + "0.12847176079734218\n", + "0.14072527060336512\n", + "0.14423186153681278\n", + "0.15505760368663593\n", + "0.022371217804451112\n", + "0.04549199799949988\n", + "0.06807889472368092\n", + "0.09850212553138285\n", + "0.10730745186296574\n", + "0.12022943235808953\n", + "0.1314403600900225\n", + "0.14740372593148288\n", + "0.1500587646911728\n" + ] + } + ], "source": [ "facies_tufa = np.array([2, 3, 4, 5], dtype=np.int32)\n", "facies = np.empty_like(Z, dtype=np.int32)\n", @@ -476,8 +594,104 @@ " facies[channel_f != -1] = channel_f[channel_f != -1]\n", "\n", " # resetting z_0:\n", - " z_0 += thick\n" + " z_0 += thick" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "Creating the final layer (the top deterministic layer) and assigning unassigned cells to the facies 4" + ] + }, + { + "cell_type": "code", + "execution_count": 8, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "0.0\n", + "0.16791029900332227\n" + ] + } + ], + "source": [ + "# final_layer!\n", + "facies[Z > simulated_thickness] = 1 # T1 facies\n", + "\n", + "print(np.sum(facies == -1) / facies.size)\n", + "print(np.sum(facies == 0) / facies.size)\n", + "facies[facies == -1] = 4\n", + "facies[facies == 0] = 4\n", + "\n", + "facies = facies.astype(np.int16)" ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "We export the model as a VTK file for visualization using the flopy interface (For that I need to define a TIME!)" + ] + }, + { + "cell_type": "code", + "execution_count": 10, + "metadata": {}, + "outputs": [ + { + "name": "stderr", + "output_type": "stream", + "text": [ + "<>:7: DeprecationWarning: invalid escape sequence '\\O'\n", + "<>:8: DeprecationWarning: invalid escape sequence '\\O'\n", + "<>:7: DeprecationWarning: invalid escape sequence '\\O'\n", + "<>:8: DeprecationWarning: invalid escape sequence '\\O'\n", + "C:\\Users\\vcant\\AppData\\Local\\Temp\\ipykernel_23368\\2991723775.py:7: DeprecationWarning: invalid escape sequence '\\O'\n", + " np.save(\"C:\\\\Users\\\\vcant\\OneDrive\\\\Kassel\\\\ammer_field\\\\hyvr_models\\\\facies_v5.npy\", facies)\n", + "C:\\Users\\vcant\\AppData\\Local\\Temp\\ipykernel_23368\\2991723775.py:8: DeprecationWarning: invalid escape sequence '\\O'\n", + " np.save(\"C:\\\\Users\\\\vcant\\OneDrive\\\\Kassel\\\\ammer_field\\\\hyvr_models\\\\centroid_v5.npy\", centroid)\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "text": [ + "WARNING: tdis package already exists. Replacing existing tdis package.\n" + ] + } + ], + "source": [ + "# Simulation time:\n", + "tdis = flopy.mf6.ModflowTdis(\n", + " sim, pname=\"tdis\", time_units=\"DAYS\", nper=1, perioddata=[(1.0, 1, 1.0)]\n", + ")\n", + "# export numpy model:\n", + "centroid = np.stack([X, Y, Z])\n", + "np.save(\n", + " \"C:\\\\Users\\\\vcant\\OneDrive\\\\Kassel\\\\ammer_field\\\\hyvr_models\\\\facies_v5.npy\", facies\n", + ")\n", + "np.save(\n", + " \"C:\\\\Users\\\\vcant\\OneDrive\\\\Kassel\\\\ammer_field\\\\hyvr_models\\\\centroid_v5.npy\",\n", + " centroid,\n", + ")\n", + "\n", + "vtk = flopy.export.vtk.Vtk(model=gwf, modelgrid=grid)\n", + "\n", + "vtk.add_array(facies, \"facies\")\n", + "\n", + "vtk.write(\"ammer_v5\")" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [] } ], "metadata": {