Target Functions (Low Level API)#

targetFunctions.reflectivityCalculation(problemStruct, controls)#

Compute the reflectivity and SLD curves for a given model using the Abeles matrix formalism.

Main entry point into the reflectivity calculation for the toolbox. This is the main function that is called by any of the minimisers or analysis tools from the rest of the toolbox.

The main job of this function is to decide which type of calculation (i.e. ‘Target function’) is required, and call the relevant routines. Different model types are specified in sub functions. The types of available target functions are:

  • normal - The main basic target function type, for non polarised neutrons (or x-rays) with non-absorbing samples.

  • domains - Target function for samples consisting of domains which are larger than the beam lateral coherence length.

Parameters:
  • problemStruct (struct) – The project class as a struct (generated via parseClassToStructs)

  • controls (struct) – The controls struct (generated via parseClassToStructs)

Returns:

result – The results of the calculation.

Return type:

struct

Common Functions#

targetFunctions.common.getFitNames(problemStruct)#

Note that this order of parameters fields is hard-coded by this routine, packParams, packParamsPriors, and unpackParams

targetFunctions.common.costFunctions.chiSquared(shiftedData, reflectivity, nParams)#

Chi-squared function is used to evaluate the goodness of fit. It is a measure of the difference between the observed and expected reflectivity.

targetFunctions.common.groupLayers.allocateLayersForContrast(layerIndices, layerValues)#

Decide which layers are needed for a particular contrast. This function takes the master array of all layers and extracts which parameters are required for a particular contrast.

INPUTS:

layerValues - List of all the available layers layerIndices - Array detailing which layers are required for this contrast

targetFunctions.common.groupLayers.allocateParamsToLayers(paramValues, layersDetails)#

Allocates parameters from the parameter array to the correct layers

This function takes the list of all layers in ‘layersDetails’, then loops over all the layers, putting in the correct parameter value from the parameters array into each layer in the ‘layerValues’ cell array

targetFunctions.common.groupLayers.groupLayersMod(layers, subRoughs, geometry)#

Arrange layers according to geometry. The paratt calculation proceeds through the z,rho,rough stack; and the parameter ‘ssub’ is the final roughness encountered.

  • For air/liquid ‘ssub’ is therefore the substrate roughness.

  • For solid/liquid, the substrate roughness is the first roughness encountered, and ‘ssub’ is then the roughness of the outermost layer.

USAGE:

[outLayers, ssubs] = groupLayersMod(resampledLayers,subRoughs,geometry)
INPUTS:
  • layers: List of layer values for this contrast.

  • subRoughs: Double of substrate roughness for this contrast.

  • geometry: ‘Air / Liquid (or solid)’ or ‘Solid / Liquid’

Outputs:
  • outputLayers: Layers parameter values for this contrast.

  • ssubs: vector of ssub values.

Normal Target Functions (normalTF)#

targetFunctions.normalTF.normalReflectivity(problemStruct, controls)#

This is the main normal reflectivity calculation. It extracts the required parameters for the contrasts from the input arrays, then passes the main calculation to the appropriate core calculation, which carries out the calculation itself. The core layers calculation is common for both standard and custom layers, with an additional core custom XY calculation.

targetFunctions.normalTF.processCustomFunction(bulkIns, bulkOuts, contrastCustomFiles, numberOfContrasts, numberOfOutputColumns, customFiles, paramValues, useImaginary)#

Top-level function for processing custom layers for all the contrasts

Domains Target Functions (domainsTF)#

targetFunctions.domainsTF.averageReflectivity(reflectivity1, reflectivity2, simulation1, simulation2, domainRatio)#

Calculates the averaged reflectivity for domains samples (incoherent sum)

targetFunctions.domainsTF.domainsReflectivity(problemStruct, controls)#

This is the main domains reflectivity calculation. It extracts the required parameters for the contrasts from the input arrays, then passes the main calculation to the appropriate core calculation, which carries out the calculation itself. The core layers calculation is common for both standard and custom layers, with an additional core custom XY calculation.

targetFunctions.domainsTF.processCustomFunction(bulkIns, bulkOuts, contrastCustomFiles, numberOfContrasts, numberOfOutputColumns, customFiles, paramValues, useImaginary)#

Top-level function for processing custom layers for all the contrasts