Changeset 710 for trunk/GSASIIimage.py


Ignore:
Timestamp:
Aug 15, 2012 10:06:27 AM (9 years ago)
Author:
vondreele
Message:

update garnet tutorial to reflect new options
fix backbone plotting for multichain proteins
finish 1st attempt at strain tensor refinement - but not right

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/GSASIIimage.py

    r706 r710  
    1313import numpy as np
    1414import numpy.linalg as nl
     15from scipy.optimize import leastsq
    1516import copy
    1617import GSASIIpath
     
    128129   
    129130def FitDetector(rings,p0,wave):
    130     from scipy.optimize import leastsq
    131131       
    132132    def CalibPrint(ValSig):
     
    752752#    print 'Masks:',Masks
    753753    StaControls = copy.deepcopy(Controls)
    754     StaControls['distance'] += StrSta['Sample z']*cosd(StrSta['Sample phi'])
     754    phi = StrSta['Sample phi']
     755    wave = Controls['wavelength']
     756    StaControls['distance'] += StrSta['Sample z']*cosd(phi)
    755757    pixSize = StaControls['pixelSize']
    756758    scalex = 1000./pixSize[0]
     
    769771        else:
    770772            rings = np.array(Ring)
    771        
    772        
     773    E = StrSta['strain']
     774    p0 = [E[0][0],E[1][1],E[2][2],E[0][1],E[0][2],E[1][2]]
     775    E = FitStrain(rings,p0,wave,phi)
     776    StrSta['strain'] = E
    773777
    774778def calcFij(omg,phi,azm,th):
    775     ''' Uses parameters as defined by Bob He & Kingsley Smity, Adv. in X-Ray Anal. 41, 501 (1997)
     779    ''' Uses parameters as defined by Bob He & Kingsley Smith, Adv. in X-Ray Anal. 41, 501 (1997)
    776780    omg: his omega = sample omega rotation; 0 when incident beam || sample surface, 90
    777781            when perp. to sample surface
     
    791795    return -Fij*nptand(th)
    792796
    793 def FitStrain(rings,p0,wave):
    794     from scipy.optimize import leastsq
     797def FitStrain(rings,p0,wave,phi):
    795798
    796799    def StrainPrint(ValSig):
     
    810813        print sigstr
    811814       
    812     def strainCalc(E,xyd,wave,phi):
     815    def strainCalc(p,xyd,wave,phi):
     816#        E = np.array([[p[0],p[3],p[4]],[p[3],p[1],p[5]],[p[4],p[5],p[2]]])
     817        E = np.array([[p[0],0,0],[0,p[1],0],[0,0,0]])
    813818        th,azm,dsp = xyd
    814819        th0 = npasind(wave/(2.*dsp))
    815         dth = 180.*np.sum(StrSta['strain']*calcFij(phi,0.,azm,th))/(np.pi*1.e6) #in degrees
    816        
     820        dth = 180.*np.sum(E*calcFij(phi,0.,azm,th).T)/(np.pi*1.e6) #in degrees & microstrain units
     821        th0 += dth
     822        return (th-th0)**2
     823       
     824    names = ['e11','e22','e33','e12','e13','e23']
     825    fmt = ['%12.2f','%12.2f','%12.2f','%12.2f','%12.2f','%12.5f']
     826    p1 = [p0[0],p0[1]]   
     827    result = leastsq(strainCalc,p1,args=(rings,wave,phi),full_output=True)
     828    vals = list(result[0])
     829    chi = np.sqrt(np.sum(strainCalc(result[0],rings,wave,phi)**2))
     830    sig = list(chi*np.sqrt(np.diag(result[1])))
     831    ValSig = zip(names,fmt,vals,sig)
     832    StrainPrint(ValSig)
     833#    return np.array([[vals[0],vals[3],vals[4]],[vals[3],vals[1],vals[5]],[vals[4],vals[5],vals[2]]])
     834    return np.array([[vals[0],0,0],[0,vals[1],0],[0,0,0]])
     835   
     836       
Note: See TracChangeset for help on using the changeset viewer.