コード例 #1
0
def test_fom():
    mag = magcoilcalc.CurrentLoop([-150, 150], 100, 420, 1)
    mag2 = magcoilcalc.CurrentLoop([-150, -150 + 63 * 40 / 63, 101], [101, 101], 63, 1, layers=2)
    mag3 = magcoilcalc.CurrentLoop([150 - 63 * 40 / 63, 150], [101, 101], 63, 1, layers=2)
    mesh = magcoilcalc.Mesh([-100, 100], [-50, 50], 61, 51)
    a = magcoilcalc.Task([mag, mag2, mag3], mesh)
    a.run()
    magcoilcalc.calculations.fom_cylindrical_cell(a, 50, 30)
コード例 #2
0
def test_magnet_creation():
    mag = magcoilcalc.CurrentLoop([-50, 10], 10, 101, 2.0, 3, 1)
    assert len(mag.start) == 2
    assert mag.nturns == 101
    assert all(mag.radius == [10, 10])
    assert all(mag.start == [-50, 10])
    assert mag.get_loop_list().shape == (101, 3)
    assert mag.get_loop_list()[-1][1] == 12
コード例 #3
0
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))
コード例 #4
0
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)))
コード例 #5
0
def test_magnet_get_field():
    mag = magcoilcalc.CurrentLoop([-50, 10], 10, 101, 2.0, 3, 1)
    mag.b_field(0, 0)
    mag.b_field(10, 0)
コード例 #6
0
    r = 400
    l = r
    bobbin_width = 10
    nturns = 100
    current = 1.0
    winding_layers = 10
    wire_diameter = 1.0
    # derived bobbin construction parameters
    bobbin_xspan = np.array(
        [l / 2 - bobbin_width / 2, l / 2 + bobbin_width / 2])
    bobbin_radius = r - winding_layers * wire_diameter / 2
    # Build "left" coil

    c1 = magcoilcalc.CurrentLoop(-bobbin_xspan,
                                 bobbin_radius,
                                 nturns,
                                 current,
                                 layers=winding_layers,
                                 layer_thickness=wire_diameter)
    # Build "right" coil
    c2 = magcoilcalc.CurrentLoop(bobbin_xspan,
                                 bobbin_radius,
                                 nturns,
                                 current,
                                 layers=winding_layers,
                                 layer_thickness=wire_diameter)
    # Create a mesh from x = -120 to 120, y = -100 t0 100, 100 steps each
    mesh = magcoilcalc.Mesh([-120, 120], [-100, 100], 100, 100)
    # Puts the two into a Task object.
    task = magcoilcalc.Task([c1, c2], mesh)
    # Runs the calculations.
    task.run()