# Changeset 989

Ignore:
Timestamp:
Jul 13, 2013 10:21:12 PM (9 years ago)
Message:

add constraint derivs for single xtal; allow cellFill to work without esds; update docs; fix controls copy bug

Location:
trunk
Files:
8 edited

Unmodified
Removed
• ## trunk/GSASIIimgGUI.py

 r923 Data['range'] = oldData['range'] Data['size'] = oldData['size'] Data['GonioAngles'] = oldData['GonioAngles'] Data['GonioAngles'] = oldData.get('GonioAngles', [0.,0.,0.]) Data['ring'] = [] Data['rings'] = []
• ## trunk/GSASIIlattice.py

 r961 --------------------------- Perform lattice-related computations''' Perform lattice-related computations Note that *g* is the reciprocal lattice tensor, and *G* is its inverse, :math:G = g^{-1}, where .. math:: G = \\left( \\begin{matrix} a^2 & a b\\cos\gamma & a c\\cos\\beta \\\\ a b\\cos\\gamma & b^2 & b c \cos\\alpha \\\\ a c\\cos\\beta &  b c \\cos\\alpha & c^2 \\end{matrix}\\right) The "*A* tensor" terms are defined as :math:A = (\\begin{matrix} G_{11} & G_{22} & G_{33} & 2G_{12} & 2G_{13} & 2G_{23}\\end{matrix}) and *A* can be used in this fashion: :math:d^* = \sqrt {A_1 h^2 + A_2 k^2 + A_3 l^2 + A_4 hk + A_5 hl + A_6 kl}, where *d* is the d-spacing, and :math:d^* is the reciprocal lattice spacing, :math:Q = 2 \\pi d^* = 2 \\pi / d ''' ########### SVN repository information ################### # $Date$ def A2Gmat(A,inverse=True): """Fill real & reciprocal metric tensor (G) from A """Fill real & reciprocal metric tensor (G) from A. :param A: reciprocal metric tensor elements as [G11,G22,G33,2*G12,2*G13,2*G23]
• ## trunk/GSASIImapvars.py

 r903 parameter names. :param dict dMdv: a dict containing derivatives for dependent parameter computed from derivDict :param list dMdv: a Jacobian, as a list of np.array containing derivatives for dependent parameter computed from derivDict '''
• ## trunk/GSASIImath.py

 r984 ''' # Note: this routine is Python 3 compatible -- I think if esd != 0: if math.isnan(value): # invalid value, bail out return '?' if math.isnan(esd): # invalid esd, treat as zero esd = 0 esdoff = 5 elif esd != 0: # transform the esd to a one or two digit integer l = math.log10(abs(esd)) % 1 extra = -math.log10(abs(value)) if extra > 0: extra += 1 print 'fmt=',"{:."+str(max(0,esdoff+int(extra)))+"f}" out = ("{:."+str(max(0,esdoff+int(extra)))+"f}").format(value) # format the value if esd > 0:
• ## trunk/GSASIIpath.py

 r981 :returns: None if svn is not found or an absolute path to the subversion executable file . executable file. ''' def is_exe(fpath): '''This performs an update of the files in a local directory from a server. :param fpath: path to repository dictionary, defaults to directory where :param str fpath: path to repository dictionary, defaults to directory where the current file is located :param version: the number of the version to be loaded. Used only cast as a string, but should be an integer or something that corresponds to a string representation of an integer value when cast. A value of None (default) causes the latest version on the server to be used. :returns: A dictionary with the files that have been changed/added and a code describing how they have been updated (see changetype) ro a code describing how they have been updated (see changetype) or None if there is a subversion error (likely because the path is not a repository or svn is not found) ''' import subprocess
• ## trunk/GSASIIstrIO.py

 r981 def cellFill(pfx,SGData,parmDict,sigDict): 'needs a doc string' '''Returns the filled-out reciprocal cell (A) terms and their uncertainties from the parameter and sig dictionaries. :param str pfx: parameter prefix ("n::", where n is a phase number) :param dict SGdata: a symmetry object :param dict parmDict: a dictionary of parameters :param dict sigDict:  a dictionary of uncertainties on parameters :returns: A,sigA where each is a list of six terms with the A terms ''' if SGData['SGLaue'] in ['-1',]: A = [parmDict[pfx+'A0'],parmDict[pfx+'A1'],parmDict[pfx+'A2'], parmDict[pfx+'A3'],parmDict[pfx+'A4'],parmDict[pfx+'A5']] sigA = [sigDict[pfx+'A0'],sigDict[pfx+'A1'],sigDict[pfx+'A2'], sigDict[pfx+'A3'],sigDict[pfx+'A4'],sigDict[pfx+'A5']] elif SGData['SGLaue'] in ['2/m',]: if SGData['SGUniq'] == 'a': A = [parmDict[pfx+'A0'],parmDict[pfx+'A1'],parmDict[pfx+'A2'], parmDict[pfx+'A3'],0,0] sigA = [sigDict[pfx+'A0'],sigDict[pfx+'A1'],sigDict[pfx+'A2'], sigDict[pfx+'A3'],0,0] elif SGData['SGUniq'] == 'b': A = [parmDict[pfx+'A0'],parmDict[pfx+'A1'],parmDict[pfx+'A2'], 0,parmDict[pfx+'A4'],0] sigA = [sigDict[pfx+'A0'],sigDict[pfx+'A1'],sigDict[pfx+'A2'], 0,sigDict[pfx+'A4'],0] else: A = [parmDict[pfx+'A0'],parmDict[pfx+'A1'],parmDict[pfx+'A2'], 0,0,parmDict[pfx+'A5']] sigA = [sigDict[pfx+'A0'],sigDict[pfx+'A1'],sigDict[pfx+'A2'], 0,0,sigDict[pfx+'A5']] elif SGData['SGLaue'] in ['mmm',]: A = [parmDict[pfx+'A0'],parmDict[pfx+'A1'],parmDict[pfx+'A2'],0,0,0] sigA = [sigDict[pfx+'A0'],sigDict[pfx+'A1'],sigDict[pfx+'A2'],0,0,0] elif SGData['SGLaue'] in ['4/m','4/mmm']: A = [parmDict[pfx+'A0'],parmDict[pfx+'A0'],parmDict[pfx+'A2'],0,0,0] sigA = [sigDict[pfx+'A0'],0,sigDict[pfx+'A2'],0,0,0] elif SGData['SGLaue'] in ['6/m','6/mmm','3m1', '31m', '3']: A = [parmDict[pfx+'A0'],parmDict[pfx+'A0'],parmDict[pfx+'A2'], parmDict[pfx+'A0'],0,0] sigA = [sigDict[pfx+'A0'],0,sigDict[pfx+'A2'],0,0,0] elif SGData['SGLaue'] in ['3R', '3mR']: A = [parmDict[pfx+'A0'],parmDict[pfx+'A0'],parmDict[pfx+'A0'], parmDict[pfx+'A3'],parmDict[pfx+'A3'],parmDict[pfx+'A3']] sigA = [sigDict[pfx+'A0'],0,0,sigDict[pfx+'A3'],0,0] elif SGData['SGLaue'] in ['m3m','m3']: A = [parmDict[pfx+'A0'],parmDict[pfx+'A0'],parmDict[pfx+'A0'],0,0,0] sigA = [sigDict[pfx+'A0'],0,0,0,0,0] try: if SGData['SGLaue'] in ['-1',]: sigA = [sigDict[pfx+'A0'],sigDict[pfx+'A1'],sigDict[pfx+'A2'], sigDict[pfx+'A3'],sigDict[pfx+'A4'],sigDict[pfx+'A5']] elif SGData['SGLaue'] in ['2/m',]: if SGData['SGUniq'] == 'a': sigA = [sigDict[pfx+'A0'],sigDict[pfx+'A1'],sigDict[pfx+'A2'], sigDict[pfx+'A3'],0,0] elif SGData['SGUniq'] == 'b': sigA = [sigDict[pfx+'A0'],sigDict[pfx+'A1'],sigDict[pfx+'A2'], 0,sigDict[pfx+'A4'],0] else: sigA = [sigDict[pfx+'A0'],sigDict[pfx+'A1'],sigDict[pfx+'A2'], 0,0,sigDict[pfx+'A5']] elif SGData['SGLaue'] in ['mmm',]: sigA = [sigDict[pfx+'A0'],sigDict[pfx+'A1'],sigDict[pfx+'A2'],0,0,0] elif SGData['SGLaue'] in ['4/m','4/mmm']: sigA = [sigDict[pfx+'A0'],0,sigDict[pfx+'A2'],0,0,0] elif SGData['SGLaue'] in ['6/m','6/mmm','3m1', '31m', '3']: sigA = [sigDict[pfx+'A0'],0,sigDict[pfx+'A2'],0,0,0] elif SGData['SGLaue'] in ['3R', '3mR']: sigA = [sigDict[pfx+'A0'],0,0,sigDict[pfx+'A3'],0,0] elif SGData['SGLaue'] in ['m3m','m3']: sigA = [sigDict[pfx+'A0'],0,0,0,0,0] except KeyError: sigA = [0,0,0,0,0,0] return A,sigA
• ## trunk/GSASIIstrMath.py

 r961 ApplyRBModelDervs(dFdvDict,parmDict,rigidbodyDict,Phase) dMdvh = np.zeros((len(varylist),len(refList))) dependentVars = G2mv.GetDependentVars() depDerivDict = {} for j in dependentVars: depDerivDict[j] = np.zeros(shape=(len(refList))) if calcControls['F**2']: for iref,ref in enumerate(refList): if var in dFdvDict: dMdvh[j][iref] = w*dFdvDict[var][iref]*parmDict[phfx+'Scale']*dervCor for var in dependentVars: if var in dFdvDict: depDerivDict[var][iref] = w*dFdvDict[var][iref]*parmDict[phfx+'Scale']*dervCor if phfx+'Scale' in varylist: dMdvh[varylist.index(phfx+'Scale')][iref] = w*ref[9]*dervCor elif phfx+'Scale' in dependentVars: depDerivDict[phfx+'Scale'][iref] = w*ref[9]*dervCor for item in ['Ep','Es','Eg']: if phfx+item in varylist: dMdvh[varylist.index(phfx+item)][iref] = w*dervDict[phfx+item]*parmDict[phfx+'Scale'] elif phfx+item in dependentVars: depDerivDict[phfx+item][iref] = w*dervDict[phfx+item]*parmDict[phfx+'Scale'] for item in ['BabA','BabU']: if phfx+item in varylist: dMdvh[varylist.index(phfx+item)][iref] = w*dervCor*dFdvDict[pfx+item][iref]*parmDict[phfx+'Scale'] elif phfx+item in dependentVars: depDerivDict[phfx+item][iref] = w*dervCor*dFdvDict[pfx+item][iref]*parmDict[phfx+'Scale'] else: for iref,ref in enumerate(refList): if var in dFdvDict: dMdvh[j][iref] = w*dFdvDict[var][iref]*dervCor*parmDict[phfx+'Scale'] for var in dependentVars: if var in dFdvDict: depDerivDict[var][iref] = w*dFdvDict[var][iref]*dervCor*parmDict[phfx+'Scale'] if phfx+'Scale' in varylist: dMdvh[varylist.index(phfx+'Scale')][iref] = w*ref[9]*dervCor dMdvh[varylist.index(phfx+'Scale')][iref] = w*ref[9]*dervCor elif phfx+'Scale' in dependentVars: depDerivDict[phfx+'Scale'][iref] = w*ref[9]*dervCor for item in ['Ep','Es','Eg']: if phfx+item in varylist: dMdvh[varylist.index(phfx+item)][iref] = w*dervDict[phfx+item]*parmDict[phfx+'Scale'] elif phfx+item in dependentVars: depDerivDict[phfx+item][iref] = w*dervDict[phfx+item]*parmDict[phfx+'Scale'] for item in ['BabA','BabU']: if phfx+item in varylist: dMdvh[varylist.index(phfx+item)][iref] = w*dervCor*dFdvDict[pfx+item][iref]*parmDict[phfx+'Scale'] elif phfx+item in dependentVars: depDerivDict[phfx+item][iref] = w*dFdvDict[pfx+item][iref]*parmDict[phfx+'Scale']*dervCor # now process derivatives in constraints G2mv.Dict2Deriv(varylist,depDerivDict,dMdvh) else: continue        #skip non-histogram entries ApplyRBModelDervs(dFdvDict,parmDict,rigidbodyDict,Phase) dMdvh = np.zeros((len(varylist),len(refList))) dependentVars = G2mv.GetDependentVars() depDerivDict = {} for j in dependentVars: depDerivDict[j] = np.zeros(shape=(len(refList))) wdf = np.zeros(len(refList)) if calcControls['F**2']: if var in dFdvDict: dMdvh[j][iref] = w*dFdvDict[var][iref]*dervCor*parmDict[phfx+'Scale'] for var in dependentVars: if var in dFdvDict: depDerivDict[var][iref] = w*dFdvDict[var][iref]*dervCor*parmDict[phfx+'Scale'] if phfx+'Scale' in varylist: dMdvh[varylist.index(phfx+'Scale')][iref] = w*ref[9]*dervCor elif phfx+'Scale' in dependentVars: depDerivDict[phfx+'Scale'][iref] = w*ref[9]*dervCor for item in ['Ep','Es','Eg']: if phfx+item in varylist: dMdvh[varylist.index(phfx+item)][iref] = w*dervDict[phfx+item]*parmDict[phfx+'Scale'] elif phfx+item in dependentVars: depDerivDict[phfx+item][iref] = w*dervDict[phfx+item]*parmDict[phfx+'Scale'] for item in ['BabA','BabU']: if phfx+item in varylist: dMdvh[varylist.index(phfx+item)][iref] = w*dFdvDict[pfx+item][iref]*parmDict[phfx+'Scale']*dervCor elif phfx+item in dependentVars: depDerivDict[phfx+item][iref] = w*dFdvDict[pfx+item][iref]*parmDict[phfx+'Scale']*dervCor else: for iref,ref in enumerate(refList): if var in dFdvDict: dMdvh[j][iref] = w*dFdvDict[var][iref]*dervCor*parmDict[phfx+'Scale'] for var in dependentVars: if var in dFdvDict: depDerivDict[var][iref] = w*dFdvDict[var][iref]*dervCor*parmDict[phfx+'Scale'] if phfx+'Scale' in varylist: dMdvh[varylist.index(phfx+'Scale')][iref] = w*ref[9]*dervCor dMdvh[varylist.index(phfx+'Scale')][iref] = w*ref[9]*dervCor elif phfx+'Scale' in dependentVars: depDerivDict[phfx+'Scale'][iref] = w*ref[9]*dervCor for item in ['Ep','Es','Eg']: if phfx+item in varylist: dMdvh[varylist.index(phfx+item)][iref] = w*dervDict[phfx+item]*parmDict[phfx+'Scale'] elif phfx+item in dependentVars: depDerivDict[phfx+item][iref] = w*dervDict[phfx+item]*parmDict[phfx+'Scale'] for item in ['BabA','BabU']: if phfx+item in varylist: dMdvh[varylist.index(phfx+item)][iref] = w*dFdvDict[pfx+item][iref]*parmDict[phfx+'Scale']*dervCor elif phfx+item in dependentVars: depDerivDict[phfx+item][iref] = w*dFdvDict[pfx+item][iref]*parmDict[phfx+'Scale']*dervCor # now process derivatives in constraints G2mv.Dict2Deriv(varylist,depDerivDict,dMdvh) if dlg: dlg.Update(Histogram['wR'],newmsg='Hessian for histogram %d Rw=%8.3f%s'%(hId,Histogram['wR'],'%'))[0]
• ## trunk/exports/G2cif.py

 r981 import GSASIIgrid as G2gd import GSASIIstrIO as G2stIO #reload(G2stIO) #import GSASIImapvars as G2mv import GSASIImath as G2mth reload(G2mth) import GSASIIlattice as G2lat import GSASIIspc as G2spg #reload(G2spg) reload(G2mth) def getCallerDocString(): # for development refprx = '_refln_' # normal print histblk.keys() #            for key in histblk: #                print key print inst print self.parmDict.keys() print self.sigDict.keys() WriteCIFitem('\n# SCATTERING FACTOR INFO') if 'Lam1' in inst: WriteCIFitem('_diffrn_radiation_wavelength',G2mth.ValEsd(lam1,slam1)) raise Exception, "testing" if not oneblock: '\n\t_pd_phase_block_id' + '\n\t_pd_phase_mass_%') wtFrSum = 0. for phasenam in phasebyhistDict.get(histlbl): pass WriteCIFitem('_pd_proc_ls_prof_R_factor','?') WriteCIFitem('_pd_proc_ls_prof_wR_factor','?') WriteCIFitem('_pd_proc_ls_prof_wR_expected','?') WriteCIFitem('_refine_ls_R_Fsqd_factor','?') hapData = self.Phases[phasenam]['Histograms'][histlbl] General = self.Phases[phasenam]['General'] wtFrSum += hapData['Scale'][0]*General['Mass'] for phasenam in phasebyhistDict.get(histlbl): hapData = self.Phases[phasenam]['Histograms'][histlbl] General = self.Phases[phasenam]['General'] wtFr = hapData['Scale'][0]*General['Mass']/wtFrSum pfx = str(self.Phases[phasenam]['pId'])+':'+str(hId)+':' if pfx+'Scale' in self.sigDict: sig = self.sigDict[pfx+'Scale']*wtFr/hapData['Scale'][0] else: sig = -0.0001 WriteCIFitem( '  '+ str(self.Phases[phasenam]['pId']) + '  '+datablockidDict[phasenam]+ '  '+G2mth.ValEsd(wtFr,sig) ) # this will need help from Bob # WriteCIFitem('_pd_proc_ls_prof_R_factor','?') # WriteCIFitem('_pd_proc_ls_prof_wR_factor','?') # WriteCIFitem('_pd_proc_ls_prof_wR_expected','?') # WriteCIFitem('_refine_ls_R_Fsqd_factor','?') phasenam = self.Phases.keys()[0] for key in self.Phases[phasenam]['Histograms']: print key print '------------' print self.Phases[phasenam]['Histograms'][key] raise Exception, "testing" print histblk.keys() for key in histblk: print key,histblk[key] print inst #print self.parmDict.keys() #print self.sigDict.keys() #WriteCIFitem('_pd_meas_2theta_fixed',text) WriteCIFitem('_pd_block_id',datablockidDict[hist]) WritePowderTemplate() WritePowderData(key1) WritePowderData(hist) elif hist.startswith("HKLF"): WriteCIFitem('\ndata_'+self.CIFname+"_sx_"+str(i)) WriteCIFitem('_pd_block_id',datablockidDict[hist]) WriteSnglXtalTemplate() WriteSingleXtalData(key1) WriteSingleXtalData(hist) WriteCIFitem('#--' + 15*'eof--' + '#')
Note: See TracChangeset for help on using the changeset viewer.