コード例 #1
0
ファイル: prog_view_DV.py プロジェクト: ont/cbox
def redraw():
    global p1,p2,p3
    print "p1 = %s,  p2 = %s,  p3 = %s" % (p1,p2,p3)
    z = Zell( p1, 0, p2, p2, p3, p1 )
    vo = Voron( *z.to_reper() )
    drawgl.clear()
    drawgl( vo )
コード例 #2
0
ファイル: test_zn2sio4.py プロジェクト: ont/cbox
def w_si( *args ):
    drawgl.clear()
    drawgl( vo )
    for v in si:
        drawgl( v )
        for vv in o:
            if abs( (v - vv).vlen() - d2 ) < 0.1:
                drawgl( Vec( *vv ), style='line', start=v )
                drawgl( Vec( *vv ), r=0.1, color=(0,0,1) )
コード例 #3
0
ファイル: test_plane.py プロジェクト: ont/cbox
def draw(nc, n):
    drawgl.clear()

    vo3.draw()
    vo1.draw()

    for p in plns[n].touch(fd1):
        p.draw(r=0.02, color=(0, 1, 0))

    for p in plns[n].touch(fd2):
        p.draw(r=0.04, color=(1, 0, 0))
コード例 #4
0
ファイル: prog_FK_FK.py プロジェクト: ont/cbox
def redraw():
    global vc, pos, delta
    v = vc.norm() * delta * pos
    p = vc.to_plane( v )
    drawgl.clear()
    drawgl( vo_h )
    drawgl( p )
    for x in p.touch( ds1_h ):
        drawgl( x, r = 0.10, color=(0,1,0) )

    for x in p.touch( ds2_h ):
        drawgl( x, r = 0.11, color=(1,0,0) )
コード例 #5
0
ファイル: test_ock_ock.py プロジェクト: ont/cbox
def draw( n ):
    drawgl.clear()
    drawgl( vo3 )

    vn = edg.norm()
    pln = vn.to_plane( vn * dr * n )
    drawgl( pln )

    for p in pln.touch( vo3.has( ds1 ) ):
        drawgl( p, color=(0,1,0) )

    for p in pln.touch( vo3.has( ds2 ) ):
        drawgl( p, r=0.04, color=(1,0,0) )
コード例 #6
0
ファイル: prog_view_K3_solutions.py プロジェクト: ont/cbox
def redraw():
    global pos, reps
    #### constructing sublattice reper
    #r1 = Zell( -1, 0, -1, -1, 0, -1 ).to_reper()
    r1, r2 = reps[ pos ]
    vo1 = Voron( *r1 )
    vo2 = Voron( *r2 )

    drawgl.clear()
    drawgl( vo1 )
    drawgl( vo2 )

    print r1, r2
コード例 #7
0
ファイル: test_cut_hex.py プロジェクト: ont/cbox
def draw():
    print num
    drawgl.clear()

    #drawgl( vo1 )
    #drawgl( vo2 )
    drawgl( vhex )

    pln = n.to_plane( r0 + num * dr )
    for p in pln.touch( vhex.has( ds1 ) ):
        drawgl( p, r=0.02, color = (0,1,0) )

    for p in pln.touch( vhex.has( ds2 ) ):
        drawgl( p, r=0.04, color = (1,0,0) )
コード例 #8
0
ファイル: test_cut_hex.py プロジェクト: ont/cbox
def fill_hex( *args ):
    print args
    drawgl.clear()

    drawgl( vo1  )
    drawgl( vo21 )
    drawgl( vo22 )
    drawgl( vhex )

    for p in vhex.has( ds1 ):
        drawgl( p, r=0.02, color = (0,1,0) )

    for p in vhex.has( ds2 ):
        drawgl( p, r=0.04, color = (1,0,0) )
コード例 #9
0
ファイル: icsd_draw.py プロジェクト: ont/cbox
    def minimize( *xxx ):
        global args, u
        
        ## test mimimization for correction
        if args.testmin:
            vo = Voron( *u.rep )  ## original Voronoi cell
            u = u.to_min()
            u_exp = u * 1

            u_exp.to_decart()

            drawgl.clear()
            drawgl( vo )

            ## draw all atoms which are in "vo"
            for n, ats in u_exp:
                r, col = UCell.data[ n ]
                col = [ x/255.0 for x in col ]

                for v in vo.has( ats ):
                    drawgl( v, r = r, color = col, invis = False )

            ## now draw all cloned Voronoi cells
            #import reper2dots
            #for v in vo.cut( u.rep.to_dots( 1, 1, 1 ) ):
            #    drawgl( Voron( *u.rep, pos = v ) )
            drawgl( Voron( *u.rep ) )
                    

        ## usual minimization process
        else:
            u = u.to_min()
            print '------------'
            print 'sort of minimized cell: ', u.rep.to_zell().to_sort().name
            print 'zell of minimized cell: ', u.rep.to_zell().norm()
            draw_with( drawgl )
コード例 #10
0
ファイル: test_ock_ock.py プロジェクト: ont/cbox
def cubic( *args ):

    ## old cube
    vc = Vec( -0.5, -0.707106781187, 0.244948974278 )
    v1 = Vec( -0.7, 0.282842712476, 0.489897948556 )
    v2 = Vec( -0.3, -0.424264068713, -0.734846922836 )
    v3 = Vec( 0.5, -0.565685424949, 0.489897948556 )
    v1,v2,v3 = v1 - vc, v2 - vc, v3 - vc


    ## new cube
    vc = Vec( 0.8, -0.141421356235, 1.22474487139 )
    v1 = Vec( -0.2, -0.282842712473, 0.979795897112 )
    v2 = Vec( 1.0, 0.141421356238, 0.244948974278 )
    v3 = Vec( 1.0, -1.1313708499, 0.979795897112 )
    v1,v2,v3 = v1 - vc, v2 - vc, v3 - vc

    drawgl.clear()


    ## -- draw cube
    vc = Voron( v1, v2, v3, pos = 0.5 * ( v1+v2+v3 ) )

    for v in vc.has( ds1 ):
        drawgl( v, color=(0,1,0) )

    for v in vc.has( ds2 ):
        drawgl( v, r=0.04, color=(1,0,0) )

    #drawgl( vc )
    drawgl( vo1 )
    drawgl( vo2 )


    basisA = vc.has( ds1 )
    basisA = vc.rep.dec2frac( basisA )
    basisA = map( lambda v: v.z2o(), basisA )
    basisB = [ Vec( 0.0, 0.0, 0.0 ),
               Vec( 0.5, 0.5, 0.5 ) ]

    basisA = set( basisA )
    basisB = set( basisB )

    print 'len( basisA ) = ', len( basisA )
    print 'len( basisB ) = ', len( basisB )

    basisA = basisA - basisB

    print 'len( basisA ) = ', len( basisA )
    print 'len( basisB ) = ', len( basisB )


    ## -- output basis to file
    f = open( '/tmp/basis_ock_ock.txt', 'w' )
    r = vc.rep
    print r.v3 * r.v1.vcross( r.v2 )

    f.write( "rprim   %s %s %s\n      %s %s %s\n      %s %s %s\n" % ( tuple( r[0] ) + tuple( r[1] ) + tuple( r[2] ) )  )
    f.write( "vc.rep\t%s\n\t\t%s\n\t\t%s\n" % ( vc.rep[ 0 ], vc.rep[ 1 ], vc.rep[ 2 ] ) )

    for v in ( vc.rep[ 0 ], vc.rep[ 1 ], vc.rep[ 2 ] ):
        drawgl( v, style = 'line' )

    f.write( '-----------\n' )
    for v in basisA:
        f.write( "%s %s %s\n" % tuple( v ) )

    f.write( '-----------\n' )
    for v in basisB:
        f.write( "%s %s %s\n" % tuple( v ) )

    f.close()


    ## -- test space groups
    for i in xrange( 1, 231 ):
        for j in SpGrp.subs( i ):
            s = SpGrp( i, j )

            f = True
            for p in basisA:
                for v in s * p:
                    if v not in basisA:
                        f = False
                        break
                if not f:
                    break

            if f:
                for p in basisB:
                    for v in s * p:
                        if v not in basisB:
                            f = False
                if f:
                    print '---', s, 'YES'

            #if f:
            #    print '---', s, 'YES'


    return 

    ## -- output other basis
    v1, v2, v3 = v1, v2, 0.5 * (v1 + v2 + v3)
    vc = Voron( v1, v2, v3 )
    drawgl( vc )

    f = open( '/tmp/basis_ock_ock2.txt', 'w' )
    r = vc.rep
    print r.v3 * r.v1.vcross( r.v2 )

    for v in r:
        drawgl( v, style="line", color=( 1,0,0 ) )

    basisA = vc.has( ds1 )
    basisA = vc.rep.dec2frac( basisA )
    basisA = map( lambda v: v.z2o(), basisA )
    basisB = [ Vec( 0.0, 0.0, 0.0 ) ]

    basisA = set( basisA )
    basisB = set( basisB )

    print 'len( basisA ) = ', len( basisA )
    print 'len( basisB ) = ', len( basisB )

    basisA = basisA - basisB

    print 'len( basisA ) = ', len( basisA )
    print 'len( basisB ) = ', len( basisB )


    f.write( "rprim %s %s %s\n      %s %s %s\n      %s %s %s\n" % ( tuple( r[0] ) + tuple( r[1] ) + tuple( r[2] ) )  )

    f.write( '-----------\n' )
    for v in basisA:
        f.write( "%s %s %s\n" % tuple( v ) )
        drawgl( r.frac2dec( v ), r=0.05, color = (0,0,1) )

    f.write( '-----------\n' )
    for v in basisB:
        f.write( "%s %s %s\n" % tuple( v ) )
        drawgl( r.frac2dec( v ), r=0.05, color = (0,1,1) )

    f.close()