예제 #1
0
def test_poisson_3d_sphere_sym(xsym, ysym, zsym):
    ri = 2.0e-3
    ro = 4.0e-3
    w = 1.1 * ro
    N = 61
    dx = 2 * w / N
    Va = 10.0
    x = np.arange(-w * (not xsym), w, dx)
    y = np.arange(-w * (not ysym), w, dx)
    z = np.arange(-w * (not zsym), w, dx)
    X, Y, Z = np.meshgrid(x, y, z, indexing='ij')
    R = np.sqrt(X**2 + Y**2 + Z**2)
    bc_bool = np.logical_or(R < ri, R > ro)
    bc_val = np.select([R < ri, R > ro], [Va, 0])
    bc = (bc_bool, bc_val)
    sc = SphereCapacitor(ri, 1.0, ro - ri)
    expected = sc.potential(X, Y, Z, Va=Va)
    potential = fdm.poisson_3d(X,
                               Y,
                               Z,
                               bc=bc,
                               conv=1e-5,
                               xsym=xsym,
                               ysym=ysym,
                               zsym=zsym)
    assert potential == approx(expected, abs=0.9)
예제 #2
0
def test_potential():
    ri = 30e-3
    ro = 50e-3
    N = 5
    sc = SphereCapacitor(ri, 2.6, ro - ri)
    X = np.linspace(ri, ro, N)
    Va = 10.0
    Q = sc.capacitance() * Va
    expected = Va - Q / (4 * np.pi * EPS0 * 2.6) * (1 / ri - 1 / X)
    potential = sc.potential(X, Va=Va)
    assert potential == approx(expected)
예제 #3
0
def test_efield():
    ri = 30e-3
    ro = 50e-3
    N = 5
    sc = SphereCapacitor(ri, 2.6, ro - ri)
    X = np.linspace(ri, ro, N)
    Va = 10.0
    Q = sc.capacitance() * Va
    expected = Q / (4 * np.pi * EPS0 * 2.6 * X**2)
    efield = sc.efield(X, Va=Va)
    assert efield == approx(expected)
예제 #4
0
def test_poisson_3d_sphere_2layer():
    ri = 2.0e-3
    re = 2.8e-3
    ro = 4.0e-3
    er1, er2 = 4.0, 1.0
    w = 1.1 * ro
    N = 61
    dx = 2 * w / N
    Va = 10.0
    x = np.arange(-w, w, dx)
    y = np.arange(-w, w, dx)
    z = np.arange(-w, w, dx)
    X, Y, Z = np.meshgrid(x, y, z, indexing='ij')
    R = np.sqrt(X**2 + Y**2 + Z**2)
    er = np.select([R <= re, R > re], [er1, er2])[:-1, :-1, :-1]
    bc_bool = np.logical_or(R < ri, R > ro)
    bc_val = np.select([R < ri, R > ro], [Va, 0])
    bc = (bc_bool, bc_val)
    sc = SphereCapacitor(ri, (er1, er2), (re - ri, ro - re))
    expected = sc.potential(X, Y, Z, Va=Va)
    potential = fdm.poisson_3d(X, Y, Z, dielectric=er, bc=bc, conv=1e-7)
    assert potential == approx(expected, abs=0.8)
예제 #5
0
def test_capacitance():
    sc = SphereCapacitor(30e-3, 2.6, 20e-3)
    assert sc.capacitance() == approx(21.7e-12, abs=0.1e-12)
예제 #6
0
def test_energy():
    sc = SphereCapacitor(0.5e-3, 5.2, 3.5e-3)
    Va = 10.0
    expected = 0.5 * sc.capacitance() * Va**2
    assert sc.energy(Va) == approx(expected)
예제 #7
0
def test_charge():
    sc = SphereCapacitor(0.5e-3, 5.2, 3.5e-3)
    Va = 10.0
    expected = sc.capacitance() * Va
    assert sc.charge(Va) == approx(expected)
예제 #8
0
def test_get_arrays():
    N = 11
    sc = SphereCapacitor(30e-3, 2.6, 20e-3)
    X, er = sc.get_arrays(N=N)
    assert X == approx(np.linspace(30e-3, 50e-3, N))
    assert er == approx(2.6 * np.ones(N - 1))