Пример #1
0
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
Пример #2
0
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
Пример #3
0
    return r[1:]

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)