Ejemplo n.º 1
0
def p2D_transient(r, t_now, C, pc, *args):
    '''
    2D solution for pressure during and after a period of (constant) injection
    '''

    alpha, T, k, nu, q, rc, pnoise = args
    #    mask = r >= rc # mask for the fit region
    #    r_fit = r[mask]
    #    r_plateau = r[~mask]
    #    assert(len(r_fit) + len(r_plateau) == len(r))

    R = (4 * alpha * T)**0.5  # characteristic length
    arg_t = t_now / T

    # for time after injection
    if arg_t >= 1:
        P = C * (4 * np.pi * k) / (nu * q)
        rbf = (arg_t - 1)**0.5
        mask = r >= min(rbf * R, rc)  # mask for the fit region
        r_fit = r[mask]
        r_plateau = r[~mask]
        arg_r = r_fit / R  # fit to region of 'large r'
        assert (len(r_fit) + len(r_plateau) == len(r))

        r_lwr = arg_r[arg_r < rbf]  # pressure here is time invariant
        r_upr = arg_r[arg_r >= rbf]  # transient pressure

        p_upr = (
            (W(r_upr**2 / arg_t) - W(r_upr**2 / (arg_t - 1))) - pc
        ) * P + pnoise  # transient pressure - includes term for background seismicity and threshold pressure
        p_upr[np.where(p_upr < 0)] = 0
        p_lwr = (
            W(1 / (1 + 1 / r_lwr**2)) - W(1) - pc
        ) * P + pnoise  # pmax - includes term for background seismicity and threshold pressure
        p_lwr[np.where(p_lwr < 0)] = 0
        p = np.concatenate((p_lwr, p_upr))

        p_plateau = np.array([p[0] for i in r_plateau])
        p = np.concatenate((p_plateau, p))
        assert (len(p) == len(r))
    else:
        P = C * (4 * np.pi * k) / (nu * q)
        #        P = 1/P
        mask = r >= rc  # mask for the fit region
        r_fit = r[mask]
        r_plateau = r[~mask]
        arg_r = (r_fit) / R  # fit to region of 'large r'

        p_fit = (
            W(arg_r**2 / arg_t) - pc
        ) * P + pnoise  # transient pressure - includes term for background seismicity and threshold pressure
        p_plat = np.array([p_fit[0] for i in r_plateau])
        p = np.concatenate((p_plat, p_fit))
        p[np.where(p < 0)] = 0
    return p
Ejemplo n.º 2
0
def p2D(r, *args):
    '''
    Solution for maximum pressure for distant radius r in 2D.
    '''

    alpha, T, k, nu, q = args
    R = (4 * alpha * T)**0.5
    arg_r = r / R
    p_factor = (4 * np.pi * k) / (nu * q)
    #    p_factor = (nu*q*R)/(4*np.pi*k) # ([m^2/s * kg/m^2/s]/[m^2])*[m]
    p = (W(1 / (1 + 1 / arg_r**2)) - W(1)) * p_factor
    return p
Ejemplo n.º 3
0
def Theis(r, t, Q=1.16, T=0.30, S=0.0008):
    t = set_time(t)
    u = np.zeros(t.shape[0], dtype=np.float)
    mask = t > 0.
    u[mask] = r ** 2 * S / (4 * T * t[mask])
    s = Q / (4 * np.pi * T) * W(u)
    return s
Ejemplo n.º 4
0
    def generateIV(self, Vmin=-2.0, Vmax=1.0, step=0.01):
        '''
            Generates voltage and current data using the Shockley diode
             equation.
            Diode parameters are obtained from the SingleDiode object.
            Voltage minimum, maximum, and step size are optional inputs.
        '''

        # initialize an empty list for current and generate the voltages
        self.currents = []
        self.voltages = list(np.arange(Vmin, Vmax, step))

        # set variables from object parameters
        n = self.ideality_factor
        T = self.temperature
        I0 = self.saturation_current
        Iph = self.photocurrent
        Rs = self.resistance_series
        Rsh = self.resistance_shunt
        A = self.area

        # thermal voltage is k_B*T
        Vth = 8.617332E-5 * T

        for V in self.voltages:
            z = (Rs * I0) / (n * Vth) * np.exp(
                (Rs * (Iph + I0) + V) / (n * Vth * (1 + Rs / Rsh)))
            I = ((Iph + I0) - V / Rsh) / (1 + Rs / Rsh) - (n * Vth) / (Rs) * W(
                z, k=0)
            self.currents.append(-I.real)
            V += step

        self.IV_data = [self.voltages, self.currents]
        self.JV_data = [self.voltages, [I / A for I in self.currents]]
        return self.IV_data
Ejemplo n.º 5
0
def crit_Ecn(L, g):
	Ec0 = -g*np.pi/(W(-g*A*np.exp(1)/(16*np.pi), -1)).real
	Ec = Ec0*np.linspace(0.45,1.05,300)
	Fm = np.zeros(len(Ec))
	xm = np.zeros(len(Ec))
	for i in range(len(Ec)):
		xm[i], Fm[i] = max_Fn(L, Ec[i], g)
	m = np.argmin(np.abs(1 - Fm))
	Ec2 = Ec[m]
	Xm2 = xm[m]
	return Ec2, Xm2
Ejemplo n.º 6
0
def max_Fp(L, Ec, g):
	D0 = 64*np.exp(2*W(-g*A*np.exp(1)/(16*np.pi), -1)-2).real
	D = np.linspace(1e-11, 2*D0, 200)
	F = np.zeros(len(D))

	for i in range(len(D)):
		F[i] = Fp(D[i], L, Ec, g)
		
	Dm = D[np.argmax(F)]
	Fm = F[np.argmax(F)]

	return Dm, Fm
Ejemplo n.º 7
0
def crit_Ecp(L, g):
	Ec0 = -g*np.pi/(W(-g*A*np.exp(1)/(16*np.pi), -1)).real
	Ec = Ec0*np.linspace(0.95,1.05,100)

	Fm = np.zeros(len(Ec))
	Dm = np.zeros(len(Ec))
	for i in range(len(Ec)):
		Dm[i], Fm[i] = max_Fp(L, Ec[i], g)

	m2 = np.argmin(np.abs(1 - Fm))
	Ec2 = Ec[m2]
	Dm2 = Dm[m2]
		
	return Ec2, Dm2
Ejemplo n.º 8
0
def max_Fn(L, Ec, g):
    x0 = np.exp(g * np.pi / Ec) / a
    #x0 is the zero crossing point
    D0 = 64 * np.exp(2 * W(-g * A * np.exp(1) / (16 * np.pi), -1) - 2).real
    #D0 is Dc at L = 0
    logx = np.linspace(-1, 0, 250)
    x = x0 * 10**logx
    #x = np.linspace(1/np.sqrt(2.5*D0),1/np.sqrt(D0),300)
    F = np.zeros(len(x))
    for i in range(len(x)):
        F[i] = Fn(x[i], L, Ec, g)

    xm = x[np.argmax(F)]
    Fm = F[np.argmax(F)]
    return xm, Fm
Ejemplo n.º 9
0
def bayes_to_sigma(delta_logz):
    '''
    Converts Bayesian Evidience ratios (Bayes factor) into equivalent sigma values

    Parameters
    ----------
    delta_logz
        Bayes evidience ratio, in log-space
    Returns
    -------
        Equivalent sigma values, calcualeted from p-values

    '''
    B = np.exp(delta_logz)
    p = np.real(np.exp(W((-1.0 / (B * np.exp(1))), -1)))
    sigma = np.sqrt(2) * erfcinv(p)

    return sigma
Ejemplo n.º 10
0
import numpy as np
from matplotlib import pyplot as plt
from scipy.special import lambertw as W

g = 0.1

dc = -4 / g * W(-g / (4 * np.sqrt(2)), -1).real

Lc0 = g**2 / 16
Lc1 = Lc0 / (W(-g / (np.exp(1) * 4 * np.sqrt(2)), -1).real)**2

print('dc =', dc)
print('Lc0 =', Lc0)
print('Lc1 =', Lc1)
print('Lc1/Lc0 =', Lc1 / Lc0)
print('log(10) =', np.log(10))

L = np.linspace(1e-10, 1, 200) * Lc1
d_inv = np.linspace(1e-10, 1, 100) / dc
l, d = np.meshgrid(L, d_inv)

G = 4 * np.sqrt(l) - 4 * d * (1 + np.sqrt(l) / d) * np.log(
    d * (1 + np.sqrt(l) / d) / np.sqrt(2))

print(G.shape)

plt.rc('text', usetex=True)
plt.rc('font', family='serif')
plt.rc('font', size=13)

plt.contour(l / Lc1, d * dc, G, [.1], colors=('k'), linewidths=(2))
Ejemplo n.º 11
0
def generate_sigma(ln_Z1, ln_Z2):
    B = np.exp(ln_Z1 - ln_Z2)
    p = np.real(np.exp(W((-1.0 / (B * np.exp(1))), -1)))
    sigma = np.sqrt(2) * erfcinv(p)

    return sigma
Ejemplo n.º 12
0
def bayes_to_pvalue(delta_logz):
    B = np.exp(delta_logz)
    p = np.real(np.exp(W((-1.0 / (B * np.exp(1))), -1)))

    return p
Ejemplo n.º 13
0

'''======================================'''
'''                                      '''
'''               PLOTTING               '''
'''                                      '''
'''======================================'''


'''READING DATA FOR THE CASE g = 0.1'''

g = 0.1

#important values#
Lc0_1 = g**2/16 #first critical L
Lc1_1 = ((g/3/W(-g*np.exp(2/3)/24, -1))**2).real #second critical L
D0_1 = 64*np.exp(2*W(-g*A*np.exp(1)/(16*np.pi), -1)-2).real #critical D at L = 0
Ec0_1 = -g*np.pi/(W(-g*A*np.exp(1)/(16*np.pi), -1)).real #critical Ec at L = 0

''' -5Lc0 < L < -20Lc1 '''

fE = open('Ecn3_g01.txt')
fD = open('Dcn3_g01.txt')

dataE = fE.read()
dataE = dataE.split()
dataE = np.array(list(map(float, dataE)))
m = int(len(dataE)/2)
dataE = np.reshape(dataE, (m, 2))
L3 = dataE[:, 0]
L3 = -np.flip(L3, 0)
Ejemplo n.º 14
0
import numpy as np
from matplotlib import pyplot as plt
from scipy.special import lambertw as W

g = .1

dc = -4 / g * W(-g / (4 * np.sqrt(2)), -1).real

Ec0 = -np.pi * (g) / W(-(g) / (4 * np.sqrt(2) * np.exp(1)), -1).real

print('dc =', dc)
print('Ec0 =', Ec0)

d = np.linspace(1, 20, 1000) * dc

Ec = -np.pi * (g + 4 / d) / W(-(g + 4 / d) /
                              (4 * np.sqrt(2) * np.exp(1)), -1).real

nc = (Ec / (4 * np.pi) - 1 / d)**2 / (d * Ec)

plt.plot(d / dc, nc, 'k', lw=2)
plt.xlabel('$d/d_{c0}$', fontsize=14)
plt.xlim(1, 20)
plt.ylabel('$n_c/p_0^2$', fontsize=14)
plt.ylim(0, 2e-7)
plt.show()
Ejemplo n.º 15
0
def idx(n):
    return W((9 * n - 1) * log(10)) / (9 * pow(10, 1 / 9.)) / log(10) + 1 / 9.
Ejemplo n.º 16
0
def Gain(A, E, a=8000):
    return np.real(np.sqrt(W(a * E * np.exp(E)) / E)) * A
def y(x): return -200 *W(-0.00089745 *np.ex(np.exp(-2*x )* x**300)**(1/200), 0)
X = np.linspace(30, 500, 100)
Ejemplo n.º 18
0
    Ec0 = -g * np.pi / (W(-g * A * np.exp(1) / (16 * np.pi), -1)).real
    Ec = Ec0 * np.linspace(0.15, 1, 200)
    Fm = np.zeros(len(Ec))
    xm = np.zeros(len(Ec))
    for i in range(len(Ec)):
        xm[i], Fm[i] = max_Fn(L, Ec[i], g)
    m = np.argmin(np.abs(1 - Fm))
    Ec2 = Ec[m]
    Xm2 = xm[m]
    return Ec2, Xm2


g = 0.01

Lc0 = g**2 / 16
Lc1 = ((g / 3 / W(-g * np.exp(2 / 3) / 24, -1))**2).real
D0 = 64 * np.exp(2 * W(-g * A * np.exp(1) / (16 * np.pi), -1) - 2).real
Ec0 = -g * np.pi / (W(-g * A * np.exp(1) / (16 * np.pi), -1)).real
x0 = np.exp(g * np.pi / Ec0) / a

print('Lc0 =', Lc0)
print('Lc1 =', Lc1)
print('D0 =', D0)
print('Ec0 =', Ec0, '\n')
print('X0/x0 = ', np.log(1 / np.sqrt(D0) / x0) / np.log(10))
'''
L = float(input('L = '))

Ec, Xc = crit_Ecn(L, g)
Dc = 1/Xc**2