\(\renewcommand\AA{\unicode{x212B}}\)

FlippingRatioCorrectionMD v1

../_images/ImageNotFound.png

Enable screenshots using DOCS_SCREENSHOTS in CMake

Summary

Creates MDEvent workspaces with polarization flipping ratio corrections.The polarization might be angle dependent.

Properties

Name

Direction

Type

Default

Description

InputWorkspace

Input

MDEventWorkspace

Mandatory

An input MDEventWorkspace.

FlippingRatio

Input

string

Mandatory

Formula to define the flipping ratio. It can depend on the variables in the list of sample logs defined below

SampleLogs

Input

str list

Comma separated list of sample logs that can appear in the formula for flipping ratio

OutputWorkspace1

Output

Workspace

Mandatory

Output workspace 1. Equal to Input workspace multiplied by FR/(FR-1).

OutputWorkspace2

Output

Workspace

Mandatory

Output workspace 2. Equal to Input workspace multiplied by 1/(FR-1).

Description

Measurements using polarized neutrons can be used to identify magnetic and nuclear contribution. In the case of coherent scattering, nuclear spins generally do not change the spin polarization of the neutrons (non spin flip scattering). For magnetic scattering, the magnetization parallel to the neutron spin direction produces non spin flip scattering, while magnetization perpendicular to the spin direction will flip the neutron spin.

When measuring spin flip and non spin flip cross sections, the finite capabilities of the instrument will allow a certain percentage of the other component to leak through. This is denoted by the flipping ratio \(F\). Using subscript “m” for measured and “c” for corrected, the corrected intensities for the spin flip (SF) and non spin flip (NSF) scattering are given by [1]:

\[\begin{split}I_{NSFc}=\frac{F}{F-1}I_{NSFm}-\frac{1}{F-1}I_{SFm}\\ I_{SFc}=\frac{F}{F-1}I_{SFm}-\frac{1}{F-1}I_{NSFm}\end{split}\]

Given a multidimensional event workspace, this algorithm will output the workspace where events are multiplied by \(F/(F-1)\) (in OutputWorkspace1) and by \(1/(F-1)\) (in OutputWorkspace2). Note however that the flipping ratio might be angle dependent. For example, in the case of type II superconductors, the flux lattice will depolarize the neutrons differently, depending on the orientation of the neutron beam with respect to the superconducting planes. In this case one must use a formula that would use a different flipping ratio for each neutron, that depends on a goniometer angle. Assuming that we have a log value omega for the sample rotation, the flipping ratio might be described by something like [2]:

\[F=6.5+2.8\cos(\pi(omega+3.7)/180)\]

The MD event workspaces label each MDEvent with the experiment info number. The time averaged log value for omega is read from each experiment info, the flipping ratio is calculated from the user provided formula, and the corrected workspaces are computed.

For the parsing of the formula, the algorithm uses muparser. Once can use any of the implemented functions. The constant “pi” can be used in the formula. Use “_e” for the base of natural logarithms.

References

Usage

Example - FlippingRatioCorrectionMD

# Fake an md workspace
CreateMDWorkspace(Dimensions=2, EventType='MDEvent', Extents='-5,5,-5,5', Names='A,B', Units='a,a' ,OutputWorkspace='mde1')
AddSampleLog(Workspace='mde1', LogName='param', LogText='0.', LogType='Number', NumberType='Double')
FakeMDEventData(InputWorkspace='mde1', PeakParams='100,-2,-2,0.1')
CreateMDWorkspace(Dimensions=2, EventType='MDEvent', Extents='-5,5,-5,5', Names='A,B', Units='a,a',OutputWorkspace='mde2')
AddSampleLog(Workspace='mde2', LogName='param', LogText='90.', LogType='Number', NumberType='Double')
FakeMDEventData(InputWorkspace='mde2', PeakParams='100,2,2,0.1')
MergeMD(InputWorkspaces='mde1,mde2', OutputWorkspace='merged')

# Calculate flipping ratio corrections
FlippingRatioCorrectionMD(InputWorkspace='merged',
                          FlippingRatio='10+5*sin(param*pi/180)',
                          SampleLogs='param',
                          OutputWorkspace1='correctionFoFm1',
                          OutputWorkspace2='correction1oFm1')

# Bin data and extract intensities
BinMD(InputWorkspace='correctionFoFm1', AlignedDim0='A,-5,5,2', AlignedDim1='B,-5,5,2', OutputWorkspace='correctionFoFm1_histo')
peak1_FoFm1=mtd['correctionFoFm1_histo'].getSignalArray()[0,0]
peak2_FoFm1=mtd['correctionFoFm1_histo'].getSignalArray()[1,1]
BinMD(InputWorkspace='correction1oFm1', AlignedDim0='A,-5,5,2', AlignedDim1='B,-5,5,2', OutputWorkspace='correction1oFm1_histo')
peak1_1oFm1=mtd['correction1oFm1_histo'].getSignalArray()[0,0]
peak2_1oFm1=mtd['correction1oFm1_histo'].getSignalArray()[1,1]
print("{:>17}   Peak1      Peak2".format(' '))
print("{:>17} {:8.3f}   {:8.3f}".format('Original',100,100))
print("{:>17} {:8.3f}   {:8.3f}".format('F',10,15))
print("{:>17} {:8.3f}   {:8.3f}".format('F/(F-1)',10./9.,15/14.))
print("{:>17} {:8.3f}   {:8.3f}".format('Corrected F/(F-1)',peak1_FoFm1,peak2_FoFm1))
print("{:>17} {:8.3f}   {:8.3f}".format('1/(F-1)',1./9.,1/14.))
print("{:>17} {:8.3f}   {:8.3f}".format('Corrected 1/(F-1)',peak1_1oFm1,peak2_1oFm1))

Output:

                    Peak1      Peak2
         Original  100.000    100.000
                F   10.000     15.000
          F/(F-1)    1.111      1.071
Corrected F/(F-1)  111.111    107.143
          1/(F-1)    0.111      0.071
Corrected 1/(F-1)   11.111      7.143

Categories: AlgorithmIndex | MDAlgorithms\Transforms

Source

C++ header: FlippingRatioCorrectionMD.h

C++ source: FlippingRatioCorrectionMD.cpp