Beispiel #1
0
def energy_calculations(D, L, nu):
	#Here we change lenght and height!
	xm, xp, ym, yp, xbar, ybar, D, L = discretize_geometry(D, L)
	N = xp.shape[0]
	inn = np.linspace(0, N, N, endpoint=True)
	dx = xp - xm
	dy = yp - ym
	ds = np.sqrt(dx**2 + dy**2)
	n1 = -(yp-ym)/ds
	n2 = (xp-xm)/ds

	phi0 = np.exp(nu*(ybar - complex(0,1)*xbar))
	ss = np.zeros((N, N), dtype=complex)

	for i in range(N):
		for j in range(N):
			xa = xbar[j] - xbar[i]
			yb = ybar[j] + ybar[i]
			zz = nu*(yb - complex(0, 1)*xa)
			f1 = -2*np.exp(zz)*mpm.e1(zz) + np.log(zz)
			zz = nu*(yb - complex(0, 1)*xa) # (91)

			
			f1 = -2*np.exp(zz)*(mpm.e1(zz) + np.log(zz) - np.log(-zz)) #(88) from lec-notes
			f2 = 2*np.pi*np.exp(zz) #(90)
			g2 = f1.real + complex(0, 1)*f2.real #()

			arg0 = (np.log((xm[j] - xbar[i] + complex(0, 1)*(ym[j] - ybar[i]))/\
					(xp[j] - xbar[i] + complex(0, 1)*(yp[j] - ybar[i])))).imag	

			if j - i == 0:
				arg0 = -np.pi

			arg1 = (np.log((xm[j] - xbar[i] + complex(0, 1)*(ym[j] + ybar[i]))/ \
					(xp[j] - xbar[i] + complex(0, 1)*(yp[j] + ybar[i])))).imag
			help1 = (n1[j]*(f1.imag + complex(0, 1)*f2.imag) + n2[j]* \
					(f1.real + complex(0, 1)*f2.real))*nu*ds[j]

			ss[i, j] = arg0 + arg1 + help1
	rhsD = -2*np.pi*phi0
	phiD = np.linalg.solve(ss, rhsD)

	XX2 = phiD*n2*ds
	sXX2 = sum(XX2)
	X2 = -complex(0, 1)*sXX2

	return phiD, inn, X2
Beispiel #2
0
def pressao(anp, q, B, mi, k, h, rw, ct, phi, r, t, S):
    if t == 0:
        return 0

    if anp:
        ctd = k * 0.0003484 / (phi * mi * ct * rw * rw)
        cpd = k * h / (q * B * mi * 19.03)
    else:
        ctd = k * 0.0002637 / (phi * mi * ct * rw * rw)
        cpd = k * h / (q * B * mi * 141.2)

    x = (r * r / (rw * rw)) / (4 * ctd * t)

    Pd = float(e1(x)) / 2
    if r == rw:
        DeltaPressao = Pd / cpd + S / cpd
    else:
        DeltaPressao = Pd / cpd
    return DeltaPressao
Beispiel #3
0
def test_immediately_after_underflow():
    x = np.nextafter(-MINEXP, np.inf)
    assert sc.e1(x) == float(mpmath.e1(x))
Beispiel #4
0
def lhs_rhs(D, L):
	nu = 0.9
	#Here we change lenght and height!
	xm, xp, ym, yp, xbar, ybar, D, L = discretize_geometry(D, L)
	N = xp.shape[0]
	inn = np.linspace(0, N, N, endpoint=True)
	dx = xp - xm
	dy = yp - ym
	ds = np.sqrt(dx**2 + dy**2)
	n1 = -(yp-ym)/ds
	n2 = (xp-xm)/ds



	xg1 = -0.5*dx/np.sqrt(3) + xbar
	xg2 = 0.5*dx/np.sqrt(3) + xbar
	yg1 = -0.5*dy/np.sqrt(3) + ybar
	yg2 = 0.5*dy/np.sqrt(3) + ybar

	phi0 = np.exp(nu*(ybar - complex(0,1)*xbar))
	phi0n = nu*(n2 - complex(0, 1)*n1)*phi0


	gg = np.zeros((N, N), dtype=complex)
	ss = np.zeros((N, N), dtype=complex)
	#for i in range(N+1):
	for i in range(N):
		for j in range(N):
			xa1 = xg1[j] - xbar[i]
			xa2 = xg2[j] - xbar[i]
			ya1 = yg1[j] - ybar[i]
			ya2 = yg2[j] - ybar[i]
			ra1 = np.sqrt(xa1**2 + ya1**2)
			ra2 = np.sqrt(xa2**2 + ya2**2)
			g0 = 0.5*(np.log(ra1) + np.log(ra2))

			#midpoint rule
			xa = xbar[j] - xbar[i]
			yb = ybar[j] + ybar[i]
			rb = np.sqrt(xa**2 + yb**2)
			g1 = -np.log(rb)
			zz = nu*(yb - complex(0, 1)*xa) # (91)

			
			f1 = -2*np.exp(zz)*(mpm.e1(zz) + np.log(zz) - np.log(-zz)) #(88) from lec-notes
			f2 = 2*np.pi*np.exp(zz) #(90)
			g2 = f1.real + complex(0, 1)*f2.real #()
			gg[i, j] = (g0 + g1 + g2)*ds[j]


			arg0 = (np.log((xm[j] - xbar[i] + complex(0, 1)*(ym[j] - ybar[i]))/\
					(xp[j] - xbar[i] + complex(0, 1)*(yp[j] - ybar[i])))).imag	
			if j - i == 0:
				arg0 = np.pi


			arg1 = (np.log((xm[j] - xbar[i] + complex(0, 1)*(ym[j] + ybar[i]))/ \
					(xp[j] - xbar[i] + complex(0, 1)*(yp[j] + ybar[i])))).imag

			help1 = (n1[j]*(f1.imag + complex(0, 1)*f2.imag) + n2[j]* \
					(f1.real + complex(0, 1)*f2.real))*nu*ds[j]

			ss[i][j] = (arg0 + arg1 + help1)
	#print(ss)
	rhs = np.matmul(gg, phi0n)
	lhs = np.matmul(ss, phi0)

	return lhs, rhs, inn, D, L
Beispiel #5
0
def calculate_phi(D, L, nu):

	#Here we change lenght and height!
	xm, xp, ym, yp, xbar, ybar, D, L = discretize_geometry(D, L)
	N = xp.shape[0]
	inn = np.linspace(0, N, N, endpoint=True)
	dx = xp - xm
	dy = yp - ym
	ds = np.sqrt(dx**2 + dy**2)
	n1 = -(yp-ym)/ds
	n2 = (xp-xm)/ds



	xg1 = -0.5*dx/np.sqrt(3) + xbar
	xg2 = 0.5*dx/np.sqrt(3) + xbar
	yg1 = -0.5*dy/np.sqrt(3) + ybar
	yg2 = 0.5*dy/np.sqrt(3) + ybar

	phi0 = np.exp(nu*(ybar - complex(0,1)*xbar))
	phi0n = nu*(n2 - complex(0, 1)*n1)*phi0


	gg = np.zeros((N, N), dtype=complex)
	ss = np.zeros((N, N), dtype=complex)
	#for i in range(N+1):
	for i in range(N):
		for j in range(N):
			xa1 = xg1[j] - xbar[i]
			xa2 = xg2[j] - xbar[i]
			ya1 = yg1[j] - ybar[i]
			ya2 = yg2[j] - ybar[i]
			ra1 = np.sqrt(xa1**2 + ya1**2)
			ra2 = np.sqrt(xa2**2 + ya2**2)
			g0 = 0.5*(np.log(ra1) + np.log(ra2))

			#midpoint rule
			xa = xbar[j] - xbar[i]
			yb = ybar[j] + ybar[i]
			rb = np.sqrt(xa**2 + yb**2)
			g1 = -np.log(rb)
			zz = nu*(yb - complex(0, 1)*xa) # (91)

			
			f1 = -2*np.exp(zz)*(mpm.e1(zz) + np.log(zz) - np.log(-zz)) #(88) from lec-notes
			f2 = 2*np.pi*np.exp(zz) #(90)
			g2 = f1.real + complex(0, 1)*f2.real #()
			gg[i, j] = (g0 + g1 + g2)*ds[j]


			arg0 = (np.log((xm[j] - xbar[i] + complex(0, 1)*(ym[j] - ybar[i]))/\
					(xp[j] - xbar[i] + complex(0, 1)*(yp[j] - ybar[i])))).imag	
			if j - i == 0:
				arg0 = -np.pi


			arg1 = (np.log((xm[j] - xbar[i] + complex(0, 1)*(ym[j] + ybar[i]))/ \
					(xp[j] - xbar[i] + complex(0, 1)*(yp[j] + ybar[i])))).imag

			help1 = (n1[j]*(f1.imag + complex(0, 1)*f2.imag) + n2[j]* \
					(f1.real + complex(0, 1)*f2.real))*nu*ds[j]

			ss[i][j] = (arg0 + arg1 + help1)

	rhs = np.matmul(gg, n2)
	phi2 = np.linalg.solve(ss, rhs)
	ff22 = phi2*n2*ds
	sum_ff22 = sum(ff22)
	AM2 = complex(0, 1)*(phi2*(nu*n2 - nu*complex(0, 1)*n1) - n2)*phi0*ds
	AP2 = complex(0, 1)*(phi2*(nu*n2 + nu*complex(0, 1)*n1) - n2)*np.conj(phi0)*ds
	sum_AM2 = sum(AM2)
	sum_AP2 = sum(AP2)

	dampingb22 = 0.5*(sum_AM2*np.conj(sum_AM2) + sum_AP2*np.conj(sum_AP2))
	v1H = sum(-complex(0, 1)*(phi0*n2 - phi2*phi0n)*ds)

	return phi2, inn, sum_ff22, sum_AM2, sum_AP2, v1H, dampingb22
def theis_solution(permeability_val=None,
                   density_val=None,
                   viscosity_val=None,
                   filename=None,
                   use_mobility=None,
                   flux_function=None,
                   b=None,
                   well_area=None,
                   Kw=None,
                   phi=None,
                   t_end=None,
                   z_plot_loc=None,
                   fixed_axis=None,
                   pp_loc=None,
                   P0=None,
                   symmetry=True):
    import numpy as np
    import matplotlib.pyplot as plt
    import mpmath
    import os
    if filename == None:
        filename = 'simple_theis_k1_csv_pressure_0009.csv'
    if permeability_val == None:
        permeability_val = 1.0  # m2
    if density_val == None:
        density_val = 1.0
        #kg/m3
    if viscosity_val == None:
        viscosity_val = 1.0
        #Pa-s
    if flux_function == None:
        flux_function = -0.233426704015
    if b == None:
        b = 1.0
        # aquifer thickness (m)
    if Kw == None:
        Kw = 1.0  # compressibility of water (Pa^-1)
    if phi == None:
        phi = 0.1  # porosity
    if t_end == None:
        t_end = 100.0
        #seconds
    if use_mobility == None:
        use_mobility = False
    if z_plot_loc == None:
        z_plot_loc = -199.77360637445
    if fixed_axis == None:
        fixed_axis = 2  # integer telling which axis should be fixed (x = 0, y = 1, z = 2)
    if pp_loc == None:
        pp_loc = -1  #integer to tell where the pore pressure is found in csv file
    if P0 == None:
        P0 = 0.
    if well_area == None:
        dx = 1.07131
        dy = 1.0
        #meters
        well_area = dx * dy
        # well area (m2)
        print('well_area ', well_area)

    ## Calculations

    if use_mobility:
        Qm = -flux_function * density_val * permeability_val / viscosity_val * well_area
    else:
        Qm = -flux_function * well_area
    print('Mass flow rate in (i.e. fluxes_in expected)', Qm)

    ignore_density = False  #Always False if use_mobility = False. Maybe also if use_mobility = True??
    if ignore_density:
        Q = Qm
    else:
        Q = Qm / density_val
    print('volumetric flow rate (checked against Theis)', Q)

    ## Calculate the analytical solution my way
    import pudb
    pudb.set_trace()
    if symmetry:
        prefactor = 4.0 * Q * viscosity_val / (
            4.0 * np.pi * b * permeability_val
        )  # Pa, multiplier of exponential integral, 4.0 factor is because of 1/4 grid symmetry
    else:
        prefactor = Q * viscosity_val / (
            4.0 * np.pi * b * permeability_val
        )  # Pa, multiplier of exponential integral, 4.0 factor is because of 1/4 grid symmetry
    r_anal = np.linspace(1, 200, 101)
    #radius in meters
    dP_anal = np.zeros(len(r_anal))
    u = (r_anal**
         2.0) * phi * viscosity_val / (4.0 * permeability_val * t_end * Kw)
    for i in xrange(0, len(u)):
        dP_anal[i] = prefactor * mpmath.e1(u[i])

    plt.plot(r_anal, dP_anal)

    x = np.zeros(40)
    pp = np.zeros(40)
    import csv
    with open(filename) as csv_file:
        csv_reader = csv.reader(csv_file, delimiter=',')
        line_count = 0
        for row in csv_reader:
            if line_count == 0:
                junkvar = 1
                line_count += 1
            else:
                if float(row[fixed_axis]) > z_plot_loc - .1 and float(
                        row[fixed_axis]) < z_plot_loc + .1 and float(
                            row[0]) > 0:
                    x[line_count - 1] = float(row[0])
                    pp[line_count - 1] = float(row[pp_loc]) - P0
                    line_count += 1
                # x = np.append([x],[row[0]]);
                # pp = np.append([pp],[row[-1]]);

    plt.plot(x, pp, '.')
def theis_solution(permeability_val=None,
                   density_val=None,
                   viscosity_val=None,
                   filename=None,
                   use_mobility=None,
                   flux_function=None):
    import numpy as np
    import matplotlib.pyplot as plt
    import mpmath
    import os
    if filename == None:
        filename = 'simple_theis_k1_csv_pressure_0009.csv'
    if permeability_val == None:
        permeability_val = 1.0  # m2
    if density_val == None:
        density_val = 1.0
        #kg/m3
    if viscosity_val == None:
        viscosity_val = 1.0
        #Pa-s
    dx = 1.071
    dy = 1.0
    #meters
    if flux_function == None:
        flux_function = -0.233426704015
    b = 1.0
    # thickness (m)
    Kw = 1.0  # compressibility of water (Pa^-1)
    phi = 0.1  # porosity
    t_end = 100.0
    #seconds
    if use_mobility == None:
        use_mobility = False
    ## Calculations
    well_area = dx * dy
    # well area (m2)
    print('well_area ', well_area)

    if use_mobility:
        Qm = -flux_function * density_val * permeability_val / viscosity_val * well_area
    else:
        Qm = -flux_function * well_area
    print('Mass flow rate in (i.e. fluxes_in expected)', Qm)

    ignore_density = False  #Always False if use_mobility = False. Maybe also if use_mobility = True??
    if ignore_density:
        Q = Qm
    else:
        Q = Qm / density_val
    print('volumetric flow rate (checked against Theis)', Q)

    ## Calculate the analytical solution my way
    prefactor = 4.0 * Q * viscosity_val / (
        4.0 * np.pi * b * permeability_val
    )  # Pa, multiplier of exponential integral, 4.0 factor is because of 1/4 grid symmetry
    r_anal = np.linspace(1, 200, 101)
    #radius in meters
    dP_anal = np.zeros(len(r_anal))
    t_final = 1.e2
    # seconds
    u = (r_anal**
         2.0) * phi * viscosity_val / (4.0 * permeability_val * t_final * Kw)
    for i in xrange(0, len(u)):
        dP_anal[i] = prefactor * mpmath.e1(u[i])

    plt.plot(r_anal, dP_anal)

    x = np.zeros(40)
    pp = np.zeros(40)
    import csv
    with open(filename) as csv_file:
        csv_reader = csv.reader(csv_file, delimiter=',')
        line_count = 0
        for row in csv_reader:
            if line_count == 0:
                junkvar = 1
                line_count += 1
            else:
                if float(row[2]) > -199.77360637445 - .1 and float(
                        row[2]) < -199.77360637445 + .1:
                    x[line_count - 1] = float(row[0])
                    pp[line_count - 1] = float(row[-1])
                    line_count += 1
                # x = np.append([x],[row[0]]);
                # pp = np.append([pp],[row[-1]]);

    plt.plot(x, pp, '.')