Exemple #1
0
    def test_create_from_twiss_parameters(self):
        """Test maus_cpp.covariance_matrix.create_from_penn_parameters"""
        try:
            maus_cpp.covariance_matrix.create_from_twiss_parameters()
            self.assertTrue(False, "Should have thrown a TypeError")
        except TypeError:
            pass
        cm1 = maus_cpp.covariance_matrix.create_from_twiss_parameters \
                      (mass=105.658, momentum=200.,
                       emittance_x=6., beta_x=333.,
                       emittance_y=6., beta_y=333.,
                       emittance_l=100., beta_l=10.)
        cm2 = maus_cpp.covariance_matrix.create_from_twiss_parameters \
                      (mass=105.658, momentum=200.,
                       emittance_x=6., beta_x=333.,
                       emittance_y=6., beta_y=333.,
                       emittance_l=100., beta_l=10.,
                       alpha_x=0., alpha_y=0., alpha_l=0.,
                       dispersion_x=0., dispersion_prime_x=0.,
                       dispersion_y=0., dispersion_prime_y=0.)
        for i in range(1, 7):
            for j in range(i, 7):
                self.assertEqual(cm1.get_element(i, j), cm2.get_element(i, j))

        cm3 = maus_cpp.covariance_matrix.create_from_twiss_parameters \
                      (mass=105.658, momentum=200.,
                       emittance_x=6., beta_x=333.,
                       emittance_y=5., beta_y=250.,
                       emittance_l=1., beta_l=10.,
                       alpha_x=1., alpha_y=2., alpha_l=1.,
                       dispersion_x=1., dispersion_prime_x=1.,
                       dispersion_y=3., dispersion_prime_y=3.)
        cm4 = maus_cpp.covariance_matrix.create_from_twiss_parameters \
                      (105.658, 200.,
                       6., 333., 5., 250., 1., 10.,
                       1., 2., 1., 1., 1., 3., 3.)
        for i in range(1, 7):
            for j in range(i, 7):
                self.assertEqual(cm3.get_element(i, j), cm4.get_element(i, j))
        bunch = Bunch.build_ellipse_2d(10., 1., 1., 200., 105.658, False)
        for i in range(0, 2):
            for j in range(0, 2):
                self.assertLess(2.*abs(bunch[i, j]-cm4.get_element(i+1, j+1))/ \
                                   abs(bunch[i, j]+cm4.get_element(i+1, j+1)),
                                   1.e-3)
        bunch = Bunch.build_ellipse_2d(333., 1., 6., 200., 105.658, False)
        for i in range(2, 4):
            for j in range(2, 4):
                a = bunch[i - 2, j - 2]
                b = cm4.get_element(i + 1, j + 1)
                self.assertLess(2. * abs(a - b) / abs(a + b), 1.e-3)
        bunch = Bunch.build_ellipse_2d(250., 2., 5., 200., 105.658, False)
        for i in range(4, 6):
            for j in range(4, 6):
                a = bunch[i - 4, j - 4]
                b = cm4.get_element(i + 1, j + 1)
                self.assertLess(2. * abs(a - b) / abs(a + b), 1.e-3)
    def test_create_from_twiss_parameters(self):
        """Test maus_cpp.covariance_matrix.create_from_penn_parameters"""
        try:
            maus_cpp.covariance_matrix.create_from_twiss_parameters()
            self.assertTrue(False, "Should have thrown a TypeError")
        except TypeError:
            pass
        cm1 = maus_cpp.covariance_matrix.create_from_twiss_parameters \
                      (mass=105.658, momentum=200.,
                       emittance_x=6., beta_x=333.,
                       emittance_y=6., beta_y=333.,
                       emittance_l=100., beta_l=10.)
        cm2 = maus_cpp.covariance_matrix.create_from_twiss_parameters \
                      (mass=105.658, momentum=200.,
                       emittance_x=6., beta_x=333.,
                       emittance_y=6., beta_y=333.,
                       emittance_l=100., beta_l=10.,
                       alpha_x=0., alpha_y=0., alpha_l=0.,
                       dispersion_x=0., dispersion_prime_x=0.,
                       dispersion_y=0., dispersion_prime_y=0.)
        for i in range(1, 7):
            for j in range(i, 7):
                self.assertEqual(cm1.get_element(i, j), cm2.get_element(i, j))
 
        cm3 = maus_cpp.covariance_matrix.create_from_twiss_parameters \
                      (mass=105.658, momentum=200.,
                       emittance_x=6., beta_x=333.,
                       emittance_y=5., beta_y=250.,
                       emittance_l=1., beta_l=10.,
                       alpha_x=1., alpha_y=2., alpha_l=1.,
                       dispersion_x=1., dispersion_prime_x=1.,
                       dispersion_y=3., dispersion_prime_y=3.)
        cm4 = maus_cpp.covariance_matrix.create_from_twiss_parameters \
                      (105.658, 200.,
                       6., 333., 5., 250., 1., 10.,
                       1., 2., 1., 1., 1., 3., 3.)
        for i in range(1, 7):
            for j in range(i, 7):
                self.assertEqual(cm3.get_element(i, j), cm4.get_element(i, j))
        bunch = Bunch.build_ellipse_2d(10., 1., 1., 200., 105.658, False)
        for i in range(0, 2):
            for j in range(0, 2):
                self.assertLess(2.*abs(bunch[i, j]-cm4.get_element(i+1, j+1))/ \
                                   abs(bunch[i, j]+cm4.get_element(i+1, j+1)),
                                   1.e-3)
        bunch = Bunch.build_ellipse_2d(333., 1., 6., 200., 105.658, False)
        for i in range(2, 4):
            for j in range(2, 4):
                a = bunch[i-2, j-2]
                b = cm4.get_element(i+1, j+1)
                self.assertLess(2.*abs(a-b)/abs(a+b), 1.e-3)
        bunch = Bunch.build_ellipse_2d(250., 2., 5., 200., 105.658, False)
        for i in range(4, 6):
            for j in range(4, 6):
                a = bunch[i-4, j-4]
                b = cm4.get_element(i+1, j+1)
                self.assertLess(2.*abs(a-b)/abs(a+b), 1.e-3)
Exemple #3
0
    def test_create_from_penn_parameters(self):
        """Test maus_cpp.covariance_matrix.create_from_penn_parameters"""
        try:
            maus_cpp.covariance_matrix.create_from_penn_parameters()
            self.assertTrue(False, "Should have thrown a TypeError")
        except TypeError:
            pass
        cm1 = maus_cpp.covariance_matrix.create_from_penn_parameters \
                      (mass=105.658, momentum=200., emittance_t=6., beta_t=333.,
                       emittance_l=1., beta_l=10.)
        cm2 = maus_cpp.covariance_matrix.create_from_penn_parameters \
                      (mass=105.658, momentum=200., emittance_t=6., beta_t=333.,
                       emittance_l=1., beta_l=10., alpha_t=0., alpha_l=0.,
                       charge=1., bz=0., ltwiddle=0., dispersion_x=0.,
                       dispersion_prime_x=0., dispersion_y=0.,
                       dispersion_prime_y=0.)
        for i in range(1, 7):
            for j in range(i, 7):
                self.assertEqual(cm1.get_element(i, j), cm2.get_element(i, j))

        cm3 = maus_cpp.covariance_matrix.create_from_penn_parameters \
                      (mass=105.658, momentum=200., emittance_t=6., beta_t=333.,
                       emittance_l=1., beta_l=10., alpha_t=1., alpha_l=1.,
                       charge=-1., bz=4.e-3, ltwiddle=1., dispersion_x=1.,
                       dispersion_prime_x=1., dispersion_y=1.,
                       dispersion_prime_y=1.)
        cm4 = maus_cpp.covariance_matrix.create_from_penn_parameters \
                      (105.658, 200., 6., 333.,
                       1., 10., 1., 1.,
                       -1., 4.e-3, 1., 1., 1., 1., 1.)
        for i in range(1, 7):
            for j in range(i, 7):
                self.assertEqual(cm3.get_element(i, j), cm4.get_element(i, j))
        bunch = Bunch.build_ellipse_2d(10., 1., 1., 200., 105.658, False)
        for i in range(0, 2):
            for j in range(0, 2):
                self.assertLess(2.*abs(bunch[i, j]-cm4.get_element(i+1, j+1))/ \
                                   abs(bunch[i, j]+cm4.get_element(i+1, j+1)),
                                   1.e-3)
        bunch = Bunch.build_penn_ellipse(6., 105.658, 333., 1., 200., 1.,
                                         4.e-3, -1.)
        for i in range(0, 4):
            for j in range(0, 4):
                self.assertAlmostEqual(bunch[i, j],
                                       cm4.get_element(i + 3, j + 3))
    def test_create_from_penn_parameters(self):
        """Test maus_cpp.covariance_matrix.create_from_penn_parameters"""
        try:
            maus_cpp.covariance_matrix.create_from_penn_parameters()
            self.assertTrue(False, "Should have thrown a TypeError")
        except TypeError:
            pass
        cm1 = maus_cpp.covariance_matrix.create_from_penn_parameters \
                      (mass=105.658, momentum=200., emittance_t=6., beta_t=333.,
                       emittance_l=1., beta_l=10.)
        cm2 = maus_cpp.covariance_matrix.create_from_penn_parameters \
                      (mass=105.658, momentum=200., emittance_t=6., beta_t=333.,
                       emittance_l=1., beta_l=10., alpha_t=0., alpha_l=0.,
                       charge=1., bz=0., ltwiddle=0., dispersion_x=0.,
                       dispersion_prime_x=0., dispersion_y=0.,
                       dispersion_prime_y=0.)
        for i in range(1, 7):
            for j in range(i, 7):
                self.assertEqual(cm1.get_element(i, j), cm2.get_element(i, j))

        cm3 = maus_cpp.covariance_matrix.create_from_penn_parameters \
                      (mass=105.658, momentum=200., emittance_t=6., beta_t=333.,
                       emittance_l=1., beta_l=10., alpha_t=1., alpha_l=1.,
                       charge=-1., bz=4.e-3, ltwiddle=1., dispersion_x=1.,
                       dispersion_prime_x=1., dispersion_y=1.,
                       dispersion_prime_y=1.)
        cm4 = maus_cpp.covariance_matrix.create_from_penn_parameters \
                      (105.658, 200., 6., 333.,
                       1., 10., 1., 1.,
                       -1., 4.e-3, 1., 1., 1., 1., 1.)
        for i in range(1, 7):
            for j in range(i, 7):
                self.assertEqual(cm3.get_element(i, j), cm4.get_element(i, j))
        bunch = Bunch.build_ellipse_2d(10., 1., 1., 200., 105.658, False)
        for i in range(0, 2):
            for j in range(0, 2):
                self.assertLess(2.*abs(bunch[i, j]-cm4.get_element(i+1, j+1))/ \
                                   abs(bunch[i, j]+cm4.get_element(i+1, j+1)),
                                   1.e-3)
        bunch = Bunch.build_penn_ellipse(6., 105.658, 333.,
                                         1., 200., 1., 4.e-3, -1.)
        for i in range(0, 4):
            for j in range(0, 4):
                self.assertAlmostEqual(bunch[i, j], cm4.get_element(i+3, j+3))