Ejemplo n.º 1
0
    def test_muon_set_frac(self):

        self._sample._reset(cell=True, sym=True, magdefs=True, muon=True)

        # check that missing cell raises error
        with self.assertRaises(CellError):
            muon_set_frac(self._sample, "0 0 0")

        # ugly way to load a lattice with its symetry
        co_lattice.seek(0)
        atoms, sym = read_cif(co_lattice, 0)  # selectd index 0

        if atoms:
            self._sample._reset(muon=True, sym=True)
            self._sample.cell = atoms
            self._sample.sym = sym
        else:
            raise RuntimeError

        muon_set_frac(self._sample, "0 0 0")
        np.testing.assert_array_almost_equal(np.array([0, 0, 0.]),
                                             self._sample.muons[0])

        muon_set_frac(self._sample, "0.125 0.125 0.125")
        np.testing.assert_array_almost_equal(np.array([0.125, 0.125, 0.125]),
                                             self._sample.muons[1])
Ejemplo n.º 2
0
    def setUp(self):
        self._sample = Sample()

        self._sample._reset(cell=True, sym=True, magdefs=True, muon=True)

        co_lattice.seek(0)
        atoms, sym = read_cif(co_lattice, 0)  # selectd index 0

        if atoms:
            self._sample._reset(muon=True, sym=True)
            self._sample.cell = atoms
            self._sample.sym = sym
        else:
            raise RuntimeError
Ejemplo n.º 3
0
 def setUp(self):
     self._sample = Sample()
    
     self._sample._reset(cell=True,sym=True,magdefs=True,muon=True)
     
     co_lattice.seek(0)
     atoms, sym = read_cif(co_lattice,0) # selectd index 0
 
     if atoms:
         self._sample._reset(muon=True,sym=True)
         self._sample.cell = atoms
         self._sample.sym = sym
     else:
         raise RuntimeError
Ejemplo n.º 4
0
    def test_muon_reset(self):
        # ugly way to load a lattice with its symetry
        co_lattice.seek(0)
        atoms, sym = read_cif(co_lattice,0) # selectd index 0
    
        if atoms:
            self._sample._reset(muon=True,sym=True)
            self._sample.cell = atoms
            self._sample.sym = sym
        else:
            raise RuntimeError
            
        muon_set_frac(self._sample, "0 0 0")
        np.testing.assert_array_almost_equal(np.array([0,0,0.]),self._sample.muons[0])

        muon_set_frac(self._sample, "0.125 0.125 0.125")
        np.testing.assert_array_almost_equal(np.array([0.125,0.125,0.125]),self._sample.muons[1])
Ejemplo n.º 5
0
 def test_find_equiv(self):
     # ugly way to load a lattice with its symetry
     co_lattice.seek(0)
     atoms, sym = read_cif(co_lattice,0) # selectd index 0
 
     if atoms:
         self._sample._reset(cell=True, muon=True, sym=True, magdefs=True)
         self._sample.cell = atoms
         self._sample.sym = sym
     else:
         raise RuntimeError        
     
     #tests throw error if no muon positions defined
     with self.assertRaises(MuonError):
         muon_find_equiv(self._sample)
     
     muon_set_frac(self._sample, "0 0 0")
     muon_find_equiv(self._sample)
     
     muon_positions = self._sample.muons
     
     self.assertEqual(len(muon_positions),atoms.get_number_of_atoms())
     for atm in atoms:
         self.assertTrue(np.any(np.all((muon_positions-atm[2])==0, axis=1)))
     
     self._sample._reset(muon=True)
     
     muon_set_frac(self._sample, "0.2 0.3 0.4")
     muon_find_equiv(self._sample)
     
     muon_positions = self._sample.muons
     #positions calculated with VESTA
     eqpositions = np.array([[ 0.200000  , 0.300000  , 0.400000],
                             [ 0.800000  , 0.700000  , 0.600000],
                             [ 0.800000  , 0.700000  , 0.400000],
                             [ 0.200000  , 0.300000  , 0.600000],
                             [ 0.800000  , 0.300000  , 0.600000],
                             [ 0.200000  , 0.700000  , 0.400000],
                             [ 0.200000  , 0.700000  , 0.600000],
                             [ 0.800000  , 0.300000  , 0.400000],
                             [ 0.400000  , 0.200000  , 0.300000],
                             [ 0.600000  , 0.800000  , 0.700000],
                             [ 0.400000  , 0.800000  , 0.700000],
                             [ 0.600000  , 0.200000  , 0.300000],
                             [ 0.600000  , 0.800000  , 0.300000],
                             [ 0.400000  , 0.200000  , 0.700000],
                             [ 0.600000  , 0.200000  , 0.700000],
                             [ 0.400000  , 0.800000  , 0.300000],
                             [ 0.300000  , 0.400000  , 0.200000],
                             [ 0.700000  , 0.600000  , 0.800000],
                             [ 0.700000  , 0.400000  , 0.800000],
                             [ 0.300000  , 0.600000  , 0.200000],
                             [ 0.300000  , 0.600000  , 0.800000],
                             [ 0.700000  , 0.400000  , 0.200000],
                             [ 0.700000  , 0.600000  , 0.200000],
                             [ 0.300000  , 0.400000  , 0.800000],
                             [ 0.300000  , 0.200000  , 0.600000],
                             [ 0.700000  , 0.800000  , 0.400000],
                             [ 0.700000  , 0.800000  , 0.600000],
                             [ 0.300000  , 0.200000  , 0.400000],
                             [ 0.300000  , 0.800000  , 0.400000],
                             [ 0.700000  , 0.200000  , 0.600000],
                             [ 0.700000  , 0.200000  , 0.400000],
                             [ 0.300000  , 0.800000  , 0.600000],
                             [ 0.200000  , 0.400000  , 0.700000],
                             [ 0.800000  , 0.600000  , 0.300000],
                             [ 0.800000  , 0.400000  , 0.300000],
                             [ 0.200000  , 0.600000  , 0.700000],
                             [ 0.800000  , 0.600000  , 0.700000],
                             [ 0.200000  , 0.400000  , 0.300000],
                             [ 0.200000  , 0.600000  , 0.300000],
                             [ 0.800000  , 0.400000  , 0.700000],
                             [ 0.400000  , 0.300000  , 0.800000],
                             [ 0.600000  , 0.700000  , 0.200000],
                             [ 0.400000  , 0.700000  , 0.200000],
                             [ 0.600000  , 0.300000  , 0.800000],
                             [ 0.600000  , 0.300000  , 0.200000],
                             [ 0.400000  , 0.700000  , 0.800000],
                             [ 0.600000  , 0.700000  , 0.800000],
                             [ 0.400000  , 0.300000  , 0.200000],
                             [ 0.200000  , 0.800000  , 0.900000],
                             [ 0.800000  , 0.200000  , 0.100000],
                             [ 0.800000  , 0.200000  , 0.900000],
                             [ 0.200000  , 0.800000  , 0.100000],
                             [ 0.800000  , 0.800000  , 0.100000],
                             [ 0.200000  , 0.200000  , 0.900000],
                             [ 0.200000  , 0.200000  , 0.100000],
                             [ 0.800000  , 0.800000  , 0.900000],
                             [ 0.300000  , 0.900000  , 0.700000],
                             [ 0.700000  , 0.100000  , 0.300000],
                             [ 0.700000  , 0.900000  , 0.300000],
                             [ 0.300000  , 0.100000  , 0.700000],
                             [ 0.300000  , 0.100000  , 0.300000],
                             [ 0.700000  , 0.900000  , 0.700000],
                             [ 0.700000  , 0.100000  , 0.700000],
                             [ 0.300000  , 0.900000  , 0.300000],
                             [ 0.300000  , 0.700000  , 0.100000],
                             [ 0.700000  , 0.300000  , 0.900000],
                             [ 0.700000  , 0.300000  , 0.100000],
                             [ 0.300000  , 0.700000  , 0.900000],
                             [ 0.300000  , 0.300000  , 0.900000],
                             [ 0.700000  , 0.700000  , 0.100000],
                             [ 0.700000  , 0.700000  , 0.900000],
                             [ 0.300000  , 0.300000  , 0.100000],
                             [ 0.200000  , 0.900000  , 0.200000],
                             [ 0.800000  , 0.100000  , 0.800000],
                             [ 0.800000  , 0.900000  , 0.800000],
                             [ 0.200000  , 0.100000  , 0.200000],
                             [ 0.800000  , 0.100000  , 0.200000],
                             [ 0.200000  , 0.900000  , 0.800000],
                             [ 0.200000  , 0.100000  , 0.800000],
                             [ 0.800000  , 0.900000  , 0.200000],
                             [ 0.900000  , 0.200000  , 0.800000],
                             [ 0.100000  , 0.800000  , 0.200000],
                             [ 0.900000  , 0.800000  , 0.200000],
                             [ 0.100000  , 0.200000  , 0.800000],
                             [ 0.100000  , 0.800000  , 0.800000],
                             [ 0.900000  , 0.200000  , 0.200000],
                             [ 0.100000  , 0.200000  , 0.200000],
                             [ 0.900000  , 0.800000  , 0.800000],
                             [ 0.900000  , 0.300000  , 0.300000],
                             [ 0.100000  , 0.700000  , 0.700000],
                             [ 0.900000  , 0.700000  , 0.700000],
                             [ 0.100000  , 0.300000  , 0.300000],
                             [ 0.100000  , 0.300000  , 0.700000],
                             [ 0.900000  , 0.700000  , 0.300000],
                             [ 0.100000  , 0.700000  , 0.300000],
                             [ 0.900000  , 0.300000  , 0.700000]])
     for p in eqpositions: 
         self.assertTrue(np.any(np.all(np.abs(muon_positions-p)<1e-10, axis=1)))
Ejemplo n.º 6
0
 def test_open_file(self):
     s = Sample()
     MnSi_cif.seek(0)  
     read_cif(MnSi_cif, 0)
Ejemplo n.º 7
0
    def test_find_equiv(self):
        # ugly way to load a lattice with its symetry
        co_lattice.seek(0)
        atoms, sym = read_cif(co_lattice, 0)  # selectd index 0

        if atoms:
            self._sample._reset(cell=True, muon=True, sym=True, magdefs=True)
            self._sample.cell = atoms
            self._sample.sym = sym
        else:
            raise RuntimeError

        #tests throw error if no muon positions defined
        with self.assertRaises(MuonError):
            muon_find_equiv(self._sample)

        muon_set_frac(self._sample, "0 0 0")
        muon_find_equiv(self._sample)

        muon_positions = self._sample.muons

        self.assertEqual(len(muon_positions), atoms.get_number_of_atoms())
        for atm in atoms:
            self.assertTrue(
                np.any(np.all((muon_positions - atm[2]) == 0, axis=1)))

        self._sample._reset(muon=True)

        muon_set_frac(self._sample, "0.2 0.3 0.4")
        muon_find_equiv(self._sample)

        muon_positions = self._sample.muons
        #positions calculated with VESTA
        eqpositions = np.array([[0.200000, 0.300000, 0.400000],
                                [0.800000, 0.700000, 0.600000],
                                [0.800000, 0.700000, 0.400000],
                                [0.200000, 0.300000, 0.600000],
                                [0.800000, 0.300000, 0.600000],
                                [0.200000, 0.700000, 0.400000],
                                [0.200000, 0.700000, 0.600000],
                                [0.800000, 0.300000, 0.400000],
                                [0.400000, 0.200000, 0.300000],
                                [0.600000, 0.800000, 0.700000],
                                [0.400000, 0.800000, 0.700000],
                                [0.600000, 0.200000, 0.300000],
                                [0.600000, 0.800000, 0.300000],
                                [0.400000, 0.200000, 0.700000],
                                [0.600000, 0.200000, 0.700000],
                                [0.400000, 0.800000, 0.300000],
                                [0.300000, 0.400000, 0.200000],
                                [0.700000, 0.600000, 0.800000],
                                [0.700000, 0.400000, 0.800000],
                                [0.300000, 0.600000, 0.200000],
                                [0.300000, 0.600000, 0.800000],
                                [0.700000, 0.400000, 0.200000],
                                [0.700000, 0.600000, 0.200000],
                                [0.300000, 0.400000, 0.800000],
                                [0.300000, 0.200000, 0.600000],
                                [0.700000, 0.800000, 0.400000],
                                [0.700000, 0.800000, 0.600000],
                                [0.300000, 0.200000, 0.400000],
                                [0.300000, 0.800000, 0.400000],
                                [0.700000, 0.200000, 0.600000],
                                [0.700000, 0.200000, 0.400000],
                                [0.300000, 0.800000, 0.600000],
                                [0.200000, 0.400000, 0.700000],
                                [0.800000, 0.600000, 0.300000],
                                [0.800000, 0.400000, 0.300000],
                                [0.200000, 0.600000, 0.700000],
                                [0.800000, 0.600000, 0.700000],
                                [0.200000, 0.400000, 0.300000],
                                [0.200000, 0.600000, 0.300000],
                                [0.800000, 0.400000, 0.700000],
                                [0.400000, 0.300000, 0.800000],
                                [0.600000, 0.700000, 0.200000],
                                [0.400000, 0.700000, 0.200000],
                                [0.600000, 0.300000, 0.800000],
                                [0.600000, 0.300000, 0.200000],
                                [0.400000, 0.700000, 0.800000],
                                [0.600000, 0.700000, 0.800000],
                                [0.400000, 0.300000, 0.200000],
                                [0.200000, 0.800000, 0.900000],
                                [0.800000, 0.200000, 0.100000],
                                [0.800000, 0.200000, 0.900000],
                                [0.200000, 0.800000, 0.100000],
                                [0.800000, 0.800000, 0.100000],
                                [0.200000, 0.200000, 0.900000],
                                [0.200000, 0.200000, 0.100000],
                                [0.800000, 0.800000, 0.900000],
                                [0.300000, 0.900000, 0.700000],
                                [0.700000, 0.100000, 0.300000],
                                [0.700000, 0.900000, 0.300000],
                                [0.300000, 0.100000, 0.700000],
                                [0.300000, 0.100000, 0.300000],
                                [0.700000, 0.900000, 0.700000],
                                [0.700000, 0.100000, 0.700000],
                                [0.300000, 0.900000, 0.300000],
                                [0.300000, 0.700000, 0.100000],
                                [0.700000, 0.300000, 0.900000],
                                [0.700000, 0.300000, 0.100000],
                                [0.300000, 0.700000, 0.900000],
                                [0.300000, 0.300000, 0.900000],
                                [0.700000, 0.700000, 0.100000],
                                [0.700000, 0.700000, 0.900000],
                                [0.300000, 0.300000, 0.100000],
                                [0.200000, 0.900000, 0.200000],
                                [0.800000, 0.100000, 0.800000],
                                [0.800000, 0.900000, 0.800000],
                                [0.200000, 0.100000, 0.200000],
                                [0.800000, 0.100000, 0.200000],
                                [0.200000, 0.900000, 0.800000],
                                [0.200000, 0.100000, 0.800000],
                                [0.800000, 0.900000, 0.200000],
                                [0.900000, 0.200000, 0.800000],
                                [0.100000, 0.800000, 0.200000],
                                [0.900000, 0.800000, 0.200000],
                                [0.100000, 0.200000, 0.800000],
                                [0.100000, 0.800000, 0.800000],
                                [0.900000, 0.200000, 0.200000],
                                [0.100000, 0.200000, 0.200000],
                                [0.900000, 0.800000, 0.800000],
                                [0.900000, 0.300000, 0.300000],
                                [0.100000, 0.700000, 0.700000],
                                [0.900000, 0.700000, 0.700000],
                                [0.100000, 0.300000, 0.300000],
                                [0.100000, 0.300000, 0.700000],
                                [0.900000, 0.700000, 0.300000],
                                [0.100000, 0.700000, 0.300000],
                                [0.900000, 0.300000, 0.700000]])
        for p in eqpositions:
            self.assertTrue(
                np.any(np.all(np.abs(muon_positions - p) < 1e-10, axis=1)))