Changeset 5041
- Timestamp:
- Sep 30, 2021 8:12:56 AM (8 months ago)
- Location:
- trunk
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/GSASIIobj.py
r5038 r5041 1141 1141 CIFs prepared with the ISODISTORT web site 1142 1142 https://stokes.byu.edu/iso/isodistort_version5.6.1/isodistort.php 1143 [B. J. Campbell, H. T. Stokes, D. E. Tanner, and D. M. Hatch, "ISODISPLACE: An Internet Tool for Exploring Structural Distortions." J. Appl. Cryst. 39, 607-614 (2006).] 1144 can be read into GSAS-II using import CIF. This will cause constraints to be established for structural distortion modes read from the CIF. 1145 At present, of the five types of modes only displacive(``_iso_displacivemode``...) and occupancy (``_iso_occupancymode``...) are processed. Not yet processed: ``_iso_magneticmode``..., ``_iso_rotationalmode``... & ``_iso_strainmode``... 1146 1147 The CIF importer :mod:`G2phase_CIF` implements class :class:`G2phase_CIF.CIFPhaseReader` which offers two methods associated with ISODISTORT (ID) input. Method :meth:`G2phase_CIF.CIFPhaseReader.ISODISTORT_test` 1148 checks to see if a CIF block contains the loops with ``_iso_displacivemode_label`` or ``_iso_occupancymode_label`` items. 1149 If so, method :meth:`G2phase_CIF.CIFPhaseReader.ISODISTORT_proc` is called to read and interpret them. 1150 The results are placed into the reader object's ``.Phase`` class variable as a dict item with key ``'ISODISTORT'``. 1151 1152 Note that each mode ID has a long label with a name such as Pm-3m[1/2,1/2,1/2]R5+(a,a,0)[La:b:dsp]T1u(a). Function :func:`G2phase_CIF.ISODISTORT_shortLbl` is used to create a short name for this, 1153 such as R5_T1u(a) which is made unique by addition of _n if the short name is duplicated. 1154 As each mode is processed, a constraint corresponding to that mode is 1155 created and is added to list in the reader object's ``.Constraints`` class variable. Items placed into that list can either be a list, which corresponds to a function (new var) type :ref:`constraint definition <Constraints_table>` entry, or an item can be a dict, which provides help information for each constraint. 1143 [B. J. Campbell, H. T. Stokes, D. E. Tanner, and D. M. Hatch, "ISODISPLACE: An Internet Tool for Exploring Structural Distortions." 1144 J. Appl. Cryst. 39, 607-614 (2006).] can be read into GSAS-II using import CIF. This will cause constraints to be established for 1145 structural distortion modes read from the CIF. At present, of the five types of modes only displacive(``_iso_displacivemode``...) 1146 and occupancy (``_iso_occupancymode``...) are processed. Not yet processed: ``_iso_magneticmode``..., 1147 ``_iso_rotationalmode``... & ``_iso_strainmode``... 1148 1149 The CIF importer :mod:`G2phase_CIF` implements class :class:`G2phase_CIF.CIFPhaseReader` which offers two methods associated 1150 with ISODISTORT (ID) input. Method :meth:`G2phase_CIF.CIFPhaseReader.ISODISTORT_test` checks to see if a CIF block contains 1151 the loops with ``_iso_displacivemode_label`` or ``_iso_occupancymode_label`` items. If so, method 1152 :meth:`G2phase_CIF.CIFPhaseReader.ISODISTORT_proc` is called to read and interpret them. The results are placed into the 1153 reader object's ``.Phase`` class variable as a dict item with key ``'ISODISTORT'``. 1154 1155 Note that each mode ID has a long label with a name such as Pm-3m[1/2,1/2,1/2]R5+(a,a,0)[La:b:dsp]T1u(a). Function 1156 :func:`G2phase_CIF.ISODISTORT_shortLbl` is used to create a short name for this, such as R5_T1u(a) which is made unique 1157 by addition of _n if the short name is duplicated. As each mode is processed, a constraint corresponding to that mode is 1158 created and is added to list in the reader object's ``.Constraints`` class variable. Items placed into that list can either 1159 be a list, which corresponds to a function (new var) type :ref:`constraint definition <Constraints_table>` entry, or an item 1160 can be a dict, which provides help information for each constraint. 1156 1161 1157 1162 ------------------------------ … … 1159 1164 ------------------------------ 1160 1165 1161 The coordinate variables, as named by ISODISTORT, are placed in 1162 ``.Phase['ISODISTORT']['IsoVarList']`` and the corresponding :class:`GSASIIobj.G2VarObj` objects for each are placed in ``.Phase['ISODISTORT']['G2VarList']``. The mode variables, 1163 as named by ISODISTORT, are placed in ``.Phase['ISODISTORT']['IsoModeList']`` and the corresponding :class:`GSASIIobj.G2VarObj` objects for each are placed in ``.Phase['ISODISTORT']['G2ModeList']``. 1164 [Use ``str(G2VarObj)`` to get the variable name from the G2VarObj object, but note that the phase number, *n*, for the prefix "*n*::" cannot be determined as the phase number is not yet assigned.] 1165 1166 Displacive modes are a bit complex in that they relate to delta displacements, relative to an offset value for each coordinate, and because the modes are normalized, while GSAS-II also uses displacements, but these are added to the coordinates after each refinement cycle and the delta values are set to zero. ISODISTORT uses fixed offsets (subtracted from the actual position to obtain the delta values) that are taken from ``_iso_coordinate_formula`` and these are placed in ``.Phase['ISODISTORT']['ParentStructure]`` (keyed by atom label). The normalization factors (which the delta values are divided by) are taken from ``_iso_displacivemodenorm_value`` and are placed in ``.Phase['ISODISTORT']['NormList']`` in the same order as as ``...['IsoModeList']`` and 1167 ``...['G2ModeList']``. 1168 1169 The CIF contains a sparse matrix, from the ``loop_`` containing 1170 ``_iso_displacivemodematrix_value`` which provides the equations for determining the mode values from the coordinates, that matrix is placed in ``.Phase['ISODISTORT']['Mode2VarMatrix']``. The matrix is inverted to produce 1171 ``.Phase['ISODISTORT']['Var2ModeMatrix']``, which determines how to compute the 1172 mode values from the delta coordinate values. These values are used for the 1173 in :func:`GSASIIconstrGUI.ShowIsoDistortCalc` which shows coordinate and mode 1174 values, the latter with s.u. values. 1166 The coordinate variables, as named by ISODISTORT, are placed in ``.Phase['ISODISTORT']['IsoVarList']`` and the 1167 corresponding :class:`GSASIIobj.G2VarObj` objects for each are placed in ``.Phase['ISODISTORT']['G2VarList']``. 1168 The mode variables, as named by ISODISTORT, are placed in ``.Phase['ISODISTORT']['IsoModeList']`` and the 1169 corresponding :class:`GSASIIobj.G2VarObj` objects for each are placed in ``.Phase['ISODISTORT']['G2ModeList']``. 1170 [Use ``str(G2VarObj)`` to get the variable name from the G2VarObj object, but note that the phase number, *n*, for the prefix 1171 "*n*::" cannot be determined as the phase number is not yet assigned.] 1172 1173 Displacive modes are a bit complex in that they relate to delta displacements, relative to an offset value for each coordinate, 1174 and because the modes are normalized, while GSAS-II also uses displacements, but these are added to the coordinates after 1175 each refinement cycle and the delta values are set to zero. ISODISTORT uses fixed offsets (subtracted from the actual position 1176 to obtain the delta values) that are taken from ``_iso_coordinate_formula`` and these are placed in 1177 ``.Phase['ISODISTORT']['ParentStructure]`` (keyed by atom label). The normalization factors (which the delta values are divided by) 1178 are taken from ``_iso_displacivemodenorm_value`` and are placed in ``.Phase['ISODISTORT']['NormList']`` in the same order as as 1179 ``...['IsoModeList']`` and ``...['G2ModeList']``. 1180 1181 The CIF contains a sparse matrix, from the ``loop_`` containing ``_iso_displacivemodematrix_value`` which provides the equations 1182 for determining the mode values from the coordinates, that matrix is placed in ``.Phase['ISODISTORT']['Mode2VarMatrix']``. 1183 The matrix is inverted to produce ``.Phase['ISODISTORT']['Var2ModeMatrix']``, which determines how to compute the 1184 mode values from the delta coordinate values. These values are used for the in :func:`GSASIIconstrGUI.ShowIsoDistortCalc` 1185 which shows coordinate and mode values, the latter with s.u. values. 1175 1186 1176 1187 … … 1181 1192 1182 1193 The delta occupancy variables, as named by ISODISTORT, are placed in 1183 ``.Phase['ISODISTORT']['OccVarList']`` and the corresponding :class:`GSASIIobj.G2VarObj` objects for each are placed in ``.Phase['ISODISTORT']['G2OccVarList']``. The mode variables, as named by ISODISTORT, are placed in ``.Phase['ISODISTORT']['OccModeList']`` and the corresponding :class:`GSASIIobj.G2VarObj` objects for each are placed in ``.Phase['ISODISTORT']['G2OccModeList']``. 1184 1185 Occupancy modes, like Displacive modes, are also refined as delta values. However, GSAS-II directly refines the fractional occupancies. 1186 Offset values for each atom, are taken from ``_iso_occupancy_formula`` and are placed in 1187 ``.Phase['ISODISTORT']['ParentOcc]``. 1188 (Offset values are subtracted from the actual position to obtain the delta values.) 1189 Modes are normalized (where the mode values are divided by the normalization factor) 1190 are taken from ``_iso_occupancymodenorm_value`` and are placed in ``.Phase['ISODISTORT']['OccNormList']`` in the same order as as ``...['OccModeList']`` and 1194 ``.Phase['ISODISTORT']['OccVarList']`` and the corresponding :class:`GSASIIobj.G2VarObj` objects for each are placed 1195 in ``.Phase['ISODISTORT']['G2OccVarList']``. The mode variables, as named by ISODISTORT, are placed in 1196 ``.Phase['ISODISTORT']['OccModeList']`` and the corresponding :class:`GSASIIobj.G2VarObj` objects for each are placed 1197 in ``.Phase['ISODISTORT']['G2OccModeList']``. 1198 1199 Occupancy modes, like Displacive modes, are also refined as delta values. However, GSAS-II directly refines the fractional 1200 occupancies. Offset values for each atom, are taken from ``_iso_occupancy_formula`` and are placed in 1201 ``.Phase['ISODISTORT']['ParentOcc]``. (Offset values are subtracted from the actual position to obtain the delta values.) 1202 Modes are normalized (where the mode values are divided by the normalization factor) are taken from ``_iso_occupancymodenorm_value`` 1203 and are placed in ``.Phase['ISODISTORT']['OccNormList']`` in the same order as as ``...['OccModeList']`` and 1191 1204 ``...['G2OccModeList']``. 1192 1205 1193 The CIF contains a sparse matrix, from the ``loop_`` containing 1194 ``_iso_occupancymodematrix_value``, which provides the equations for determining the mode values from the coordinates. That matrix is placed in ``.Phase['ISODISTORT']['Occ2VarMatrix']``. The matrix is inverted to produce 1195 ``.Phase['ISODISTORT']['Var2OccMatrix']``, which determines how to compute the1206 The CIF contains a sparse matrix, from the ``loop_`` containing ``_iso_occupancymodematrix_value``, which provides the 1207 equations for determining the mode values from the coordinates. That matrix is placed in ``.Phase['ISODISTORT']['Occ2VarMatrix']``. 1208 The matrix is inverted to produce ``.Phase['ISODISTORT']['Var2OccMatrix']``, which determines how to compute the 1196 1209 mode values from the delta coordinate values. 1197 1210 … … 1201 1214 ------------------------------ 1202 1215 1203 Constraints are processed after the CIF has been read in 1204 :meth:`GSASIIdataGUI.GSASII.OnImportPhase` or 1205 :meth:`GSASIIscriptable.G2Project.add_phase` by moving them from the reader 1206 object's ``.Constraints`` class variable to 1207 the Constraints tree entry's ['Phase'] list (for list items defining constraints) or 1216 Constraints are processed after the CIF has been read in :meth:`GSASIIdataGUI.GSASII.OnImportPhase` or 1217 :meth:`GSASIIscriptable.G2Project.add_phase` by moving them from the reader object's ``.Constraints`` 1218 class variable to the Constraints tree entry's ['Phase'] list (for list items defining constraints) or 1208 1219 the Constraints tree entry's ['_Explain'] dict (for dict items defining constraint help information) 1209 1220 1210 The information in ``.Phase['ISODISTORT']`` is used 1211 in :func:`GSASIIconstrGUI.ShowIsoDistortCalc` which shows coordinate and mode 1221 The information in ``.Phase['ISODISTORT']`` is used in :func:`GSASIIconstrGUI.ShowIsoDistortCalc` which shows coordinate and mode 1212 1222 values, the latter with s.u. values. This can be called from the Constraints and Phase/Atoms tree items. 1213 1223 1214 Before each refinement, constraints are processed as 1215 :ref:`described elsewhere <Constraints_processing>`. After a refinement 1216 is complete, :func:`GSASIImapvars.PrintIndependentVars` shows the 1217 shifts and s.u.'s on the refined modes, using GSAS-II values, but 1218 :func:`GSASIIstrIO.PrintISOmodes` prints the ISODISTORT modes as computed 1219 in the web site. 1224 Before each refinement, constraints are processed as :ref:`described elsewhere <Constraints_processing>`. After a refinement 1225 is complete, :func:`GSASIImapvars.PrintIndependentVars` shows the shifts and s.u.'s on the refined modes, 1226 using GSAS-II values, but :func:`GSASIIstrIO.PrintISOmodes` prints the ISODISTORT modes as computed in the web site. 1220 1227 1221 1228 -
trunk/GSASIIphsGUI.py
r5037 r5041 4764 4764 pairSizer.Add(G2G.ValidatedTxtCtrl(pnl,RMCPdict['Pairs'][pair],0,xmin=0.,xmax=10.,size=(50,25)),0,WACV) 4765 4765 pairSizer.Add(wx.StaticText(pnl,label='%14s'%' Search from: '),0,WACV) 4766 el se:4766 elif G2frame.RMCchoice == 'fullrmc': 4767 4767 pairSizer.Add(wx.StaticText(pnl,label='%14s'%' Distance min: '),0,WACV) 4768 4768 for pair in RMCPdict['Pairs']: … … 4968 4968 mainSizer = wx.BoxSizer(wx.VERTICAL) 4969 4969 runFile = ' ' 4970 choice = ['RMCProfile','fullrmc', ]4970 choice = ['RMCProfile','fullrmc','PDFfit'] 4971 4971 RMCsel = wx.RadioBox(G2frame.FRMC,-1,' Select RMC method:',choices=choice) 4972 4972 RMCsel.SetStringSelection(G2frame.RMCchoice) … … 5289 5289 subSizer.Add(wx.StaticText(G2frame.FRMC,label='RMCProfile setup'),0,WACV) 5290 5290 subSizer.Add((-1,-1),1,wx.EXPAND) 5291 mainSizer.Add(subSizer,0, wx.EXPAND)5291 mainSizer.Add(subSizer,0,WACV) 5292 5292 mainSizer.Add((5,5)) 5293 5293 mainSizer.Add(wx.StaticText(G2frame.FRMC,label= … … 5737 5737 5738 5738 FileSizer(RMCPdict,mainSizer) 5739 5739 else: 5740 subSizer = wx.BoxSizer(wx.HORIZONTAL) 5741 subSizer.Add((-1,-1),1,wx.EXPAND) 5742 subSizer.Add(wx.StaticText(G2frame.FRMC,label='PDFfit setup'),0,WACV) 5743 subSizer.Add((-1,-1),1,wx.EXPAND) 5744 mainSizer.Add(subSizer,0,WACV) 5745 mainSizer.Add((5,5)) 5746 mainSizer.Add(wx.StaticText(G2frame.FRMC,label= 5747 '''"PDFfit2 and PDFgui: computer progerama for studying nanostructures in crystals", 5748 C.L. Farrow, P.Juhas, J.W. Liu, D. Bryndin, E.S. Bozin, J. Bloch, Th. Proffen && 5749 S.J.L. Billinge, J. Phys, Condens. Matter 19, 335219 (2007)., Jour. Phys.: Cond. Matter 5750 (2007), 19, 335218. doi: https://doi.org/10.1088/0953-8984/19/33/335219''')) 5751 mainSizer.Add((5,5)) 5752 if 'PDFfit' not in data['RMC']: 5753 Atypes = [atype.split('+')[0].split('-')[0] for atype in data['General']['AtomTypes']] 5754 aTypes = dict(zip(Atypes,len(Atypes)*[0.10,])) 5755 files = {'Neutron real space data; G(r): ':['Select',0.05,'G(r)','RMC',], 5756 'Xray real space data; G(r): ':['Select',0.01,'G(r)','RMC',],} 5757 data['RMC']['PDFfit'] = {'files':files} 5758 5759 RMCPdict = data['RMC']['PDFfit'] 5740 5760 bigSizer.Add(mainSizer,1,wx.EXPAND) 5741 # add help button to bring up help web page - at right s ede of window5761 # add help button to bring up help web page - at right side of window 5742 5762 bigSizer.Add(G2G.HelpButton(G2frame.FRMC,helpIndex=G2frame.dataWindow.helpKey)) 5743 5763 SetPhaseWindow(G2frame.FRMC,bigSizer) … … 5765 5785 rname = G2pwd.MakefullrmcRun(pName,data,RMCPdict) 5766 5786 print('build of fullrmc file {} completed'.format(rname)) 5767 el se:5787 elif G2frame.RMCchoice == 'RMCProfile': 5768 5788 pName = generalData['Name'].replace(' ','_') 5769 5789 G2frame.dataWindow.FRMCDataEdit.Enable(G2G.wxID_RUNRMC,True) … … 5808 5828 print('RMCProfile file build failed - no histogram selected') 5809 5829 G2frame.dataWindow.FRMCDataEdit.Enable(G2G.wxID_RUNRMC,False) 5830 elif G2frame.RMCchoice == 'PDFfit': 5831 print('PDFfit2 prep under construction') 5810 5832 5811 5833 def OnRunRMC(event): 5812 '''Run a previously created RMCProfile/fullrmc script5834 '''Run a previously created RMCProfile/fullrmc/PDFfit2 script 5813 5835 ''' 5814 5836 generalData = data['General'] … … 5892 5914 # TODO: better to create this in a new terminal on Linux 5893 5915 subp.Popen(['/bin/bash','fullrmc.sh']) 5894 el se:5916 elif G2frame.RMCchoice == 'RMCProfile': 5895 5917 pName = generalData['Name'].replace(' ','_') 5896 5918 RMCPdict = data['RMC']['RMCProfile'] … … 5947 5969 batch.close() 5948 5970 subp.Popen('runrmc.bat',creationflags=subp.CREATE_NEW_CONSOLE) 5971 elif G2frame.RMCchoice == 'PDFfit': 5972 PDFfit_exec = G2pwd.findPDFfit() 5973 if PDFfit_exec is None: 5974 G2G.G2MessageBox(G2frame,'PDFfit2 Python not found. How did we get here?') 5975 return 5976 pName = generalData['Name'].replace(' ','_') 5977 rname = pName+'_PDFfit.py' 5978 if not os.path.exists(rname): 5979 G2G.G2MessageBox(G2frame, 5980 'The PDFfit script has not been created. Running setup.', 5981 'Not setup') 5982 OnSetupRMC(event) 5983 wx.MessageBox(''' For use of PDFfit2, please cite: 5984 PDFfit2 and PDFgui: computer progerama for studying nanostructures in crystals, 5985 C.L. Farrow, P.Juhas, J.W. Liu, D. Bryndin, E.S. Bozin, J. Bloch, Th. Proffen & 5986 S.J.L. Billinge, J. Phys, Condens. Matter 19, 335219 (2007)., Jour. Phys.: Cond. Matter 5987 (2007), 19, 335218. doi: https://doi.org/10.1088/0953-8984/19/33/335219''', 5988 caption='PDFfit2',style=wx.ICON_INFORMATION) 5989 G2frame.OnFileSave(event) 5990 print (' GSAS-II project saved') 5991 if sys.platform.lower().startswith('win'): 5992 batch = open('pdffit2.bat','w') 5993 batch.write(PDFfit_exec+' '+rname+'\n') 5994 batch.write('pause') 5995 batch.close() 5996 subp.Popen('pdffit2.bat',creationflags=subp.CREATE_NEW_CONSOLE) 5997 else: 5998 batch = open('pdffit2.sh','w') 5999 batch.write('#!/bin/bash\n') 6000 batch.write('cd ' + os.path.split(os.path.abspath(rname))[0] + '\n') 6001 batch.write(PDFfit_exec + ' ' + os.path.abspath(rname) + '\n') 6002 batch.close() 6003 if sys.platform == "darwin": 6004 GSASIIpath.MacRunScript(os.path.abspath('pdffit2.sh')) 6005 else: 6006 # TODO: better to create this in a new terminal on Linux 6007 subp.Popen(['/bin/bash','pdffit2.sh']) 5949 6008 5950 6009 def OnStopRMC(event): … … 6061 6120 lines=True,names=plotLbls) 6062 6121 return 6063 el se:6122 elif G2frame.RMCchoice == 'RMCProfile': 6064 6123 generalData = data['General'] 6065 6124 RMCPdict = data['RMC']['RMCProfile'] … … 6321 6380 newPlot=False,Title='Number of %s-%s Bonds'%(bond[0],bond[1]),Centro=True) 6322 6381 OutFile.close() 6382 elif G2frame.RMCchoice == 'PDFfit': 6383 generalData = data['General'] 6384 RMCPdict = data['RMC']['PDFfit'] 6385 pName = generalData['Name'].replace(' ','_') 6386 print('PDFfit plots under construction') 6323 6387 6324 6388 -
trunk/GSASIIpwd.py
r5037 r5041 2927 2927 return os.path.abspath(sorted(fl)[0]) 2928 2928 2929 def findPDFfit(): 2930 '''Find where PDFfit2 is installed. Does the following: 2931 :returns: the full path to a python executable that is assumed to 2932 have PDFfit2 installed or None, if it was not found. 2933 ''' 2934 try: 2935 import diffpy.pdffit2 2936 return sys.executable 2937 except: 2938 return None 2939 2929 2940 def MakefullrmcRun(pName,Phase,RMCPdict): 2930 2941 '''Creates a script to run fullrmc. Returns the name of the file that was
Note: See TracChangeset
for help on using the changeset viewer.