I get the error RuntimeWarning: overflow encountered in double_scalars and I am not sure what it means (internet research did not help) and what double_scalars are.
I am not dividing by zero, so could it be that the warning/error arrises as I have too many decimal points or because the numbers are to large? I do get inf for a lot of them.
Is there a way I can get around this error?
This part ist just importing and defining variable:
## IMPORT PACKAGES
import numpy as np
import math
import matplotlib.pyplot as plt
## DEFINITION AND VALUE OF PARAMETERS
A = 10**-16
rho = 910
g = 9.81
a = 1
n = 3
fact = A * ((rho * g)**n)
t_end = 10
dt = 1
dx = 100
L = 300000
b = 0
H_0 = 1000
This part should be ok
## Solve equation numerically
# initialization
xint = np.arange(-L, L+dx, dx)
H_old = []
for xind in range(len(xint)):
x = xint[xind]
H_old.append(H_0 * (1 - abs(x)/L))
H_new = H_old
result = [H_old]
print(len(xint),len(H_old))
I think that this part causes troubles
# Loops through the time-span
for t in range(0, t_end+dt, dt):
print(t,min(H_old),max(H_old))
# Loops through the x-range
for xind in range(1,len(xint)):
x = xint[xind]
if x < L and x > -L:
dH1 = (H_old[xind]-H_old[xind-1])/dx
H1 = H_old[xind]
dH2 = (H_old[xind+1]-H_old[xind])/dx
H2 = H_old[xind+1]
v1 = - (2/4)/(n+1) * fact * ((abs(dH1))**(n-1)) * dH1 * H1**4
v2 = - (2/4)/(n+1) * fact * ((abs(dH2))**(n-1)) * dH2 * H2**4
dH_dt = - (H2*v2-H1*v1)/dx + a
H_new[xind] = H_old[xind] + dt * dH_dt
else:
H_new[xind] = 0.0
H_old = H_new
result.append(H_old)
Thanks