Skip to content

Commit 467baed

Browse files
committed
work on Bilbao self-test, to be run independently
1 parent afaae67 commit 467baed

File tree

2 files changed

+62
-32
lines changed

2 files changed

+62
-32
lines changed

.github/workflows/bilbao-test.yml

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
name: Bilbao Test
2+
3+
on:
4+
schedule:
5+
# Run weekly on Mondays at 5:00 AM UTC
6+
- cron: '0 5 * * 1'
7+
workflow_dispatch:
8+
9+
# Default to bash
10+
defaults:
11+
run:
12+
shell: bash
13+
14+
jobs:
15+
test:
16+
runs-on: ubuntu-latest
17+
18+
steps:
19+
- uses: actions/checkout@v4
20+
21+
- name: set up pixi
22+
uses: prefix-dev/[email protected]
23+
with:
24+
environments: ${{ matrix.env }}
25+
pixi-version: v0.39.5
26+
manifest-path: pixi/pixi.toml
27+
28+
- name: test
29+
run: |
30+
cd tests
31+
pixi run --manifest-path ../pixi/pixi.toml python -m pytest run_bilbao.py

GSASII/SUBGROUPS.py

Lines changed: 31 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -829,38 +829,37 @@ def createStdSetting(cifFile,rd):
829829
if not os.path.exists(cifFile):
830830
print(f'createStdSetting error: file {cifFile} not found')
831831
return False
832-
fil = open(cifFile,'rb')
833-
files = {'cifile': fil}
834-
values = {'strtidy':''}
835-
print(f'''Submitting structure to Bilbao "CIF to Standard Setting" (strtidy)
836-
web service. Please cite:
837-
{G2G.GetCite('Bilbao: PSEUDOLATTICE',wrap=70,indent=5)}''')
838-
r0 = requests.post(bilbaoSite+cif2std, files=files, data=values)
839-
structure = r0.text[r0.text.lower().find('<pre>')+5:r0.text.lower().find('</pre>')].strip()
840-
spnum,celllist,natom = structure.split('\n')[:3]
841-
#spgNam = G2spc.spgbyNum[int(spnum)]
842-
cell = [float(i) for i in celllist.split()]
843-
# replace cell, space group and atom info with info from Bilbao
844-
# could try to xfer Uiso (Uij needs xform), but that would be too involved
845-
rd.Phase['General']['SGData'] = SGData = G2spc.SpcGroup(G2spc.spgbyNum[int(spnum)])[1]
846-
rd.Phase['General']['Cell'] = [False] + list(cell) + [G2lat.calc_V(G2lat.cell2A(cell))]
847-
rd.Phase['Atoms'] = []
848-
for i,line in enumerate(structure.split('\n')[3:]):
849-
atomlist = ['','Xe','',0.,0.,0.,1.0,'',0.,'I',0.01, 0.,0.,0.,0.,0.,0.,]
850-
elem,lbl,wyc,x,y,z = line.split()
851-
elem = elem.rstrip('0123456789-+')
852-
atomlist[0] = elem + lbl
853-
if G2elem.CheckElement(elem):
854-
atomlist[1] = elem
855-
atomlist[3:6] = [float(i) for i in (x,y,z)]
856-
atomlist[7],atomlist[8] = G2spc.SytSym(atomlist[3:6],SGData)[:2]
857-
atomlist[1] = G2elem.FixValence(atomlist[1])
858-
859-
atomlist.append(ran.randint(0,sys.maxsize)) # add a random Id
860-
rd.Phase['Atoms'].append(atomlist)
861-
if i == int(natom)-1: break
862-
del rd.SymOps['xyz'] # as-read sym ops now obsolete
863-
fil.close()
832+
with open(cifFile,'rb') as fil:
833+
files = {'cifile': fil}
834+
values = {'strtidy':''}
835+
print(f'''Submitting structure to Bilbao "CIF to Standard Setting" (strtidy)
836+
web service. Please cite:
837+
{G2G.GetCite('Bilbao: PSEUDOLATTICE',wrap=70,indent=5)}''')
838+
r0 = requests.post(bilbaoSite+cif2std, files=files, data=values)
839+
structure = r0.text[r0.text.lower().find('<pre>')+5:r0.text.lower().find('</pre>')].strip()
840+
spnum,celllist,natom = structure.split('\n')[:3]
841+
#spgNam = G2spc.spgbyNum[int(spnum)]
842+
cell = [float(i) for i in celllist.split()]
843+
# replace cell, space group and atom info with info from Bilbao
844+
# could try to xfer Uiso (Uij needs xform), but that would be too involved
845+
rd.Phase['General']['SGData'] = SGData = G2spc.SpcGroup(G2spc.spgbyNum[int(spnum)])[1]
846+
rd.Phase['General']['Cell'] = [False] + list(cell) + [G2lat.calc_V(G2lat.cell2A(cell))]
847+
rd.Phase['Atoms'] = []
848+
for i,line in enumerate(structure.split('\n')[3:]):
849+
atomlist = ['','Xe','',0.,0.,0.,1.0,'',0.,'I',0.01, 0.,0.,0.,0.,0.,0.,]
850+
elem,lbl,wyc,x,y,z = line.split()
851+
elem = elem.rstrip('0123456789-+')
852+
atomlist[0] = elem + lbl
853+
if G2elem.CheckElement(elem):
854+
atomlist[1] = elem
855+
atomlist[3:6] = [float(i) for i in (x,y,z)]
856+
atomlist[7],atomlist[8] = G2spc.SytSym(atomlist[3:6],SGData)[:2]
857+
atomlist[1] = G2elem.FixValence(atomlist[1])
858+
859+
atomlist.append(ran.randint(0,sys.maxsize)) # add a random Id
860+
rd.Phase['Atoms'].append(atomlist)
861+
if i == int(natom)-1: break
862+
del rd.SymOps['xyz'] # as-read sym ops now obsolete
864863

865864
#if __name__ == '__main__':
866865
# Note that self-tests have been moved to file ``tests/run_bilbao.py``.

0 commit comments

Comments
 (0)