Changeset 4624 for trunk

Oct 26, 2020 9:40:05 PM (13 months ago)

improve rigid body stuff; finish tutorial

5 edited


  • trunk/

    r4615 r4624  
    20982098            G2frame.rbBook.SetSelection(G2frame.rbBook.FindPage(pagename))
     2100            HelpInfo = '''
     2101This window shows all the atoms that were read from the
     2102selected phase file. Select the atoms that will be used in the
     2103rigid body processing (this may include atoms needed to
     2104define an axis or origin that will not be included in the
     2105eventual rigid body.) Note that in the plot window,
     2106unselected atoms appear much darker than selected atoms.
    21002108            mainSizer = G2G.G2MultiChoiceWindow(RBImpPnl,
    21012109                            'Select atoms to import',
    2102                             atomlist,atmsel,OnChange=ShowSelection)
     2110                            atomlist,atmsel,OnChange=ShowSelection,
     2111                            helpText=HelpInfo)
    21042113            # OK/Cancel buttons       
    24022411            mainSizer = wx.BoxSizer(wx.HORIZONTAL)
    24032412            btnSizer = wx.BoxSizer(wx.VERTICAL)
     2413            helpText = '''
     2414In this window, if wanted,
     2415one can select one or more atoms and use them
     2416to define an origin, a specified axis or place the selected atoms into
     2417a selected plane. (Different sets of atoms can be used for each
     2419%%Once that is done, atoms can be selected and can be exported in a
     2420"XYZ" file for use in a program such as Avogadro or can be used to
     2421create a Vector or Residue rigid body.
     2423            btnSizer.Add(G2G.HelpButton(RBImpPnl,helpText,wrap=400),
     2424                             0,wx.ALIGN_RIGHT)
    24042425            btnSizer.Add(wx.StaticText(RBImpPnl,wx.ID_ANY,'Reorder atoms by dragging'),0,wx.ALL)
    24052426            btnSizer.Add((-1,15))
  • trunk/

    r4615 r4624  
    18411841    def __init__(self, parent, title, ChoiceList, SelectList, toggle=True,
    18421842                 monoFont=False, filterBox=True,
    1843                      OnChange=None, OnChangeArgs=[]):
     1843                     OnChange=None, OnChangeArgs=[], helpText=None):
    18441844        self.SelectList = SelectList
    18451845        self.ChoiceList = ['%4d) %s'%(i,item) for i,item in enumerate(ChoiceList)] # numbered list of choices (list of str values)
    18551855        Sizer = self
    18561856        topSizer = wx.BoxSizer(wx.HORIZONTAL)
    1857         topSizer.Add(wx.StaticText(self.frm,wx.ID_ANY,title,size=(-1,35)),
    1858             1,wx.ALL|wx.EXPAND|WACV,1)
     1857        topSizer.Add(wx.StaticText(self.frm,wx.ID_ANY,title,size=(-1,35)),0,WACV)
     1858        if helpText:
     1859            topSizer.Add(HelpButton(self.frm,helpText,wrap=400),0,wx.ALL,5)
     1860        topSizer.Add((1,-1),1,wx.ALL|wx.EXPAND,1)
    18591861        if filterBox:
    18601862            self.timer = wx.Timer()
    60226024tutorialIndex = (
    60236025    # tutorial dir,      web page file name,      title for page,  description
    6024     ['Getting started'],
     6026['Getting started'],
    60256027    ['StartingGSASII', 'Starting GSAS.htm', 'Starting GSAS-II',
    60266028     '''An introduction to GSAS-II with starting instructions and a brief description of the displays.'''],
    6028     ['Rietveld refinement'],
     6030['Rietveld refinement'],
    60296031    ['CWNeutron', 'Neutron CW Powder Data.htm', 'CW Neutron Powder fit for Yttrium-Iron Garnet',
    60306032     '''This shows a simple Rietveld refinement with constraints from CW neutron powder diffraction data.'''],
    60536055     plotting programs.'''],
    6055     ['Magnetic Structure Analysis'],
     6057    ['RigidBody', 'RigidBodyRef.html', 'Rietveld Fitting with Rigid Bodies',
     6058     '''Shows how to set up and refine with rigid bodies to simplify and improve the crystal structure model.'''],
     6060['Magnetic Structure Analysis'],
    60566061    ['SimpleMagnetic', 'SimpleMagnetic.htm',"Simple Magnetic Structure Analysis",
    60576062     '''Analysis of a simple antiferromagnet and a simple ferromagnet from CW neutron powder data'''],
    60726077     '''Analysis of a complex Type IV antiferromagnet with two propagation vectorse using Bilbao k-SUBGROUPSMAG from TOF neutron powder data'''],
    6074     ['Parametric sequential fitting'],
     6079['Parametric sequential fitting'],
    60756080    ['SeqRefine', 'SequentialTutorial.htm', 'Sequential refinement of multiple datasets',
    60766081     '''This shows the fitting of a structural model to multiple data sets collected as a function of temperature (7-300K).
    60856090      fitting of the result to get Hookes Law coefficients for elastic deformations.'''],
    6087     ['Structure solution'],
     6092['Structure solution'],
    60886093    ['FitPeaks', 'Fit Peaks.htm', 'Fitting individual peaks & autoindexing',
    60896094     '''This covers two examples of selecting individual powder diffraction peaks, fitting them and then
    61106115     via Monte Carlo/Simulated Annealing (MC/SA).'''],
    6112     ['Reverse Monte Carlo Modeling'],
     6117['Reverse Monte-Carlo Modeling'],
    61136118    ['RMCProfile-I', 'RMCProfile-I.htm','RMC Modeling with RMCProfile-I',
    61146119     '''Big box modelling for real and reciprocal space diffraction data for SF6'''],
    61206125     '''x-ray big box modelling with potential energy restraints for real and reciprocal space diffraction data for GaPO4'''],
    6122     ['Stacking Fault Modeling'],
     6127['Stacking Fault Modeling'],
    61236128    ['StackingFaults-I', 'Stacking Faults-I.htm', 'Stacking fault simulations for diamond',
    61246129     '''This shows how to simulate the diffraction patterns from faulted diamond.'''],
    61306135     '''This shows how to simulate some diffraction patterns from poorly ordered Georgia kaolinite (Al2Si2O5(OH)4) clay.'''],
    6132     ['Powder diffractometer calibration'],
     6137['Powder diffractometer calibration'],
    61336138    ['CWInstDemo', 'FindProfParamCW.htm',  'Determining Starting Profile Parameters from a Standard',
    61346139     '''This shows how to determine profile parameters by fitting individual peaks
    61476152     coefficients thus fully describing the instrument contribution to the peak profiles.''' ],
    6149     ['2D Image Processing'],
     6154['2D Image Processing'],
    61506155    ['2DCalibration', 'Calibration of an area detector in GSAS.htm', 'Calibration of an area detector',
    61516156     '''A demonstration of calibrating a Perkin-Elmer area detector,  where the detector was intentionally tilted at 45 degrees.
    61736178     for future reuse.'''],
    6175     ['Small-Angle Scattering'],       
     6180['Small-Angle Scattering'],       
    61766181    ['SAsize', 'Small Angle Size Distribution.htm', 'Small angle x-ray data size distribution (alumina powder)',
    61776182     '''This shows how to determine the size distribution of particles using data from a constant
    61896194     factor for non-dilute systems. '''],
    6191     ['Other'],   
    61926197    ['MerohedralTwins', 'Merohedral twin refinement in GSAS.htm', 'Merohedral twin refinements',
    61936198     '''This shows how to use GSAS-II to refine the structure of a few single crystal structures where there is merohedral twinning. '''],
  • trunk/

    r4622 r4624  
    33143314        '''Make sure the data tree has the minimally expected controls.
    33153315        '''
     3316        new = False
    33163317        if not GetGPXtreeItemId(self,self.root,'Notebook'):
     3318            new = True
    33173319            sub = self.GPXtree.AppendItem(parent=self.root,text='Notebook')
    33183320            self.GPXtree.SetItemPyData(sub,[''])
    33193321        if not GetGPXtreeItemId(self,self.root,'Controls'):
     3322            new = True
    33203323            sub = self.GPXtree.AppendItem(parent=self.root,text='Controls')
    33213324            self.GPXtree.SetItemPyData(sub,copy.copy(G2obj.DefaultControls))
    33223325        if not GetGPXtreeItemId(self,self.root,'Covariance'):
     3326            new = True
    33233327            sub = self.GPXtree.AppendItem(parent=self.root,text='Covariance')
    33243328            self.GPXtree.SetItemPyData(sub,{})
    33253329        if not GetGPXtreeItemId(self,self.root,'Constraints'):
     3330            new = True
    33263331            sub = self.GPXtree.AppendItem(parent=self.root,text='Constraints')
    33273332            self.GPXtree.SetItemPyData(sub,{'Hist':[],'HAP':[],'Phase':[]})
    33283333        if not GetGPXtreeItemId(self,self.root,'Restraints'):
     3334            new = True
    33293335            sub = self.GPXtree.AppendItem(parent=self.root,text='Restraints')
    33303336            self.GPXtree.SetItemPyData(sub,{})
    33313337        if not GetGPXtreeItemId(self,self.root,'Rigid bodies'):
     3338            new = True
    33323339            sub = self.GPXtree.AppendItem(parent=self.root,text='Rigid bodies')
    33333340            self.GPXtree.SetItemPyData(sub,{'Vector':{'AtInfo':{}},
    33343341                'Residue':{'AtInfo':{}},'RBIds':{'Vector':[],'Residue':[]}})
     3342        if new:
     3343            self.GPXtree.Expand(self.GPXtree.root)
    33363345    class CopyDialog(wx.Dialog):
    38163825            self.GPXtree.GetItemPyData(subr).update({PhaseName:{}})
    38173826        self.GPXtree.AppendItem(parent=subr,text=PhaseName)
    3818         sub = self.GPXtree.AppendItem(parent=sub,text=PhaseName)
     3827        newphase = self.GPXtree.AppendItem(parent=sub,text=PhaseName)
    38193828        E,SGData = G2spc.SpcGroup('P 1')
    3820         self.GPXtree.SetItemPyData(sub,G2obj.SetNewPhase(Name=PhaseName,SGData=SGData))
    3821         SelectDataTreeItem(self,sub) #bring up new phase General tab
     3829        self.GPXtree.SetItemPyData(newphase,G2obj.SetNewPhase(Name=PhaseName,SGData=SGData))
     3830        self.GPXtree.Expand(sub)
     3831        SelectDataTreeItem(self,newphase) #bring up new phase General tab
    38233833    def OnDeletePhase(self,event):
  • trunk/

    r4623 r4624  
    9855     def FillRigidBodyGrid(refresh=True):
     9855    def FillRigidBodyGrid(refresh=True,vecId=None,resId=None):
    98569856        '''Fill the Rigid Body Phase information tab page.
    98579857        Note that the page is a ScrolledWindow, not a Grid
    98739873            elif val == 'None':
    98749874                RBObj['ThermalMotion'][0] = 'None'
    9875             wx.CallAfter(FillRigidBodyGrid,True)
    98769875            if val != 'None':
    98779876                cia = data['General']['AtomPtrs'][3]
    98789877                for i,Id in enumerate(RBObj['Ids']):
    98799878                    data['Atoms'][AtLookUp[Id]][cia] = Ttype
     9879            resId,vecId = None,None
     9880            if resSelect:
     9881                resId = resSelect.GetSelection()
     9882            if select:
     9883                vecId = select.GetSelection()
     9884            wx.CallAfter(FillRigidBodyGrid,True,vecId=vecId,resId=resId)
    98809885            G2plt.PlotStructure(G2frame,data)
    99629967            maxMult = len(SGData['SGOps'])*len(SGData['SGCen'])
    99639968            if SGData['SGInv']: maxMult *= 2
     9969            rbSizer = wx.BoxSizer(wx.VERTICAL)
    99649970            topSizer = wx.FlexGridSizer(0,6,5,5)
    99659971            if type(RBObj['Orig'][0]) is tuple:      # patch because somehow adding RB origin is becoming a tuple
    999610002            Sytsym,Mult = G2spc.SytSym(rbObj['Orig'][0],SGData)[:2]
    999710003            sytsymtxt = wx.StaticText(RigidBodies,label='Origin site symmetry: %s, multiplicity: %d '%(Sytsym,Mult))
    9998             topSizer.Add(sytsymtxt)
    9999             return topSizer
     10004            rbSizer.Add(topSizer)
     10005            rbSizer.Add(sytsymtxt)
     10006            return rbSizer
    1000110008        def ResrbSizer(RBObj):
    1012210129        def OnResSelect(event):
    10123             rbId = select.GetSelection()
     10130            rbId = resSelect.GetSelection()
    1012410131            wx.CallLater(100,RepaintRBInfo,'Residue',rbId)
    1016810175        mainSizer = wx.BoxSizer(wx.VERTICAL)
    1016910176        nobody = True
     10177        resSelect = None
     10178        select = None
    1017010179        if 'Residue' in data['RBModels'] and len(data['RBModels']['Residue']):
    1017110180            nobody = False
    1017610185            for RBObj in data['RBModels']['Residue']:
    1017710186                RBnames.append(RBObj['RBname']+RBObj['numChain'])
    10178             rbName = RBnames[0]
    10179             rbObj = data['RBModels']['Residue'][0]
     10187            if resId is None:
     10188                resId = 0
     10189            rbName = RBnames[resId]
     10190            rbObj = data['RBModels']['Residue'][resId]
    1018010191            data['Drawing']['viewPoint'][0] = rbObj['Orig'][0]
    1018110192            data['Drawing']['Quaternion'] = rbObj['Orient'][0]
    10182             select = wx.ListBox(RigidBodies,choices=RBnames,style=wx.LB_SINGLE,size=(-1,120))
    10183             select.SetSelection(RBnames.index(rbName))
    10184             select.SetFirstItem(RBnames.index(rbName))
    10185             select.Bind(wx.EVT_LISTBOX,OnResSelect)
    10186             mainSizer.Add(select,0)
     10193            resSelect = wx.ListBox(RigidBodies,choices=RBnames,style=wx.LB_SINGLE,size=(-1,120))
     10194            resSelect.SetSelection(RBnames.index(rbName))
     10195            resSelect.SetFirstItem(RBnames.index(rbName))
     10196            resSelect.Bind(wx.EVT_LISTBOX,OnResSelect)
     10197            mainSizer.Add(resSelect,0)
    1018710198            G2frame.bottomSizer = wx.BoxSizer(wx.VERTICAL)
    1018810199            G2frame.bottomSizer.Add(ResrbSizer(rbObj))
    1019810209            for RBObj in data['RBModels']['Vector']:
    1019910210                RBnames.append(RBObj['RBname'])
    10200             rbName = RBnames[0]
    10201             rbObj = data['RBModels']['Vector'][0]
     10211            if vecId is None:
     10212                vecId = 0
     10213            rbName = RBnames[vecId]
     10214            rbObj = data['RBModels']['Vector'][vecId]
    1020210215            data['Drawing']['viewPoint'][0] = rbObj['Orig'][0]
    1020310216            data['Drawing']['Quaternion'] = rbObj['Orient'][0]
    1069010703            atNames = data['testRBObj']['atNames']
    1069110704            topSizer = wx.BoxSizer(wx.HORIZONTAL)
    10692             topSizer.Add(wx.StaticText(RigidBodies,label='Locating rigid body : '+rbName), 0, WACV)
     10705            helpText = '''
     10706This window is used to insert a rigid body into a unit cell, determining
     10707the initial settings for the position and orientation of the body,
     10708as well as any torsion angles. The origin
     10709determines where the origin of the rigid body will be placed in the
     10710unit cell (expressed in fractional coordinates).
     10711The orientation is determined by a quaternion
     10712that is expressed here as vector (in fraction coordinates) and an azimuthal
     10713rotation (in degrees) around that quaternion vector. For systems where symmetry
     10714dictates that the rigid body needs to be oriented in a particular direction,
     10715the rigid body coordinate system must be defined with the symmetry
     10716direction along the Cartesian x, y, z, x+y or x+y+z and this must be
     10717selected with the "Rigid body symmetry axis." This places the
     10718selected Cartesian axis along the quaternion vector.
     10720%%If there are atoms in the unit cell that are of the appropriate type and
     10721are not already assigned to rigid bodies, a table shows each
     10722atom in the rigid body and the closest atom unit cell atom, as well
     10723as the distance between them. This pairing can be set manually using the
     10724pulldown menu in the "Assign as atom" column, where a particular atom
     10725can be selected. One option is "create new" which means that that RB atom
     10726will not be paired to a unit cell atom. "Update Assignments" recomputes distance
     10727between paired atoms.
     10728Note that when a row in the table is selected, the corresponding atoms
     10729are highlighted in green. The tab key or the "Crystal Highlight" pulldown
     10730can be used to highlight differing unit cell atoms. Alt-Tab highlights different
     10731RB atoms.
     10732If at least one atom is paired manually using "Assign as", the
     10733"Set Origin" button can be used to place the rigid body origin to best fit
     10734the paired atom(s). Likewise, with two or more atoms assigned, the
     10735"Set Orientation" button will determine the quaternion azimuth and vector. Three
     10736or more pairs are assignments allow use of the "Set both" button, which
     10737sets the orientation and origin to best give the smallest distances between
     10738the assigned atoms.
     10739%%The GSAS-II graphics window shows the unit cell contents (use the
     10740"Ball & Sticks" or "Sticks" buttons to change the display of this) and
     10741the rigid body is shown with small balls and green sticks. At the origin of the
     10742RB the axes are indicated with red, green and blue lines (for x, y, & z).
     10743A white line indicates the quaternion vector direction.
     10744The mouse can also be used to position the rigid body in the plot by holding
     10745the Alt key down while dragging with the mouse: Alt+left button to rotates
     10746the RB in the screen x & y; Alt+middle mouse to rotates around the screen z
     10747(out of plane); Alt+right mouse translates the RB in the screen x-y plane.
     10748Note that dragging the mouse without the Alt button changes the view
     10749of the crystal structure.
     10750%%Once the rigid body has been placed in the desired position, press the "Add" button.
     10752            topSizer.Add(G2G.HelpButton(RigidBodies,helpText,wrap=700),
     10753                             0,wx.RIGHT,5)
     10754            topSizer.Add(wx.StaticText(RigidBodies,label='Locating rigid body: '+rbName), 0, WACV)
    1069310755            topSizer.Add((10,-1),0)
    1069410756            topSizer.Add(wx.StaticText(RigidBodies,label='Display crystal structure as:'), 0, WACV)
    1073610798                xmin=0.,xmax=360.,typeHint=float,OnLeave=UpdateOrientation))
    1073710799            OriSizer2.Add(OrientVecSiz[-1],0,WACV)
    10738             azSlide = wx.Slider(RigidBodies,style=wx.SL_HORIZONTAL,value=int(rbObj['OrientVec'][0]*10.),size=(200,25))
     10800            azSlide = wx.Slider(RigidBodies,style=wx.SL_HORIZONTAL,size=(200,25))
    1073910801            azSlide.SetRange(0,3600)
     10802            azSlide.SetValue(int(10*rbObj['OrientVec'][0]))
    1074010803            azSlide.Bind(wx.EVT_SLIDER, OnAzSlide)
    1074110804            OriSizer2.Add(azSlide,0,WACV)
  • trunk/

    r4622 r4624  
    425425        try:
    426426            Page = self.nb.GetPage(self.nb.GetSelection())
    427         except ValueError: # occurs with no plot tabs
     427        except: # occurs with no plot tabs
     428            event.Skip()
    428429            return
    429430        try:
Note: See TracChangeset for help on using the changeset viewer.