def test_gauss_1d_coax(): cc = CoaxCapacitor(0.5e-3, 5.2, 3.5e-3) X, er = cc.get_arrays(101) v1 = 10.0 V = cc.potential(X, Va=v1) # 1D gauss returns a charge density over circumference # Result is negative due to direction of X Q = np.array([ -2 * np.pi * X[i] * fdm.gauss_1d(X, V, er, i) for i in range(1, len(X) - 1) ]) Qa = cc.charge(v1) assert Q == approx(Qa, rel=0.01)
def test_gauss_2d_coax_xysym(): ri = 1.0e-3 ro = 4.0e-3 rm = 0.5 * (ri + ro) assert rm * 1.414 < ro w = 1.1 * ro dx = ri / 40 Va = 10.0 x = np.arange(0, w, dx) y = np.arange(0, w, dx) X, Y = np.meshgrid(x, y, indexing='ij') cc = CoaxCapacitor(ri, 1.0, ro - ri) V = cc.potential(X, Y, Va=Va) expected = cc.charge(Va) er = np.ones_like(V)[:-1, :-1] xi1 = 0 xi2 = np.searchsorted(x, rm) yi1 = 0 yi2 = np.searchsorted(y, rm) gauss = fdm.gauss_2d(X, Y, V, er, xi1, xi2, yi1, yi2) assert gauss == approx(expected, rel=0.01, abs=1e-14)
def test_charge(): cc = CoaxCapacitor(0.5e-3, 5.2, 3.5e-3) Va = 10.0 expected = cc.capacitance() * Va assert cc.charge(Va) == approx(expected)