diff --git a/Testing/SystemTests/tests/framework/ISIS_PowderPolarisTest.py b/Testing/SystemTests/tests/framework/ISIS_PowderPolarisTest.py index 1ed723344d9e..a6980d522f90 100644 --- a/Testing/SystemTests/tests/framework/ISIS_PowderPolarisTest.py +++ b/Testing/SystemTests/tests/framework/ISIS_PowderPolarisTest.py @@ -145,7 +145,7 @@ def assert_output_file_exists(directory, filename): assert_output_file_exists(output_dat_dir, "POL98533-b_{}-d.dat".format(bankno)) for ws in self.focus_results: - self.assertEqual(ws.sample().getMaterial().name(), "Si") + self.assertEqual(ws.sample().getMaterial().name(), "Si Si") self.tolerance_is_rel_err = True self.tolerance = 1e-6 return self.focus_results.name(), "ISIS_Powder-POLARIS98533_FocusSempty.nxs" @@ -188,7 +188,7 @@ def assert_output_file_exists(directory, filename): assert_output_file_exists(output_dat_dir, "POL98533-b_{}-d.dat".format(bankno)) for ws in self.focus_results: - self.assertEqual(ws.sample().getMaterial().name(), "Si") + self.assertEqual(ws.sample().getMaterial().name(), "Si Si") self.tolerance_is_rel_err = True self.tolerance = 1e-6 return self.focus_results.name(), "ISIS_Powder-POLARIS98533_FocusPaalmanPings.nxs" @@ -231,7 +231,7 @@ def assert_output_file_exists(directory, filename): assert_output_file_exists(output_dat_dir, "POL98533-b_{}-d.dat".format(bankno)) for ws in self.focus_results: - self.assertEqual(ws.sample().getMaterial().name(), "Si") + self.assertEqual(ws.sample().getMaterial().name(), "Si Si") self.tolerance_is_rel_err = True self.tolerance = 1e-5 # MayersSampleCorrection involves a fit that may give slightly different results on different OS @@ -261,7 +261,7 @@ def runTest(self): def validate(self): # This will only pass if instead of failing or deafaulting to PDF it correctly picks Rietveld for ws in self.focus_results: - self.assertEqual(ws.sample().getMaterial().name(), "Si") + self.assertEqual(ws.sample().getMaterial().name(), "Si Si") # this needs to be put in due to rounding errors between OS' for the proton_charge_by_period log self.disableChecking.append("Sample") self.tolerance = 1e-7 @@ -291,7 +291,7 @@ def runTest(self): def validate(self): self.tolerance_is_rel_err = True - self.tolerance = 1e-6 + self.tolerance = 1e-5 # same tolused in FocusTestAbsorptionMayers return self.focus_results.name(), "ISIS_Powder-POLARIS98533_FocusMayers.nxs" def cleanup(self): @@ -332,7 +332,7 @@ def assert_output_file_exists(directory, filename): assert_output_file_exists(output_dat_dir, "POL98533-b_{}-d.dat".format(bankno)) for ws in self.focus_results: - self.assertEqual(ws.sample().getMaterial().name(), "Si") + self.assertEqual(ws.sample().getMaterial().name(), "Si Si") self.tolerance_is_rel_err = True self.tolerance = 1e-5 return self.focus_results.name(), "ISIS_Powder-POLARIS98533_FocusPerDet.nxs" @@ -358,7 +358,7 @@ def runTest(self): def validate(self): # Whilst total scattering is in development, the validation will avoid using reference files as they will have # to be updated very frequently. In the meantime, the expected peak in the PDF at ~3.9 Angstrom will be checked - expected_peak_values = [0.8808, 1.1001, 2.9530, 4.6600, 4.3528] + expected_peak_values = [0.8808, 1.1001, 2.9530, 4.6593, 4.3521] for index, ws in enumerate(self.pdf_output): idx = get_bin_number_at_given_r(ws.dataX(0), 3.9) self.assertAlmostEqual(ws.dataY(0)[idx], expected_peak_values[index], places=3) @@ -378,7 +378,7 @@ def validate(self): # Whilst total scattering is in development, the validation will avoid using reference files as they will have # to be updated very frequently. In the meantime, the expected peak in the PDF at ~3.9 Angstrom will be checked. idx = get_bin_number_at_given_r(self.pdf_output.dataX(0), 3.9) - self.assertAlmostEqual(self.pdf_output.dataY(0)[idx], 4.5806, places=3) + self.assertAlmostEqual(self.pdf_output.dataY(0)[idx], 4.5799, places=3) class TotalScatteringMergedPerDetTest(systemtesting.MantidSystemTest): @@ -395,7 +395,7 @@ def validate(self): # Whilst total scattering is in development, the validation will avoid using reference files as they will have # to be updated very frequently. In the meantime, the expected peak in the PDF at ~3.9 Angstrom will be checked. idx = get_bin_number_at_given_r(self.pdf_output.dataX(0), 3.9) - self.assertAlmostEqual(self.pdf_output.dataY(0)[idx], 4.531, places=3) + self.assertAlmostEqual(self.pdf_output.dataY(0)[idx], 4.5305, places=3) class TotalScatteringPDFRebinTest(systemtesting.MantidSystemTest): @@ -501,7 +501,7 @@ def validate(self): # Whilst total scattering is in development, the validation will avoid using reference files as they will have # to be updated very frequently. In the meantime, the expected peak in the PDF at ~3.9 Angstrom will be checked. idx = get_bin_number_at_given_r(self.pdf_output.dataX(0), 3.9) - self.assertAlmostEqual(self.pdf_output.dataY(0)[idx], 8.8486, places=3) + self.assertAlmostEqual(self.pdf_output.dataY(0)[idx], 8.8473, places=3) def run_total_scattering( @@ -672,7 +672,9 @@ def setup_inst_object(mode, with_container=False): ) sample_details = SampleDetails(height=4.0, radius=0.2985, center=[0, 0, 0], shape="cylinder") - sample_details.set_material(chemical_formula="Si") + # define multi-atom cell to stop regression of bug calling MaterialBuilder.build() without setting number density + # which works for one atom cells as number density is automatically calculated + sample_details.set_material(chemical_formula="Si Si", number_density=0.04996) if with_container: sample_details.set_container(radius=0.3175, chemical_formula="V") inst_obj.set_sample_details(sample=sample_details) diff --git a/Testing/SystemTests/tests/framework/reference/ISIS_Powder-POLARIS98533_FocusMayers.nxs.md5 b/Testing/SystemTests/tests/framework/reference/ISIS_Powder-POLARIS98533_FocusMayers.nxs.md5 index e7e199266bb2..1708516a1506 100644 --- a/Testing/SystemTests/tests/framework/reference/ISIS_Powder-POLARIS98533_FocusMayers.nxs.md5 +++ b/Testing/SystemTests/tests/framework/reference/ISIS_Powder-POLARIS98533_FocusMayers.nxs.md5 @@ -1 +1 @@ -914e84974be0b4fd3efa06c2f5e667a7 +aa23f24d8f3d1e62bfb185ae9006190d diff --git a/Testing/SystemTests/tests/framework/reference/ISIS_Powder-POLARIS98533_FocusPaalmanPings.nxs.md5 b/Testing/SystemTests/tests/framework/reference/ISIS_Powder-POLARIS98533_FocusPaalmanPings.nxs.md5 index 3831291a6802..44c115798ab7 100644 --- a/Testing/SystemTests/tests/framework/reference/ISIS_Powder-POLARIS98533_FocusPaalmanPings.nxs.md5 +++ b/Testing/SystemTests/tests/framework/reference/ISIS_Powder-POLARIS98533_FocusPaalmanPings.nxs.md5 @@ -1 +1 @@ -b8d958c46a50716b2b4038d2aa8afa85 +40a0f25448d0733e7929a7b1e71d8ddb diff --git a/docs/source/release/v6.11.0/Diffraction/Powder/Bugfixes/37814.rst b/docs/source/release/v6.11.0/Diffraction/Powder/Bugfixes/37814.rst new file mode 100644 index 000000000000..c8d396145c51 --- /dev/null +++ b/docs/source/release/v6.11.0/Diffraction/Powder/Bugfixes/37814.rst @@ -0,0 +1 @@ +- Fix bug in POLARIS (ISIS) routine ``create_total_scattering_pdf`` causing unhandled error when calculating cross-sections of multi-atom unit cells for pdf normalisation. \ No newline at end of file diff --git a/scripts/Diffraction/isis_powder/polaris_routines/polaris_algs.py b/scripts/Diffraction/isis_powder/polaris_routines/polaris_algs.py index 04e0fc1419a6..bd42529ccc2e 100644 --- a/scripts/Diffraction/isis_powder/polaris_routines/polaris_algs.py +++ b/scripts/Diffraction/isis_powder/polaris_routines/polaris_algs.py @@ -104,7 +104,8 @@ def generate_ts_pdf( # convert diff cross section to S(Q) - 1 material_builder = MaterialBuilder() - sample = material_builder.setFormula(sample_details.material_object.chemical_formula).build() + material_builder.setFormula(sample_details.material_object.chemical_formula) + sample = material_builder.setNumberDensity(1.0).build() # number density not used in calculating xs (barns/atom) sample_total_scatter_cross_section = sample.totalScatterXSection() sample_coh_scatter_cross_section = sample.cohScatterXSection() focused_ws = focused_ws - sample_total_scatter_cross_section / (4 * math.pi)