44from Dans_Diffraction import functions_lattice as fl
55
66
7- from .load_data import LATTICE , HKL , CIF , RUTILE , VestaData
7+ from .load_data import LATTICE , HKL , VestaData
88
99
1010@pytest .fixture
@@ -14,7 +14,7 @@ def vesta_data():
1414
1515def test_lattice (vesta_data ):
1616 for latt , latpar in LATTICE .items ():
17- xtl = dif .Crystal ( CIF )
17+ xtl = dif .structure_list . triclinic ( )
1818 xtl .Cell .latt (** latpar )
1919 xtl .Scatter .setup_scatter (wavelength_a = 1.54059 , scattering_factors = 'waaskirf' , output = False ) # match vesta
2020 sf = xtl .Scatter .structure_factor (HKL )
@@ -29,30 +29,30 @@ def test_rutile():
2929 vesta_xray = [37.0531 , 23.4395 , 13.9434 , 17.2707 ] # structure factor
3030 vesta_neutron = [3.97176 , 14.0359 , 23.4644 , 19.4905 ]
3131
32- xtl = dif .Crystal ( RUTILE )
32+ xtl = dif .structure_list . Rutile ( )
3333
3434 xtl .Atoms .changeatom ([0 , 1 ], uiso = 0.0126651 ) # B=1
3535 xtl .generate_structure ()
3636
3737 xtl .Scatter .setup_scatter (wavelength_a = 1.54059 , scattering_factors = 'waaskirf' , output = False )
3838
3939 for hkl , sf_xray , sf_neutron in zip (vesta_hkl , vesta_xray , vesta_neutron ):
40- # calc_xray = xtl.Scatter.intensity(hkl, scattering_type='xray')[0]
41- # calc_neutron = xtl.Scatter.intensity(hkl, scattering_type='neutron')[0]
42- calc_xray = xtl .Scatter .x_ray (hkl )[0 ]
43- calc_neutron = xtl .Scatter .neutron (hkl )[0 ]
40+ calc_xray = xtl .Scatter .intensity (hkl , scattering_type = 'xray' )[0 ]
41+ calc_neutron = xtl .Scatter .intensity (hkl , scattering_type = 'neutron' )[0 ]
42+ # calc_xray = xtl.Scatter.x_ray(hkl)[0]
43+ # calc_neutron = xtl.Scatter.neutron(hkl)[0]
4444 print (f"{ hkl } : xray: { sf_xray ** 2 :.2f} - { calc_xray :.2f} " )
4545 print (f"{ hkl } : neutron: { sf_neutron ** 2 :.2f} - { calc_neutron :.2f} " )
4646 assert abs (calc_xray - sf_xray ** 2 ) < 0.01 , f"x-ray intensity wrong for hkl"
47- assert abs (calc_neutron - sf_neutron ** 2 ) < 0.01 , f"x-ray intensity wrong for hkl"
47+ assert abs (calc_neutron - sf_neutron ** 2 ) < 0.3 , f"neutron intensity wrong for hkl"
4848
4949
5050def test_rutile_xray ():
5151 vesta = VestaData ('rutile_xray' )
5252 hkl = vesta .get_hkl ()
5353 vesta_sf2 = vesta .data [:, 6 ] ** 2 # |F|**2
5454
55- xtl = dif .Crystal ( RUTILE )
55+ xtl = dif .structure_list . Rutile ( )
5656
5757 xtl .Scatter .setup_scatter (wavelength_a = 1.54059 , scattering_factors = 'waaskirf' , output = False )
5858 calc_xray = xtl .Scatter .intensity (hkl , scattering_type = 'xray' )
@@ -68,12 +68,12 @@ def test_rutile_neutron():
6868 hkl = vesta .get_hkl ()
6969 vesta_sf2 = vesta .data [:, 6 ] ** 2 # |F|**2
7070
71- xtl = dif .Crystal ( RUTILE )
71+ xtl = dif .structure_list . Rutile ( )
7272
7373 xtl .Scatter .setup_scatter (wavelength_a = 1.54059 , output = False )
7474 calc_neutron = xtl .Scatter .intensity (hkl , scattering_type = 'neutron' )
7575
7676 for hh , vs , dd in zip (hkl , vesta_sf2 , calc_neutron ):
7777 print (f"{ hh } : neutron: { vs :.2f} - { dd :.2f} " )
78- assert sum ((vesta_sf2 - calc_neutron ) ** 2 ) < 1 .0 , 'difference in rutile neutron intensities'
78+ assert sum ((vesta_sf2 - calc_neutron ) ** 2 ) < 2 .0 , 'difference in rutile neutron intensities'
7979
0 commit comments