Exemple #1
0
    def test_magnet_at(self):
        cct = CCT(
            LocalCoordinateSystem.global_coordinate_system(),
            0.95,
            83 * MM + 15 * MM * 2,
            67.5,
            [30.0, 80.0, 90.0, 90.0],
            128,
            -9664,
            P2(0, 0),
            P2(128 * np.pi * 2, 67.5 / 180.0 * np.pi),
        )

        m = cct.magnetic_field_at(P3.origin())
        self.assertEqual(
            m,
            P3(0.0031436355039083964, -0.00470478301086915,
               0.00888627084434009))
        float *p0 = winding + tid * DIM;
        float *p1 = winding + (tid + 1) * DIM;
        float db[3];

        dB(p0, p1, p, db);

        atomicAdd(&ret[X], db[X]);
        atomicAdd(&ret[Y], db[Y]);
        atomicAdd(&ret[Z], db[Z]);
    }
}""")

magnet = mod.get_function("magnet_solo_cct")

cct = CCT(
    LocalCoordinateSystem.global_coordinate_system(),
    0.95,
    83 * MM + 15 * MM * 2,
    67.5,
    [30.0, 80.0, 90.0, 90.0],
    128,
    -9664,
    P2(0, 0),
    P2(128 * np.pi * 2, 67.5 / 180.0 * np.pi),
)

length = int(cct.dispersed_path3.shape[0])
winding = cct.dispersed_path3.flatten().astype(np.float32)

ret = np.empty((3, ), dtype=np.float32)