Skip to content

Commit d2db3b9

Browse files
committed
Merge remote-tracking branch 'origin/main' into TOFgroup
2 parents f9e6ed3 + ed01419 commit d2db3b9

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

56 files changed

+199
-136
lines changed

.notes/.linenoteplus

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
# The location of this `.linenoteplus` file determines
2+
# the path to store and retrieve your notes.
3+
4+
# To relocate your notes, simply move or rename
5+
# the directory that contains this `.linenoteplus` file.

GSASII/GSASIIpath.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2160,6 +2160,15 @@ def openInNewTerm(project=None,g2script=None,pythonapp=sys.executable):
21602160
lastver = sorted([t for t in taglist if 'v' in t])[-1]
21612161
lastnum = sorted([t for t in taglist if 'v' not in t],key=int)[-1]
21622162
#print('tags=',lastver,lastnum)
2163+
# make directory for config file if needed
2164+
localdir = os.path.expanduser(os.path.normpath('~/.GSASII'))
2165+
if not os.path.exists(localdir):
2166+
try:
2167+
os.mkdir(localdir)
2168+
print(f'Created directory {localdir}')
2169+
except Exception as msg:
2170+
print(f'Error trying to create directory {localdir}\n{msg}')
2171+
sys.exit()
21632172
# add tag info to config file
21642173
import configparser
21652174
cfgfile = os.path.expanduser(os.path.normpath('~/.GSASII/config.ini'))

GSASII/GSASIIphsGUI.py

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6388,8 +6388,12 @@ def RunRMCProfile(event):
63886388
ascript_file = os.path.join(os.getcwd(), "runrmc.script")
63896389
with open(ascript_file, 'w') as f:
63906390
f.write('tell application "Terminal"\n')
6391-
f.write(f''' do script "echo 'Running RMCprofile'"\n''')
6391+
f.write(' if not (exists window 1) then\n')
6392+
f.write(f' do script "bash {script_file}"\n')
6393+
f.write(' else\n')
63926394
f.write(f' do script "bash {script_file}" in window 1\n')
6395+
f.write(' end if\n')
6396+
f.write(' activate\n')
63936397
f.write("end tell\n")
63946398
subp.Popen(['osascript', ascript_file])
63956399
elif sys.platform.startswith("linux"):
@@ -6607,8 +6611,12 @@ def OnViewRMC(event):
66076611
generalData = data['General']
66086612
RMCPdict = data['RMC']['RMCProfile']
66096613
pName = generalData['Name'].replace(' ','_')
6614+
if sys.platform == "darwin":
6615+
wildcard = 'RMCProfile result csv files|' + pName + '*.csv' + '|All files|*.*'
6616+
else:
6617+
wildcard = 'RMCProfile result csv files|' + pName + '*.csv'
66106618
dlg = wx.FileDialog(G2frame, "Choose any RMCProfile csv results file for "+pName+":",
6611-
defaultDir=G2frame.LastGPXdir,style=wx.FD_CHANGE_DIR,wildcard='RMCProfile result csv files|'+pName+'*.csv')
6619+
defaultDir=G2frame.LastGPXdir,style=wx.FD_CHANGE_DIR,wildcard=wildcard)
66126620
if dlg.ShowModal() == wx.ID_OK:
66136621
path = os.path.split(dlg.GetPath())[0]
66146622
dlg.Destroy()
@@ -6631,8 +6639,9 @@ def OnViewRMC(event):
66316639
'_SQ1partials.csv':[],'_SQ2partials.csv':[],'_FQ1.csv':[],'_FT_XFQ1.csv':[],
66326640
'_FQ1partials.csv':[],'_bragg.csv':[],'.chi2':[]}
66336641
for item in files:
6634-
if os.path.exists(os.path.join(path,pName+item)):
6635-
OutFile = open(pName+item,'r')
6642+
fileName = os.path.join(path,pName+item)
6643+
if os.path.exists(fileName):
6644+
OutFile = open(fileName,'r')
66366645
files[item] = OutFile.readlines()
66376646
OutFile.close()
66386647
print('RMCProfile file %s read'%(pName+item))
@@ -9094,7 +9103,7 @@ def SelDeformAtom(event):
90949103
# orbDict.update(cofTerms)
90959104
# orbDict.update({'Ne':[float(orbs[orb]['Ne']),False]})
90969105
# data['Deformations'][Ids[indx]].append([orb,orbDict])
9097-
data['Deformations'][-Ids[indx]] = {'U':'X','V':'Y','UVmat':np.eye(3),
9106+
data['Deformations'][-Ids[indx]] = {'U':'X','V':'Y','UVmat':np.eye(3),'PtGrp':'1',
90989107
'MUV':"A: X'=U, Y'=(UxV)xU & Z'=UxV",'Radial':radial,'fxchoice':fxchoice}
90999108
dlg.Destroy()
91009109
if not len(indxes):

GSASII/GSASIIphsGUI2.py

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -314,8 +314,9 @@ def NeSizer(deformation,orbSizer,dId,orb,Indx):
314314
Indx[Tcheck.GetId()] = [dId,iorb,'Ne']
315315
orbSizer.Add(Tcheck)
316316

317-
def Dsizer(deformation,orbSizer,dId,orb,Indx):
318-
orbSizer.Add(wx.StaticText(deformation,label=item+':'))
317+
def Dsizer(deformation,orbSizer,Names,dId,orb,Indx):
318+
name = Names.get(item,'') #Names only go to order = 3
319+
orbSizer.Add(wx.StaticText(deformation,label=item+name+':'))
319320
orbSizer.Add(G2G.ValidatedTxtCtrl(deformation,orb[1][item],0,nDig=(8,5),xmin=-1.,xmax=1.))
320321
Tcheck = wx.CheckBox(deformation,-1,'Refine?')
321322
Tcheck.SetValue(orb[1][item][1])
@@ -506,6 +507,10 @@ def OnAtCol(event):
506507
oriSizer.Add(delHarm,0,WACV)
507508
mainSizer.Add(oriSizer)
508509
G2G.HorizontalLine(mainSizer,deformation)
510+
Names = {'D(1,-1)':'px','D(1,0)':'pz','D(1,1)':'py',
511+
'D(2,-2)':'dxy','D(2,-1)':'dxz','D(2,0)':'dz2','D(2,1)':'dyz','D(2,2)':'dx2-y2',
512+
'D(3,-3)':'fy(3x2-y2)','D(3,-2)':'fz(x2-y2)','D(3,-1':'fyz2','D(3,0)':'fz3',
513+
'D(3,1)':'fxz2','D(3,2)':'fxyz','D(3,3)':'fy(3x2-y2)',}
509514
mainSizer.Add(wx.StaticText(deformation,label=' Deformation parameters:'))
510515
orbSizer = wx.FlexGridSizer(0,9,2,2)
511516
for iorb,orb in enumerate(deformationData[dId]):
@@ -529,7 +534,7 @@ def OnAtCol(event):
529534
for item in orb[1]:
530535
if 'D' in item:
531536
nItem += 1
532-
Dsizer(deformation,orbSizer,dId,orb,Indx)
537+
Dsizer(deformation,orbSizer,Names,dId,orb,Indx)
533538
if nItem in [2,4,6,8,10]:
534539
for i in range(3): orbSizer.Add((5,5),0)
535540
for i in range(3): orbSizer.Add((5,5),0)
@@ -551,7 +556,7 @@ def OnAtCol(event):
551556
if nItems:
552557
nB = 9-nItems
553558
for i in range(nB): orbSizer.Add((5,5),0)
554-
Dsizer(deformation,orbSizer,dId,orb,Indx)
559+
Dsizer(deformation,orbSizer,Names,dId,orb,Indx)
555560
mainSizer.Add(orbSizer)
556561

557562
G2phsG.SetPhaseWindow(deformation,mainSizer)

GSASII/GSASIIplot.py

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3523,8 +3523,8 @@ def PlotDeform(G2frame,general,atName,atType,deform,UVmat,radial,neigh):
35233523
RAP = G2mth.Cart2Polar(XYZ[0],XYZ[1],XYZ[2])
35243524
P = np.zeros((31,31))
35253525
for shc in SHC:
3526-
p = 2.*SHC[shc][0]*SHC[shc][2]**3*G2lat.KslCalc(shc,RAP[1],RAP[2]).reshape((31,31))
3527-
P += p**2
3526+
p = 2.*SHC[shc][0]*SHC[shc][2]**3*(G2lat.KslCalc(shc,RAP[1],RAP[2])**2).reshape((31,31))
3527+
P += p
35283528
if not np.any(P):
35293529
P = np.ones((31,31))
35303530
# P *= P
@@ -7351,22 +7351,23 @@ def Draw(caller='',Fade=[],NPkey=False):
73517351
#### put deformation texture on sphere here
73527352
if atom[ci] in deformationData:
73537353
defCtrls = deformationData[-atom[ci]]
7354-
defParms = deformationData[atom[ci]]
7355-
SytSym = G2spc.SytSym(atom[cx:cx+3],SGData)[0]
73567354
if defCtrls.get('showDef',False) and defCtrls['Radial'] == 'Slater':
73577355
useAtColor = defCtrls.get('atColor',True)
73587356
atcolor = None
73597357
if useAtColor:
73607358
atcolor = atColor*255
7359+
defParms = deformationData[atom[ci]]
7360+
SytSym = G2spc.SytSym(atom[cx:cx+3],SGData)[0]
7361+
SGM = np.array(G2spc.GetOpFromCode(atom[cs-1],SGData)[0])
73617362
SHC = defParms[0][1]
73627363
SHC = {item.replace('D','C'):SHC[item] for item in SHC if item not in ['Ne','kappa']}
7363-
UVMat = defCtrls['UVmat']
7364+
UVMat = np.inner(defCtrls['UVmat'],SGM)
73647365
Npsi,Ngam = 90,45
73657366
PSI,GAM = np.mgrid[0:Npsi,0:Ngam] #[azm,pol]
7366-
PSI = PSI.flatten()*360./Npsi #azimuth 0-360 ncl
7367+
PSI = PSI.flatten()*360./Npsi #azimuth 0-360 incl
73677368
GAM = GAM.flatten()*180./Ngam #polar 0-180 incl
7368-
Rp,PSIp,GAMp = G2mth.RotPolbyM(np.ones_like(PSI),PSI,GAM,UVMat)
7369-
P = G2lat.SHarmcal(SytSym,SHC,PSIp,GAMp).reshape((Npsi,Ngam))
7369+
Rp,PSIp,GAMp = G2mth.RotPolbyM(np.ones_like(PSI),PSI,GAM,UVMat) #TODO: needs symmetry operation for equiv. positions
7370+
P = G2lat.SHarmcal(SytSym,SHC,PSIp,GAMp).reshape((Npsi,Ngam))**2
73707371
if np.min(P) < np.max(P):
73717372
P = (P-np.min(P))/(np.max(P)-np.min(P))
73727373
RenderTextureSphere(x,y,z,radius,atcolor,shape=[Npsi,Ngam],Texture=P.T,ifFade=False)

GSASII/GSASIIpwd.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3431,7 +3431,7 @@ def MakeRMCPdat(PWDdata,Name,Phase,RMCPdict):
34313431
dMin = refList[-1][4]
34323432
gsasType = 'xray2'
34333433
if 'T' in inst['Type'][1]:
3434-
gsasType = 'gsas3'
3434+
gsasType = 'gsas3_new'
34353435
elif 'X' in inst['Type'][1]:
34363436
XFF = G2elem.GetFFtable(Atseq)
34373437
Xfl = open(Name+'.xray','w')

GSASII/GSASIIrmcGUI.py

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -226,13 +226,14 @@ def OnFileSel(event):
226226
style=wx.FD_OPEN ,wildcard=fil+'(*.*)|*.*')
227227
if dlg.ShowModal() == wx.ID_OK:
228228
fpath,fName = os.path.split(dlg.GetPath())
229-
if os.path.exists(fName): # is there a file by this name in the current directory?
229+
if os.path.exists(os.path.join(G2frame.LastGPXdir,fName)): # is there a file by this name in the current directory?
230230
RMCPdict['files'][fil][0] = fName
231231
else: # nope, copy it
232232
# TODO: is G2frame.LastGPXdir the right choice here or
233233
# do I want the current working directory (same?)
234234
shutil.copy(dlg.GetPath(), os.path.join(G2frame.LastGPXdir,fName))
235-
if not os.path.exists(fName): # sanity check
235+
RMCPdict['files'][fil][0] = fName
236+
if not os.path.exists(os.path.join(G2frame.LastGPXdir,fName)): # sanity check
236237
print(f'Error: file {fName} not found in .gpx directory ({G2frame.LastGPXdir})')
237238
return
238239
G2frame.LastImportDir = fpath #set so next file is found in same place
@@ -260,7 +261,10 @@ def OnFileSel(event):
260261
def OnFileFormat(event):
261262
Obj = event.GetEventObject()
262263
fil = Indx[Obj.GetId()]
263-
RMCPdict['files'][fil][3] = Obj.GetStringSelection()
264+
Fmt = Obj.GetStringSelection()
265+
RMCPdict['files'][fil][3] = Fmt
266+
if 'PDF' in Fmt:
267+
RMCPdict['files'][fil][2] = 'G(r)P'
264268

265269
def OnPlotBtn(event):
266270
Obj = event.GetEventObject()
@@ -270,7 +274,7 @@ def OnPlotBtn(event):
270274
XY = np.empty((1,2))
271275
while XY.shape[0] == 1:
272276
try:
273-
XY = np.loadtxt(fileItem[0],skiprows=start)
277+
XY = np.loadtxt(os.path.join(G2frame.LastGPXdir,fileItem[0]),skiprows=start)
274278
except ValueError:
275279
start += 1
276280
if start > 500: #absurd number of header lines!
@@ -345,7 +349,7 @@ def OnSeqReverse(event):
345349
mainSizer.Add(topSizer)
346350
Heads = ['Name','File','type','Plot','Delete']
347351
fileSizer = wx.FlexGridSizer(5,5,5)
348-
Formats = ['RMC','GUDRUN','STOG']
352+
Formats = ['RMC','GUDRUN','STOG','PDFGET']
349353
for head in Heads:
350354
fileSizer.Add(wx.StaticText(G2frame.FRMC,label=head),0,WACV)
351355
for fil in RMCPdict['files']:
@@ -411,7 +415,7 @@ def OnSeqReverse(event):
411415
if G2frame.RMCchoice == 'PDFfit' and RMCPdict['refinement'] == 'sequential':
412416

413417
def OnAddPDF(event):
414-
''' Add PDF G(r)s while maintanining original sequence
418+
''' Add PDF G(r)s while maintaining original sequence
415419
'''
416420
usedList = RMCPdict['seqfiles']
417421
PDFlist = [item[1:][0] for item in G2frame.GetFileList('PDF')]
@@ -534,7 +538,7 @@ def OnSetVal(event):
534538
# RMCProfile & PDFfit (Normal)
535539
Heads = ['Name','File','Format','Weight','Plot','Delete']
536540
fileSizer = wx.FlexGridSizer(6,5,5)
537-
Formats = ['RMC','GUDRUN','STOG']
541+
Formats = ['RMC','GUDRUN','STOG','PDFGET']
538542
for head in Heads:
539543
fileSizer.Add(wx.StaticText(G2frame.FRMC,label=head),0,WACV)
540544
for fil in RMCPdict['files']:
@@ -547,11 +551,13 @@ def OnSetVal(event):
547551
Indx[filSel.GetId()] = fil
548552
fileSizer.Add(filSel,0,WACV)
549553
nform = 3
554+
if 'G(r)' in fil:
555+
nform = 4
550556
Name = 'Ndata'
551557
if 'Xray' in fil:
552558
nform = 1
553559
Name = 'Xdata'
554-
if Rfile and os.path.exists(Rfile): #incase .gpx file is moved away from G(R), F(Q), etc. files
560+
if Rfile and os.path.exists(os.path.join(G2frame.LastGPXdir,Rfile)): #incase .gpx file is moved away from G(R), F(Q), etc. files
555561
fileFormat = wx.ComboBox(G2frame.FRMC,choices=Formats[:nform],style=wx.CB_DROPDOWN|wx.TE_READONLY)
556562
fileFormat.SetStringSelection(RMCPdict['files'][fil][3])
557563
Indx[fileFormat.GetId()] = fil

GSASII/GSASIIspc.py

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1459,6 +1459,26 @@ def GetOpNum(Opr,SGData):
14591459
opNum += cent*Nops
14601460
return opNum
14611461

1462+
def GetOpFromCode(Code,SGData):
1463+
"takes Sym Op code from Draw Atoms table & returns space group operation details"
1464+
SGOps = SGData['SGOps']
1465+
SGCent = SGData['SGCen']
1466+
if '+' not in Code:
1467+
SymOp = Code
1468+
Unit = '(0,0,0)'
1469+
else:
1470+
SymOp,Unit = Code.split('+')
1471+
SymOp = int(SymOp)
1472+
opNum = abs(SymOp)%100-1
1473+
cent = abs(opNum)//100
1474+
Unit = list(eval(Unit))
1475+
Cent = SGCent[cent]
1476+
SGM,SGT = SGOps[opNum]
1477+
if SymOp < 0:
1478+
SGM *= -1
1479+
SGT *= -1
1480+
return SGM,SGT,Cent,Unit
1481+
14621482
################################################################################
14631483
#### Superspace group codes
14641484
################################################################################

GSASII/GSASIIstrMath.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -437,7 +437,7 @@ def MakeSpHarmFF(HKL,Amat,Bmat,SHCdict,Tdata,hType,FFtables,ORBtables,BLtables,F
437437
:param str hType: histogram type
438438
:param dict FFtables: x-ray form factor tables
439439
:param dict ORBtables: x-ray orbital form factor tables
440-
:param dict BLtables: neutron scattering lenghts
440+
:param dict BLtables: neutron scattering lengths
441441
:param array FF: form factors - will be modified by adding the spin/deformation RB spherical harmonics terms
442442
:param array SQ: 1/4d^2 for the HKL set
443443
:param bool ifDeriv: True if dFF/dcoff to be returned
@@ -580,7 +580,7 @@ def MakePolar(Orient,QB):
580580
for term in orbs[orb]:
581581
if 'D(' in term:
582582
item = term.replace('D','C')
583-
SH = G2lat.KslCalc(item,Th,Ph)
583+
SH = G2lat.KslCalc(item,Th,Ph)**2
584584
FFval += SH*orbs[orb][term]*ff
585585
name = 'A%s%s:%d'%(term,orb,iAt)
586586
dFFdS[name] = SH*ff
@@ -597,7 +597,7 @@ def MakePolar(Orient,QB):
597597
for term in orbs[orb]:
598598
if 'D(' in term: #skip 'Ne'
599599
item = term.replace('D','C')
600-
SH = G2lat.KslCalc(item,Th,Ph)
600+
SH = G2lat.KslCalc(item,Th,Ph)**2
601601
FFval += SH*orbs[orb][term]*ff
602602
name = 'A%s%s:%d'%(term,orb,iAt)
603603
dFFdS[name] = SH*ff

GSASII/exports/G2export_PDB.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -277,7 +277,7 @@ def Exporter(self,event=None):
277277
A,B = G2lat.cell2AB(Cell)
278278
self.Write('# GSAS-II generated ORCA input file\n# Basic Mode')
279279
self.Write('#%Sym SymThresh 0.01 End')
280-
self.Write('# after xyz is charge & multiplicity; change as needed')
280+
self.Write('# after xyz is charge & multiplicity; change as needed for ions')
281281
self.Write('* xyz 0 1')
282282
fmt = '{:4s}'+3*'{:12.4f}'
283283
for atom in Atoms:

0 commit comments

Comments
 (0)