def test_agreement_sheet_and_loop(): cs = magcoilcalc.CurrentSheet([-180, 180], 123, 300, 1) cl = magcoilcalc.CurrentLoop([-180, 180], 123, 300, 1) xl = np.linspace(-300, 300, 10) yl = np.linspace(-100, 100, 10) xg, yg = np.meshgrid(xl, yl) xgl = xg.flatten() ygl = yg.flatten() for x, y in zip(xgl, ygl): assert np.all(np.isclose(cs.b_field(x, y), cl.b_field(x, y), rtol=2e-2))
def test_source_collection(): s1 = magcoilcalc.CurrentLoop([-50, 60], 50, 101, 2.0, 3, 1) s2 = magcoilcalc.CurrentSheet([-30, 40], 60, 101, 2.0) c1 = magcoilcalc.SourceCollection([s1, s2]) c2 = magcoilcalc.SourceCollection(s1) c2.add_sources(s2) assert np.all(c1.b_field(10, 10) == c2.b_field(10, 10)) assert np.all( np.array(c1.b_field(-20, 20)) == (np.array(s1.b_field(-20, 20)) + s2.b_field(-20, 20)))
def test_current_sheet_spawn(): cs = magcoilcalc.CurrentSheet([-50, 10], 10, 50, 1.2) assert len(cs.start) == 2 assert cs.nturns == 50 assert all(cs.radius == [10, 10]) assert all(cs.start == [-50, 10])
def test_add_currentsheet(): cs = magcoilcalc.CurrentSheet([-180, 180], 123, 300, 1) mesh = magcoilcalc.Mesh([-20, 20], [-10, 10], 21, 21) t = magcoilcalc.Task([cs], mesh) t.run()
def test_current_sheet_get_field(): cs = magcoilcalc.CurrentSheet([-50, 10], 10, 50, 1.2) cs.b_field(0, 0) cs.b_field(20, 20) cs.b_field(-20, 20)