예제 #1
0
def test_poisson_1d_unity_dielectric():
    X = np.linspace(0, 5, 11)
    er = np.ones_like(X[1:])
    v0 = 10
    V = fdm.poisson_1d(X, v_left=v0, conv=1e-7)
    Ver = fdm.poisson_1d(X, dielectric=er, v_left=v0, conv=1e-7)
    assert V == approx(Ver)
예제 #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)
예제 #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)
예제 #4
0
def test_poisson_1d_bc_slice():
    X = np.linspace(0, 5, 7)
    v0 = -2.0
    v1 = 5.0
    v2 = 8.0
    bc_val = np.zeros_like(X)
    bc_val[2:5] = v1
    bc_bool = bc_val > 0
    bc = (bc_bool, bc_val)
    V = fdm.poisson_1d(X, v_left=v0, v_right=v2, bc=bc, conv=1e-3, sor=1)
    assert V == approx([-2, 1.5, 5, 5, 5, 6.5, 8])
예제 #5
0
def test_efield_pplate_fdm():
    er1, t1 = 5.0, 1e-3
    er2, t2 = 1.0, 3e-3
    Va = 200
    pp = ParallelPlates((er1, er2), (t1, t2))
    X, dx = np.linspace(0, 4e-3, 21, retstep=True)
    V = pp.potential(X, Va)
    E = em.efield_1d(V, dx)

    er = np.where(X[:-1] < t1, er1, er2)
    Vfdm = fdm.poisson_1d(X, dielectric=er, v_right=Va)
    Efdm = em.efield_1d(Vfdm, dx)
    assert Efdm == approx(E, rel=0.001)