Changeset 4080


Ignore:
Timestamp:
Aug 7, 2019 11:35:30 AM (4 years ago)
Author:
vondreele
Message:

fix to ellipsoid size math & GUI revisions

Location:
trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/GSASIIddataGUI.py

    r4047 r4080  
    2828import GSASIIctrlGUI as G2G
    2929import numpy as np
     30import numpy.linalg as nl
    3031
    3132WACV = wx.ALIGN_CENTER_VERTICAL
     
    178179                pass
    179180            Obj.SetValue("%.5f"%(UseList[G2frame.hist]['Size'][4][pid]))          #reset in case of error
     181            wx.CallAfter(UpdateDData,G2frame,DData,data,G2frame.hist)
    180182        else:
    181183            try:
     
    405407            dataSizer.Add(sizeVal,0,WACV|wx.BOTTOM,5)
    406408        return dataSizer
    407        
     409
    408410    def EllSizeDataSizer():
    409411        parms = zip(['S11','S22','S33','S12','S13','S23'],UseList[G2frame.hist]['Size'][4],
    410412            UseList[G2frame.hist]['Size'][5],range(6))
    411         dataSizer = wx.FlexGridSizer(0,6,5,5)
    412         for Pa,val,ref,Id in parms:
     413        dataSizer = wx.BoxSizer(wx.VERTICAL)
     414        # dataSizer = wx.FlexGridSizer(0,6,5,5)
     415        matrixSizer = wx.FlexGridSizer(0,6,5,5)
     416        Sij = []
     417        for Pa,val,ref,id in parms:
    413418            sizeRef = wx.CheckBox(DData,wx.ID_ANY,label=Pa)
    414419            sizeRef.thisown = False
    415420            sizeRef.SetValue(ref)
    416             Indx[sizeRef.GetId()] = [G2frame.hist,Id]
     421            Indx[sizeRef.GetId()] = [G2frame.hist,id]
    417422            sizeRef.Bind(wx.EVT_CHECKBOX, OnSizeRef)
    418             dataSizer.Add(sizeRef,0,WACV)
    419 #        azmthOff = G2G.ValidatedTxtCtrl(G2frame.dataDisplay,data,'azmthOff',nDig=(10,2),typeHint=float,OnLeave=OnAzmthOff)
     423            # dataSizer.Add(sizeRef,0,WACV)
     424            matrixSizer.Add(sizeRef,0,WACV)
     425    #        azmthOff = G2G.ValidatedTxtCtrl(G2frame.dataDisplay,data,'azmthOff',nDig=(10,2),typeHint=float,OnLeave=OnAzmthOff)
    420426            sizeVal = wx.TextCtrl(DData,wx.ID_ANY,'%.3f'%(val),style=wx.TE_PROCESS_ENTER)
    421             Indx[sizeVal.GetId()] = [G2frame.hist,Id]
     427            # Create Sij matrix
     428            Sij += [val]
     429            Indx[sizeVal.GetId()] = [G2frame.hist,id]
    422430            sizeVal.Bind(wx.EVT_TEXT_ENTER,OnSizeVal)
    423431            sizeVal.Bind(wx.EVT_KILL_FOCUS,OnSizeVal)
    424             dataSizer.Add(sizeVal,0,WACV)
     432            # dataSizer.Add(sizeVal,0,WACV)
     433            matrixSizer.Add(sizeVal,0,WACV)
     434        dataSizer.Add(matrixSizer, 0, WACV)
     435        Esize,Rsize = nl.eigh(G2lat.U6toUij(np.asarray(Sij)))
     436        lengths = Esize
     437        G,g = G2lat.cell2Gmat(data['General']['Cell'][1:7])       #recip & real metric tensors
     438        GA,GB = G2lat.Gmat2AB(G)    #Orthogonalization matricies
     439        hkls = [x/(sum(x**2)**0.5) for x in np.dot(Rsize, GA)]
     440        Ids = np.argsort(lengths)
     441        dataSizer.Add(wx.StaticText(DData,label=' Principal ellipsoid components:'),0,WACV)
     442        compSizer = wx.FlexGridSizer(3,3,5,5)
     443        Axes = [' Short Axis:',' Middle Axis:',' Long Axis:']
     444        for Id in Ids:
     445            compSizer.Add(wx.StaticText(DData,label=Axes[Id]),0,WACV)
     446            compSizer.Add(wx.StaticText(DData,label='(%.3f, %.3f, %.3f) '%(hkls[Id][0], hkls[Id][1], hkls[Id][2])),0,WACV)
     447            compSizer.Add(wx.StaticText(DData,label='Length: %.3f'%lengths[Id]),0,WACV)
     448        dataSizer.Add(compSizer)
    425449        return dataSizer
    426450       
  • trunk/GSASIIpwd.py

    r4048 r4080  
    11121112
    11131113def ellipseSize(H,Sij,GB):
    1114     'needs a doc string'
     1114    'Implements r=1/sqrt(sum((1/S)*(q.v)^2) per note from Alexander Brady'
    11151115    HX = np.inner(H.T,GB)
    11161116    lenHX = np.sqrt(np.sum(HX**2))
    11171117    Esize,Rsize = nl.eigh(G2lat.U6toUij(Sij))           
    1118     R = np.inner(HX/lenHX,Rsize)*Esize         #want column length for hkl in crystal
    1119     lenR = np.sqrt(np.sum(R**2))
     1118    R = np.inner(HX/lenHX,Rsize)**2*Esize         #want column length for hkl in crystal
     1119    lenR = 1./np.sqrt(np.sum(R))
    11201120    return lenR
    11211121
Note: See TracChangeset for help on using the changeset viewer.