def plot_qs(self): length = 0.2 * M aper = 30 * MM g = 10.0 L = 0 lc = LocalCoordinateSystem() qs = QS(lc, length, g, L, aper) Plot3.plot_qs(qs)
def test_quad_1(self): """ 测试 qs 四极场 Returns ------- """ length = 0.2 * M aper = 30 * MM g = -45.7 L = 0 lc = LocalCoordinateSystem(P3(), -P3.x_direct(), P3.y_direct()) qs = QS(lc, length, g, L, aper) m = qs.magnetic_field_at(P3(10 * MM, 0.1, 0)) self.assertTrue(m == P3(0.0, 0.0, 0.457)) m = qs.magnetic_field_at(P3(15 * MM, 0.1, 0)) self.assertTrue(m == P3(0.0, 0.0, 0.6855)) m = qs.magnetic_field_at(P3(15 * MM, 0.1, 5 * MM)) self.assertTrue(m == P3(0.2285, 1.399158968025851e-17, 0.6855))
def test_quad_0(self): """ 测试 qs 四极场 Returns ------- """ length = 0.2 * M aper = 30 * MM g = 10.0 L = 0 lc = LocalCoordinateSystem(P3(), -P3.x_direct(), P3.y_direct()) qs = QS(lc, length, g, L, aper) m = qs.magnetic_field_at(P3(10 * MM, 0.1, 0.0)) self.assertTrue(m == P3(0.0, 0.0, -0.1)) m = qs.magnetic_field_at(P3(15 * MM, 0.1, 0.0)) self.assertTrue(m == P3(0.0, 0.0, -0.15)) m = qs.magnetic_field_at(P3(15 * MM, 0.1, 5 * MM)) self.assertTrue(m == P3(-0.05, -3.061616997868383e-18, -0.15))
from cctpy import M, MM, LocalCoordinateSystem, QS, Plot3, P3 length = 0.2 * M aper = 30 * MM g = 10.0 L = 0 lc = LocalCoordinateSystem(P3(), -P3.x_direct(), P3.y_direct()) qs = QS(lc, length, g, L, aper) Plot3.plot_qs(qs) Plot3.show() m = qs.magnetic_field_at_cpu(P3(10 * MM, 0.1, 0.0)) print(m)