Skip to content

Commit

Permalink
Merge d7a8863 into 975a074
Browse files Browse the repository at this point in the history
  • Loading branch information
Huite committed Jun 19, 2024
2 parents 975a074 + d7a8863 commit e5c333a
Show file tree
Hide file tree
Showing 29 changed files with 437 additions and 295 deletions.
6 changes: 5 additions & 1 deletion .git-blame-ignore-revs
Original file line number Diff line number Diff line change
@@ -1,2 +1,6 @@
# Migrate code style to black
998b86fc128e35f1506e3d4facb169c558679bde
998b86fc128e35f1506e3d4facb169c558679bde

# Migrate code style to ruff
a11f92ff2732d7fdc548559f15f009e4a3d5ea7a
571e4b5af45bd1ca6f025dd883b9ea800acb4aef
8 changes: 3 additions & 5 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,12 +30,10 @@ jobs:
python -m pip install --upgrade pip
pip install -e .[ci]
- name: Lint with flake8
- name: Lint with ruff
run: |
# stop the build if there are Python syntax errors or undefined names
flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics
# exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide
flake8 . --count --exit-zero --max-complexity=10 --max-line-length=80 --statistics
ruff check .
ruff format --check
- name: Run tests
run: |
Expand Down
115 changes: 66 additions & 49 deletions examples/timml_notebook0_sol.py
Original file line number Diff line number Diff line change
@@ -1,34 +1,32 @@

# coding: utf-8

# # TimML Notebook 0
# ## Single layer flow

# Consider uniform flow from East to West. The gradient is 0.001. The hydraulic conductivity is $k=10$ m/d. The aquifer bottom and top are at 0 m and 10 m. The head at $x=-1000$ m and $y=0$ is fixed at 41 m.
# Consider uniform flow from East to West. The gradient is 0.001. The hydraulic conductivity is $k=10$ m/d. The aquifer bottom and top are at 0 m and 10 m. The head at $x=-1000$ m and $y=0$ is fixed at 41 m.

# In[1]:

import numpy as np

from timml import *
from pylab import *

import timml

# In[2]:


ml = ModelMaq(kaq=10, z=[10, 0])
ml = timml.ModelMaq(kaq=10, z=[10, 0])


# In[3]:


rf = Constant(ml, xr=-1000, yr=0, hr=41)
rf = timml.Constant(ml, xr=-1000, yr=0, hr=41)


# In[4]:


uf = Uflow(ml, slope=0.001, angle=0)
uf = timml.Uflow(ml, slope=0.001, angle=0)


# In[5]:
Expand All @@ -40,36 +38,55 @@
# In[6]:


ml.contour(x1=-1200, x2=200, nx=50, y1=-500, y2=500, ny=50,
levels=10, labels=True, decimals=2, legend=True)
ml.contour(
x1=-1200,
x2=200,
nx=50,
y1=-500,
y2=500,
ny=50,
levels=10,
labels=True,
decimals=2,
legend=True,
)


# The default contour levels are not what we want for this example, so let's specify the levels
# The default contour levels are not what we want for this example, so let's specify the levels
# to go from 39 to 42 with steps of 0.1 (not all those levels are present in the current window).

# In[7]:


ml.contour(x1=-1200, x2=200, nx=50, y1=-500, y2=500, ny=50,
levels=arange(39, 42, 0.1), labels=True, decimals=1)
ml.contour(
x1=-1200,
x2=200,
nx=50,
y1=-500,
y2=500,
ny=50,
levels=np.arange(39, 42, 0.1),
labels=True,
decimals=1,
)


# A well is located at $(x,y)=(-400,0)$ with a discharge $Q=50$ m$^3$ and a radius of 0.2 m.

# In[8]:


w = Well(ml, xw=-400, yw=0, Qw=50., rw=0.2)
w = timml.Well(ml, xw=-400, yw=0, Qw=50.0, rw=0.2)


# After the well is added (or any other elements), the model needs to be solved again. A contour plot is created and a 10 strace line are added. The stepsize is given in meters and represents the largest space step that is taken, but it is reduced when certain accuracy constraints are not met. Note that, after running the code cell below, for each trace line it is printed to the screen what the reason was that the traceline was aborted. In this case it was either because the trace line reached a well or reached the maximum number of steps (the default is 100 steps, but this can be changed by specifying the `nstepmax` keyword).
# After the well is added (or any other elements), the model needs to be solved again. A contour plot is created and a 10 strace line are added. The stepsize is given in meters and represents the largest space step that is taken, but it is reduced when certain accuracy constraints are not met. Note that, after running the code cell below, for each trace line it is printed to the screen what the reason was that the traceline was aborted. In this case it was either because the trace line reached a well or reached the maximum number of steps (the default is 100 steps, but this can be changed by specifying the `nstepmax` keyword).

# In[9]:


ml.solve()
ml.contour(-1000, 100, 50, -500, 500, 50, levels=np.arange(39, 42, 0.1))
ml.tracelines(-800 * ones(1), -200 * ones(1), zeros(1), hstepmax=20)
ml.tracelines(-800 * np.ones(1), -200 * np.ones(1), np.zeros(1), hstepmax=20)


# ### Exercise a
Expand All @@ -79,7 +96,7 @@


ml.contour(-1000, 100, 50, -500, 500, 50, levels=np.arange(39, 42, 0.1))
ml.tracelines(-800 * ones(10), linspace(-500, 500, 10), zeros(10), hstepmax=20)
ml.tracelines(-800 * np.ones(10), np.linspace(-500, 500, 10), np.zeros(10), hstepmax=20)


# ### Exercise b
Expand All @@ -88,14 +105,14 @@
# In[11]:


ml = ModelMaq(kaq=10, z=[10, 0])
rf = Constant(ml, xr=-1000, yr=0, hr=41)
uf = Uflow(ml, slope=0.001, angle=0)
w = Well(ml, xw=-400, yw=0, Qw=200, rw=0.2)
ml = timml.ModelMaq(kaq=10, z=[10, 0])
rf = timml.Constant(ml, xr=-1000, yr=0, hr=41)
uf = timml.Uflow(ml, slope=0.001, angle=0)
w = timml.Well(ml, xw=-400, yw=0, Qw=200, rw=0.2)
ml.solve()
ml.contour(-1000, 100, 50, -500, 500, 50, levels=np.arange(39, 42, 0.1))
ml.tracelines(-800 * ones(10), linspace(-500, 500, 10), zeros(10), hstepmax=20)
print(('head at well:', w.headinside()))
ml.tracelines(-800 * np.ones(10), np.linspace(-500, 500, 10), np.zeros(10), hstepmax=20)
print(("head at well:", w.headinside()))


# ### Add a river
Expand All @@ -104,33 +121,37 @@
# In[12]:


ml = ModelMaq(kaq=10, z=[10, 0])
rf = Constant(ml, xr=-1000, yr=0, hr=41)
uf = Uflow(ml, slope=0.001, angle=0)
w = Well(ml, xw=-400, yw=0, Qw=200, rw=0.2)
ls1 = HeadLineSink(ml, 0, -500, 0, 500, 40)
ml = timml.ModelMaq(kaq=10, z=[10, 0])
rf = timml.Constant(ml, xr=-1000, yr=0, hr=41)
uf = timml.Uflow(ml, slope=0.001, angle=0)
w = timml.Well(ml, xw=-400, yw=0, Qw=200, rw=0.2)
ls1 = timml.HeadLineSink(ml, 0, -500, 0, 500, 40)
ml.solve()
ml.contour(-1000, 100, 50, -500, 500, 50, levels=arange(39, 42, 0.1))
print(('head at well:', w.headinside()))
ml.contour(-1000, 100, 50, -500, 500, 50, levels=np.arange(39, 42, 0.1))
print(("head at well:", w.headinside()))


# ### Exercise c
# Simulate the river with 20 line-sinks from $y=-800$ to $y=800$.
# Simulate the river with 20 line-sinks from $y=-800$ to $y=800$.

# In[13]:


ml = ModelMaq(kaq=10, z=[10, 0])
rf = Constant(ml, xr=-1000, yr=0, hr=41)
uf = Uflow(ml, slope=0.001, angle=0)
w = Well(ml, xw=-400, yw=0, Qw=200, rw=0.2)
xls = zeros(21)
yls = linspace(-800, 800, 21)
ls = HeadLineSinkString(ml, xy=list(zip(xls, yls)), hls=40, layers=0)
ml = timml.ModelMaq(kaq=10, z=[10, 0])
rf = timml.Constant(ml, xr=-1000, yr=0, hr=41)
uf = timml.Uflow(ml, slope=0.001, angle=0)
w = timml.Well(ml, xw=-400, yw=0, Qw=200, rw=0.2)
xls = np.zeros(21)
yls = np.linspace(-800, 800, 21)
ls = timml.HeadLineSinkString(ml, xy=list(zip(xls, yls)), hls=40, layers=0)
ml.solve()
ml.contour(-1000, 100, 50, -500, 500, 50, levels=arange(39, 42, 0.1))
ml.tracelines(-800 * ones(10), linspace(-500, 500, 10), zeros(10), hstepmax=20, color='b')
ml.tracelines(-0.01 * ones(5), linspace(-150, 150, 5), zeros(5), hstepmax=20, color='r')
ml.contour(-1000, 100, 50, -500, 500, 50, levels=np.arange(39, 42, 0.1))
ml.tracelines(
-800 * np.ones(10), np.linspace(-500, 500, 10), np.zeros(10), hstepmax=20, color="b"
)
ml.tracelines(
-0.01 * np.ones(5), np.linspace(-150, 150, 5), np.zeros(5), hstepmax=20, color="r"
)


# ### Capture zone
Expand All @@ -139,8 +160,8 @@
# In[14]:


ml.contour(-1000, 100, 50, -500, 500, 50, levels=arange(39, 42, 0.1), layers=0)
w.plotcapzone(hstepmax=20, nt=20, zstart=0, tmax=5 * 365.25, color='b')
ml.contour(-1000, 100, 50, -500, 500, 50, levels=np.arange(39, 42, 0.1), layers=0)
w.plotcapzone(hstepmax=20, nt=20, zstart=0, tmax=5 * 365.25, color="b")


# ### Exercise d
Expand All @@ -149,12 +170,8 @@
# In[15]:


ml.contour(-1000, 100, 50, -500, 500, 50, levels=arange(39, 42, 0.1), layers=0)
w.plotcapzone(hstepmax=20, nt=20, zstart=0, tmax=20 * 365.25, color='b')
ml.contour(-1000, 100, 50, -500, 500, 50, levels=np.arange(39, 42, 0.1), layers=0)
w.plotcapzone(hstepmax=20, nt=20, zstart=0, tmax=20 * 365.25, color="b")


# In[ ]:




Loading

0 comments on commit e5c333a

Please sign in to comment.