mantidproject / mantid

Main repository for Mantid code
https://www.mantidproject.org
GNU General Public License v3.0
210 stars 122 forks source link

Investigate multiple scattering with McStas #11945

Closed Anders-Markvardsen closed 6 years ago

Anders-Markvardsen commented 9 years ago

The issue is to investigate if McStas can be used together with Mantid as an approach for calculated multiple scattering for general geometries and samples.

As of this writing Mantid as one algorithm for calculating multiple scattering: http://docs.mantidproject.org/nightly/algorithms/MayersSampleCorrection-v1.html, which only works for cylinder-shape samples and for few real samples, where vanadium is one such sample. Mantid has one other special purpose multiple scattering algorithm: http://docs.mantidproject.org/nightly/algorithms/MultipleScatteringCylinderAbsorption-v1.html restricted to vanadium.

The main purpose of this investigation is to see if McStas combined with Mantid can provide a workable solution for calculating MS for general geometries and general samples.

Groups which have should an interest in this includes:

ISIS Sans: Richard Heenan has identified the SANS2D dataset, run 17915, as a dataset that is believed to suffer from significant multiple scatter.

ISIS Spectroscopy group.

ESS, DMSC

This investigation must include: following the recipe described in a comment below to calculate vanadium MS using McStas, followed by reading this result into Mantid can compare it with results from using MayersSampleCorrection.

Output is worked examples in concept pages.

Anders-Markvardsen commented 9 years ago

@Anders-Markvardsen (2015-02-27T11:23:17): Spencer interested it what this work may output, hence CCed in


@Anders-Markvardsen (2015-04-17T15:37:05): Investigation from meeting at ess in copenhagen last week produced a number of interesting results.

We agreed on a workflow which is:

  1. create S(Q) for SANS2D for example and S(Q,omega) for MARI data using Mantid
  2. Make the assumption that multiple scattering for S does not contain multiple scattering and is a reasonable 1st approximation of the true S for the sample
  3. Insert this S into a McStas component and do a McStas simulation where the output of this simulation is piped into one scattered neutrons and multiple scattering neutrons
  4. Then simply take the multiple scattering neutron output from 3, run it through Mantid reduction to get a S_ms_corr curve

We ran have run this so far with Richard's ludox data. Further inputs are needed to truely believe in the output produced, but a very preliminary output is attached as Iq_ms_only.pdf together with one-scattering output Iq_total.pdf.


@Anders-Markvardsen (2015-04-17T15:37:48): preliminary ms calculation for ludox data


@Anders-Markvardsen (2015-04-17T15:38:16): associated one-scattering Iq


@NickDraper (2015-04-27T08:10:34): Moved to R3.5 at the R3.4 code freeze

Anders-Markvardsen commented 9 years ago

http://trac.mantidproject.org/mantid/raw-attachment/ticket/11106/Iq_ms_only.pdf (uploaded by @Anders-Markvardsen on 2015-04-17T15:37:48)


http://trac.mantidproject.org/mantid/raw-attachment/ticket/11106/Iq_total.pdf (uploaded by @Anders-Markvardsen on 2015-04-17T15:38:16)


Anders-Markvardsen commented 7 years ago

A process for how to calculate multiple scattering using McStas has been identified see above and description in Nielsen, T.R. et al.: McStas and Mantid integration Journal of Neutron Research, vol. 18, no. 2-3, pp. 61-77, 2015 DOI: 10.3233/JNR-16002.

What remains is to try this one on 1 real neutron datasets measured on a simple system where the multiple scattering is known from other means (or believed to be known). That way the multiple scattering calculated by McStas can be verified, and if the comparison is good this could be a method we could recommend going forward.

Input needed is neutron data on a simple system where the multiple scattering is believed to be known. The work will then entail building up a McStas sample model(s). Run McStas simulations and process these in Mantid.

Further, it is important to try to compare this multiple scattering output, where possible, with what is already in Mantid. As of this writing this is: Mayers sample correction (Vanadium) implemented - restricted to cylinder sample shapes.

One simple system which must be used is Vanadium.

Anders-Markvardsen commented 7 years ago

@trnielsen

Anders-Markvardsen commented 7 years ago

@DavidFair has provided the following script to run multiple scattering on vanadium on using Mantid Mayers MS algorithm:

# USER SETUP
# This needs to be set to the extracted folder path from .zip
folder_path = r"Insert name"

# Note this script takes 5-15 minutes for multiple scattering corrections
# Radius is in cm
cylinder_radius = 0.4

# Details for MayersSampleCorrection
mayers_cylinder_height = 4.0
mayers_position = [0., 0., 0.]

#----------------------------------------------------------------------------------------------------------------------#

# Load vanadium
input_ws = Load(Filename=folder_path + '\\POL95598.nxs', OutputWorkspace='read_ws')
input_ws = RenameWorkspace(InputWorkspace='read_ws', OutputWorkspace='POL95598')
input_ws = NormaliseByCurrent(InputWorkspace='POL95598', OutputWorkspace='POL95598')
# Load background count
input_ws = Load(Filename=folder_path + '\\POL95597.nxs', OutputWorkspace='read_ws')
input_ws = RenameWorkspace(InputWorkspace='read_ws', OutputWorkspace='POL95597')
input_ws = NormaliseByCurrent(InputWorkspace='POL95597', OutputWorkspace='POL95597')
# subtract the background from the vanadium
input_ws = Minus(LHSWorkspace='POL95598', RHSWorkspace='POL95597', OutputWorkspace='POL95598')
# get rid of 'negative' counts at very low TOF
input_ws = CropWorkspace(InputWorkspace='POL95598', OutputWorkspace='POL95598', XMin=750, XMax=20000)
aligned_ws = AlignDetectors(InputWorkspace='POL95598', OutputWorkspace='POL95598_reference', CalibrationFile=folder_path + '\\cycle_16_3_silicon_all_spectra.cal')
# the first 55 detectors are unused detectors or monitors on Polaris
MaskDetectors(Workspace=aligned_ws, SpectraList='0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54')

# Mayers Sample Corrections
mayers_ws = CloneWorkspace(InputWorkspace=aligned_ws, OutputWorkspace="POL95598_Mayers")
mayers_ws = ConvertUnits(InputWorkspace=aligned_ws, OutputWorkspace=mayers_ws, Target='TOF')
geometry_json = {'Shape': 'Cylinder', 'Height': mayers_cylinder_height, 'Radius': cylinder_radius, 'Center': mayers_position}
material_json = {'ChemicalFormula': 'V'}
SetSample(InputWorkspace=mayers_ws, Geometry=geometry_json, Material=material_json)
# TODO reset this back!!!
mayers_no_ms = CloneWorkspace(InputWorkspace=mayers_ws, OutputWorkspace="POL95598_Mayers_No_MS")
mayers_ws = MayersSampleCorrection(InputWorkspace=mayers_ws, MultipleScattering=True, OutputWorkspace=mayers_ws)
mayers_ws = ReplaceSpecialValues(InputWorkspace=mayers_ws, OutputWorkspace=mayers_ws, NaNValue=0, NaNError=0)

mayers_no_ms = MayersSampleCorrection(InputWorkspace=mayers_no_ms, MultipleScattering=False, OutputWorkspace=mayers_no_ms)
mayers_no_ms = ReplaceSpecialValues(InputWorkspace=mayers_no_ms, OutputWorkspace=mayers_no_ms, NaNValue=0, NaNError=0)

# to dSpacing + focussing
focused_list = []
for ws in [aligned_ws, mayers_ws, mayers_no_ms]:
    loop_ws = ConvertUnits(InputWorkspace=ws, OutputWorkspace=ws, Target='dSpacing')
    focused_list.append(DiffractionFocussing(InputWorkspace=ws, OutputWorkspace=ws, GroupingFileName=folder_path + '\\Master_copy_of_grouping_file_with_essential_masks.cal'))

all_plot = plot(focused_list, 3)

This code outputs

mayers - reference

Please note that the green curve is the focussed uncorrected data. The red curve is corrected for attenuation and correctly site above the green curve (since it shows the scattering as if there was no absorption, @martyngigg) and the black curve is where multiple scattering correction has been subtracted.

Anders-Markvardsen commented 7 years ago

From a meeting with Mads Bertelsen (@mads-bertelsen) at ICANS XXII meeting, Oxford.

Mads has extended McStas so it can handle multiple-scattering for more than one McStas component. For a video of his work see: http://media.mcstas.org/ESS_DMSC_20161117/DMSC_talk_MBertelsen_McStas_Union.mp4

Mads has done calculation simulating the MARI instrument with a Vanadium sample. This sample is not a cylinder and therefore these results cannot (currently) be compared with the Vanadium multiple scattering numbers from Mantid. Also, Mads calculations on MARI includes multiple-scattering contributions from both the sample environment and Vanadium.

An idea Mads suggested for normalising the multiple scattering signal is to use the intensity of the signal from single scattering and multiple scattering that comes out of McStas.

To compare with Mantid cylinder Vanadium multiple-scattering, this can be done with ISIS powder diffraction instruments, for which we have many experimental data and also a number of powder instruments to chose from.

Anders-Markvardsen commented 7 years ago

@NickDraper

Anders-Markvardsen commented 7 years ago

@willend

Anders-Markvardsen commented 7 years ago

Ron Smith would like to be updated on this work also

Anders-Markvardsen commented 7 years ago

physics summer student expected to start work on this 5th July

Anders-Markvardsen commented 7 years ago

Just spoken to Spencer and he reiterated that he is interested in this issue

Anders-Markvardsen commented 7 years ago

This work discussed in Mantid development meeting: Slides: https://github.com/mantidproject/documents/blob/master/Presentations/DevMeetings/2017-06/dev_workshop_2017_mcstas_markvardsen.pptx

If results from using McStas with multiple-scattering works well then this provides an (additional) motivation to allow Mantid users to run mcstas simulation from Mantid. Writing a parser that translates Mantid IDFs to McStas IDFs should take ~two weeks.

mads-bertelsen commented 7 years ago

A small note on how multiple scattering is handled by McStas: Each component can choose to simulate multiple scattering, and the mcstas-component manual have a handy overview of which of the standard sample components include this feature.

mcstas_samples.pdf

When using the contributed Union components, multiple scattering is always taken into account. A version of PowderN has been imported as a Union process, so if you want to start with powders that is an option.

willend commented 7 years ago

Hi all, now back from vacation.

Supplementing the input from @mads-bertelsen, you are also welcome to have a look at the below table which lists a few more of the non-union components:

https://confluence.esss.lu.se/display/MCSTAS/McStas+sample+model+functionality-matrix (Fairly recent, updated 2015 - but hence does not include the Union capabilities)

jamesquantum commented 7 years ago

Just uploaded the first version of my report: Investigating multiple scattering with McStas

Anders-Markvardsen commented 6 years ago

Investigation completed see report above. Also subsequently made change to loadmcstas to handle multiple scat data from mcstas a lot better: #20369 and updating mcstas documentation: https://github.com/McStasMcXtrace/McCode/issues/587 . As of this writing nightly build of mcstas and mantid required. Note, mcstas windows bug is being worked on https://github.com/McStasMcXtrace/McCode/issues/582