Commits

Yi-Xin (Eshin) Liu  committed aca2da0

Relax the constraint in G^2 comparison by reduce EPS from 1e-10 to 1e-6. This normally occurs at high resolution.

  • Participants
  • Parent commits 75ca943

Comments (0)

Files changed (6)

File gyroid/basis.py

             raise ValueError('Check cancel failed when creating a Star.')
         self.dim = group.dim
         self.Gsq = Gsq
+        #print "Gsq = ",Gsq
         waves = self.__select_waves(grid,Gsq)
         sorted_waves,phases = self.__sort_waves(waves)
         self.__find_stars(group,grid,sorted_waves)
     def __form_star(self,G,group,grid,waves):
         star_waves = None
         phases = None
+        #print "waves = ",waves
+        #print "G = ",G
         for i in np.arange(group.order):
             Gn = self.__calc_wave(G,group.symm[i].R,group.type)
             # Pseudo-Spectral method
+            #print "Gn = ",Gn
             Gn,Gn2 = grid.to_BZ(Gn)
+            #print "Gn_BZ = ",Gn," Gn^2 = ",Gn2
 
             if index_waves(Gn,waves.T) is not None:
                 if star_waves is None:
         self.stars = []
         self.N = 0
         rw = waves
+        #print "all waves = ",waves
         while rw is not None:
             G1 = rw[:,0]
             star_waves, phases = self.__form_star(G1,g,grid,rw)

File gyroid/common.py

 import numpy as np
 from numpy.linalg import inv
 
-EPS = 1e-10
+# To let the G2 comparison pass, EPS should not be too small
+EPS = 1e-6
+
 SMALL = 1e-10
 LARGE = 1e+10
 

File gyroid/grid.py

 
     '''
 
-    def __init__(self,ngrid,g):
+    def __init__(self,ngrid,g,lowBZ=-1,highBZ=1):
         ''' Initiator of :class:`Grid`
 
         :param ngrid: contains number of grids in each dimension
         :type ngrid: `numpy.array` with integers
         :param g: a :class:`Group` object
+        :param lowBZ: low bound to find G in BZ, default to -1
+        :param highBZ: high bound to find G in BZ, default to 1
 
         '''
 
                              'not match.')
         self.N = ngrid
         self.shape = g.shape
+        self.lowBZ = lowBZ
+        self.highBZ = highBZ
         self.__create_waves(g)
 
     def to_BZ(self,G):
         return length
 
     def __find_G_in_BZ(self,G):
-        low = -1
-        high = 1
+        low = self.lowBZ
+        high = self.highBZ
         G_try = G
         G_min = G
         Gsq_min = LARGE

File gyroid/space_group.py

                 Symmetry(2,b,h,R200,t0),
                 Symmetry(2,b,h,Rmxx,t0)
                ]
-    else:
-        raise ValueError('ITA number not supported.')
+
+    raise ValueError('ITA number not supported.')
 
 def symmetry_generator3(ITA_number,b,h):
     ''' Output 3D space point group symmetry generators.

File gyroid/util.py

 
     '''
 
+    # If generate_structure_by_fft failed
+    # Give generate_structure a try.
     #struct = basis.generate_structure((Na,Nb),c)
     struct = basis.generate_structure_by_fft((Na,Nb),c,grid)
+
     # For debug only
-    #print basis.fft2sabf(np.fft.fftn(struct),grid)
+    print "Input c: ",c
+    print "c from constructed structure: "
+    print basis.fft2sabf(np.fft.fftn(struct),grid)
+
     rx = np.zeros((Na,Nb))
     ry = np.zeros((Na,Nb))
     for (i,j) in np.ndindex(Na,Nb):

File tests/test_basis.py

     b = "Bravais"
     N1,N2 = 128,128
 
-    uc = UnitCell(2,HEXAGONAL,np.array([2.7]))
-    print uc.__dict__
+    uc = UnitCell(2,HEXAGONAL,np.array([1.0]))
+    #print uc.__dict__
     g1 = Group(2,b,uc.shape,"P6mm")
-    print g1.__dict__
-    gd1 = Grid(np.array([16,16]),g1)
-    print gd1.__dict__
+    #print g1.__dict__
+    gd1 = Grid(np.array([128,128]),g1)
+    gd1.lowBZ = -8
+    gd1.highBZ = 8
     bs = Basis(g1,gd1)
-    print bs.__dict__
     #for s in bs.stars:
         #print s.__dict__
     c = np.zeros(bs.N)
     c[0] = 1.0*N1*N2
-    c[1] = 256.0
-    c[2] = 10.0
-    c[3] = 3.0
+    c[1] = 18.0
+    c[2] = 5.0
+    #c[3] = 3.0
     #c[4] = 1.0
     render_structure_2d(bs,gd1,N1,N2,c)
 
 
 def run_test():
     #test_Basis1()
-    #test_Basis2()
-    test_Basis3()
+    test_Basis2()
+    #test_Basis3()
 
 if __name__ == '__main__':
     run_test()