@@ -3005,361 +3005,3 @@ def textureIndex(SHCoef):
30053005
30063006cellUlbl = ('a' ,'b' ,'c' ,u'\u03B1 ' ,u'\u03B2 ' ,u'\u03B3 ' )
30073007'unicode labels for a, b, c, alpha, beta, gamma'
3008-
3009- # self-test materials follow.
3010- selftestlist = []
3011- '''Defines a list of self-tests'''
3012- selftestquiet = True
3013- def _ReportTest ():
3014- 'Report name and doc string of current routine when ``selftestquiet`` is False'
3015- if not selftestquiet :
3016- import inspect
3017- caller = inspect .stack ()[1 ][3 ]
3018- doc = eval (caller ).__doc__
3019- if doc is not None :
3020- print ('testing ' + __file__ + ' with ' + caller + ' (' + doc + ')' )
3021- else :
3022- print ('testing ' + __file__ ()+ " with " + caller )
3023- NeedTestData = True
3024- def TestData ():
3025- array = np .array
3026- global NeedTestData
3027- NeedTestData = False
3028- global CellTestData
3029- # output from uctbx computed on platform darwin on 2010-05-28
3030- CellTestData = [
3031- # cell, g, G, cell*, V, V*
3032- [(4 , 4 , 4 , 90 , 90 , 90 ),
3033- array ([[ 1.60000000e+01 , 9.79717439e-16 , 9.79717439e-16 ],
3034- [ 9.79717439e-16 , 1.60000000e+01 , 9.79717439e-16 ],
3035- [ 9.79717439e-16 , 9.79717439e-16 , 1.60000000e+01 ]]), array ([[ 6.25000000e-02 , 3.82702125e-18 , 3.82702125e-18 ],
3036- [ 3.82702125e-18 , 6.25000000e-02 , 3.82702125e-18 ],
3037- [ 3.82702125e-18 , 3.82702125e-18 , 6.25000000e-02 ]]), (0.25 , 0.25 , 0.25 , 90.0 , 90.0 , 90.0 ), 64.0 , 0.015625 ],
3038- # cell, g, G, cell*, V, V*
3039- [(4.0999999999999996 , 5.2000000000000002 , 6.2999999999999998 , 100 , 80 , 130 ),
3040- array ([[ 16.81 , - 13.70423184 , 4.48533243 ],
3041- [- 13.70423184 , 27.04 , - 5.6887143 ],
3042- [ 4.48533243 , - 5.6887143 , 39.69 ]]), array ([[ 0.10206349 , 0.05083339 , - 0.00424823 ],
3043- [ 0.05083339 , 0.06344997 , 0.00334956 ],
3044- [- 0.00424823 , 0.00334956 , 0.02615544 ]]), (0.31947376387537696 , 0.25189277536327803 , 0.16172643497798223 , 85.283666420376008 , 94.716333579624006 , 50.825714168082683 ), 100.98576357983838 , 0.0099023858863968445 ],
3045- # cell, g, G, cell*, V, V*
3046- [(3.5 , 3.5 , 6 , 90 , 90 , 120 ),
3047- array ([[ 1.22500000e+01 , - 6.12500000e+00 , 1.28587914e-15 ],
3048- [ - 6.12500000e+00 , 1.22500000e+01 , 1.28587914e-15 ],
3049- [ 1.28587914e-15 , 1.28587914e-15 , 3.60000000e+01 ]]), array ([[ 1.08843537e-01 , 5.44217687e-02 , 3.36690552e-18 ],
3050- [ 5.44217687e-02 , 1.08843537e-01 , 3.36690552e-18 ],
3051- [ 3.36690552e-18 , 3.36690552e-18 , 2.77777778e-02 ]]), (0.32991443953692895 , 0.32991443953692895 , 0.16666666666666669 , 90.0 , 90.0 , 60.000000000000021 ), 63.652867178156257 , 0.015710211406520427 ],
3052- ]
3053- global CoordTestData
3054- CoordTestData = [
3055- # cell, ((frac, ortho),...)
3056- ((4 ,4 ,4 ,90 ,90 ,90 ,), [
3057- ((0.10000000000000001 , 0.0 , 0.0 ),(0.40000000000000002 , 0.0 , 0.0 )),
3058- ((0.0 , 0.10000000000000001 , 0.0 ),(2.4492935982947065e-17 , 0.40000000000000002 , 0.0 )),
3059- ((0.0 , 0.0 , 0.10000000000000001 ),(2.4492935982947065e-17 , - 2.4492935982947065e-17 , 0.40000000000000002 )),
3060- ((0.10000000000000001 , 0.20000000000000001 , 0.29999999999999999 ),(0.40000000000000013 , 0.79999999999999993 , 1.2 )),
3061- ((0.20000000000000001 , 0.29999999999999999 , 0.10000000000000001 ),(0.80000000000000016 , 1.2 , 0.40000000000000002 )),
3062- ((0.29999999999999999 , 0.20000000000000001 , 0.10000000000000001 ),(1.2 , 0.80000000000000004 , 0.40000000000000002 )),
3063- ((0.5 , 0.5 , 0.5 ),(2.0 , 1.9999999999999998 , 2.0 )),
3064- ]),
3065- # cell, ((frac, ortho),...)
3066- ((4.1 ,5.2 ,6.3 ,100 ,80 ,130 ,), [
3067- ((0.10000000000000001 , 0.0 , 0.0 ),(0.40999999999999998 , 0.0 , 0.0 )),
3068- ((0.0 , 0.10000000000000001 , 0.0 ),(- 0.33424955703700043 , 0.39834311042186865 , 0.0 )),
3069- ((0.0 , 0.0 , 0.10000000000000001 ),(0.10939835193016617 , - 0.051013289294572106 , 0.6183281045774256 )),
3070- ((0.10000000000000001 , 0.20000000000000001 , 0.29999999999999999 ),(0.069695941716497567 , 0.64364635296002093 , 1.8549843137322766 )),
3071- ((0.20000000000000001 , 0.29999999999999999 , 0.10000000000000001 ),(- 0.073350319180835066 , 1.1440160419710339 , 0.6183281045774256 )),
3072- ((0.29999999999999999 , 0.20000000000000001 , 0.10000000000000001 ),(0.67089923785616512 , 0.74567293154916525 , 0.6183281045774256 )),
3073- ((0.5 , 0.5 , 0.5 ),(0.92574397446582857 , 1.7366491056364828 , 3.0916405228871278 )),
3074- ]),
3075- # cell, ((frac, ortho),...)
3076- ((3.5 ,3.5 ,6 ,90 ,90 ,120 ,), [
3077- ((0.10000000000000001 , 0.0 , 0.0 ),(0.35000000000000003 , 0.0 , 0.0 )),
3078- ((0.0 , 0.10000000000000001 , 0.0 ),(- 0.17499999999999993 , 0.3031088913245536 , 0.0 )),
3079- ((0.0 , 0.0 , 0.10000000000000001 ),(3.6739403974420595e-17 , - 3.6739403974420595e-17 , 0.60000000000000009 )),
3080- ((0.10000000000000001 , 0.20000000000000001 , 0.29999999999999999 ),(2.7675166561703527e-16 , 0.60621778264910708 , 1.7999999999999998 )),
3081- ((0.20000000000000001 , 0.29999999999999999 , 0.10000000000000001 ),(0.17500000000000041 , 0.90932667397366063 , 0.60000000000000009 )),
3082- ((0.29999999999999999 , 0.20000000000000001 , 0.10000000000000001 ),(0.70000000000000018 , 0.6062177826491072 , 0.60000000000000009 )),
3083- ((0.5 , 0.5 , 0.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,12 ),(3 ,1 ,2 ,12 ),(1 ,1 ,- 6 ,6 ),(2 ,2 ,3 ,6 ),(2 ,2 ,- 3 ,6 ),(1 ,1 ,6 ,6 ))],
3121- }
3122-
3123- global FLnhTestData
3124- FLnhTestData = [{
3125- 'C(4,0,0)' : (0.965 , 0.42760447 ),
3126- 'C(2,0,0)' : (1.0122 , - 0.80233610 ),
3127- 'C(2,0,2)' : (0.0061 , 8.37491546E-03 ),
3128- 'C(6,0,4)' : (- 0.0898 , 4.37985696E-02 ),
3129- 'C(6,0,6)' : (- 0.1369 , - 9.04081762E-02 ),
3130- 'C(6,0,0)' : (0.5935 , - 0.18234928 ),
3131- 'C(4,0,4)' : (0.1872 , 0.16358127 ),
3132- 'C(6,0,2)' : (0.6193 , 0.27573633 ),
3133- 'C(4,0,2)' : (- 0.1897 , 0.12530720 )},[1 ,0 ,0 ]]
3134- def test0 ():
3135- if NeedTestData : TestData ()
3136- msg = 'test cell2Gmat, fillgmat, Gmat2cell'
3137- for (cell , tg , tG , trcell , tV , trV ) in CellTestData :
3138- G , g = cell2Gmat (cell )
3139- assert np .allclose (G ,tG ),msg
3140- assert np .allclose (g ,tg ),msg
3141- tcell = Gmat2cell (g )
3142- assert np .allclose (cell ,tcell ),msg
3143- tcell = Gmat2cell (G )
3144- assert np .allclose (tcell ,trcell ),msg
3145- selftestlist .append (test0 )
3146-
3147- def test1 ():
3148- 'test cell2A and A2Gmat'
3149- _ReportTest ()
3150- if NeedTestData : TestData ()
3151- msg = 'test cell2A and A2Gmat'
3152- for (cell , tg , tG , trcell , tV , trV ) in CellTestData :
3153- G , g = A2Gmat (cell2A (cell ))
3154- assert np .allclose (G ,tG ),msg
3155- assert np .allclose (g ,tg ),msg
3156- selftestlist .append (test1 )
3157-
3158- def test2 ():
3159- 'test Gmat2A, A2cell, A2Gmat, Gmat2cell'
3160- _ReportTest ()
3161- if NeedTestData : TestData ()
3162- msg = 'test Gmat2A, A2cell, A2Gmat, Gmat2cell'
3163- for (cell , tg , tG , trcell , tV , trV ) in CellTestData :
3164- G , g = cell2Gmat (cell )
3165- tcell = A2cell (Gmat2A (G ))
3166- assert np .allclose (cell ,tcell ),msg
3167- selftestlist .append (test2 )
3168-
3169- def test3 ():
3170- 'test invcell2Gmat'
3171- _ReportTest ()
3172- if NeedTestData : TestData ()
3173- msg = 'test invcell2Gmat'
3174- for (cell , tg , tG , trcell , tV , trV ) in CellTestData :
3175- G , g = invcell2Gmat (trcell )
3176- assert np .allclose (G ,tG ),msg
3177- assert np .allclose (g ,tg ),msg
3178- selftestlist .append (test3 )
3179-
3180- def test4 ():
3181- 'test calc_rVsq, calc_rV, calc_V'
3182- _ReportTest ()
3183- if NeedTestData : TestData ()
3184- msg = 'test calc_rVsq, calc_rV, calc_V'
3185- for (cell , tg , tG , trcell , tV , trV ) in CellTestData :
3186- assert np .allclose (calc_rV (cell2A (cell )),trV ), msg
3187- assert np .allclose (calc_V (cell2A (cell )),tV ), msg
3188- selftestlist .append (test4 )
3189-
3190- def test5 ():
3191- 'test A2invcell'
3192- _ReportTest ()
3193- if NeedTestData : TestData ()
3194- msg = 'test A2invcell'
3195- for (cell , tg , tG , trcell , tV , trV ) in CellTestData :
3196- rcell = A2invcell (cell2A (cell ))
3197- assert np .allclose (rcell ,trcell ),msg
3198- selftestlist .append (test5 )
3199-
3200- def test6 ():
3201- 'test cell2AB'
3202- _ReportTest ()
3203- if NeedTestData : TestData ()
3204- msg = 'test cell2AB'
3205- for (cell ,coordlist ) in CoordTestData :
3206- A ,B = cell2AB (cell )
3207- for (frac ,ortho ) in coordlist :
3208- to = np .inner (A ,frac )
3209- tf = np .inner (B ,to )
3210- assert np .allclose (ortho ,to ), msg
3211- assert np .allclose (frac ,tf ), msg
3212- to = np .sum (A * frac ,axis = 1 )
3213- tf = np .sum (B * to ,axis = 1 )
3214- assert np .allclose (ortho ,to ), msg
3215- assert np .allclose (frac ,tf ), msg
3216- selftestlist .append (test6 )
3217-
3218- def test7 ():
3219- 'test GetBraviasNum() and GenHBravais()'
3220- _ReportTest ()
3221- import os .path
3222- import sys
3223- import GSASIIspc as spc
3224- testdir = os .path .join (os .path .split (os .path .abspath ( __file__ ))[0 ],'testinp' )
3225- if os .path .exists (testdir ):
3226- if testdir not in sys .path : sys .path .insert (0 ,testdir )
3227- import sgtbxlattinp
3228- derror = 1e-4
3229- def indexmatch (hklin , hkllist , system ):
3230- for hklref in hkllist :
3231- hklref = list (hklref )
3232- # these permutations are far from complete, but are sufficient to
3233- # allow the test to complete
3234- if system == 'cubic' :
3235- permlist = [(1 ,2 ,3 ),(1 ,3 ,2 ),(2 ,1 ,3 ),(2 ,3 ,1 ),(3 ,1 ,2 ),(3 ,2 ,1 ),]
3236- elif system == 'monoclinic' :
3237- permlist = [(1 ,2 ,3 ),(- 1 ,2 ,- 3 )]
3238- else :
3239- permlist = [(1 ,2 ,3 )]
3240-
3241- for perm in permlist :
3242- hkl = [abs (i ) * hklin [abs (i )- 1 ] / i for i in perm ]
3243- if hkl == hklref : return True
3244- if [- i for i in hkl ] == hklref : return True
3245- else :
3246- return False
3247-
3248- for key in sgtbxlattinp .sgtbx7 :
3249- spdict = spc .SpcGroup (key )
3250- cell = sgtbxlattinp .sgtbx7 [key ][0 ]
3251- system = spdict [1 ]['SGSys' ]
3252- center = spdict [1 ]['SGLatt' ]
3253-
3254- bravcode = GetBraviasNum (center , system )
3255-
3256- g2list = GenHBravais (sgtbxlattinp .dmin , bravcode , cell2A (cell ))
3257-
3258- assert len (sgtbxlattinp .sgtbx7 [key ][1 ]) == len (g2list ), 'Reflection lists differ for %s' % key
3259- for h ,k ,l ,d ,num in g2list :
3260- for hkllist ,dref in sgtbxlattinp .sgtbx7 [key ][1 ]:
3261- if abs (d - dref ) < derror :
3262- if indexmatch ((h ,k ,l ,), hkllist , system ):
3263- break
3264- else :
3265- assert 0 ,'No match for %s at %s (%s)' % ((h ,k ,l ),d ,key )
3266- selftestlist .append (test7 )
3267-
3268- def test8 ():
3269- 'test GenHLaue'
3270- _ReportTest ()
3271- import GSASIIspc as spc
3272- import sgtbxlattinp
3273- derror = 1e-4
3274- dmin = sgtbxlattinp .dmin
3275-
3276- def indexmatch (hklin , hklref , system , axis ):
3277- # these permutations are far from complete, but are sufficient to
3278- # allow the test to complete
3279- if system == 'cubic' :
3280- permlist = [(1 ,2 ,3 ),(1 ,3 ,2 ),(2 ,1 ,3 ),(2 ,3 ,1 ),(3 ,1 ,2 ),(3 ,2 ,1 ),]
3281- elif system == 'monoclinic' and axis == 'b' :
3282- permlist = [(1 ,2 ,3 ),(- 1 ,2 ,- 3 )]
3283- elif system == 'monoclinic' and axis == 'a' :
3284- permlist = [(1 ,2 ,3 ),(1 ,- 2 ,- 3 )]
3285- elif system == 'monoclinic' and axis == 'c' :
3286- permlist = [(1 ,2 ,3 ),(- 1 ,- 2 ,3 )]
3287- elif system == 'trigonal' :
3288- permlist = [(1 ,2 ,3 ),(2 ,1 ,3 ),(- 1 ,- 2 ,3 ),(- 2 ,- 1 ,3 )]
3289- elif system == 'rhombohedral' :
3290- permlist = [(1 ,2 ,3 ),(2 ,3 ,1 ),(3 ,1 ,2 )]
3291- else :
3292- permlist = [(1 ,2 ,3 )]
3293-
3294- hklref = list (hklref )
3295- for perm in permlist :
3296- hkl = [abs (i ) * hklin [abs (i )- 1 ] / i for i in perm ]
3297- if hkl == hklref : return True
3298- if [- i for i in hkl ] == hklref : return True
3299- return False
3300-
3301- for key in sgtbxlattinp .sgtbx8 :
3302- spdict = spc .SpcGroup (key )[1 ]
3303- cell = sgtbxlattinp .sgtbx8 [key ][0 ]
3304- Axis = spdict ['SGUniq' ]
3305- system = spdict ['SGSys' ]
3306-
3307- g2list = GenHLaue (dmin ,spdict ,cell2A (cell ))
3308- #if len(g2list) != len(sgtbxlattinp.sgtbx8[key][1]):
3309- # print 'failed',key,':' ,len(g2list),'vs',len(sgtbxlattinp.sgtbx8[key][1])
3310- # print 'GSAS-II:'
3311- # for h,k,l,d in g2list: print ' ',(h,k,l),d
3312- # print 'SGTBX:'
3313- # for hkllist,dref in sgtbxlattinp.sgtbx8[key][1]: print ' ',hkllist,dref
3314- assert len (g2list ) == len (sgtbxlattinp .sgtbx8 [key ][1 ]), (
3315- 'Reflection lists differ for %s' % key
3316- )
3317- #match = True
3318- for h ,k ,l ,d in g2list :
3319- for hkllist ,dref in sgtbxlattinp .sgtbx8 [key ][1 ]:
3320- if abs (d - dref ) < derror :
3321- if indexmatch ((h ,k ,l ,), hkllist , system , Axis ): break
3322- else :
3323- assert 0 ,'No match for %s at %s (%s)' % ((h ,k ,l ),d ,key )
3324- #match = False
3325- #if not match:
3326- #for hkllist,dref in sgtbxlattinp.sgtbx8[key][1]: print ' ',hkllist,dref
3327- #print center, Laue, Axis, system
3328- selftestlist .append (test8 )
3329-
3330- def test9 ():
3331- 'test GenHLaue'
3332- _ReportTest ()
3333- import GSASIIspc as G2spc
3334- if NeedTestData : TestData ()
3335- for spc in LaueTestData :
3336- data = LaueTestData [spc ]
3337- cell = data [0 ]
3338- hklm = np .array (data [1 ])
3339- H = hklm [- 1 ][:3 ]
3340- hklO = hklm .T [:3 ].T
3341- A = cell2A (cell )
3342- dmin = 1. / np .sqrt (calc_rDsq (H ,A ))
3343- SGData = G2spc .SpcGroup (spc )[1 ]
3344- hkls = np .array (GenHLaue (dmin ,SGData ,A ))
3345- hklN = hkls .T [:3 ].T
3346- #print spc,hklO.shape,hklN.shape
3347- err = True
3348- for H in hklO :
3349- if H not in hklN :
3350- print ('%d %s' % (H ,' missing from hkl from GSASII' ))
3351- err = False
3352- assert (err )
3353- selftestlist .append (test9 )
3354-
3355-
3356-
3357-
3358- if __name__ == '__main__' :
3359- import GSASIIpath
3360- GSASIIpath .SetBinaryPath ()
3361- # run self-tests
3362- selftestquiet = False
3363- for test in selftestlist :
3364- test ()
3365- print ("OK" )
0 commit comments