<jupyter_start><jupyter_text>A 1-D Groundwater Finite Difference Example <NAME><jupyter_code>import numpy as np
import matplotlib.pyplot as plt

K = 2.0

xL = 0.0
xR = 100.0
dx = 1

Nx = (xR - xL)/dx + 1

ti = 0.0
tf = 500.0
dt = 0.2

Nt = (tf - ti)/dt + 1

hi = 8.0
hf = 4.0

hL = np.linspace(hi,hi,num=Nt,endpoint=True)
hR = np.linspace(hi,hf,num=Nt,endpoint=True)

x = np.linspace(xL,xR,num=Nx,endpoint=True)

h0 = hi*np.ones(shape=(int(Nx),1))<jupyter_output><empty_output><jupyter_text>Checking for model stability<jupyter_code>alpha = K*dt/dx**2
print("alpha = ",alpha)
print("dt = ",dt)
print("dx = ",dx)
if alpha >= 0.5:
    raise Exception("Stability criteria error! Either decrease dt or increase dx!")<jupyter_output>alpha =  0.4
dt =  0.2
dx =  1<jupyter_text>Running the model<jupyter_code>H = np.zeros(shape=(int(Nt),int(Nx)))

plt.figure(figsize=(6,4), dpi=150)
plt.xlabel("Distance")
plt.ylabel("Pressure head")
plt.title("Example 1D groundwater model")
plt.ylim(0.0,hi+2.0)
plt.plot(x,h0,'b',linewidth=0.5)

for i in range(0,int(Nt)):
    for j in range(0,int(Nx)):
        if j == 0:
            H[i,j] = hL[i]
        elif j == (Nx-1):
            H[i,j] = hR[i]
        else:
            if i == 0:
                H[i,j] = h0[j] + alpha*(h0[j-1] - 2*h0[j] + h0[j+1])
            else:
                H[i,j] = H[i-1,j] + alpha*(H[i-1,j-1] - 2*H[i-1,j] + H[i-1,j+1])
    if (i % 200) == 0:
        plt.plot(x,H[i,:],'b',linewidth=0.5)

plt.show()<jupyter_output><empty_output><jupyter_text>A slightly more complicated model<jupyter_code>hL = np.linspace(hi,hf,num=Nt,endpoint=True)
hR = np.linspace(hi,hf,num=Nt,endpoint=True)

H2 = np.zeros(shape=(int(Nt),int(Nx)))

plt.figure(figsize=(6,4), dpi=150)
plt.xlabel("Distance")
plt.ylabel("Pressure head")
plt.title("Example 1D groundwater model")
plt.ylim(0.0,hi+2.0)
plt.plot(x,h0,'b',linewidth=0.5)

for i in range(0,int(Nt)):
    for j in range(0,int(Nx)):
        if j == 0:
            H2[i,j] = hL[i]
        elif j == (Nx-1):
            H2[i,j] = hR[i]
        else:
            if i == 0:
                H2[i,j] = h0[j] + alpha*(h0[j-1] - 2*h0[j] + h0[j+1])
            else:
                H2[i,j] = H2[i-1,j] + alpha*(H2[i-1,j-1] - 2*H2[i-1,j] + H2[i-1,j+1])
    if (i % 200) == 0:
        plt.plot(x,H2[i,:],'b',linewidth=0.5)

plt.show()<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.20714589536367503, 'fraction_numerical': 0.05104210974053594, 'mean_word_length': 3.0551724137931036, 'pattern_counts': {'":': 0, '<': 17, '<?xml version=': 0, '>': 18, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '4', 'dir': 'jupyter-structured-clean-dedup', 'id': '286403', 'license': 'MIT', 'n_tokens_mistral': 1162, 'n_tokens_neox': 1107, 'n_words': 188, 'path': 'Module11_BoundaryValueProblems/FTCS_ExplicitExample.ipynb', 'repo_name': 'LejoFlores/GEOS_518', 'size': '2356'}