Yi-Xin (Eshin) Liu avatar Yi-Xin (Eshin) Liu committed eca0838

Add 2D space groups #1-#6. Reformat R and t constant.

Comments (0)

Files changed (6)

 
 Here you can see the full list of changes between each gyroid release.
 
+
+Version 0.2
+-----------
+
+* Basis.generate_structure now be replaced by Basis.generate_structure_by_fft. It is much faster.
+* Add two methods in Basis, sabf2fft and fft2sabf
+* Documentaion has been greatly improved.
+
+
 Version 0.2
 -----------
 

gyroid/space_group.py

     There are **17** 2D space groups.
     Currently, Only following 2D space groups are supported::
 
-       [17]
+       [1,2,3,4,5,6,17]
 
     :param ITA_number: a sequential number as given in the International Tables for Crystallography, Vol. A, allowed range `[1,17]`
     :type ITA_number: integer
     '''
 
     I = np.eye(2)
+    sI = Symmetry(2,b,h,I,t0)
+    # q = 1/4, r = 3/4, s= 1/2, o = 1/8
+    # Rotation
+    R200 = np.array([[-1., 0.],
+                     [ 0.,-1.]])
+
+    R20y = np.array([[-1.,0.],
+                     [ 0.,1.]])
+
+    R300 = np.array([[0.,-1.],
+                     [1.,-1.]])
+
+    Rmxx = np.array([[ 0.,-1.],
+                     [-1., 0.]])
+
+    Rmx0 = np.array([[1., 0.],
+                     [0.,-1.]])
+    # Translation
     t0 = np.zeros(2)
-    sI = Symmetry(2,b,h,I,t0)
-    R300 = np.array([[0.0,-1.0],[1.0,-1.0]])
-    R200 = np.array([[-1.0,0.0],[0.0,-1.0]])
-    Rmxx = np.array([[0.0,-1.0],[-1.0,0.0]])
+    t0s = np.array([.0,.5])
+    ts0 = np.array([.5,.0])
+    tss = np.array([.5,.5])
+
+    if ITA_number == 1:
+        # P1, Oblique
+        return [sI]
+
+    if ITA_number == 2:
+        # P2, Oblique
+        return [sI,
+                Symmetry(2,b,h,R200,t0)
+               ]
+
+    if ITA_number == 3:
+        # Pm, Rectangular
+        return [sI,
+                Symmetry(2,b,h,R20y,t0)
+               ]
+
+    if ITA_number == 4:
+        # Pg, Rectangular
+        return [sI,
+                Symmetry(2,b,h,R20y,t0s)
+               ]
+
+    if ITA_number == 5:
+        # cm, Rectangular
+        return [sI,
+                Symmetry(2,b,h,R20y,t0),
+                Symmetry(2,b,h,I,tss)
+               ]
+
+    if ITA_number == 6:
+        # P2mm, Rectangular
+        return [sI,
+                Symmetry(2,b,h,R20y,t0),
+                Symmetry(2,b,h,R200,t0)
+               ]
+
     if ITA_number == 17:
-        # "P6mm 2D"
+        # "P6mm 2D", Hexagonal
         return [sI,
                 Symmetry(2,b,h,R300,t0),
                 Symmetry(2,b,h,R200,t0),
 def symmetry_generator3(ITA_number,b,h):
     ''' Output 3D space point group symmetry generators.
 
-    There are **230** 3D space groups.
+    There are **230** 3D space groups. The symmetry generators can
+    be found at http://cryst.ehu.es/cryst/get_gen.html.
     Currently, the supported 3D space groups are::
 
-       [183, 230]
+       [183, 229, 230]
 
     :param ITA_number: a sequential number as given in the International Tables for Crystallography, Vol. A, allowed range `[1,17]`
     :type ITA_number: integer
     sI = Symmetry(3,b,h,I,t0)
     # q = 1/4, r = 3/4, s= 1/2, o = 1/8
     # Rotation
-    R300z = np.array([[0.0,-1.0,0.0],[1.0,-1.0,0.0],[0.0,0.0,1.0]])
-    R200z = np.array([[-1.0,0.0,0.0],[0.0,-1.0,0.0],[0.0,0.0,1.0]])
-    R20y0 = np.array([[-1.0,0.0,0.0],[0.0,1.0,0.0],[0.0,0.0,-1.0]])
-    Rmxxz = np.array([[0.0,-1.0,0.0],[-1.0,0.0,0.0],[0.0,0.0,1.0]])
-    R2q0z = np.array([[-1.0,0.0,0.0],[0.0,-1.0,0.0],[0.0,0.0,1.0]])
-    R20yq = np.array([[-1.0,0.0,0.0],[0.0,1.0,0.0],[0.0,0.0,-1.0]])
-    R3xxx = np.array([[0.0,0.0,1.0],[1.0,0.0,0.0],[0.0,1.0,0.0]])
-    R2xxo = np.array([[0.0,1.0,0.0],[1.0,0.0,0.0],[0.0,0.0,-1.0]])
-    R2xx0 = np.array([[0.0,1.0,0.0],[1.0,0.0,0.0],[0.0,0.0,-1.0]])
-    R1000 = np.array([[-1.0,0.0,0.0],[0.0,-1.0,0.0],[0.0,0.0,-1.0]])
+    R300z = np.array([[0.,-1.,0.],
+                      [1.,-1.,0.],
+                      [0., 0.,1.]])
+
+    R200z = np.array([[-1., 0.,0.],
+                      [ 0.,-1.,0.],
+                      [ 0., 0.,1.]])
+
+    R20y0 = np.array([[-1.,0., 0.],
+                      [ 0.,1., 0.],
+                      [ 0.,0.,-1.]])
+
+    Rmxxz = np.array([[ 0.,-1.,0.],
+                      [-1., 0.,0.],
+                      [ 0., 0.,1.]])
+
+    R2q0z = np.array([[-1., 0.,0.],
+                      [ 0.,-1.,0.],
+                      [ 0., 0.,1.]])
+
+    R20yq = np.array([[-1.,0., 0.],
+                      [ 0.,1., 0.],
+                      [ 0.,0.,-1.]])
+
+    R3xxx = np.array([[0.,0.,1.],
+                      [1.,0.,0.],
+                      [0.,1.,0.]])
+
+    R2xxo = np.array([[0.,1., 0.],
+                      [1.,0., 0.],
+                      [0.,0.,-1.]])
+
+    R2xx0 = np.array([[0.,1., 0.],
+                      [1.,0., 0.],
+                      [0.,0.,-1.]])
+
+    R1000 = np.array([[-1., 0., 0.],
+                      [ 0.,-1., 0.],
+                      [ 0., 0.,-1.]])
     # Translation
-    Ts0s = np.array([0.5,0.0,0.5])
-    T0ss = np.array([0.0,0.5,0.5])
-    Trqq = np.array([0.75,0.25,0.25])
-    Tsss = np.array([0.5,0.5,0.5])
+    Ts0s = np.array([.5,.0,.5])
+    T0ss = np.array([.0,.5,.5])
+    Trqq = np.array([.75,.25,.25])
+    Tsss = np.array([.5,.5,.5])
+
     if ITA_number == 183:
-        # "P6mm 3D"
+        # "P6mm 3D", Hexagonal
         return [sI,
                 Symmetry(3,b,h,R300z,t0),
                 Symmetry(3,b,h,R200z,t0),
                 Symmetry(3,b,h,Rmxxz,t0)
                ]
     if ITA_number == 229:
-        # "Im-3m 3D"
-	    return [sI,
+        # "Im-3m 3D", Cubic
+        return [sI,
                 Symmetry(3,b,h,R200z,t0),
                 Symmetry(3,b,h,R20y0,t0),
                 Symmetry(3,b,h,R3xxx,t0),
                ]
 
     if ITA_number == 230:
-        # "Ia-3d 3D"
+        # "Ia-3d 3D", Cubic
         return [sI,
                 Symmetry(3,b,h,R2q0z,Ts0s),
                 Symmetry(3,b,h,R20yq,T0ss),

gyroid/unitcell.py

                 self.type = cell_type
                 self.__standard_cell_1D(cell_type,cell_param)
             else:
-                raise ValueError('Unkonw crystal system for 1D space.')
+                raise ValueError('Unkonwn crystal system for 1D space.')
 
         if dim == 2:
             if cell_type in CRYSTAL_SYSTEM2:
                 self.type = cell_type
                 self.__standard_cell_2D(cell_type,cell_param)
             else:
-                raise ValueError('Unkonw crystal system for 2D space.')
+                raise ValueError('Unkonwn crystal system for 2D space.')
 
         if dim == 3:
             if cell_type in CRYSTAL_SYSTEM3:
                 self.type = cell_type
                 self.__standard_cell_3D(cell_type,cell_param)
             else:
-                raise ValueError('Unkonw crystal system for 3D space.')
+                raise ValueError('Unkonwn crystal system for 3D space.')
 
         self.shape = self.__create_shape()
 
 from matplotlib import colors
 from mayavi import mlab
 
-__all__ = ["render_structure_1d","render_structure_2d","render_structure_3d"]
+__all__ = [
+    "render_structure_1d",
+    "render_structure_2d",
+    "render_structure_3d",
+    "prepare_scft_input"]
+
+def prepare_scft_input(basis,grid,uc):
+    pass
 
 def render_structure_1d(basis,grid,Na,c,
                         save_data=True,data_name="struct1d.mat",
 gyroid
 ======
 
-**gyroid** is a python package that generates *symmetry adapted basis functions* based on the space group of a unit cell.
+**gyroid** is a python package that generates *symmetry adapted basis functions* based on the space group of a unit cell. 
 
 Quickstart
 ----------
     $ python setup.py install
 
 Required packages:
-* numpy: it should be installed before installing gyroid.
-* scipy: use it to save data in Matlab mat format.
-* matplotlib: 2D Graphic plotting.
-* mayavi: it depends on many packages, e.g. VTK (compiled with python wrapper and shared library on). If you do not need the render_structure_3d functionality, simply ignore it.
+
+* `numpy`: it should be installed before installing gyroid.
+* `scipy`: use it to save data in Matlab mat format.
+* `matplotlib`: 2D Graphic plotting.
+* `mayavi`: it depends on many packages, e.g. VTK (compiled with python wrapper and shared library on). If you do not need the render_structure_3d functionality, simply ignore it.
 
 2. Usage
 ^^^^^^^^
 
-::
+Following is a typical usange of the package. It will produce a set of SABFs with point group Ia-3d (#230) in a cubic unit cell. The last line will syntheses a gyroid structure with all coefficients for SABF equal to 1.0, save the structure data into a Matlab mat file, show a screenshot of the rendered image and save the image in a file.
 
-    >>>import gyroid as gy
-
-    >>>uc = gy.UnitCell(3)
-    >>>group = gy.Group(3,gy.BRAVAIS,uc.shape,"Ia-3d")
-    >>>grid = gy.Grid(np.array([4,4,4]),group)
-    >>>basis = gy.Basis(group,grid)
-
-    >>>render_structure_3d(basis,32,32,32,1.0)
+>>> import gyroid as gy
+>>> import numpy as np
+>>> N1,N2,N3 = 32,32,32
+number of grids in each dimension of a unit cell
+>>> uc = gy.UnitCell(3)
+create a standard cubic unit cell with side length 1.0
+>>> group = gy.Group(3,gy.BRAVAIS,uc.shape,"Ia-3d")
+create a Ia-3d point group
+>>> grid = gy.Grid(np.array([N1,N2,N3]),group)
+create a collection of waves that are not canceled
+>>> basis = gy.Basis(group,grid)
+create the SABFs
+>>> gy.render_structure_3d(basis,grid,N1,N2,N3,1.0)
+create the gyroid structure and render it
 
 Ask for Help
 ------------
 
 setup(
     name='gyroid',
-    version='0.2',
+    version='0.3',
     license='BSD',
     description='A symmetry adapted basis function (SABF) generator.',
     author='Yi-Xin Liu',

tests/test_basis.py

 
 def test_Basis2():
     b = "Bravais"
-    N1,N2 = 64,64
+    N1,N2 = 128,128
 
-    uc = UnitCell(2,HEXAGONAL,np.array([1.0]))
+    uc = UnitCell(2,HEXAGONAL,np.array([4.25]))
     g1 = Group(2,b,uc.shape,"P6mm")
     gd1 = Grid(np.array([64,64]),g1)
     bs = Basis(g1,gd1)
 def test_Basis3():
     b = "Bravais"
 
-    N1,N2,N3 = 16,16,16
-    uc = UnitCell(3,HEXAGONAL,np.array([1.0,1.0]))
+    N1,N2,N3 = 32,32,32
+    uc = UnitCell(3,HEXAGONAL,np.array([4.0,4.0]))
     g = Group(3,b,uc.shape,"P6mm")
     gd = Grid(np.array([N1,N2,N3]),g)
     bs = Basis(g,gd)
     print bs.__dict__
     for s in bs.stars:
         print s.__dict__
-    c = 1.0
-#    c = np.zeros(bs.N)
-#    c[0] = 1.0
-#    c[1] = 1.0
-#    c[2] = 1.0
-#    c[3] = 1.0
-#    c[4] = 1.0
+#    c = 1.0
+    c = np.zeros(bs.N)
+    c[0] = N1 * N2 * N3;
+    c[1] = 10.0
+    c[2] = 50.0
+    c[3] = 1.0
+#    c[4] = 5.0
     render_structure_3d(bs,gd,N1,N2,N3,c)
 
 #    N1,N2,N3 = 32,32,32
 #    render_structure_3d(bs2,gd2,N1,N2,N3,c)
 
 def run_test():
-    test_Basis1()
-    #test_Basis2()
+    #test_Basis1()
+    test_Basis2()
     #test_Basis3()
 
 if __name__ == '__main__':
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.