Skip to content

Commit

Permalink
Add documentation page
Browse files Browse the repository at this point in the history
  • Loading branch information
cailafinn committed May 1, 2024
1 parent 689d838 commit f9cc30a
Showing 1 changed file with 58 additions and 0 deletions.
58 changes: 58 additions & 0 deletions docs/source/algorithms/FlipperEfficiency-v1.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
.. algorithm::

.. summary::

.. relatedalgorithms::

.. properties::

Description
-----------

Calculates the efficiency of a single flipper with regards to wavelength. The input workspace must be a group workspace
containing four known spin states, which can be given by the ``SpinStates`` parameter. It then uses these four spin
states to calculate the proportion of neutrons lost to the flipper with regards to wavelength.

The polarisation of the flipper :math:`P_{F}` is given by:

.. math::
P_F = \frac{T_{11} - T_{10}}{T_{00} - T_{01}}
Since the efficiency :math:`\epsilon_{F}` is equal to :math:`\frac{1 + P_{F}}{2}`, we can calculate the efficiency of
the flipper directly using:

.. math::
\epsilon_{F} = \frac{T_{00} - T_{01} + T_{11} - T_{10}}{2(T_{00} - T_{01})}
Usage
-----

**Example - Calculate Flipper Efficiency**

.. testcode:: FlipperEfficiencyExample

CreateSampleWorkspace(OutputWorkspace='out_00', Function='User Defined', UserDefinedFunction='name=Lorentzian, Amplitude=48000, PeakCentre=2.65, FWHM=1.2', XUnit='wavelength', NumBanks=1, BankPixelWidth=1, XMin=0, XMax=16.5, BinWidth=0.1)
CreateSampleWorkspace(OutputWorkspace='out_11', Function='User Defined', UserDefinedFunction='name=Lorentzian, Amplitude=47000, PeakCentre=2.65, FWHM=1.2', XUnit='wavelength', NumBanks=1, BankPixelWidth=1, XMin=0, XMax=16.5, BinWidth=0.1)
CreateSampleWorkspace(OutputWorkspace='out_10', Function='User Defined', UserDefinedFunction='name=Lorentzian, Amplitude=22685, PeakCentre=2.55, FWHM=0.6', XUnit='wavelength', NumBanks=1, BankPixelWidth=1, XMin=0, XMax=16.5, BinWidth=0.1)
CreateSampleWorkspace(OutputWorkspace='out_01', Function='User Defined', UserDefinedFunction='name=Lorentzian, Amplitude=22685, PeakCentre=2.55, FWHM=0.6', XUnit='wavelength', NumBanks=1, BankPixelWidth=1, XMin=0, XMax=16.5, BinWidth=0.1)

group = GroupWorkspaces(['out_00','out_11','out_10','out_01'])

group = ConvertUnits(group, "Wavelength")

out = FlipperEfficiency(group, SpinStates="00, 11, 10, 01")

print("Flipper efficiency at a wavelength of " + str(mtd['out'].dataX(0)[3]) + " Å is " + str(mtd['out'].dataY(0)[3]))

Output:

.. testoutput:: FlipperEfficiencyExample
:options: +ELLIPSIS +NORMALIZE_WHITESPACE

Flipper efficiency at a wavelength of 4.0 Å is ...

.. categories::

.. sourcelink::

0 comments on commit f9cc30a

Please sign in to comment.