def test_tube_dsdx_2(): xs = [0, 2, 4, 6] ds = [1, 2, 4, 2] t = Tube(xs, ds) for i in range(33): x1 = 0 + random.random() * 2 x2 = 0 + random.random() * 2 x1, x2 = min(x1, x2), max(x1, x2) assert t.get_dsdx(np.array([x1, x2])) == approx([ (pi * 2**2 / 4 - pi * 1**2 / 4) / 2 ]) for i in range(33): x1 = 2 + random.random() * 2 x2 = 2 + random.random() * 2 x1, x2 = min(x1, x2), max(x1, x2) assert t.get_dsdx(np.array([x1, x2])) == approx([ (pi * 4**2 / 4 - pi * 2**2 / 4) / 2 ]) for i in range(33): x1 = 4 + random.random() * 2 x2 = 4 + random.random() * 2 x1, x2 = min(x1, x2), max(x1, x2) assert t.get_dsdx(np.array([x1, x2])) == approx([ (pi * 2**2 / 4 - pi * 4**2 / 4) / 2 ])
def test_tube_dsdx_1(): xs = [1, 2, 4] ds = [1, 1, 1] s = pi / 4 t = Tube(xs, ds) for i in range(33): x1 = -10 + random.random() * 30 x2 = -10 + random.random() * 30 x1, x2 = min(x1, x2), max(x1, x2) assert t.get_dsdx(np.array([x1, x2])) == approx([0.0])