Example #1
0
    def test_check_positionsND1Pos_multPos(self):
        ha = pot.harmonicOsc(x_shift=-5)
        hb = pot.harmonicOsc(x_shift=5)
        potential = pot.envelopedPotential(V_is=[ha, hb])

        positions = [0, 0.5, 1, 2]
        expected = np.array([[[0, 0.5, 1, 2], [0, 0.5, 1, 2]]], ndmin=2)
        checked = potential._check_positions_type_multiPos(positions=positions)

        #print(checked)
        np.testing.assert_equal(checked, expected, "not the same sorry.")
Example #2
0
    def test_check_positionsNDPoscorrectType_singlePos(self):
        ha = pot.harmonicOsc(x_shift=-5)
        hb = pot.harmonicOsc(x_shift=5)
        potential = pot.envelopedPotential(V_is=[ha, hb])

        positions = [[1, 2], [3, 4]]
        expected = np.array([[1, 2], [3, 4]], ndmin=2)
        checked = potential._check_positions_type_singlePos(position=positions)

        #print(checked)
        np.testing.assert_equal(checked, expected, "not the same sorry.")
Example #3
0
    def test_check_positions_1DNPosSameState_IterableIterable_multiPos(self):
        ha = pot.harmonicOsc(x_shift=-5)
        hb = pot.harmonicOsc(x_shift=5)
        potential = pot.envelopedPotential(V_is=[ha, hb])

        positions = np.array([[4], [2], [3]])
        expected = np.array([[[4], [4]], [[2], [2]], [[3], [3]]], ndmin=3)
        checked = potential._check_positions_type_multiPos(positions=positions)

        #print(checked)
        np.testing.assert_equal(checked, expected, "not the same sorry.")
Example #4
0
    def test_check_positions_2DIterable(self):
        ha = pot.harmonicOsc(x_shift=-5)
        hb = pot.harmonicOsc(x_shift=5)
        potential = pot.envelopedPotential(V_is=[ha, hb])

        positions = np.array((4, 1))
        expected = np.array([[[4, 1], [4, 1]]], ndmin=3)
        checked = potential._check_positions_type(positions=positions)

        #print(checked)
        np.testing.assert_equal(checked, expected, "not the same sorry.")
Example #5
0
    def test_check_positions_1D1Pos_float_singlePos(self):
        ha = pot.harmonicOsc(x_shift=-5)
        hb = pot.harmonicOsc(x_shift=5)
        potential = pot.envelopedPotential(V_is=[ha, hb])

        position = 4
        expected = np.array([[4], [4]])
        checked = potential._check_positions_type_singlePos(position=position)

        #print(checked)
        np.testing.assert_equal(checked, expected, "not the same sorry.")
Example #6
0
    def test_energies1D1Pos_multipos(self):
        ha = pot.harmonicOsc(x_shift=-5)
        hb = pot.harmonicOsc(x_shift=5)
        s = (1, 1)
        positions = [5, -5, 0]
        expected_result = np.array(61.80685281944005)
        potential = pot.envelopedPotentialMultiS(V_is=[ha, hb], s=s)

        energies = potential.ene(positions)

        #print(energies)
        self.assertEqual(
            type(expected_result),
            type(energies),
            msg=
            "returnType of potential was not correct! it should be an np.array"
        )
        np.testing.assert_almost_equal(desired=expected_result,
                                       actual=energies,
                                       err_msg="The results of " +
                                       potential.name + " are not correct!",
                                       decimal=8)
Example #7
0
    def test_energies2D(self):
        fc = 1.0
        x_shift = 0.0
        y_shift = 0.0
        positions = [(0, 1), (1, 2), (3, 4)]
        expected_result = np.array([0.5, 2.5, 12.5])

        potential = pot.harmonicOsc(fc=fc, x_shift=x_shift, y_shift=y_shift)
        energies = potential.ene(positions)
        self.assertEqual(
            type(expected_result),
            type(energies),
            msg=
            "returnType of potential was not correct! it should be an np.array"
        )
        np.testing.assert_almost_equal(desired=list(expected_result),
                                       actual=list(energies),
                                       err_msg="The results of " +
                                       potential.name + " are not correct!",
                                       decimal=8)
Example #8
0
    def test_energiesND1Pos(self):
        fc = 1.0
        x_shift = 0.0
        y_shift = 0.0
        positions = [0, 1, 2, 0.5]
        expected_result = np.array(2.625, ndmin=1)

        potential = pot.harmonicOsc(fc=fc, x_shift=x_shift, y_shift=y_shift)
        energies = potential.ene(positions)

        self.assertEqual(
            type(expected_result),
            type(energies),
            msg=
            "returnType of potential was not correct! it should be an np.array"
        )
        np.testing.assert_almost_equal(desired=expected_result,
                                       actual=energies,
                                       err_msg="The results of " +
                                       potential.name + " are not correct!",
                                       decimal=8)
Example #9
0
    def test_constructor(self):
        ha = pot.harmonicOsc(x_shift=-5)
        hb = pot.harmonicOsc(x_shift=5)
        s = (1, 1)

        potential = pot.envelopedPotentialMultiS(V_is=[ha, hb], s=s)
Example #10
0
    def test_constructor(self):
        ha = pot.harmonicOsc(x_shift=-5)
        hb = pot.harmonicOsc(x_shift=5)

        potential = pot.envelopedPotential(V_is=[ha, hb])
Example #11
0
 def test_constructor(self):
     potential = pot.harmonicOsc()