- Timestamp:
- Jul 5, 2010 4:19:33 PM (12 years ago)
- Location:
- trunk
- Files:
-
- 2 added
- 3 edited
- 1 moved
Legend:
- Unmodified
- Added
- Removed
-
trunk/GSASIIlattice.py
r93 r102 383 383 HKL.append([h,k,l,1/math.sqrt(rdsq)]) 384 384 elif Laue == '2/m': #monoclinic 385 Hmax = SwapIndx(Axis,Hmax) 385 axisnum = 1 + ['a','b','c'].index(Axis) 386 Hmax = SwapIndx(axisnum,Hmax) 386 387 for h in range(Hmax[0]+1): 387 388 for k in range(-Hmax[1],Hmax[1]+1): … … 389 390 if k < 0:lmin = 1 390 391 for l in range(lmin,Hmax[2]+1): 391 [h,k,l] = SwapIndx(- Axis,[h,k,l])392 [h,k,l] = SwapIndx(-axisnum,[h,k,l]) 392 393 H = [] 393 394 if CentCheck(Cent,[h,k,l]): H=[h,k,l] … … 396 397 if 0 < rdsq <= dminsq: 397 398 HKL.append([h,k,l,1/math.sqrt(rdsq)]) 398 [h,k,l] = SwapIndx( Axis,[h,k,l])399 [h,k,l] = SwapIndx(axisnum,[h,k,l]) 399 400 elif Laue in ['mmm','4/m','6/m']: #orthorhombic 400 401 for l in range(Hmax[2]+1): … … 402 403 kmin = 1 403 404 if Laue == 'mmm' or h ==0: kmin = 0 404 for k in range(kmin,Hmax[ 2]+1):405 for k in range(kmin,Hmax[1]+1): 405 406 H = [] 406 407 if CentCheck(Cent,[h,k,l]): H=[h,k,l] … … 581 582 assert np.allclose(frac,tf), msg 582 583 584 # test GetBraviasNum(...) and GenHBravais(...) 585 def test7(): 586 import os.path 587 import sys 588 import GSASIIspc as spc 589 testdir = os.path.join(os.path.split(os.path.abspath( __file__ ))[0],'testinp') 590 if os.path.exists(testdir): 591 if testdir not in sys.path: sys.path.insert(0,testdir) 592 import sgtbxlattinp 593 derror = 1e-4 594 def indexmatch(hklin, hkllist, system): 595 for hklref in hkllist: 596 hklref = list(hklref) 597 # these permutations are far from complete, but are sufficient to 598 # allow the test to complete 599 if system == 'cubic': 600 permlist = [(1,2,3),(1,3,2),(2,1,3),(2,3,1),(3,1,2),(3,2,1),] 601 elif system == 'monoclinic': 602 permlist = [(1,2,3),(-1,2,-3)] 603 else: 604 permlist = [(1,2,3)] 605 606 for perm in permlist: 607 hkl = [abs(i) * hklin[abs(i)-1] / i for i in perm] 608 if hkl == hklref: return True 609 if [-i for i in hkl] == hklref: return True 610 else: 611 return False 612 613 for key in sgtbxlattinp.sgtbx7: 614 spdict = spc.SpcGroup(key) 615 cell = sgtbxlattinp.sgtbx7[key][0] 616 system = spdict[1]['SGSys'] 617 center = spdict[1]['SGLatt'] 618 619 bravcode = GetBraviasNum(center, system) 620 621 g2list = GenHBravais(sgtbxlattinp.dmin, bravcode, cell2A(cell)) 622 623 assert len(sgtbxlattinp.sgtbx7[key][1]) == len(g2list), 'Reflection lists differ for %s' % key 624 for h,k,l,d,num in g2list: 625 for hkllist,dref in sgtbxlattinp.sgtbx7[key][1]: 626 if abs(d-dref) < derror: 627 if indexmatch((h,k,l,), hkllist, system): 628 break 629 else: 630 assert 0,'No match for %s at %s (%s)' % ((h,k,l),d,key) 631 632 def test8(): 633 import GSASIIspc as spc 634 import sgtbxlattinp 635 derror = 1e-4 636 dmin = sgtbxlattinp.dmin 637 638 def indexmatch(hklin, hklref, system, axis): 639 # these permutations are far from complete, but are sufficient to 640 # allow the test to complete 641 if system == 'cubic': 642 permlist = [(1,2,3),(1,3,2),(2,1,3),(2,3,1),(3,1,2),(3,2,1),] 643 elif system == 'monoclinic' and axis=='b': 644 permlist = [(1,2,3),(-1,2,-3)] 645 elif system == 'monoclinic' and axis=='a': 646 permlist = [(1,2,3),(1,-2,-3)] 647 elif system == 'monoclinic' and axis=='c': 648 permlist = [(1,2,3),(-1,-2,3)] 649 elif system == 'trigonal': 650 permlist = [(1,2,3),(2,1,3),(-1,-2,3),(-2,-1,3)] 651 else: 652 permlist = [(1,2,3)] 653 654 hklref = list(hklref) 655 for perm in permlist: 656 hkl = [abs(i) * hklin[abs(i)-1] / i for i in perm] 657 if hkl == hklref: return True 658 if [-i for i in hkl] == hklref: return True 659 return False 660 661 for key in sgtbxlattinp.sgtbx8: 662 spdict = spc.SpcGroup(key)[1] 663 cell = sgtbxlattinp.sgtbx8[key][0] 664 center = spdict['SGLatt'] 665 Laue = spdict['SGLaue'] 666 Axis = spdict['SGUniq'] 667 system = spdict['SGSys'] 668 669 g2list = GenHLaue(dmin,Laue,center,Axis,cell2A(cell)) 670 #if len(g2list) != len(sgtbxlattinp.sgtbx8[key][1]): 671 # print 'failed',key,':' ,len(g2list),'vs',len(sgtbxlattinp.sgtbx8[key][1]) 672 # print 'GSAS-II:' 673 # for h,k,l,d in g2list: print ' ',(h,k,l),d 674 # print 'SGTBX:' 675 # for hkllist,dref in sgtbxlattinp.sgtbx8[key][1]: print ' ',hkllist,dref 676 assert len(g2list) == len(sgtbxlattinp.sgtbx8[key][1]), ( 677 'Reflection lists differ for %s' % key 678 ) 679 #match = True 680 for h,k,l,d in g2list: 681 for hkllist,dref in sgtbxlattinp.sgtbx8[key][1]: 682 if abs(d-dref) < derror: 683 if indexmatch((h,k,l,), hkllist, system, Axis): break 684 else: 685 assert 0,'No match for %s at %s (%s)' % ((h,k,l),d,key) 686 #match = False 687 #if not match: 688 #for hkllist,dref in sgtbxlattinp.sgtbx8[key][1]: print ' ',hkllist,dref 689 #print center, Laue, Axis, system 690 583 691 if __name__ == '__main__': 584 692 test0() … … 589 697 test5() 590 698 test6() 699 test7() 700 test8() 591 701 print "OK" -
trunk/GSASIIspc.py
r69 r102 489 489 return GetKNsym(str(Isym)),Mult 490 490 491 '''A list of space groups as ordered and named in the pre-2002 International 492 Tables Volume A, except that spaces are used following the GSAS convention to 493 separate the different crystallographic directions. 494 Note that the symmetry codes here will recognize many non-standard space group 495 symbols with different settings. 496 ''' 497 spglist = { 498 'triclinic' : ('P 1','P -1',), # 1-2 499 'monoclinic': ('P 2','P 21','C 2','P m','P c','C m','C c','P 2/m','P 21/m', 500 'C 2/m','P 2/c','P 21/c','C 2/c',), #3-15 501 'orthorhombic': ('P 2 2 2','P 2 2 21','P 21 21 2','P 21 21 21','C 2 2 21', 502 'C 2 2 2','F 2 2 2','I 2 2 2','I 21 21 21', 503 'P m m 2','P m c 21','P c c 2','P m a 2','P c a 21', 504 'P n c 2','P m n 21','P b a 2','P n a 21','P n n 2', 505 'C m m 2','C m c 21','C c c 2','A m m 2','A b m 2', 506 'A m a 2','A b a 2','F m m 2','F d d 2','I m m 2', 507 'I b a 2','I m a 2','P m m m','P n n n','P c c m', 508 'P b a n','P m m a','P n n a','P m n a','P c c a', 509 'P b a m','P c c n','P b c m','P n n m','P m m n', 510 'P b c n','P b c a','P n m a','C m c m','C m c a', 511 'C m m m','C c c m','C m m a','C c c a','F m m m', 512 'F d d d','I m m m','I b a m','I b c a','I m m a',), #16-74 513 'tetragonal': ('P 4','P 41','P 42','P 43','I 4','I 41','P -4','I -4', 514 'P 4/m','P 42/m','P 4/n','P 42/n','I 4/m','I 41/a', 515 'P 4 2 2','P 4 21 2','P 41 2 2','P 41 21 2','P 42 2 2', 516 'P 42 21 2','P 43 2 2','P 43 21 2','I 4 2 2','I 41 2 2', 517 'P 4 m m','P 4 b m','P 42 c m','P 42 n m','P 4 c c', 518 'P 4 n c','P 42 m c','P 42 b c','I 4 m m','I 4 c m', 519 'I 41 m d','I 41 c d','P -4 2 m','P -4 2 c','P -4 21 m', 520 'P -4 21 c','P -4 m 2','P -4 c 2','P -4 b 2','P -4 n 2', 521 'I -4 m 2','I -4 c 2','I -4 2 m','I -4 2 d','P 4/m m m', 522 'P 4/m c c','P 4/n b m','P 4/n n c','P 4/m b m','P 4/m n c', 523 'P 4/n m m','P 4/n c c','P 42/m m c','P 42/m c m', 524 'P 42/n b c','P 42/n n m','P 42/m b c','P 42/m n m', 525 'P 42/n m c','P 42/n c m','I 4/m m m','I 4/m c m', 526 'I 41/a m d','I 41/a c d',), # 75-142 527 'trigonal': ('P 3','P 31','P 32','R 3','P -3','R -3','P 3 1 2','P 3 2 1', 528 'P 31 1 2','P 31 2 1','P 32 1 2','P 32 2 1','R 3 2', 'P 3 m 1', 529 'P 3 1 m','P 3 c 1','P 3 1 c','R 3 m','R 3 c','P -3 1 m', 530 'P -3 1 c','P -3 m 1','P -3 c 1','R -3 m','R -3 c',), #143-167 531 'hexagonal': ('P 6','P 61','P 65','P 62','P 64','P 63','P -6','P 6/m', 532 'P 63/m','P 6 2 2','P 61 2 2','P 65 2 2','P 62 2 2', 533 'P 64 2 2','P 63 2 2','P 6 m m','P 6 c c','P 63 c m', 534 'P 63 m c','P -6 m 2','P -6 c 2','P -6 2 m','P -6 2 c', 535 'P 6/m m m','P 6/m c c','P 63/m c m','P 63/m m c',), #144-194 536 'cubic': ('P 2 3','F 2 3','I 2 3','P 21 3','I 21 3','P m -3','P n -3', 537 'F m -3','F d -3','I m -3','P a -3','I a -3','P 4 3 2','P 42 3 2', 538 'F 4 3 2','F 41 3 2','I 4 3 2','P 43 3 2','P 41 3 2','I 41 3 2', 539 'P -4 3 m','F -4 3 m','I -4 3 m','P -4 3 n','F -4 3 c','I -4 3 d', 540 'P m -3 m','P n -3 n','P m -3 n','P n -3 m','F m -3 m','F m -3 c', 541 'F d -3 m','F d -3 c','I m -3 m','I a -3 d',), #195-230 542 } 543 'A few non-standard space groups for test use' 544 nonstandard_sglist = ('P 21 1 1','P 1 21 1','P 1 1 21','R 3 r','R 3 2 h', 545 'R -3 r', 'R 3 2 r','R 3 m h', 'R 3 m r', 546 'R 3 c r','R -3 c r','R -3 m r',), 547 '''A list of orthorhombic space groups that were renamed in the 2002 Volume A, 548 along with the pre-2002 name. The e designates a double glide-plane''' 549 sgequiv_2002_orthorhombic= (('A e m 2', 'A b m 2',), 550 ('A e a 2', 'A b a 2',), 551 ('C m c e', 'C m c a',), 552 ('C m m e', 'C m m a',), 553 ('C c c e', 'C c c a'),) 554 '''Use the space groups types in this order to list the symbols in the 555 order they are listed in the International Tables, vol. A''' 556 symtypelist = ('triclinic', 'monoclinic', 'orthorhombic', 'tetragonal', 557 'trigonal', 'hexagonal', 'cubic') 558 491 559 # self-test materials follow. Requires files in directory testinp 492 560 def test0(): -
trunk/unit_tests.py
r71 r102 23 23 def test_GSASIIlattice6(): 24 24 G2l.test6() 25 def test_GSASIIlattice7(): 26 G2l.test7() 27 def test_GSASIIlattice8(): 28 G2l.test8() 25 29 26 30 if __name__ == '__main__': … … 36 40 G2l.test5() 37 41 G2l.test6() 42 G2l.test7() 43 G2l.test8() 38 44 print "OK"
Note: See TracChangeset
for help on using the changeset viewer.