Changeset 443 for trunk/GSASIIstruct.py
- Timestamp:
- Dec 16, 2011 1:15:09 PM (11 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/GSASIIstruct.py
r441 r443 1259 1259 hapData[item][1][0] = parmDict[pfx+item+':i'] 1260 1260 if item == 'Size': 1261 hapData[item][1][0] = min(10.,max(0.0 1,hapData[item][1][0]))1261 hapData[item][1][0] = min(10.,max(0.001,hapData[item][1][0])) 1262 1262 if pfx+item+':i' in sigDict: 1263 1263 SizeMuStrSig[item][0][0] = sigDict[pfx+item+':i'] … … 1265 1265 hapData[item][1][1] = parmDict[pfx+item+':a'] 1266 1266 if item == 'Size': 1267 hapData[item][1][1] = min(10.,max(0.0 1,hapData[item][1][1]))1267 hapData[item][1][1] = min(10.,max(0.001,hapData[item][1][1])) 1268 1268 if pfx+item+':a' in sigDict: 1269 1269 SizeMuStrSig[item][0][1] = sigDict[pfx+item+':a'] … … 1287 1287 1288 1288 def GetBackgroundParms(hId,Background): 1289 bakType,bakFlag = Background[:2] 1290 backVals = Background[3:] 1289 Back = Background[0] 1290 Debye = Background[1] 1291 bakType,bakFlag = Back[:2] 1292 backVals = Back[3:] 1291 1293 backNames = [':'+str(hId)+':Back:'+str(i) for i in range(len(backVals))] 1292 if bakFlag: #returns backNames as varyList = backNames 1293 return bakType,dict(zip(backNames,backVals)),backNames 1294 else: #no background varied; varyList = [] 1295 return bakType,dict(zip(backNames,backVals)),[] 1294 backDict = dict(zip(backNames,backVals)) 1295 backVary = [] 1296 if bakFlag: 1297 backVary = backNames 1298 backDict[':'+str(hId)+':nDebye'] = Debye['nDebye'] 1299 debyeDict = {} 1300 debyeList = [] 1301 for i in range(Debye['nDebye']): 1302 debyeNames = [':'+str(hId)+':DebyeA:'+str(i),':'+str(hId)+':DebyeR:'+str(i),':'+str(hId)+':DebyeU:'+str(i)] 1303 debyeDict.update(dict(zip(debyeNames,Debye['debyeTerms'][i][::2]))) 1304 debyeList += zip(debyeNames,Debye['debyeTerms'][i][1::2]) 1305 debyeVary = [] 1306 for item in debyeList: 1307 if item[1]: 1308 debyeVary.append(item[0]) 1309 backDict.update(debyeDict) 1310 backVary += debyeVary 1311 return bakType,backDict,backVary 1296 1312 1297 1313 def GetInstParms(hId,Inst): … … 1306 1322 if flag: 1307 1323 insVary.append(insName) 1308 instDict[pfx+'X'] = max(instDict[pfx+'X'],0.0 1)1309 instDict[pfx+'Y'] = max(instDict[pfx+'Y'],0.0 1)1324 instDict[pfx+'X'] = max(instDict[pfx+'X'],0.001) 1325 instDict[pfx+'Y'] = max(instDict[pfx+'Y'],0.001) 1310 1326 instDict[pfx+'SH/L'] = max(instDict[pfx+'SH/L'],0.0005) 1311 1327 return dataType,instDict,insVary … … 1330 1346 1331 1347 def PrintBackground(Background): 1332 print '\n Background function: ',Background[0],' Refine?',bool(Background[1]) 1348 Back = Background[0] 1349 Debye = Background[1] 1350 print '\n Background function: ',Back[0],' Refine?',bool(Back[1]) 1333 1351 line = ' Coefficients: ' 1334 for i,back in enumerate(Back ground[3:]):1352 for i,back in enumerate(Back[3:]): 1335 1353 line += '%10.3f'%(back) 1336 1354 if i and not i%10: 1337 1355 line += '\n'+15*' ' 1338 print line 1356 print line 1357 if Debye['nDebye']: 1358 print '\n Debye diffuse scattering coefficients' 1359 parms = ['DebyeA','DebyeR','DebyeU'] 1360 line = ' names :' 1361 for parm in parms: 1362 line += '%16s'%(parm) 1363 print line 1364 for j,term in enumerate(Debye['debyeTerms']): 1365 line = ' term'+'%2d'%(j)+':' 1366 for i in range(3): 1367 line += '%10.4f %5s'%(term[2*i],bool(term[2*i+1])) 1368 print line 1339 1369 1340 1370 def PrintInstParms(Inst): … … 1388 1418 controlDict[pfx+'Limits'] = Histogram['Limits'][1] 1389 1419 1390 Background = Histogram['Background'] [0]1420 Background = Histogram['Background'] 1391 1421 Type,bakDict,bakVary = GetBackgroundParms(hId,Background) 1392 1422 controlDict[pfx+'bakType'] = Type … … 1427 1457 1428 1458 def SetBackgroundParms(pfx,Background,parmDict,sigDict): 1429 lenBack = len(Background[3:]) 1430 backSig = [0 for i in range(lenBack)] 1459 Back = Background[0] 1460 Debye = Background[1] 1461 lenBack = len(Back[3:]) 1462 backSig = [0 for i in range(lenBack+3*Debye['nDebye'])] 1431 1463 for i in range(lenBack): 1432 Back ground[3+i] = parmDict[pfx+'Back:'+str(i)]1464 Back[3+i] = parmDict[pfx+'Back:'+str(i)] 1433 1465 if pfx+'Back:'+str(i) in sigDict: 1434 1466 backSig[i] = sigDict[pfx+'Back:'+str(i)] 1467 if Debye['nDebye']: 1468 for i in range(Debye['nDebye']): 1469 names = [pfx+'DebyeA:'+str(i),pfx+'DebyeR:'+str(i),pfx+'DebyeU:'+str(i)] 1470 for j,name in enumerate(names): 1471 Debye['debyeTerms'][i][2*j] = parmDict[name] 1472 if name in sigDict: 1473 backSig[lenBack+3*i+j] = sigDict[name] 1435 1474 return backSig 1436 1475 … … 1461 1500 1462 1501 def PrintBackgroundSig(Background,backSig): 1463 print '\n Background function: ',Background[0] 1502 Back = Background[0] 1503 Debye = Background[1] 1504 lenBack = len(Back[3:]) 1505 print '\n Background function: ',Back[0] 1464 1506 valstr = ' value : ' 1465 1507 sigstr = ' sig : ' 1466 for i,back in enumerate(Back ground[3:]):1508 for i,back in enumerate(Back[3:]): 1467 1509 valstr += '%10.4f'%(back) 1468 if Back ground[1]:1510 if Back[1]: 1469 1511 sigstr += '%10.4f'%(backSig[i]) 1470 1512 else: … … 1472 1514 print valstr 1473 1515 print sigstr 1516 if Debye['nDebye']: 1517 ifAny = False 1518 ptfmt = "%12.5f" 1519 names = ' names :' 1520 ptstr = ' values:' 1521 sigstr = ' esds :' 1522 for item in sigDict: 1523 if 'Debye' in item: 1524 ifAny = True 1525 names += '%12s'%(item) 1526 ptstr += ptfmt%(parmDict[item]) 1527 sigstr += ptfmt%(sigDict[item]) 1528 if ifAny: 1529 print '\n Debye diffuse scattering coefficients' 1530 print names 1531 print ptstr 1532 print sigstr 1474 1533 1475 1534 def PrintInstParmsSig(Inst,instSig): … … 1522 1581 hId = Histogram['hId'] 1523 1582 pfx = ':'+str(hId)+':' 1524 Background = Histogram['Background'] [0]1583 Background = Histogram['Background'] 1525 1584 backSig = SetBackgroundParms(pfx,Background,parmDict,sigDict) 1526 1585 … … 1956 2015 #microstrain derivatives 1957 2016 if calcControls[phfx+'MustrainType'] == 'isotropic': 1958 gamDict[phfx+'Mustrain: 0'] = 0.018*tanth/np.pi2017 gamDict[phfx+'Mustrain:i'] = 0.018*tanth/np.pi 1959 2018 elif calcControls[phfx+'MustrainType'] == 'uniaxial': 1960 2019 H = np.array(refl[:3]) 1961 2020 P = np.array(calcControls[phfx+'MustrainAxis']) 1962 2021 cosP,sinP = G2lat.CosSinAngle(H,P,G) 1963 Si = parmDict[phfx+'Mustrain: 0']1964 Sa = parmDict[phfx+'Mustrain: 1']2022 Si = parmDict[phfx+'Mustrain:i'] 2023 Sa = parmDict[phfx+'Mustrain:a'] 1965 2024 gami = 0.018*Si*Sa*tanth/np.pi 1966 2025 sqtrm = np.sqrt((Si*cosP)**2+(Sa*sinP)**2) 1967 2026 gam = gami/sqtrm 1968 gamDict[phfx+'Mustrain: 0'] = gam/Si-gami*Si*cosP**2/sqtrm**31969 gamDict[phfx+'Mustrain: 1'] = gam/Sa-gami*Sa*sinP**2/sqtrm**32027 gamDict[phfx+'Mustrain:i'] = gam/Si-gami*Si*cosP**2/sqtrm**3 2028 gamDict[phfx+'Mustrain:a'] = gam/Sa-gami*Sa*sinP**2/sqtrm**3 1970 2029 else: #generalized - P.W. Stephens model 1971 2030 pwrs = calcControls[phfx+'MuPwrs'] … … 2267 2326 bakType = calcControls[hfx+'bakType'] 2268 2327 dMdv = np.zeros(shape=(len(varylist),len(x))) 2328 dMdb,dMddb = G2pwd.getBackgroundDerv(hfx,parmDict,bakType,x) 2269 2329 if hfx+'Back:0' in varylist: # for now assume that Back:x vars to not appear in constraints 2270 dMdb = G2pwd.getBackgroundDerv(hfx,parmDict,bakType,x)2271 2330 bBpos =varylist.index(hfx+'Back:0') 2272 2331 dMdv[bBpos:bBpos+len(dMdb)] = dMdb 2273 2332 names = [hfx+'DebyeA',hfx+'DebyeR',hfx+'DebyeU'] 2333 for name in varylist: 2334 if 'Debye' in name: 2335 id = int(name.split(':')[-1]) 2336 parm = name[:int(name.rindex(':'))] 2337 ip = names.index(parm) 2338 dMdv[varylist.index(name)] = dMddb[3*id+ip] 2274 2339 if 'C' in calcControls[hfx+'histType']: 2275 2340 dx = x[1]-x[0] … … 2416 2481 G2mv.Dict2Map(parmdict,varylist) 2417 2482 Histograms,Phases = HistoPhases 2483 nvar = len(varylist) 2418 2484 dMdv = np.empty(0) 2419 2485 for histogram in Histograms: … … 2585 2651 sigDict = dict(zip(varyList,sig)) 2586 2652 newCellDict = GetNewCellParms(parmDict,varyList) 2587 print newCellDict2588 2653 newAtomDict = ApplyXYZshifts(parmDict,varyList) 2589 2654 covData = {'variables':result[0],'varyList':varyList,'sig':sig,
Note: See TracChangeset
for help on using the changeset viewer.