import matplotlib.pyplot as plt
import numpy as np
from scipy.optimize import fsolve

Dd = 1.426e-17
Q0 = 4.65e19
xj = 1.75e-6
Cb = 1.75e19

pre_ln = 2.519e-9

f = lambda t: 2* np.sqrt(Dd * t) * np.log((Cb * np.sqrt(np.pi * Dd * t))/(2*Q0))

h = lambda t: (Cb * np.sqrt(np.pi * Dd * t))/(2*Q0)

def g(t):
    return 2*np.sqrt(Dd*t) * np.log((Cb * np.sqrt(np.pi * Dd * t))/(2*Q0)) - xj

t_line = np.linspace(1e3, 1e18, 100)
x_vals = g(t_line)

print(np.log(h(3400)))

ans = fsolve(f, 3400)

print(ans)

plt.plot(t_line, x_vals)
#plt.plot(t_line, [0 for t in t_line], linestyle = '--')
#plt.xscale('log')
plt.show()