mantid icon indicating copy to clipboard operation
mantid copied to clipboard

Fix bug polaris total scattering normalisation for multi-atom unit cells

Open RichardWaiteSTFC opened this issue 6 months ago • 3 comments

Description of work

There was a bug in the call to MaterialBuilder here https://github.com/mantidproject/mantid/blob/2ae50d1627844610269f2d8abae305fa68248811/scripts/Diffraction/isis_powder/polaris_routines/polaris_algs.py#L107 The build method requires unit cells with multiple atoms to have a number density set.

The number density is not actually used to calculate the cross-sections required for the PDF normalisation - so here I just set it to an arbitrary number (1).

There is no associated issue.

Report to: Helen Playford

To test:

(1) Unzip these files somewhere and update the script below with the path. Also update the paths in the file polaris_config_example.yaml PR34144Files.zip (2) Run this script without error

from mantid.simpleapi import *
import matplotlib.pyplot as plt
import numpy as np
from isis_powder import polaris, SampleDetails


config_file_path = r"C:\Total Scattering\polaris_config_example.yaml"
polaris = polaris.Polaris(config_file=config_file_path, user_name="test", mode="PDF")

sam = SampleDetails(height=4.6,radius=0.29855,center=[0,0,0],shape='cylinder')
sam.set_container(radius=0.3175,chemical_formula='V')
sam.set_material(chemical_formula='Pb-Sn-F4',
number_density=0.059, packing_fraction=0.5)
polaris.set_sample_details(sample=sam)

polaris.create_vanadium(first_cycle_run_no="98532", multiple_scattering=True, do_absorb_corrections=True, mayers_mult_scat_events=1)
polaris.focus(run_number="98533", input_mode='Summed', do_absorb_corrections=True,multiple_scattering=False,
              do_van_normalisation=True, van_normalisation_method="Absolute",
              keep_raw_workspace=False, mayers_mult_scat_events=1)

# q_lim from script on https://github.com/mantidproject/mantid/pull/28447
q_lim = [[2.5, 3, 4, 6, 7], [3.5, 5, 7, 11, 40]]
polaris.create_total_scattering_pdf(run_number="98533", merge_banks=True,q_lims=q_lim, 
                                    freq_params=[1.0], pdf_type="g(r)", merge_banks=True,)

Reviewer

Please comment on the points listed below (full description). Your comments will be used as part of the gatekeeper process, so please comment clearly on what you have checked during your review. If changes are made to the PR during the review process then your final comment will be the most important for gatekeepers. In this comment you should make it clear why any earlier review is still valid, or confirm that all requested changes have been addressed.

Code Review

  • Is the code of an acceptable quality?
  • Does the code conform to the coding standards?
  • Are the unit tests small and test the class in isolation?
  • If there is GUI work does it follow the GUI standards?
  • If there are changes in the release notes then do they describe the changes appropriately?
  • Do the release notes conform to the release notes guide?

Functional Tests

  • Do changes function as described? Add comments below that describe the tests performed?
  • Do the changes handle unexpected situations, e.g. bad input?
  • Has the relevant (user and developer) documentation been added/updated?

Does everything look good? Mark the review as Approve. A member of @mantidproject/gatekeepers will take care of it.

Gatekeeper

If you need to request changes to a PR then please add a comment and set the review status to "Request changes". This will stop the PR from showing up in the list for other gatekeepers.

RichardWaiteSTFC avatar Aug 16 '24 14:08 RichardWaiteSTFC