Exemple #1
0
 def test_replace_outoflimits(self):
     ''' Must leave current image unchanged if it tries to replace an non existing image'''
     chain.Replace_Image(self.p_state,
                         idx_image=5)  # replace 0th with 5th (not exist)
     self.assertEqual(system.Get_Index(self.p_state), 0)  # active is 0th
     self.assertEqual(chain.Get_NOI(self.p_state), 1)  # total 1 image
     chain.Replace_Image(self.p_state,
                         idx_image=-5)  # replace 0th with -5th (not exist)
     self.assertEqual(system.Get_Index(self.p_state), 0)  # active is 0th
     self.assertEqual(chain.Get_NOI(self.p_state), 1)  # total 1 image
Exemple #2
0
 def test_pop_back(self):
     ''' Must make the image with next smaller index active when the active is poped'''
     chain.Insert_Image_Before(self.p_state)  # add before active
     self.assertEqual(system.Get_Index(self.p_state), 1)  # active is 1st
     chain.Pop_Back(self.p_state)  # delete the last (active)
     self.assertEqual(system.Get_Index(self.p_state), 0)  # active is 0th
     self.assertEqual(chain.Get_NOI(self.p_state), 1)  # total 1 image
Exemple #3
0
 def test_update(self):
     noi = chain.Get_NOI(self.p_state)
     Ei = chain.Get_Energy(self.p_state)  # Energy initial
     chain.Update_Data(self.p_state)
     Ef = chain.Get_Energy(self.p_state)  # Energy final
     for i in range(noi):
         self.assertEqual(Ei[i], Ef[i])  # should be equal
Exemple #4
0
 def test_Rx(self):
     chain.Insert_Image_Before(self.p_state)  # active is 1st
     noi = chain.Get_NOI(self.p_state)  # total 2 images
     self.assertAlmostEqual(noi, 2)
     Rx = chain.Get_Rx(self.p_state)  # get Rx values
     Rx_interp = chain.Get_Rx_Interpolated(self.p_state)  # get Rx interpol
     self.assertNotAlmostEqual(Rx[noi - 1], 0)
Exemple #5
0
    def test_delete_outoflimits(self):

        chain.Insert_Image_Before(self.p_state)  # active is 1st
        chain.Insert_Image_Before(self.p_state)  # active is 2nd
        self.assertEqual(system.Get_Index(self.p_state), 2)  # active is 2nd
        self.assertEqual(chain.Get_NOI(self.p_state), 3)  # total 3 images

        # test the deletion of a non existing image with positive idx
        chain.Delete_Image(self.p_state,
                           idx_image=5)  # delete -5th (not exist)
        self.assertEqual(chain.Get_NOI(self.p_state), 3)  # total 3 images

        # test the deletion of a non existing image with negative idx
        chain.Delete_Image(self.p_state,
                           idx_image=-5)  # delete -5th (not exist)
        self.assertEqual(chain.Get_NOI(self.p_state), 2)  # total 2 images
        self.assertEqual(system.Get_Index(self.p_state), 1)  # active is 1st
Exemple #6
0
def configurations(p_state):
    ### Copy the system a few times
    chain.Image_to_Clipboard(p_state)
    for number in range(1, 7):
        chain.Insert_Image_After(p_state)
    noi = chain.Get_NOI(p_state)

    ### Read Image from file
    # Configuration_from_File(state.get(), spinsfile, 0);
    ### Read Chain from file
    # Chain_from_File(state.get(), chainfile);

    ### First image is homogeneous with a Skyrmion at pos
    configuration.PlusZ(p_state, idx_image=0)
    configuration.Skyrmion(p_state, 5.0, phase=-90.0, idx_image=0)
    ### Last image is homogeneous
    configuration.PlusZ(p_state, idx_image=noi - 1)

    # spinsfile = "input/spins.txt"
    # io.Image_Read(p_state, spinsfile)

    ### Create transition of images between first and last
    transition.Homogeneous(p_state, 0, noi - 1)
Exemple #7
0
 def test_push_back(self):
     ''' Must add one image and leave active's index unchanged '''
     chain.Push_Back(self.p_state)  # add after all
     self.assertEqual(chain.Get_NOI(self.p_state), 2)  # total 2 images
     self.assertEqual(system.Get_Index(self.p_state), 0)  # active is 0th
Exemple #8
0
 def test_insert_before(self):
     ''' Must reindex (increment by one) active image '''
     chain.Insert_Image_Before(self.p_state)  # add before active
     self.assertEqual(chain.Get_NOI(self.p_state), 2)  # total 2 images
     self.assertEqual(system.Get_Index(self.p_state), 1)  # active is 1st
Exemple #9
0
 def test_insert_after(self):
     ''' Must leave the index of active image the same '''
     chain.Insert_Image_After(self.p_state)  # add after active
     self.assertEqual(chain.Get_NOI(self.p_state), 2)  # total 2 images
     self.assertEqual(system.Get_Index(self.p_state), 0)  # active is 0th
Exemple #10
0
 def test_NOI(self):
     ''' NOI -> Number of images in that chain '''
     self.assertEqual(chain.Get_NOI(self.p_state), 1)  # total 1 image
Exemple #11
0
 def tearDown(self):
     ''' clean the p_state '''
     noi = chain.Get_NOI(self.p_state)
     for i in range(noi - 1):
         chain.Pop_Back(self.p_state)
     self.assertEqual(chain.Get_NOI(self.p_state), 1)
Exemple #12
0
 def test_remove_smallest_index_active(self):
     '''' Must set the active to the image with the smallest index left'''
     chain.Insert_Image_After(self.p_state)  # active is 0th
     chain.Delete_Image(self.p_state)  # delete 0th
     self.assertEqual(chain.Get_NOI(self.p_state), 1)  # total 1 image
     self.assertEqual(system.Get_Index(self.p_state), 0)  # active is 0th
Exemple #13
0
 def test_delete_trivial(self):
     ''' Must NOT delete the image of a chain with only one image'''
     chain.Delete_Image(self.p_state)  # delete 0th
     self.assertEqual(chain.Get_NOI(self.p_state), 1)  # total 1 image