Example #1
0
def test_2layer():
    er1, t1 = 5.0, 1e-3
    er2, t2 = 1.0, 3e-3
    pp = ParallelPlates((er1, er2), (t1, t2))
    X, er = pp.get_arrays(N=5)
    assert pp.thickness == approx(t1 + t2)
    assert X == approx([0.0, 1e-3, 2e-3, 3e-3, 4e-3])
    assert er == approx([er1, er2, er2, er2])
Example #2
0
def test_poisson_1d():
    pp = ParallelPlates(1.0, 5e-3)
    X, _ = pp.get_arrays(101)
    v0 = -2
    v1 = 5
    V = fdm.poisson_1d(X, v_left=v0, v_right=v1, conv=1e-5)
    Va = pp.potential(X, v1 - v0, v0)
    assert V == approx(Va, abs=0.01)
Example #3
0
def test_poisson_1d_dielectric2():
    pp = ParallelPlates((1.0, 5.0, 1.0), (2e-3, 1e-3, 1e-3))
    v0 = 0
    v1 = 200
    X, er = pp.get_arrays(101)
    V = fdm.poisson_1d(X, dielectric=er, v_left=v0, v_right=v1, conv=1e-7)
    Va = pp.potential(X, v1 - v0, v0)
    assert V == approx(Va, abs=0.01)
Example #4
0
def test_gauss_1d_dielectric():
    pp = ParallelPlates((2.0, 4.0), (3e-3, 2e-3))
    X, er = pp.get_arrays(101)
    v1 = 10.0
    V = pp.potential(X, v1)
    Q = np.array([fdm.gauss_1d(X, V, er, i) for i in range(1, len(X) - 1)])
    Qa = pp.charge(v1)
    assert Q == approx(Qa)
Example #5
0
def test_get_arrays():
    N = 11
    pp = ParallelPlates(3.5, 1e-3)
    X, er = pp.get_arrays(N=N)
    assert X == approx(np.linspace(0, 1e-3, N))
    assert er == approx(3.5 * np.ones(N - 1))