Changeset 4659
- Timestamp:
- Nov 21, 2020 2:15:49 PM (3 years ago)
- Location:
- trunk
- Files:
-
- 2 added
- 8 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/GSASIIElem.py
r4629 r4659 543 543 return (FP, FPP, Mu) 544 544 545 545 mapDefault = {'MapType':'','RefList':'','GridStep':0.25,'Show bonds':True, 546 'rho':[],'rhoMax':0.,'mapSize':10.0,'cutOff':50.,'Flip':False} 547 548 def SetupGeneral(data, dirname): 549 '''Initialize the General sections of the Phase tree contents 550 Called by SetupGeneral in GSASIIphsGUI and in GSASIIscriptable.SetupGeneral 551 ''' 552 generalData = data['General'] 553 atomData = data['Atoms'] 554 generalData['AtomTypes'] = [] 555 generalData['Isotopes'] = {} 556 # various patches 557 if 'Isotope' not in generalData: 558 generalData['Isotope'] = {} 559 if 'Data plot type' not in generalData: 560 generalData['Data plot type'] = 'Mustrain' 561 if 'POhkl' not in generalData: 562 generalData['POhkl'] = [0,0,1] 563 if 'Map' not in generalData: 564 generalData['Map'] = mapDefault.copy() 565 if 'Flip' not in generalData: 566 generalData['Flip'] = {'RefList':'','GridStep':0.25,'Norm element':'None', 567 'k-factor':0.1,'k-Max':20.,} 568 if 'testHKL' not in generalData['Flip']: 569 generalData['Flip']['testHKL'] = [[0,0,2],[2,0,0],[1,1,1],[0,2,0],[1,2,3]] 570 if 'doPawley' not in generalData: 571 generalData['doPawley'] = False #ToDo: change to '' 572 if 'Pawley dmin' not in generalData: 573 generalData['Pawley dmin'] = 1.0 574 if 'Pawley dmax' not in generalData: 575 generalData['Pawley dmax'] = 100.0 576 if 'Pawley neg wt' not in generalData: 577 generalData['Pawley neg wt'] = 0.0 578 if '3Dproj' not in generalData: 579 generalData['3Dproj'] = '' 580 if 'doDysnomia' not in generalData: 581 generalData['doDysnomia'] = False 582 if 'Algolrithm' in generalData.get('MCSA controls',{}) or \ 583 'MCSA controls' not in generalData: 584 generalData['MCSA controls'] = {'Data source':'','Annealing':[0.7,0.1,250], 585 'dmin':2.8,'Algorithm':'log','fast parms':[0.8,0.6],'log slope':0.9, 586 'Cycles':1,'Results':[],'newDmin':True} 587 if 'AtomPtrs' not in generalData: 588 generalData['AtomPtrs'] = [3,1,7,9] 589 if generalData['Type'] == 'macromolecular': 590 generalData['AtomPtrs'] = [6,4,10,12] 591 elif generalData['Type'] == 'magnetic': 592 generalData['AtomPtrs'] = [3,1,10,12] 593 if generalData['Modulated']: 594 if 'Super' not in generalData: 595 generalData['Super'] = 1 596 generalData['SuperVec'] = [[0.,0.,0.],False,1] 597 generalData['SSGData'] = {} 598 if '4DmapData' not in generalData: 599 generalData['4DmapData'] = mapDefault.copy() 600 generalData['4DmapData'].update({'MapType':'Fobs'}) 601 atomData = data['Atoms'] 602 for atom in atomData: 603 # if 'SS1' not in atom: 604 # atom += [[],[],{'SS1':{'waveType':'Fourier','Sfrac':[],'Spos':[],'Sadp':[],'Smag':[]}}] 605 if isinstance(atom[-1],dict) and 'waveType' in atom[-1]['SS1']: 606 waveType = atom[-1]['SS1']['waveType'] 607 for parm in ['Sfrac','Spos','Sadp','Smag']: 608 if len(atom[-1]['SS1'][parm]): 609 wType = 'Fourier' 610 if parm == 'Sfrac': 611 if 'Crenel' in waveType: 612 wType = 'Crenel' 613 elif parm == 'Spos': 614 if not 'Crenel' in waveType: 615 wType = waveType 616 atom[-1]['SS1'][parm] = [wType,]+list(atom[-1]['SS1'][parm]) 617 del atom[-1]['SS1']['waveType'] 618 else: 619 generalData['Super'] = 0 620 if 'Modulated' not in generalData: 621 generalData['Modulated'] = False 622 if 'HydIds' not in generalData: 623 generalData['HydIds'] = {} 624 if generalData['Type'] == 'magnetic': 625 if 'SGGray' not in generalData['SGData']: 626 generalData['SGData']['SGGray'] = False 627 if 'Resolution' in generalData['Map']: 628 generalData['Map']['GridStep'] = generalData['Map']['Resolution']/2. 629 generalData['Flip']['GridStep'] = generalData['Flip']['Resolution']/2. 630 del generalData['Map']['Resolution'] 631 del generalData['Flip']['Resolution'] 632 if 'Compare' not in generalData: 633 generalData['Compare'] = {'Oatoms':'','Tatoms':'', 634 'Tilts':{'Otilts':[],'Ttilts':[]}, 635 'Bonds':{'Obonds':[],'Tbonds':[]},'Vects':{'Ovec':[],'Tvec':[]}, 636 'dVects':{'Ovec':[],'Tvec':[]},'Sampling':1.0} 637 if 'Sampling' not in generalData['Compare']: 638 generalData['Compare']['Sampling'] = 1.0 639 640 # end of patches 641 cx,ct,cs,cia = generalData['AtomPtrs'] 642 generalData['NoAtoms'] = {} 643 generalData['BondRadii'] = [] 644 generalData['AngleRadii'] = [] 645 generalData['vdWRadii'] = [] 646 generalData['AtomMass'] = [] 647 generalData['Color'] = [] 648 if generalData['Type'] == 'magnetic': 649 generalData['MagDmin'] = generalData.get('MagDmin',1.0) 650 landeg = generalData.get('Lande g',[]) 651 generalData['Mydir'] = dirname 652 badList = {} 653 for iat,atom in enumerate(atomData): 654 atom[ct] = atom[ct].lower().capitalize() #force to standard form 655 if generalData['AtomTypes'].count(atom[ct]): 656 generalData['NoAtoms'][atom[ct]] += atom[cx+3]*float(atom[cs+1]) 657 elif atom[ct] != 'UNK': 658 Info = GetAtomInfo(atom[ct]) 659 if not Info: 660 if atom[ct] not in badList: 661 badList[atom[ct]] = 0 662 badList[atom[ct]] += 1 663 atom[ct] = 'UNK' 664 continue 665 atom[ct] = Info['Symbol'] # N.B. symbol might be changed by GetAtomInfo 666 generalData['AtomTypes'].append(atom[ct]) 667 generalData['Z'] = Info['Z'] 668 generalData['Isotopes'][atom[ct]] = Info['Isotopes'] 669 generalData['BondRadii'].append(Info['Drad']) 670 generalData['AngleRadii'].append(Info['Arad']) 671 generalData['vdWRadii'].append(Info['Vdrad']) 672 if atom[ct] in generalData['Isotope']: 673 if generalData['Isotope'][atom[ct]] not in generalData['Isotopes'][atom[ct]]: 674 isotope = list(generalData['Isotopes'][atom[ct]].keys())[-1] 675 generalData['Isotope'][atom[ct]] = isotope 676 generalData['AtomMass'].append(Info['Isotopes'][generalData['Isotope'][atom[ct]]]['Mass']) 677 else: 678 generalData['Isotope'][atom[ct]] = 'Nat. Abund.' 679 if 'Nat. Abund.' not in generalData['Isotopes'][atom[ct]]: 680 isotope = list(generalData['Isotopes'][atom[ct]].keys())[-1] 681 generalData['Isotope'][atom[ct]] = isotope 682 generalData['AtomMass'].append(Info['Mass']) 683 generalData['NoAtoms'][atom[ct]] = atom[cx+3]*float(atom[cs+1]) 684 generalData['Color'].append(Info['Color']) 685 if generalData['Type'] == 'magnetic': 686 if len(landeg) < len(generalData['AtomTypes']): 687 landeg.append(2.0) 688 if generalData['Type'] == 'magnetic': 689 generalData['Lande g'] = landeg[:len(generalData['AtomTypes'])] 690 691 F000X = 0. 692 F000N = 0. 693 for i,elem in enumerate(generalData['AtomTypes']): 694 F000X += generalData['NoAtoms'][elem]*generalData['Z'] 695 isotope = generalData['Isotope'][elem] 696 F000N += generalData['NoAtoms'][elem]*generalData['Isotopes'][elem][isotope]['SL'][0] 697 generalData['F000X'] = F000X 698 generalData['F000N'] = F000N 699 generalData['Mass'] = G2mth.getMass(generalData) 700 701 if badList: 702 msg = 'Warning: element symbol(s) not found:' 703 for key in badList: 704 msg += '\n\t' + key 705 if badList[key] > 1: 706 msg += ' (' + str(badList[key]) + ' times)' 707 #wx.MessageBox(msg,caption='Element symbol error') 708 raise ValueError("Phase error:\n" + msg) -
trunk/GSASIIctrlGUI.py
r4654 r4659 169 169 import GSASIIobj as G2obj 170 170 import GSASIIfiles as G2fil 171 import GSASIIElem as G2elem 171 172 import GSASIIscriptable as G2sc 172 173 import GSASIIpwd as G2pwd 173 174 import GSASIIlattice as G2lat 175 import GSASIImath as G2mth 176 import GSASIIstrMain as G2stMn 174 177 if sys.version_info[0] >= 3: 175 178 unicode = str … … 7009 7012 AutoLoadWindow = dlg # save window reference 7010 7013 7014 ################################################################################ 7015 # Deal with Origin 1/2 ambiguities 7016 ################################################################################ 7017 def ChooseOrigin(G2frame,rd): 7018 # make copy of Phase but shift atoms Origin 1->2 7019 O2Phase = copy.deepcopy(rd.Phase) 7020 # make copy of atoms, shift to alternate origin 7021 T = G2spc.spg2origins[rd.Phase['General']['SGData']['SpGrp']] 7022 O2atoms = O2Phase['Atoms'] 7023 cx,ct,cs,cia = rd.Phase['General']['AtomPtrs'] 7024 SGData = rd.Phase['General']['SGData'] 7025 for atom in O2atoms: 7026 for i in [0,1,2]: 7027 atom[cx+i] += T[i] 7028 atom[cs:cs+2] = G2spc.SytSym(atom[3:6],SGData)[0:2] # update symmetry & mult 7029 #get density & distances 7030 DisAglData = {} 7031 DisAglData['SGData'] = rd.Phase['General']['SGData'] 7032 DisAglData['Cell'] = rd.Phase['General']['Cell'][1:] #+ volume 7033 DisAglCtls = {'Factors': [0.85, 0], 7034 'BondRadii': [], 'AngleRadii': [], 'AtomTypes': []} 7035 for atom in rd.Phase['Atoms']: 7036 DisAglCtls['BondRadii'].append(1.5) 7037 DisAglCtls['AngleRadii'].append(0) 7038 DisAglCtls['AtomTypes'].append(atom[ct]) 7039 txt = '' 7040 for i,phObj in enumerate([rd.Phase,O2Phase]): 7041 if i: 7042 txt += "\n\nWith origin shift applied\n" 7043 else: 7044 txt += "\nWith original origin\n" 7045 cellContents = {} 7046 for atom in phObj['Atoms']: 7047 if atom[ct] in cellContents: 7048 cellContents[atom[ct]] += atom[cs+1] 7049 else: 7050 cellContents[atom[ct]] = atom[cs+1] 7051 txt += ' Unit cell Contents: ' 7052 for i,k in enumerate(cellContents): 7053 if i: txt += ', ' 7054 txt += '{}*{}'.format(cellContents[k],k) 7055 G2elem.SetupGeneral(phObj,G2frame.dirname) 7056 den,_ = G2mth.getDensity(phObj['General']) 7057 txt += "\n Density {:.2f} g/cc\n".format(den) 7058 7059 DisAglData['OrigAtoms'] = DisAglData['TargAtoms'] = [ 7060 [i,]+atom[ct-1:ct+1]+atom[cx:cx+3] for 7061 i,atom in enumerate(phObj['Atoms'])] 7062 lbl,dis,angle = G2stMn.RetDistAngle(DisAglCtls,DisAglData) 7063 # get unique distances 7064 minDis = {} 7065 for i in dis: 7066 for j,o,s,d,e in dis[i]: 7067 key = '-'.join(sorted([lbl[i],lbl[j]])) 7068 if key not in minDis: 7069 minDis[key] = d 7070 elif d < minDis[key]: 7071 minDis[key] = d 7072 thirdShortest = sorted([minDis[k] for k in minDis])[:3][-1] 7073 shortTxt = '' 7074 for k in minDis: 7075 if minDis[k] <= thirdShortest: 7076 if shortTxt: shortTxt += ', ' 7077 shortTxt += "{}: {:.2f}".format(k,minDis[k]) 7078 txt += " Shortest distances are "+shortTxt 7079 7080 # do we know if there is a center of symmetry at origin? 7081 centro = None 7082 if 'xyz' in rd.SymOps: 7083 centro = False 7084 if '-x,-y,-z' in [i.replace(' ','').lower() for i in rd.SymOps['xyz']]: 7085 centro = True 7086 7087 msg = 'Be careful here. This space group has two origin settings. GSAS-II requires the origin to be placed at a center of symmetry (Origin 2). You must choose the correct option below or all subsequent results will be *wrong*. For more info, press the help button (bottom right).\n' 7088 if centro: 7089 msg += '\nThere is an -x,-y,-z symmetry op in the file input, so this is likely already in Origin 2.\n' 7090 elif centro is None: 7091 msg += '\nNo symmetry operations read from the input file; you must decide what to do. You are recommended to review a plot of the structure to make sure the symmetry is correct.\n' 7092 else: 7093 msg += '\nSymmetry operations in the input file do not contain -x,-y,-z, indicating an origin shift is likely needed.\n' 7094 7095 msg += '\nNote that computations below, made from the coordinates, may help determine the correct origin choice:' 7096 7097 width = 600 7098 dlg = wx.Dialog(G2frame,wx.ID_ANY,'Warning: Shift origin?', 7099 pos=wx.DefaultPosition,style=wx.DEFAULT_DIALOG_STYLE, 7100 size=(width,-1)) 7101 dlg.CenterOnParent() 7102 mainSizer = wx.BoxSizer(wx.VERTICAL) 7103 txtbox = wx.StaticText(dlg,wx.ID_ANY,msg) 7104 txtbox.Wrap(width-10) 7105 mainSizer.Add(txtbox,0) 7106 mainSizer.Add((5,5)) 7107 txtbox = wx.StaticText(dlg,wx.ID_ANY,txt) 7108 mainSizer.Add(txtbox,0,wx.ALIGN_CENTER,1) 7109 mainSizer.Add((10,10)) 7110 7111 O1Btn = wx.Button(dlg,wx.ID_ANY,"Shift to Origin 2") 7112 O1Btn.Bind(wx.EVT_BUTTON, lambda x: dlg.EndModal(wx.ID_OK)) 7113 O2Btn = wx.Button(dlg,wx.ID_ANY,"Keep current coordinates") 7114 O2Btn.Bind(wx.EVT_BUTTON, lambda x: dlg.EndModal(wx.ID_YES)) 7115 if centro: 7116 O2Btn.SetDefault() 7117 elif centro is not None: 7118 O1Btn.SetDefault() 7119 btnSizer = wx.BoxSizer(wx.HORIZONTAL) 7120 btnSizer.Add((20,20),1) 7121 btnSizer.Add(O1Btn) 7122 btnSizer.Add((10,10),0) 7123 btnSizer.Add(O2Btn) 7124 btnSizer.Add((20,20),1) 7125 btnSizer.Add(HelpButton(dlg,helpIndex='Origin1'),0,wx.RIGHT,5) 7126 mainSizer.Add(btnSizer,0,wx.EXPAND|wx.BOTTOM|wx.TOP, 10) 7127 dlg.SetSizer(mainSizer) 7128 dlg.Fit() 7129 ans = dlg.ShowModal() 7130 if ans == wx.ID_OK: 7131 dlg.Destroy() 7132 return O2Phase 7133 elif ans == wx.ID_YES: 7134 dlg.Destroy() 7135 return rd.Phase 7136 else: 7137 dlg.Destroy() 7138 return None 7011 7139 7012 7140 if __name__ == '__main__': -
trunk/GSASIIdataGUI.py
r4658 r4659 1127 1127 rd.Phase['General']['Name'] = G2obj.MakeUniqueLabel(PhaseName,phaseNameList) 1128 1128 if rd.Phase['General']['SGData']['SpGrp'] in G2spc.spg2origins: 1129 wx.MessageDialog(self,' The atom positions for this structure must be in the 2nd setting for the space group '+ 1130 rd.Phase['General']['SGData']['SpGrp'], 1131 'Is this 2nd setting?', wx.OK).ShowModal() 1132 1129 choice = G2G.ChooseOrigin(self,rd) 1130 if choice is None: return # dialog cancelled 1131 rd.Phase = choice 1133 1132 PhaseName = rd.Phase['General']['Name'][:] 1134 1133 newPhaseList.append(PhaseName) -
trunk/GSASIIobj.py
r4655 r4659 2432 2432 extensionlist,strictExtension) 2433 2433 self.Phase = None # a phase must be created with G2IO.SetNewPhase in the Reader 2434 self.SymOps = {} # specified when symmetry ops are in file (e.g. CIF) 2434 2435 self.Constraints = None 2435 2436 -
trunk/GSASIIphsGUI.py
r4654 r4659 80 80 BLACK = wx.Colour(0,0,0) 81 81 WACV = wx.ALIGN_CENTER_VERTICAL 82 mapDefault = {'MapType':'','RefList':'','GridStep':0.25,'Show bonds':True, 83 'rho':[],'rhoMax':0.,'mapSize':10.0,'cutOff':50.,'Flip':False} 82 mapDefault = G2elem.mapDefault 84 83 TabSelectionIdDict = {} 85 84 # trig functions in degrees … … 1615 1614 1616 1615 def SetupGeneral(): 1617 generalData = data['General'] 1618 atomData = data['Atoms'] 1619 generalData['AtomTypes'] = [] 1620 generalData['Isotopes'] = {} 1621 # various patches 1622 if 'Isotope' not in generalData: 1623 generalData['Isotope'] = {} 1624 if 'Data plot type' not in generalData: 1625 generalData['Data plot type'] = 'Mustrain' 1626 if 'POhkl' not in generalData: 1627 generalData['POhkl'] = [0,0,1] 1628 if 'Map' not in generalData: 1629 generalData['Map'] = mapDefault.copy() 1630 if 'Flip' not in generalData: 1631 generalData['Flip'] = {'RefList':'','GridStep':0.25,'Norm element':'None', 1632 'k-factor':0.1,'k-Max':20.,} 1633 if 'testHKL' not in generalData['Flip']: 1634 generalData['Flip']['testHKL'] = [[0,0,2],[2,0,0],[1,1,1],[0,2,0],[1,2,3]] 1635 if 'doPawley' not in generalData: 1636 generalData['doPawley'] = False #ToDo: change to '' 1637 if 'Pawley dmin' not in generalData: 1638 generalData['Pawley dmin'] = 1.0 1639 if 'Pawley dmax' not in generalData: 1640 generalData['Pawley dmax'] = 100.0 1641 if 'Pawley neg wt' not in generalData: 1642 generalData['Pawley neg wt'] = 0.0 1643 if '3Dproj' not in generalData: 1644 generalData['3Dproj'] = '' 1645 if 'doDysnomia' not in generalData: 1646 generalData['doDysnomia'] = False 1647 if 'Algolrithm' in generalData.get('MCSA controls',{}) or \ 1648 'MCSA controls' not in generalData: 1649 generalData['MCSA controls'] = {'Data source':'','Annealing':[0.7,0.1,250], 1650 'dmin':2.8,'Algorithm':'log','fast parms':[0.8,0.6],'log slope':0.9, 1651 'Cycles':1,'Results':[],'newDmin':True} 1652 if 'AtomPtrs' not in generalData: 1653 generalData['AtomPtrs'] = [3,1,7,9] 1654 if generalData['Type'] == 'macromolecular': 1655 generalData['AtomPtrs'] = [6,4,10,12] 1656 elif generalData['Type'] == 'magnetic': 1657 generalData['AtomPtrs'] = [3,1,10,12] 1658 if generalData['Modulated']: 1659 if 'Super' not in generalData: 1660 generalData['Super'] = 1 1661 generalData['SuperVec'] = [[0.,0.,0.],False,1] 1662 generalData['SSGData'] = {} 1663 if '4DmapData' not in generalData: 1664 generalData['4DmapData'] = mapDefault.copy() 1665 generalData['4DmapData'].update({'MapType':'Fobs'}) 1666 atomData = data['Atoms'] 1667 for atom in atomData: 1668 # if 'SS1' not in atom: 1669 # atom += [[],[],{'SS1':{'waveType':'Fourier','Sfrac':[],'Spos':[],'Sadp':[],'Smag':[]}}] 1670 if isinstance(atom[-1],dict) and 'waveType' in atom[-1]['SS1']: 1671 waveType = atom[-1]['SS1']['waveType'] 1672 for parm in ['Sfrac','Spos','Sadp','Smag']: 1673 if len(atom[-1]['SS1'][parm]): 1674 wType = 'Fourier' 1675 if parm == 'Sfrac': 1676 if 'Crenel' in waveType: 1677 wType = 'Crenel' 1678 elif parm == 'Spos': 1679 if not 'Crenel' in waveType: 1680 wType = waveType 1681 atom[-1]['SS1'][parm] = [wType,]+list(atom[-1]['SS1'][parm]) 1682 del atom[-1]['SS1']['waveType'] 1683 else: 1684 generalData['Super'] = 0 1685 if 'Modulated' not in generalData: 1686 generalData['Modulated'] = False 1687 if 'HydIds' not in generalData: 1688 generalData['HydIds'] = {} 1689 if generalData['Type'] == 'magnetic': 1690 if 'SGGray' not in generalData['SGData']: 1691 generalData['SGData']['SGGray'] = False 1692 if 'Resolution' in generalData['Map']: 1693 generalData['Map']['GridStep'] = generalData['Map']['Resolution']/2. 1694 generalData['Flip']['GridStep'] = generalData['Flip']['Resolution']/2. 1695 del generalData['Map']['Resolution'] 1696 del generalData['Flip']['Resolution'] 1697 if 'Compare' not in generalData: 1698 generalData['Compare'] = {'Oatoms':'','Tatoms':'', 1699 'Tilts':{'Otilts':[],'Ttilts':[]}, 1700 'Bonds':{'Obonds':[],'Tbonds':[]},'Vects':{'Ovec':[],'Tvec':[]}, 1701 'dVects':{'Ovec':[],'Tvec':[]},'Sampling':1.0} 1702 if 'Sampling' not in generalData['Compare']: 1703 generalData['Compare']['Sampling'] = 1.0 1704 1705 # end of patches 1706 cx,ct,cs,cia = generalData['AtomPtrs'] 1707 generalData['NoAtoms'] = {} 1708 generalData['BondRadii'] = [] 1709 generalData['AngleRadii'] = [] 1710 generalData['vdWRadii'] = [] 1711 generalData['AtomMass'] = [] 1712 generalData['Color'] = [] 1713 if generalData['Type'] == 'magnetic': 1714 generalData['MagDmin'] = generalData.get('MagDmin',1.0) 1715 landeg = generalData.get('Lande g',[]) 1716 generalData['Mydir'] = G2frame.dirname 1717 badList = {} 1718 for iat,atom in enumerate(atomData): 1719 atom[ct] = atom[ct].lower().capitalize() #force to standard form 1720 if generalData['AtomTypes'].count(atom[ct]): 1721 generalData['NoAtoms'][atom[ct]] += atom[cx+3]*float(atom[cs+1]) 1722 elif atom[ct] != 'UNK': 1723 Info = G2elem.GetAtomInfo(atom[ct]) 1724 if not Info: 1725 if atom[ct] not in badList: 1726 badList[atom[ct]] = 0 1727 badList[atom[ct]] += 1 1728 atom[ct] = 'UNK' 1729 continue 1730 atom[ct] = Info['Symbol'] # N.B. symbol might be changed by GetAtomInfo 1731 generalData['AtomTypes'].append(atom[ct]) 1732 generalData['Z'] = Info['Z'] 1733 generalData['Isotopes'][atom[ct]] = Info['Isotopes'] 1734 generalData['BondRadii'].append(Info['Drad']) 1735 generalData['AngleRadii'].append(Info['Arad']) 1736 generalData['vdWRadii'].append(Info['Vdrad']) 1737 if atom[ct] in generalData['Isotope']: 1738 if generalData['Isotope'][atom[ct]] not in generalData['Isotopes'][atom[ct]]: 1739 isotope = list(generalData['Isotopes'][atom[ct]].keys())[-1] 1740 generalData['Isotope'][atom[ct]] = isotope 1741 generalData['AtomMass'].append(Info['Isotopes'][generalData['Isotope'][atom[ct]]]['Mass']) 1742 else: 1743 generalData['Isotope'][atom[ct]] = 'Nat. Abund.' 1744 if 'Nat. Abund.' not in generalData['Isotopes'][atom[ct]]: 1745 isotope = list(generalData['Isotopes'][atom[ct]].keys())[-1] 1746 generalData['Isotope'][atom[ct]] = isotope 1747 generalData['AtomMass'].append(Info['Mass']) 1748 generalData['NoAtoms'][atom[ct]] = atom[cx+3]*float(atom[cs+1]) 1749 generalData['Color'].append(Info['Color']) 1750 if generalData['Type'] == 'magnetic': 1751 if len(landeg) < len(generalData['AtomTypes']): 1752 landeg.append(2.0) 1753 if generalData['Type'] == 'magnetic': 1754 generalData['Lande g'] = landeg[:len(generalData['AtomTypes'])] 1755 1756 if badList: 1757 msg = 'Warning: element symbol(s) not found:' 1758 for key in badList: 1759 msg += '\n\t' + key 1760 if badList[key] > 1: 1761 msg += ' (' + str(badList[key]) + ' times)' 1616 try: 1617 G2elem.SetupGeneral(data,G2frame.dirname) 1618 except ValueError as msg: 1762 1619 wx.MessageBox(msg,caption='Element symbol error') 1763 F000X = 0.1764 F000N = 0.1765 for i,elem in enumerate(generalData['AtomTypes']):1766 F000X += generalData['NoAtoms'][elem]*generalData['Z']1767 isotope = generalData['Isotope'][elem]1768 F000N += generalData['NoAtoms'][elem]*generalData['Isotopes'][elem][isotope]['SL'][0]1769 generalData['F000X'] = F000X1770 generalData['F000N'] = F000N1771 generalData['Mass'] = G2mth.getMass(generalData)1772 1773 1620 1774 1621 ################################################################################ … … 3005 2852 SGData['SGSpin'] = G2spc.GetSGSpin(SGData,SGData['MagSpGrp']) 3006 2853 else: 3007 dlg.Destroy()3008 2854 return 3009 2855 finally: … … 3019 2865 for i in [0,1,2]: 3020 2866 atom[cx+i] += T[i] 2867 SytSym,Mul,Nop,dupDir = G2spc.SytSym(atom[3:6],SGData) # update symmetry & mult 2868 atom[cs:cs+2] = SytSym,Mul 3021 2869 data['Drawing'] = [] 3022 break 2870 #force redraw of page 2871 sub = G2frame.GPXtree.GetSelection() 2872 G2frame.GPXtree.SelectItem(G2frame.GPXtree.root) 2873 wx.CallAfter(G2frame.GPXtree.SelectItem,sub) 2874 return 3023 2875 else: 3024 2876 phaseName = newPhase['General']['Name'] -
trunk/GSASIIscriptable.py
r4654 r4659 1394 1394 1395 1395 def SetupGeneral(data, dirname): 1396 """Helps initialize phase data. 1397 1398 From GSASIIphsGui.py, function of the same name. Minor changes for imports etc. 1399 1400 Author: Jackson O'Donnell (jacksonhodonnell .at. gmail.com) 1401 """ 1402 mapDefault = {'MapType':'','RefList':'','Resolution':0.5,'Show bonds':True, 1403 'rho':[],'rhoMax':0.,'mapSize':10.0,'cutOff':50.,'Flip':False} 1404 generalData = data['General'] 1405 atomData = data['Atoms'] 1406 generalData['AtomTypes'] = [] 1407 generalData['Isotopes'] = {} 1408 1409 if 'Isotope' not in generalData: 1410 generalData['Isotope'] = {} 1411 if 'Data plot type' not in generalData: 1412 generalData['Data plot type'] = 'Mustrain' 1413 if 'POhkl' not in generalData: 1414 generalData['POhkl'] = [0,0,1] 1415 if 'Map' not in generalData: 1416 generalData['Map'] = mapDefault.copy() 1417 if 'Flip' not in generalData: 1418 generalData['Flip'] = {'RefList':'','Resolution':0.5,'Norm element':'None', 1419 'k-factor':0.1,'k-Max':20.,} 1420 if 'testHKL' not in generalData['Flip']: 1421 generalData['Flip']['testHKL'] = [[0,0,2],[2,0,0],[1,1,1],[0,2,0],[1,2,3]] 1422 if 'doPawley' not in generalData: 1423 generalData['doPawley'] = False #ToDo: change to '' 1424 if 'Pawley dmin' not in generalData: 1425 generalData['Pawley dmin'] = 1.0 1426 if 'Pawley neg wt' not in generalData: 1427 generalData['Pawley neg wt'] = 0.0 1428 if 'Algolrithm' in generalData.get('MCSA controls',{}) or \ 1429 'MCSA controls' not in generalData: 1430 generalData['MCSA controls'] = {'Data source':'','Annealing':[50.,0.001,50], 1431 'dmin':2.0,'Algorithm':'log','Jump coeff':[0.95,0.5],'boltzmann':1.0, 1432 'fast parms':[1.0,1.0,1.0],'log slope':0.9,'Cycles':1,'Results':[],'newDmin':True} 1433 if 'AtomPtrs' not in generalData: 1434 generalData['AtomPtrs'] = [3,1,7,9] 1435 if generalData['Type'] == 'macromolecular': 1436 generalData['AtomPtrs'] = [6,4,10,12] 1437 elif generalData['Type'] == 'magnetic': 1438 generalData['AtomPtrs'] = [3,1,10,12] 1439 if generalData['Modulated']: 1440 generalData['Type'] = 'nuclear' 1441 if 'Super' not in generalData: 1442 generalData['Super'] = 1 1443 generalData['SuperVec'] = [[0,0,.1],False,4] 1444 generalData['SSGData'] = {} 1445 if '4DmapData' not in generalData: 1446 generalData['4DmapData'] = mapDefault.copy() 1447 generalData['4DmapData'].update({'MapType':'Fobs'}) 1448 if 'Modulated' not in generalData: 1449 generalData['Modulated'] = False 1450 if 'HydIds' not in generalData: 1451 generalData['HydIds'] = {} 1452 cx,ct,cs,cia = generalData['AtomPtrs'] 1453 generalData['NoAtoms'] = {} 1454 generalData['BondRadii'] = [] 1455 generalData['AngleRadii'] = [] 1456 generalData['vdWRadii'] = [] 1457 generalData['AtomMass'] = [] 1458 generalData['Color'] = [] 1459 if generalData['Type'] == 'magnetic': 1460 generalData['MagDmin'] = generalData.get('MagDmin',1.0) 1461 landeg = generalData.get('Lande g',[]) 1462 generalData['Mydir'] = dirname 1463 badList = {} 1464 for iat,atom in enumerate(atomData): 1465 atom[ct] = atom[ct].lower().capitalize() #force to standard form 1466 if generalData['AtomTypes'].count(atom[ct]): 1467 generalData['NoAtoms'][atom[ct]] += atom[cx+3]*float(atom[cs+1]) 1468 elif atom[ct] != 'UNK': 1469 Info = G2elem.GetAtomInfo(atom[ct]) 1470 if not Info: 1471 if atom[ct] not in badList: 1472 badList[atom[ct]] = 0 1473 badList[atom[ct]] += 1 1474 atom[ct] = 'UNK' 1475 continue 1476 atom[ct] = Info['Symbol'] # N.B. symbol might be changed by GetAtomInfo 1477 generalData['AtomTypes'].append(atom[ct]) 1478 generalData['Z'] = Info['Z'] 1479 generalData['Isotopes'][atom[ct]] = Info['Isotopes'] 1480 generalData['BondRadii'].append(Info['Drad']) 1481 generalData['AngleRadii'].append(Info['Arad']) 1482 generalData['vdWRadii'].append(Info['Vdrad']) 1483 if atom[ct] in generalData['Isotope']: 1484 if generalData['Isotope'][atom[ct]] not in generalData['Isotopes'][atom[ct]]: 1485 isotope = list(generalData['Isotopes'][atom[ct]].keys())[-1] 1486 generalData['Isotope'][atom[ct]] = isotope 1487 generalData['AtomMass'].append(Info['Isotopes'][generalData['Isotope'][atom[ct]]]['Mass']) 1488 else: 1489 generalData['Isotope'][atom[ct]] = 'Nat. Abund.' 1490 if 'Nat. Abund.' not in generalData['Isotopes'][atom[ct]]: 1491 isotope = list(generalData['Isotopes'][atom[ct]].keys())[-1] 1492 generalData['Isotope'][atom[ct]] = isotope 1493 generalData['AtomMass'].append(Info['Mass']) 1494 generalData['NoAtoms'][atom[ct]] = atom[cx+3]*float(atom[cs+1]) 1495 generalData['Color'].append(Info['Color']) 1496 if generalData['Type'] == 'magnetic': 1497 if len(landeg) < len(generalData['AtomTypes']): 1498 landeg.append(2.0) 1499 if generalData['Type'] == 'magnetic': 1500 generalData['Lande g'] = landeg[:len(generalData['AtomTypes'])] 1501 1502 if badList: 1503 msg = 'Warning: element symbol(s) not found:' 1504 for key in badList: 1505 msg += '\n\t' + key 1506 if badList[key] > 1: 1507 msg += ' (' + str(badList[key]) + ' times)' 1508 raise G2ScriptException("Phase error:\n" + msg) 1509 # wx.MessageBox(msg,caption='Element symbol error') 1510 F000X = 0. 1511 F000N = 0. 1512 for i,elem in enumerate(generalData['AtomTypes']): 1513 F000X += generalData['NoAtoms'][elem]*generalData['Z'] 1514 isotope = generalData['Isotope'][elem] 1515 F000N += generalData['NoAtoms'][elem]*generalData['Isotopes'][elem][isotope]['SL'][0] 1516 generalData['F000X'] = F000X 1517 generalData['F000N'] = F000N 1518 import GSASIImath as G2mth 1519 generalData['Mass'] = G2mth.getMass(generalData) 1520 1396 '''Initialize phase data. 1397 ''' 1398 try: 1399 G2elem.SetupGeneral(data,dirname) 1400 except ValueError as msg: 1401 raise G2ScriptException(msg) 1521 1402 1522 1403 def make_empty_project(author=None, filename=None): -
trunk/help/gsasII.html
r4621 r4659 5823 5823 "Times New Roman"'>This gives overall parameters describing the phase such as 5824 5824 the name, space group, the unit cell parameters and overall parameters for the 5825 atom present in the phase. It also has the controls for computing Fourier maps 5826 for this phase.<span class=MsoHyperlink><span style='color:windowtext; 5825 atom present in the phase. It also has the controls for Pawley 5826 intensity extraction and for computing Fourier maps 5827 for this phase. It can also be used to compute new structures based on 5828 the unit cell and atom poistions. 5829 <span class=MsoHyperlink><span style='color:windowtext; 5827 5830 text-decoration:none;text-underline:none'><o:p></o:p></span></span></span></p> 5828 5831 … … 5838 5841 </span></span></span></span><![endif]><span style='mso-fareast-font-family: 5839 5842 "Times New Roman"'>Menu ‘<b style='mso-bidi-font-weight:normal'>Compute’</b> – 5840 The compute menu shows computations that are possible for this phase.<span 5841 class=MsoHyperlink><span style='color:windowtext;text-decoration:none; 5842 text-underline:none'><o:p></o:p></span></span></span></p> 5843 5844 <p class=MsoListParagraphCxSpMiddle style='margin-left:1.5in;mso-add-space: 5845 auto;text-indent:-.25in;mso-list:l2 level2 lfo27'><![if !supportLists]><span 5846 class=MsoHyperlink><span style='mso-fareast-font-family:"Times New Roman"; 5847 color:windowtext;text-decoration:none;text-underline:none'><span 5848 style='mso-list:Ignore'>a.<span style='font:7.0pt "Times New Roman"'> 5849 </span></span></span></span><![endif]><b style='mso-bidi-font-weight:normal'><span 5850 style='mso-fareast-font-family:"Times New Roman"'>Fourier maps</span></b><span 5851 style='mso-fareast-font-family:"Times New Roman"'> – compute Fourier maps 5852 according to the controls set at bottom of General page.<span 5853 class=MsoHyperlink><span style='color:windowtext;text-decoration:none; 5854 text-underline:none'><o:p></o:p></span></span></span></p> 5855 5856 <p class=MsoListParagraphCxSpMiddle style='margin-left:1.5in;mso-add-space: 5857 auto;text-indent:-.25in;mso-list:l2 level2 lfo27'><![if !supportLists]><span 5858 class=MsoHyperlink><span style='mso-fareast-font-family:"Times New Roman"; 5859 color:windowtext;text-decoration:none;text-underline:none'><span 5860 style='mso-list:Ignore'>b.<span style='font:7.0pt "Times New Roman"'> 5861 </span></span></span></span><![endif]><b style='mso-bidi-font-weight:normal'><span 5862 style='mso-fareast-font-family:"Times New Roman"'>Search maps </span></b><span 5863 style='mso-fareast-font-family:"Times New Roman"'>– search the computed Fourier 5843 The compute menu shows computations that are possible for this phase. 5844 5845 <DL class=MsoListParagraphCxSpMiddle style='margin-left:1.5in;mso-add-space: 5846 auto;mso-list:l2 level2 lfo27'> 5847 <DT><B>Fourier maps</B></DT> 5848 <DD>compute Fourier maps 5849 according to the controls set at bottom of General page.</DD> 5850 <DT><B>Search maps</B></DT> 5851 <DD>search the computed Fourier 5864 5852 map. Peaks that are above ‘Peak cutoff’ % of the maximum will be found in this 5865 5853 procedure; they will be printed on the console and will be shown in the ‘<a 5866 href="Map_peaks">Map peaks</a><span 5867 style='mso-bookmark:Map_peaks'></span>’ page. This page will immediately be 5854 href="Map_peaks">Map peaks</a>’ page. This page will immediately be 5868 5855 shown and the peaks will be shown on the structure drawing for this phase as 5869 white 3-D crosses.<span class=MsoHyperlink><span style='color:windowtext; 5870 text-decoration:none;text-underline:none'><o:p></o:p></span></span></span></p> 5871 5872 <p class=MsoListParagraphCxSpMiddle style='margin-left:1.5in;mso-add-space: 5873 auto;text-indent:-.25in;mso-list:l2 level2 lfo27'><![if !supportLists]><span 5874 class=MsoHyperlink><span style='mso-fareast-font-family:"Times New Roman"; 5875 color:windowtext;text-decoration:none;text-underline:none'><span 5876 style='mso-list:Ignore'>c.<span style='font:7.0pt "Times New Roman"'> 5877 </span></span></span></span><![endif]><b style='mso-bidi-font-weight:normal'><span 5878 style='mso-fareast-font-family:"Times New Roman"'>Charge flipping </span></b><span 5879 style='mso-fareast-font-family:"Times New Roman"'>– This performs a charge 5856 white 3-D crosses.</DD> 5857 <DT><B>Charge flipping </B></DT> 5858 <DD>This performs a charge 5880 5859 flipping <i style='mso-bidi-font-style:normal'>ab initio</i> structure solution 5881 5860 using the method of Oszlanyi & Suto (Acta Cryst. A60, 134-141, 2004). You … … 5890 5869 properly place symmetry operators (NB: depends on the quality of the resulting 5891 5870 phases), searched for peaks and the display shifts to <b style='mso-bidi-font-weight: 5892 normal'>Map peaks</b> to show them.<span class=MsoHyperlink><span 5893 style='color:windowtext;text-decoration:none;text-underline:none'><o:p></o:p></span></span></span></p> 5894 5895 <p class=MsoListParagraphCxSpMiddle style='margin-left:1.5in;mso-add-space: 5896 auto;text-indent:-.25in;mso-list:l2 level2 lfo27'><![if !supportLists]><span 5897 class=MsoHyperlink><span style='mso-fareast-font-family:"Times New Roman"; 5898 color:windowtext;text-decoration:none;text-underline:none'><span 5899 style='mso-list:Ignore'>d.<span style='font:7.0pt "Times New Roman"'> 5900 </span></span></span></span><![endif]><b style='mso-bidi-font-weight:normal'><span 5901 style='mso-fareast-font-family:"Times New Roman"'>Clear map </span></b><span 5902 style='mso-fareast-font-family:"Times New Roman"'>– This clears any 5903 Fourier/charge flip map from memory; the Fourier map controls are also cleared.<span 5871 normal'>Map peaks</b> to show them.</DD> 5872 <DT><B>Clear map </B></DT> 5873 <DD>This clears any 5874 Fourier/charge flip map from memory; the Fourier map controls are also 5875 cleared.</DD> 5876 <DT><B>Transform</B></DT> 5877 <DD>This allows for a change in axes, symmetry or unit cell. It is 5878 also used to create a magnetic phase from a chemical (nuclear) 5879 phase. One important transformation that can be done here is for 5880 Origin 1 settings to Origin 2 (<a href="#Origin1">described below</a>) 5881 5882 5883 </DD> 5884 </DL> 5885 5886 <span 5904 5887 class=MsoHyperlink><span style='color:windowtext;text-decoration:none; 5905 5888 text-underline:none'><o:p></o:p></span></span></span></p> … … 6281 6264 algorithm is chosen these determine the jump components for each trial.<o:p></o:p></span></span></p> 6282 6265 6266 <h5 style='margin-left:0.5in'><a name=Origin1></a>Origin 1 -> 6267 Origin 2 Transformations</h5> 6268 6269 <p class=MsoNormal style='margin-left:1.0in'><span style='mso-fareast-font-family:"Times New Roman"'> 6270 An important transformation may be needed in certain cases when space 6271 groups that two alternate origin settings 6272 (<A 6273 href="https://gsas-ii.readthedocs.io/en/latest/GSASIIutil.html#GSASIIspc.spg2origins">listed here</a>). 6274 These are centrosymmetric space groups where the highest symmetry 6275 point in the structure does not contain a center of symmetry. Origin 1 6276 places the origin at the highest symmetry setting while Origin 2 6277 places the origin at a center of symmetry (creating a -x,-y,-z 6278 symmetry operator, which means that reflection phases can only be 0 or π.) 6279 GSAS-II requires use of the Origin 2 settings because computations are much 6280 faster and simpler without complex structure factors. 6281 Alas, the literature contains a number of structures reported in 6282 Origin 1, where the origin choice may not be clearly communicated. (The 6283 CIF standard does not require that origin choice be indicated.) 6284 When a structure is imported that uses any of the space groups where 6285 an origin choice is possible, a message is shown in GSAS-II notifying 6286 the user that they must confirm that the origin choice is correct. 6287 </p><p></p><p class=MsoNormal style='margin-left:1.0in'><span style='mso-fareast-font-family:"Times New Roman"'> 6288 <B>Example:</B> 6289 An 6290 example of what can go wrong is illustrated with the structure of 6291 anatase. The space group is <I>I</I> 4<sub>1</sub>/<I>a m d</I>. In 6292 Origin 1 the coordinates are: 6293 <TABLE border=2; style='margin-left:2.0in'> 6294 <TR> 6295 <th colspan=4>Origin 1</th> 6296 </TR> 6297 <TR> 6298 <th>atom</th> 6299 <th colspan=3>coordinates</th> 6300 </TR> 6301 <TR> 6302 <TD>Ti</TD> 6303 <TD>0</TD> 6304 <TD>0</TD> 6305 <TD>0</TD> 6306 </TR> 6307 <TR> 6308 <TD>O</TD> 6309 <TD>0</TD> 6310 <TD>0</TD> 6311 <TD>0.208</TD> 6312 </TR> 6313 </TABLE> 6314 6315 and in Origin 2 the coordinates are: 6316 <TABLE border=2; style='margin-left:2.0in'> 6317 <TR> 6318 <th colspan=4>Origin 2</th> 6319 </TR> 6320 <TR> 6321 <th>atom</th> 6322 <th colspan=3>coordinates</th> 6323 </TR> 6324 <TR> 6325 <TD>Ti</TD> 6326 <TD>0</TD> 6327 <TD>1/4</TD> 6328 <TD>-1/8</TD> 6329 </TR> 6330 <TR> 6331 <TD>O</TD> 6332 <TD>0</TD> 6333 <TD>1/4</TD> 6334 <TD>0.083</TD> 6335 </TR> 6336 </TABLE> 6337 where the origin is shifted by (0,0.25,-0.125). 6338 </p><p></p><p class=MsoNormal style='margin-left:1.0in'><span style='mso-fareast-font-family:"Times New Roman"'> 6339 <img src="gsasII_files/wrong.png" align="right"> 6340 Since GSAS-II always the symmetry operators for Origin 2, 6341 if structure is input incorrectly with the coordinates set for Origin 6342 1, there are several fairly obvious signs of problems: (1) the 6343 site symmetries and multiplicities are wrong, often giving an incorrect 6344 chemical formula, (2) the interatomic distances are incorrect, and (3) 6345 a plot of the structure is improbable. 6346 In this case incorrect multiplicities gives 6347 rise to a density of 7.9 g/cc, double the correct value. 6348 Impossible interatomic distances of 1.88Å for Ti-Ti, and 6349 1.39Å for Ti-O are seen. The unit 6350 cell contents with the wrong space group operators is shown to the 6351 right. 6352 </p><p></p><p class=MsoNormal style='margin-left:1.0in'><span style='mso-fareast-font-family:"Times New Roman"'> 6353 With coordinates that match the space 6354 group operations, the correct Ti-O distances are 1.92Å and 6355 1.97Å and the shortest Ti-Ti distance is 3.0Å. 6356 (Note that interatomic distances can be computed in GSAS-II using the Phase Atoms 6357 tab and the Compute/"Show Distances & Angles" menu item.) 6358 6359 </p><p></p><p class=MsoNormal style='margin-left:1.0in'><span 6360 style='mso-fareast-font-family:"Times New Roman"'> 6361 <img src="gsasII_files/xform.png" align="right"> 6362 <B>Transform Origin:</B> 6363 To transform a space group setting from Origin setting 1 to 2, use the 6364 Transform option in the Compute menu and then select the last option in the "Common 6365 transformations" pulldown menu, which will be setting 1->2 for space 6366 groups where both origins are available, as shown to the right. The 6367 transformation matrix will be set to the identity and the "V" vector 6368 will have the required origin shift loaded. Press OK. The changes can 6369 be seen by selecting the Atoms tab. 6370 6371 </span></p> 6372 <BR CLEAR="right" /> 6283 6373 <h4 style='margin-left:0.25in'><a name=Data></a><u>Data</u></h4> 6284 6374 … … 7353 7443 <hr size=2 width="100%" align=center> 7354 7444 7355 <!-- hhmts start -->Last modified: Fri Oct 23 15:56:02 CDT 2020 <!-- hhmts end -->7445 <!-- hhmts start -->Last modified: Sat Nov 21 12:25:40 CST 2020 <!-- hhmts end --> 7356 7446 7357 7447 </div> -
trunk/imports/G2phase_CIF.py
r4635 r4659 250 250 SGData = G2obj.P1SGData # P 1 251 251 self.Phase['General']['SGData'] = SGData 252 # save symmetry operators, if specified (use to check for origin 1 in GSASIIdataGUI OnImportPhase) 253 ops = blk.get("_symmetry_equiv_pos_as_xyz") # try older name 1st 254 if ops: 255 self.SymOps['xyz'] = ops 256 elif blk.get("_space_group_symop_operation_xyz"): 257 self.SymOps['xyz'] = blk.get("_space_group_symop_operation_xyz") 258 else: 259 if 'xyz' in self.SymOps: del self.SymOps['xyz'] 252 260 if Super: 253 261 E,SSGData = G2spc.SSpcGroup(SGData,SuperSg)
Note: See TracChangeset
for help on using the changeset viewer.