Changeset 902 for trunk/GSASIImath.py
- Timestamp:
- May 10, 2013 3:07:50 PM (12 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
TabularUnified trunk/GSASIImath.py ¶
r889 r902 203 203 if atom[cia] == 'A': 204 204 UIJ = atom[cia+2:cia+8] 205 206 def TLS2Uij(xyz,g,Amat,rbObj): 207 TLStype,TLS = rbObj['ThermalMotion'][:2] 208 Tmat = np.zeros((3,3)) 209 Lmat = np.zeros((3,3)) 210 Smat = np.zeros((3,3)) 211 gvec = np.sqrt(np.array([g[0][0]**2,g[1][1]**2,g[2][2]**2, 212 g[0][0]*g[1][1],g[0][0]*g[2][2],g[1][1]*g[2][2]])) 213 if 'T' in TLStype: 214 Tmat = G2lat.U6toUij(TLS[:6]) 215 if 'L' in TLStype: 216 Lmat = G2lat.U6toUij(TLS[6:12]) 217 if 'S' in TLStype: 218 Smat = np.array([[TLS[18],TLS[12],TLS[13]],[TLS[14],TLS[19],TLS[15]],[TLS[16],TLS[17],0] ]) 219 XYZ = np.inner(Amat,xyz) 220 Axyz = np.array([[ 0,XYZ[2],-XYZ[1]], [-XYZ[2],0,XYZ[0]], [XYZ[1],-XYZ[0],0]] ) 221 Umat = Tmat+np.inner(Axyz,Smat)+np.inner(Smat.T,Axyz.T)+np.inner(np.inner(Axyz,Lmat),Axyz.T) 222 beta = np.inner(np.inner(g,Umat),g) 223 return G2lat.UijtoU6(beta)*gvec 205 224 206 225 def AtomTLS2UIJ(atomData,atPtrs,Amat,rbObj): … … 217 236 Lmat = G2lat.U6toUij(TLS[6:12]) 218 237 if 'S' in TLStype: 219 Smat = np.array([ [TLS[18],TLS[12],S[13]],[TLS[14],TLS[19],TLS[15]],[TLS[16],TLS[17],0]])238 Smat = np.array([ [TLS[18],TLS[12],TLS[13]], [TLS[14],TLS[19],TLS[15]], [TLS[16],TLS[17],0] ]) 220 239 for atom in atomData: 221 240 XYZ = np.inner(Amat,atom[cx:cx+3]) 222 Axyz = np.array([ 0,XYZ[2],-XYZ[1]],[-XYZ[2],0,XYZ[0]],[XYZ[1],-XYZ[0],0])241 Axyz = np.array([ 0,XYZ[2],-XYZ[1], -XYZ[2],0,XYZ[0], XYZ[1],-XYZ[0],0],ndmin=2 ) 223 242 if 'U' in TSLtype: 224 243 atom[cia+1] = TLS[0] … … 352 371 for j,xyz in enumerate(XYZ): 353 372 for i,x in enumerate(np.array([[dx,0,0],[0,dx,0],[0,0,dx]])): 354 XYZ[j] += x373 XYZ[j] -= x 355 374 d1 = Func(getSyXYZ(XYZ,ops,SGData),Amat) 356 XYZ[j] -= 2*x375 XYZ[j] += 2*x 357 376 d2 = Func(getSyXYZ(XYZ,ops,SGData),Amat) 358 XYZ[j] += x377 XYZ[j] -= x 359 378 deriv[j][i] = (d1-d2)/(2*dx) 360 379 return deriv.flatten() … … 432 451 for j,xyz in enumerate(XYZ): 433 452 for i,x in enumerate(np.array([[dx,0,0],[0,dx,0],[0,0,dx]])): 434 XYZ[j] += x453 XYZ[j] -= x 435 454 tor = getRestTorsion(XYZ,Amat) 436 455 p,d1 = calcTorsionEnergy(tor,Coeff) 437 XYZ[j] -= 2*x456 XYZ[j] += 2*x 438 457 tor = getRestTorsion(XYZ,Amat) 439 458 p,d2 = calcTorsionEnergy(tor,Coeff) 440 XYZ[j] += x441 deriv[j][i] = (d 1-d2)/(2*dx)459 XYZ[j] -= x 460 deriv[j][i] = (d2-d1)/(2*dx) 442 461 return deriv.flatten() 443 462 … … 469 488 for j,xyz in enumerate(XYZ): 470 489 for i,x in enumerate(np.array([[dx,0,0],[0,dx,0],[0,0,dx]])): 471 XYZ[j] += x490 XYZ[j] -= x 472 491 phi,psi = getRestRama(XYZ,Amat) 473 492 p,d1 = calcRamaEnergy(phi,psi,Coeff) 474 XYZ[j] -= 2*x493 XYZ[j] += 2*x 475 494 phi,psi = getRestRama(XYZ,Amat) 476 495 p,d2 = calcRamaEnergy(phi,psi,Coeff) 477 XYZ[j] += x478 deriv[j][i] = (d 1-d2)/(2*dx)496 XYZ[j] -= x 497 deriv[j][i] = (d2-d1)/(2*dx) 479 498 return deriv.flatten() 480 499 … … 505 524 deriv = np.zeros(6) 506 525 for i in [0,1,2]: 507 Oxyz[i] += dx526 Oxyz[i] -= dx 508 527 d0 = calcDist(Oxyz,Txyz,Tunit,inv,C,M,T,Amat) 509 Oxyz[i] -= 2*dx528 Oxyz[i] += 2*dx 510 529 deriv[i] = (calcDist(Oxyz,Txyz,Tunit,inv,C,M,T,Amat)-d0)/(2.*dx) 511 Oxyz[i] += dx512 Txyz[i] += dx530 Oxyz[i] -= dx 531 Txyz[i] -= dx 513 532 d0 = calcDist(Oxyz,Txyz,Tunit,inv,C,M,T,Amat) 514 Txyz[i] -= 2*dx533 Txyz[i] += 2*dx 515 534 deriv[i+3] = (calcDist(Oxyz,Txyz,Tunit,inv,C,M,T,Amat)-d0)/(2.*dx) 516 Txyz[i] += dx535 Txyz[i] -= dx 517 536 return deriv 518 537 … … 556 575 Ang = calcAngle(OxA,TxA,TxB,unitA,unitB,invA,CA,MA,TA,invB,CB,MB,TB,Amat) 557 576 for i in [0,1,2]: 558 OxA[i] += dx577 OxA[i] -= dx 559 578 a0 = calcAngle(OxA,TxA,TxB,unitA,unitB,invA,CA,MA,TA,invB,CB,MB,TB,Amat) 560 OxA[i] -= 2*dx561 dadx[i] = (calcAngle(OxA,TxA,TxB,unitA,unitB,invA,CA,MA,TA,invB,CB,MB,TB,Amat)-a0)/ dx562 OxA[i] += dx579 OxA[i] += 2*dx 580 dadx[i] = (calcAngle(OxA,TxA,TxB,unitA,unitB,invA,CA,MA,TA,invB,CB,MB,TB,Amat)-a0)/(2*dx) 581 OxA[i] -= dx 563 582 564 TxA[i] += dx583 TxA[i] -= dx 565 584 a0 = calcAngle(OxA,TxA,TxB,unitA,unitB,invA,CA,MA,TA,invB,CB,MB,TB,Amat) 566 TxA[i] -= 2*dx567 dadx[i+3] = (calcAngle(OxA,TxA,TxB,unitA,unitB,invA,CA,MA,TA,invB,CB,MB,TB,Amat)-a0)/ dx568 TxA[i] += dx585 TxA[i] += 2*dx 586 dadx[i+3] = (calcAngle(OxA,TxA,TxB,unitA,unitB,invA,CA,MA,TA,invB,CB,MB,TB,Amat)-a0)/(2*dx) 587 TxA[i] -= dx 569 588 570 TxB[i] += dx589 TxB[i] -= dx 571 590 a0 = calcAngle(OxA,TxA,TxB,unitA,unitB,invA,CA,MA,TA,invB,CB,MB,TB,Amat) 572 TxB[i] -= 2*dx573 dadx[i+6] = (calcAngle(OxA,TxA,TxB,unitA,unitB,invA,CA,MA,TA,invB,CB,MB,TB,Amat)-a0)/ dx574 TxB[i] += dx591 TxB[i] += 2*dx 592 dadx[i+6] = (calcAngle(OxA,TxA,TxB,unitA,unitB,invA,CA,MA,TA,invB,CB,MB,TB,Amat)-a0)/(2*dx) 593 TxB[i] -= dx 575 594 576 595 sigAng = np.sqrt(np.inner(dadx,np.inner(AngVcov,dadx))) … … 721 740 ia = i/3 722 741 ix = i%3 723 Oatoms[ia][ix+1] += dx742 Oatoms[ia][ix+1] -= dx 724 743 a0 = calcTorsion(Oatoms,SyOps,Amat) 725 Oatoms[ia][ix+1] -= 2*dx744 Oatoms[ia][ix+1] += 2*dx 726 745 dadx[i] = (calcTorsion(Oatoms,SyOps,Amat)-a0)/(2.*dx) 746 Oatoms[ia][ix+1] -= dx 727 747 covMatrix = covData['covMatrix'] 728 748 varyList = covData['varyList']
Note: See TracChangeset
for help on using the changeset viewer.