- Timestamp:
- Oct 16, 2020 12:00:27 PM (3 years ago)
- Location:
- trunk
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/GSASIImath.py
r4595 r4598 58 58 59 59 def pinv(a, rcond=1e-15 ): 60 """60 ''' 61 61 Compute the (Moore-Penrose) pseudo-inverse of a matrix. 62 62 Modified from numpy.linalg.pinv; assumes a is Hessian & returns no. zeros found … … 96 96 .. [1] G. Strang, *Linear Algebra and Its Applications*, 2nd Ed., Orlando, FL, Academic Press, Inc., 1980, pp. 139-142. 97 97 98 """98 ''' 99 99 u, s, vt = nl.svd(a) 100 100 cutoff = rcond*np.maximum.reduce(s) … … 106 106 107 107 def HessianLSQ(func,x0,Hess,args=(),ftol=1.49012e-8,xtol=1.e-6, maxcyc=0,lamda=-3,Print=False,refPlotUpdate=None): 108 """108 ''' 109 109 Minimize the sum of squares of a function (:math:`f`) evaluated on a series of 110 values (y): :math:`\ sum_{y=0}^{N_{obs}} f(y,{args})`111 where :math:`x = arg min(\ sum_{y=0}^{N_{obs}} (func(y)^2,axis=0))`110 values (y): :math:`\\sum_{y=0}^{N_{obs}} f(y,{args})` 111 where :math:`x = arg min(\\sum_{y=0}^{N_{obs}} (func(y)^2,axis=0))` 112 112 113 113 :param function func: callable method or function … … 148 148 * 'SVD0': 149 149 150 """150 ''' 151 151 152 152 ifConverged = False … … 246 246 def HessianSVD(func,x0,Hess,args=(),ftol=1.49012e-8,xtol=1.e-6, maxcyc=0,lamda=-3,Print=False,refPlotUpdate=None): 247 247 248 """248 ''' 249 249 Minimize the sum of squares of a function (:math:`f`) evaluated on a series of 250 values (y): :math:`\ sum_{y=0}^{N_{obs}} f(y,{args})`251 where :math:`x = arg min(\ sum_{y=0}^{N_{obs}} (func(y)^2,axis=0))`250 values (y): :math:`\\sum_{y=0}^{N_{obs}} f(y,{args})` 251 where :math:`x = arg min(\\sum_{y=0}^{N_{obs}} (func(y)^2,axis=0))` 252 252 253 253 :param function func: callable method or function … … 287 287 * 'SVD0': 288 288 289 """289 ''' 290 290 291 291 ifConverged = False … … 4266 4266 4267 4267 def getstart_temp(self, best_state): 4268 """Find a matching starting temperature and starting parameters vector4268 ''' Find a matching starting temperature and starting parameters vector 4269 4269 i.e. find x0 such that func(x0) = T0. 4270 4270 … … 4274 4274 :returns: x0 : array 4275 4275 The starting parameters vector. 4276 """4276 ''' 4277 4277 4278 4278 assert(not self.dims is None) … … 4381 4381 lower=-100, upper=100, dwell=50, slope=0.9,ranStart=False, 4382 4382 ranRange=0.10,autoRan=False,dlg=None): 4383 """Minimize a function using simulated annealing.4383 '''Minimize a function using simulated annealing. 4384 4384 4385 4385 Schedule is a schedule class implementing the annealing schedule. 4386 4386 Available ones are 'fast', 'cauchy', 'boltzmann' 4387 4387 4388 :param callable func: f(x, \ *args)4388 :param callable func: f(x, \\*args) 4389 4389 Function to be optimized. 4390 4390 :param ndarray x0: … … 4472 4472 T_new = T0 * exp(-c * k**quench) 4473 4473 4474 """4474 ''' 4475 4475 4476 4476 ''' Scipy license: … … 4642 4642 4643 4643 class RandomDisplacementBounds(object): 4644 """random displacement with bounds"""4644 '''random displacement with bounds''' 4645 4645 def __init__(self, xmin, xmax, stepsize=0.5): 4646 4646 self.xmin = xmin … … 4649 4649 4650 4650 def __call__(self, x): 4651 """take a random step but ensure the new position is within the bounds"""4651 '''take a random step but ensure the new position is within the bounds''' 4652 4652 while True: 4653 4653 # this could be done in a much more clever way, but it will work for example purposes … … 5075 5075 5076 5076 def prodQVQ(Q,V): 5077 """5077 ''' 5078 5078 compute the quaternion vector rotation qvq-1 = v' 5079 5079 q=r+ai+bj+ck 5080 """5080 ''' 5081 5081 T2 = Q[0]*Q[1] 5082 5082 T3 = Q[0]*Q[2] -
trunk/GSASIIphsGUI.py
r4597 r4598 9960 9960 for ix in range(3): 9961 9961 origX = G2G.ValidatedTxtCtrl(RigidBodies,RBObj['Orig'][0],ix,nDig=(8,5), 9962 typeHint=float,OnLeave=OnOrigX, 9963 xmin=-1,xmax=1.,size=(70,-1)) 9962 typeHint=float,OnLeave=OnOrigX,xmin=-1,xmax=1.,size=(70,-1)) 9964 9963 topSizer.Add(origX,0,WACV) 9965 9964 topSizer.Add((5,0),) … … 9977 9976 for ix,x in enumerate(Orien): 9978 9977 orien = G2G.ValidatedTxtCtrl(RigidBodies,Orien,ix,nDig=(8,dp), 9979 typeHint=float,OnLeave=OnOrien, 9980 xmin=xmin,xmax=xmax,size=(70,-1)) 9978 typeHint=float,OnLeave=OnOrien,xmin=xmin,xmax=xmax,size=(70,-1)) 9981 9979 dp, xmin,xmax = 4,-1.,1. 9982 9980 Indx['Orien'][ix] = orien … … 10019 10017 resrbSizer.Add(wx.StaticText(RigidBodies,-1,120*'-')) 10020 10018 topLine = wx.BoxSizer(wx.HORIZONTAL) 10021 topLine.Add(wx.StaticText(RigidBodies,-1, 10022 'Name: '+RBObj['RBname']+RBObj['numChain']+' '),0,WACV) 10019 topLine.Add(wx.StaticText(RigidBodies,-1,'Name: '+RBObj['RBname']+RBObj['numChain']+' '),0,WACV) 10023 10020 rbId = RBObj['RBId'] 10024 10021 delRB = wx.Button(RigidBodies,wx.ID_ANY,'Delete',style=wx.BU_EXACTFIT) … … 10039 10036 lbl = 'z' 10040 10037 topLine.Add(wx.StaticText(RigidBodies,-1, 10041 ' Rigid body {} axis is aligned along oriention vector' 10042 .format(lbl)),0,WACV) 10038 ' Rigid body {} axis is aligned along oriention vector'.format(lbl)),0,WACV) 10043 10039 resrbSizer.Add(topLine) 10044 10040 resrbSizer.Add(LocationSizer(RBObj,'Residue')) … … 10679 10675 xmin=0.,xmax=360.,typeHint=float,OnLeave=UpdateOrientation)) 10680 10676 OriSizer.Add(OrientVecSiz[-1],0,WACV) 10681 azSlide = wx.Slider(RigidBodies,style=wx.SL_HORIZONTAL )10677 azSlide = wx.Slider(RigidBodies,style=wx.SL_HORIZONTAL,value=int(rbObj['OrientVec'][0]*10.),size=(200,25)) 10682 10678 azSlide.SetRange(0,3600) 10683 azSlide.SetValue(int(rbObj['OrientVec'][0]*10.))10684 10679 azSlide.Bind(wx.EVT_SLIDER, OnAzSlide) 10685 OriSizer.Add(azSlide, 1,WACV)10680 OriSizer.Add(azSlide,0,WACV) 10686 10681 mainSizer.Add(OriSizer) 10687 10682 OriSizer = wx.BoxSizer(wx.HORIZONTAL)
Note: See TracChangeset
for help on using the changeset viewer.