Skip to content
Snippets Groups Projects
MSDFit-v1.rst 1.85 KiB
Newer Older
Dan Nixon's avatar
Dan Nixon committed
.. algorithm::

.. summary::

.. relatedalgorithms::
Dan Nixon's avatar
Dan Nixon committed

.. properties::

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

Fits :math:`intensity` vs :math:`Q` with a straight line for each run
Dan Nixon's avatar
Dan Nixon committed
to obtain the mean square displacement for a given range of runs.

This algorithm operates on the :math:`Q` workspace (*_eq*) generated by
the :ref:`ElasticWindowMultiple <algm-ElasticWindowMultiple>` algorithm.

The model used for obtaining the mean squared displacement can be
selected. These models include 'Gaussian', 'Peters', 'Yi'.
Dan Nixon's avatar
Dan Nixon committed

Workflow
--------

.. diagram:: MSDFit-v1_wkflw.dot

Usage
-----

**Example - Performing MSDFit on simulated data.**

.. testcode:: ExGeneratedDataFit

    # Create some data that is similar to the output of ElasticWindowMultiple
    sample = CreateSampleWorkspace(Function='User Defined',
                    UserDefinedFunction='name=ExpDecay,Height=1,Lifetime=6',
                    NumBanks=1, BankPixelWidth=1, XUnit='momentum', XMin=0.0,
                    XMax=5.0, BinWidth=0.1)

    g_msd, g_param, g_fit = MSDFit(InputWorkspace=sample,
                                   Model="Gauss",
                                   XStart=0.0, XEnd=5.0,
                                   SpecMin=0, SpecMax=0)

    y_msd, y_param, y_fit = MSDFit(InputWorkspace=sample,
                                   Model="Yi",
                                   XStart=0.0, XEnd=5.0,
                                   SpecMin=0, SpecMax=0)

    print('Using Gauss Model')
    print('A0: ' + str(g_msd.readY(0)))
    print('A1: ' + str(g_msd.readY(1)))
    print('Using Yi Model')
    print('A0: ' + str(y_msd.readY(0)))
    print('A1: ' + str(y_msd.readY(1)))

Output:

.. testoutput:: ExGeneratedDataFit

    Using Gauss Model
    A0: [ 0.87079958]
    A1: [ 0.03278263]
    Using Yi Model
    A0: [ 0.95770532]
    A1: [ 0.58819225]
Dan Nixon's avatar
Dan Nixon committed
.. categories::
  :cpp: None
  :h: None