def test_mesh_exp5(): eps = 1e-8 r = mesh_exp(0, 100, a=20, N=4) correct = array([0. , 3.21724644, 11.95019684, 35.65507127, 100.]) assert (abs(r-correct) < eps).all() r = mesh_exp(0, 100, a=40, N=4) correct = array([0. , 1.78202223, 7.87645252, 28.71911092, 100.]) assert (abs(r-correct) < eps).all() r = mesh_exp(0, 100, a=100, N=4) correct = array([0. , 0.78625046, 4.43570179, 21.37495437, 100.]) assert (abs(r-correct) < eps).all()
def test_mesh_exp6(): eps = 1e-10 r = mesh_exp(1e-7, 50, 21.37, 700) r_min, r_max, a, N = get_mesh_exp_params(r) assert abs(r_min - 1e-7) < eps assert abs(r_max - 50) < eps assert abs(a - 21.37) < eps assert N == 700 r = mesh_exp(1, 50, 21.37, 700) r_min, r_max, a, N = get_mesh_exp_params(r) assert abs(r_min - 1) < eps assert abs(r_max - 50) < eps assert abs(a - 21.37) < eps assert N == 700
def f(a): # Mesh: #r = create_hyperbolic_grid(rmin=5e-8, rmax=20, k0=30000) #r = create_log_mesh(a=1e-5, b=100, par=10000, n_elem=10000) r = mesh_exp(r_min=1e-8, r_max=50, a=a, N=1000) Z = 82 # Potential: vr = -Z/r # Speed of light taken from: # http://arxiv.org/abs/1012.3627 c = 137.035999037 # Polynomial degree for predictor-corrector: np = 2 tot_error = -1 # (n, l): # either k == l, or k == l + 1: for n in range(1, 5): for l in range(0, n): k_list = [] if l > 0: k_list.append(l) k_list.append(l+1) for k in k_list: # Initial guess: E = -1.0 E, R = rdirac(c, n, l, k, np, r, vr, E) E_exact = E_nl_dirac(n, l, spin_up=(k == l+1), Z=Z, c=c) delta = abs(E-E_exact) if delta > tot_error: tot_error = delta return tot_error
def test_mesh_exp4(): eps = 1e-10 r = mesh_exp(0, 10, 2, 50) a = (r[-1] - r[-2]) / (r[1] - r[0]) assert abs(a - 2) < eps r_min, r_max, a, N = get_mesh_exp_params(r) assert abs(r_min - 0) < eps assert abs(r_max - 10) < eps assert abs(a - 2) < eps assert N == 50 r = mesh_exp(0, 10, 3, 50) a = (r[-1] - r[-2]) / (r[1] - r[0]) assert abs(a - 3) < eps r = mesh_exp(0, 10, 4, 50) a = (r[-1] - r[-2]) / (r[1] - r[0]) assert abs(a - 4) < eps r = mesh_exp(0, 10, 10.5, 50) a = (r[-1] - r[-2]) / (r[1] - r[0]) assert abs(a - 10.5) < eps r = mesh_exp(0, 10, 1, 50) a = (r[-1] - r[-2]) / (r[1] - r[0]) assert abs(a - 1) < eps r = mesh_exp(0, 10, 0.5, 50) a = (r[-1] - r[-2]) / (r[1] - r[0]) assert abs(a - 0.5) < eps r = mesh_exp(0, 10, 0.1, 50) a = (r[-1] - r[-2]) / (r[1] - r[0]) assert abs(a - 0.1) < eps r_min, r_max, a, N = get_mesh_exp_params(r) assert abs(r_min - 0) < eps assert abs(r_max - 10) < eps assert abs(a - 0.1) < eps assert N == 50
def mesh_nist3_direct(r_min, r_max, N): # Uniform mesh in rho: rho = mesh_exp(log(r_min), log(r_max), a=1, N=N) r = exp(rho) return r
def mesh_nist3_direct(r_min, r_max, N): # Uniform mesh in rho: rho = mesh_exp(log(r_min), log(r_max), a=1, N=N) r = exp(rho) return r Z = 92 eps = 1e-10 data = [] # 1 r = mesh_nist1_direct(1./(160*Z), 50, 15788) r_min, r_max, a, N = get_mesh_exp_params(r) assert (abs(mesh_exp(r_min, r_max, a, N) - r) < eps).all() data.append((r_min, r_max, "%e" % a, N)) # 2 r = mesh_nist1_direct(1e-6/Z, 800/sqrt(Z), 8000) r_min, r_max, a, N = get_mesh_exp_params(r) assert (abs(mesh_exp(r_min, r_max, a, N) - r) < eps).all() data.append((r_min, r_max, "%e" % a, N)) # 3 # H #r = mesh_nist2_direct(4.34e-6/1, 0.002304, 50) # U r = mesh_nist2_direct(4.34e-6/Z, 0.002304, 50) r_min, r_max, a, N = get_mesh_exp_params(r) assert (abs(mesh_exp(r_min, r_max, a, N) - r) < eps).all()
def test_mesh_exp1(): eps = 1e-10 r = mesh_exp(0, 10, 2, 1) correct = array([0., 10.]) assert (abs(r-correct) < eps).all()
def test_mesh_exp3(): eps = 1e-10 r = mesh_exp(0, 10, 2, 3) correct = array([0, 2.2654091966098644, 5.4691816067802712, 10]) assert (abs(r-correct) < eps).all()
def test_mesh_exp2(): eps = 1e-10 r = mesh_exp(0, 10, 2, 2) correct = array([0, 3 + 1./3, 10]) assert (abs(r-correct) < eps).all()