Changeset 2466
- Timestamp:
- Sep 13, 2016 9:42:05 AM (6 years ago)
- Location:
- trunk
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/GSASIIgrid.py
r2464 r2466 230 230 def __init__(self,parent,title,text,table,names,spins,): 231 231 wx.Dialog.__init__(self,parent,wx.ID_ANY,title,pos=wx.DefaultPosition, 232 style=wx.DEFAULT_DIALOG_STYLE|wx.RESIZE_BORDER,size=wx.Size(4 00,350))232 style=wx.DEFAULT_DIALOG_STYLE|wx.RESIZE_BORDER,size=wx.Size(420,350)) 233 233 self.text = text 234 234 self.table = table … … 238 238 mainSizer = wx.BoxSizer(wx.VERTICAL) 239 239 mainSizer.Add((0,10)) 240 first = text[0].split(':') 241 cents = [ '',]242 if not 'P' in first[1][0]:240 first = text[0].split(':')[-1].strip() 241 cents = [0,] 242 if 'P' != first[0]: 243 243 cents = text[-1].split(';') 244 244 for line in text: … … 271 271 if not j%2: 272 272 tableSizer.Add((20,0)) 273 mainSizer.Add(tableSizer,0,wx.ALIGN_ LEFT)273 mainSizer.Add(tableSizer,0,wx.ALIGN_CENTER) 274 274 275 275 btnsizer = wx.StdDialogButtonSizer() … … 2448 2448 if 'HatomFix' not in data: 2449 2449 data['HatomFix'] = False 2450 if 'Marquardt' not in data: 2451 data['Marquardt'] = -3 2450 2452 2451 2453 #end patch … … 2527 2529 data['max cyc'] = int(maxCyc.GetValue()) 2528 2530 maxCyc.SetValue(str(data['max cyc'])) 2531 2532 def OnMarqLam(event): 2533 data['Marquardt'] = int(marqLam.GetValue()) 2534 marqLam.SetValue(str(data['Marquardt'])) 2529 2535 2530 2536 def OnFactor(event): … … 2574 2580 maxCyc = wx.ComboBox(parent=G2frame.dataDisplay,value=str(data['max cyc']),choices=Choice, 2575 2581 style=wx.CB_READONLY|wx.CB_DROPDOWN) 2576 maxCyc.SetValue(str(data['max cyc']))2582 # maxCyc.SetValue(str(data['max cyc'])) 2577 2583 maxCyc.Bind(wx.EVT_COMBOBOX, OnMaxCycles) 2578 2584 LSSizer.Add(maxCyc,0,WACV) 2585 LSSizer.Add(wx.StaticText(G2frame.dataDisplay,label=' Initial lambda = 10**'),0,WACV) 2586 MarqChoice = ['-3','-2','-1','0','1','2','3','4'] 2587 marqLam = wx.ComboBox(parent=G2frame.dataDisplay,value=str(data['Marquardt']),choices=MarqChoice, 2588 style=wx.CB_READONLY|wx.CB_DROPDOWN) 2589 marqLam.Bind(wx.EVT_COMBOBOX,OnMarqLam) 2590 LSSizer.Add(marqLam,0,WACV) 2579 2591 else: 2580 2592 LSSizer.Add(wx.StaticText(G2frame.dataDisplay,label=' Initial shift factor: '),0,WACV) -
trunk/GSASIImath.py
r2448 r2466 51 51 ################################################################################ 52 52 53 def HessianLSQ(func,x0,Hess,args=(),ftol=1.49012e-8,xtol=1.49012e-8, maxcyc=0, Print=False):53 def HessianLSQ(func,x0,Hess,args=(),ftol=1.49012e-8,xtol=1.49012e-8, maxcyc=0,lamda=-3,Print=False): 54 54 55 55 """ … … 75 75 :param int maxcyc: The maximum number of cycles of refinement to execute, if -1 refine 76 76 until other limits are met (ftol, xtol) 77 :param int lamda: initial Marquardt lambda=10**lamda 77 78 :param bool Print: True for printing results (residuals & times) by cycle 78 79 … … 109 110 icycle = 0 110 111 One = np.ones((n,n)) 111 lam = 0.001112 lam = 10.**lamda 112 113 lamMax = lam 113 114 nfev = 0 -
trunk/GSASIIspc.py
r2464 r2466 145 145 elif (not SGData['SGInv']) and (SGData['SGLaue'] in ['3','3m1','31m','6/m','6/mmm']) and (gen == 1): 146 146 SGData['SGGen'][i] = 24 147 if gen in [99,]: 147 gen = SGData['SGGen'][i] 148 if gen == 99: 149 gen = 8 148 150 if SGData['SGLaue'] in ['3m1','31m','6/m','6/mmm']: 149 SGData['SGGen'][i]= 3151 gen = 3 150 152 elif SGData['SGLaue'] == 'm3m': 151 SGData['SGGen'][i]= 12152 else:153 SGData['SGGen'][i] = 8154 elif gen in [98,]:153 gen = 12 154 SGData['SGGen'][i] = gen 155 elif gen == 98: 156 gen = 8 155 157 if SGData['SGLaue'] in ['3m1','31m','6/m','6/mmm']: 156 SGData['SGGen'][i] = 4 157 else: 158 SGData['SGGen'][i] = 8 158 gen = 4 159 SGData['SGGen'][i] = gen 159 160 elif not SGData['SGInv'] and gen in [23,] and SGData['SGLaue'] in ['m3','m3m']: 160 161 SGData['SGGen'][i] = 24 161 162 elif gen >= 16 and gen != 128: 162 163 if not SGData['SGInv']: 163 SGData['SGGen'][i] = 31 164 else: 165 SGData['SGGen'][i] = gen^Ibarx 164 gen = 31 165 else: 166 gen ^= Ibarx 167 SGData['SGGen'][i] = gen 166 168 if SGData['SGInv']: 167 169 if gen < 128: 168 moregen.append( gen^Ibar)170 moregen.append(SGData['SGGen'][i]^Ibar) 169 171 else: 170 172 moregen.append(1) … … 566 568 UsymOp.append(OprNames[4]) 567 569 OprFlg.append(SGData['SGGen'][3]) 568 if '21 00' in OprNames[1]: UsymOp[-1] = ' 2100 '570 if '2110' in OprNames[1]: UsymOp[-1] = ' 2100 ' 569 571 elif Nsyms == 8: #Point symmetry mmm, 4/m, or 422, etc 570 572 if '4' in OprNames[1]: #Tetragonal … … 578 580 if 'x' in OprNames[4]: #4mm type group 579 581 UsymOp.append(OprNames[4]) 580 OprFlg.append( 5)582 OprFlg.append(6) 581 583 UsymOp.append(OprNames[7]) 582 OprFlg.append( 7)584 OprFlg.append(8) 583 585 else: #-42m, -4m2, and 422 type groups 584 586 UsymOp.append(OprNames[5]) 585 OprFlg.append( 7)587 OprFlg.append(8) 586 588 UsymOp.append(OprNames[6]) 587 OprFlg.append(1 8)589 OprFlg.append(19) 588 590 else: #Orthorhombic, mmm 589 591 NunqOp = 3 … … 609 611 else: #6mm, -62m, -6m2 or 622 610 612 UsymOp.append(OprNames[6]) 611 OprFlg.append(1 7)612 if 'm' in OprNames[1]: OprFlg[-1] = 20613 OprFlg.append(18) 614 if 'm' in UsymOp[-1]: OprFlg[-1] = 20 613 615 UsymOp.append(OprNames[7]) 614 OprFlg.append(2 3)616 OprFlg.append(24) 615 617 elif Nsyms in [16,24]: 616 618 if '3' in OprNames[1]: … … 632 634 if '4' in OprNames[1]: #4/mmm 633 635 UsymOp.append(' mx ') 634 OprFlg.append( 19)636 OprFlg.append(20) 635 637 UsymOp.append(' m110 ') 636 OprFlg.append(2 1)638 OprFlg.append(24) 637 639 else: #6/mmm 638 640 UsymOp.append(' m110 ') 639 OprFlg.append( 3)641 OprFlg.append(4) 640 642 UsymOp.append(' m+-0 ') 641 OprFlg.append( 7)643 OprFlg.append(8) 642 644 else: #System is cubic 643 645 if Nsyms == 48: 644 646 NunqOp = 2 645 647 UsymOp.append(' mx ') 646 OprFlg.append( 3)648 OprFlg.append(4) 647 649 UsymOp.append(' m110 ') 648 OprFlg.append(2 3)650 OprFlg.append(24) 649 651 else: 650 652 NunqOp = 0 … … 670 672 elif SGData['SGCen'][icv][1] == 0.5: 671 673 UsymOp.append(' Acen ') 672 else:673 if (icv == 1) and ('c' not in SGData['SpGrp']):674 UsymOp.append(' Rcen ')675 674 return UsymOp,OprFlg 676 675 … … 678 677 ''' Check for exceptions in spin rules 679 678 ''' 680 if SGData['SpGrp'] in ['R 3 2','R -3',]: 681 if SGData['SGSpin'][isym] < 0: 682 SGData['SGSpin'][(isym+1)%2] = 1 683 elif SGData['SpGrp'] == 'R -3 m': 684 if SGData['SGSpin'][2] < 0: 685 if SGData['SGSpin'][0]*SGData['SGSpin'][1] < 0: 686 if SGData['SGSpin'][isym] < 0: 687 SGData['SGSpin'][:2] = [-1,-1] 688 else: 689 SGData['SGSpin'][:2] = [1,1] 690 elif SGData['SpGrp'] in ['C c','C 1 c 1','A a','A 1 a 1','B b 1 1','C c 1 1', 679 if SGData['SpGrp'] in ['C c','C 1 c 1','A a','A 1 a 1','B b 1 1','C c 1 1', 691 680 'A 1 1 a','B 1 1 b','I -4']: 692 681 if SGData['SGSpin'][:2] == [-1,-1]: … … 824 813 magSym[0] = magSym[0].split('(')[0] 825 814 if len(GenSym) == 1: #all ok 826 if 'R' in GenSym[0]: 827 if SpnFlp[0] < 0: 828 magSym[0] += '(R)' 829 else: 830 id = 2 831 if (len(magSym) == 4) and (magSym[2] == '1'): 832 id = 3 833 if '3' in GenSym[0]: 834 id = 1 835 magSym[id].strip("'") 836 if SpnFlp[0] < 0: 837 magSym[id] += "'" 815 id = 2 816 if (len(magSym) == 4) and (magSym[2] == '1'): 817 id = 3 818 if '3' in GenSym[0]: 819 id = 1 820 magSym[id].strip("'") 821 if SpnFlp[0] < 0: 822 magSym[id] += "'" 838 823 elif len(GenSym) == 2: 839 824 if 'R' in GenSym[1]: 840 if SpnFlp[1] < 0:841 magSym[0] += '(R)'842 825 magSym[-1].strip("'") 843 826 if SpnFlp[0] < 0: … … 858 841 else: 859 842 if 'c' not in magSym[2]: 860 if SpnFlp[2] < 0:861 magSym[0] += '(R)'862 843 i,j = [1,2] 863 844 magSym[i].strip("'") … … 936 917 SGData['MagMom'] = MagMom 937 918 # print 'SgOps:',OprNames 919 # print 'SGGen:',SGData['SGGen'] 938 920 # print 'SpnFlp:',SpnFlp 939 921 # print 'MagMom:',MagMom -
trunk/GSASIIstrMain.py
r2450 r2466 70 70 ncyc = int(result[2]['nfev']/2) 71 71 elif 'Hessian' in Controls['deriv type']: 72 Lamda = Controls.get('Marquardt',-3) 72 73 maxCyc = Controls['max cyc'] 73 result = G2mth.HessianLSQ(G2stMth.errRefine,values,Hess=G2stMth.HessRefine,ftol=Ftol,maxcyc=maxCyc,Print=ifPrint, 74 result = G2mth.HessianLSQ(G2stMth.errRefine,values,Hess=G2stMth.HessRefine,ftol=Ftol,maxcyc=maxCyc,Print=ifPrint,lamda=Lamda, 74 75 args=([Histograms,Phases,restraintDict,rigidbodyDict],parmDict,varyList,calcControls,pawleyLookup,dlg)) 75 76 ncyc = result[2]['num cyc']+1 76 77 Rvals['lamMax'] = result[2]['lamMax'] 78 Controls['Marquardt'] = -3 #reset to default 77 79 else: #'numeric' 78 80 result = so.leastsq(G2stMth.errRefine,values,full_output=True,ftol=Ftol,epsfcn=1.e-8,factor=Factor,
Note: See TracChangeset
for help on using the changeset viewer.