Target Functions (Low Level API)#
- targetFunctions.reflectivityCalculation(problemStruct, problemCells, problemLimits, controls)#
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. The types of available target functions are:
non polarised - The main basic target function type, for non polarised neutrons (or x-rays) with non-absorbing samples. Different model types are specified in sub functions from here.
oil water - Target function for oil-water samples
domains - Target function for samples consisting of domains which are larger than the beam lateral coherence length.
magnetic - Target function for cases for polarised neutrons with polarisation analysis.
Common Functions#
- targetFunctions.common.backSort(contrastBackgroundParams, contrastQzshifts, contrastScalefactors, contrastBulkIns, contrastBulkOuts, contrastResolutionParams, backgroundParams, qzshifts, scalefactors, bulkIn, bulkOut, resolutionParams)#
Distributes the background and shift values among the different contrasts
USAGE:
[backgroundParams,qzshift,scalefactor,bulkIn,bulkOut,resolutionParams] = backsort(contrastBackgrounds,contrastQzshifts,contrastScalefactors,contrastBulkIns,contrastBulkOuts,contrastResolutions,backs,qzshifts,scalefactor,bulkIn,bulkOut,res)
- INPUTS:
contrastBackgroundParams: Which background value is associated with each contrast
contrastQzshifts: Which qz_shift value is associated with each contrast
contrastScalefactors: Which scalefactor value is associated with each contrast
contrastBulkIns: Which BulkIn value is associated with each contrast
contrastBulkOuts: Which BulkOut value is associated with each contrast
contrastResolutionParams: Which resolution value is associated with each contrast
backgroundParams: List of all background parameter values.
qzshifts: List of all qzshift values
scalefactors: List of all scalefactor values
bulkIn: List of all bulkIn values
bulkOut: List of all bulkOut values
resolutionParams: List of all resolution parameter values
- OUTPUTS:
outBackground: list of actual background parameter values for each contrast
outQzshift: list of actual qzshift values for each contrast
outScalefactor: list of actual scalefactor values for each contrast
outBulkIn: list of actual bulkIn values for each contrast
outBulkOut: list of actual bulkOut values for each contrast
outResolution: list of actual resolution parameter for each contrast
- targetFunctions.common.extractProblemParams(problemStruct)#
Extract individual parameters from problem
- targetFunctions.common.parseCells(problemCells)#
Splits up the master input list of all arrays into separate arrays
- INPUTS:
problemCells: cell array where all the project data is grouped together.
- OUTPUTS:
repeatLayers: controls repeating of the layers stack.
data: Array of all the data arrays.
dataLimits: Min max limits in q for the data arrays.
simLimits: Limits in Q for the reflectivity simulations.
layersDetails: Master array of all available layers.
contrastLayers: Which specific combination of arrays are needed for each contrast.
customFiles:Filenames and path for any custom files used.
- targetFunctions.common.shiftData(scalefactor, qzshift, dataPresent, data, dataLimits, simLimits)#
Shifts the data according to scale factor. If there is no data, makes x-data over the simulation range.
- INPUTS:
scalefactor: problemStruct.scalefactors
qzshift: problemStruct.qzhifts
dataPresent: problemStruct.dataPresent
data: problemStruct.data
dataLimits: problemStruct.dataLimits
simLimits: problemStruct.simLimits
- OUTPUTS:
shiftedData: Data shifted using given scale factor
- targetFunctions.common.costFunctions.chiSquared(thisData, thisFit, P)#
Chi-squared function is used to evaluate the goodness of fit. It is a measure of the difference between the observed and expected.
- targetFunctions.common.groupLayers.allocateLayersForContrast(contrastLayers, outParameterisedLayers, useImaginary)#
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:
outParameterisedLayers - List of all the available layers thisContrastLayers - Array detailing which layers are required for this contrast
- targetFunctions.common.groupLayers.allocateParamsToLayers(params, 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 ‘outLayers’ cell array
- targetFunctions.common.groupLayers.groupLayersMod(resampledLayers, subRoughs, geometry, bulkIns, bulkOuts)#
Arrange layers according to geometry and apply any coverage correction. The paratt calculation proceeds through the z,rho,rough stack, and the parameter ‘ssub’ in callParatt 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, outSsubs] = groupLayersMod(resampledLayers,subRoughs,geometry,bulkIns,bulkOuts)
- INPUTS:
resampledLayers: cell array, one for each contrast. Each cell is the list of layer values for each contrast.
subRoughs: Double of substrate roughness for each contrast.
geometry: ‘Air / Liquid (or solid)’ or ‘Solid / Liquid’
bulkIns: vector of bulkIn values.
bulkOuts: vector of bulkOut values.
- Outputs:
outLayers: cell array of layers param values for each contrast.
outSsubs: vector of substrate roughness values.
- targetFunctions.common.groupLayers.groupLayersModImaginary(resampledLayers, subRoughs, geometry, bulkIns, bulkOuts)#
Arrange layers according to geometry and apply any coverage correction. The paratt calculation proceeds through the z,rho,rough stack, and the parameter ‘ssub’ in callParatt 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, outSsubs] = groupLayersModImaginary(resampledLayers,subRoughs,geometry,bulkIns,bulkOuts)
- INPUTS:
resampledLayers: cell array, one for each contrast. Each cell is the list of layer values for each contrast.
subRoughs: Double of substrate roughness for each contrast.
geometry: ‘Air / Liquid (or solid)’ or ‘Solid / Liquid’
bulkIns: vector of bulkIn values.
bulkOuts: vector of bulkOut values.
- Outputs:
outLayers: cell array of layers param values for each contrast.
outSsubs: vector of substrate roughness values.
Non-Polarised Target Functions (nonPolarisedTF)
- targetFunctions.nonPolarisedTF.customLayers.processCustomFunction(contrastBulkIns, contrastBulkOuts, bulkInArray, bulkOutArray, cCustFiles, numberOfContrasts, customFiles, params, useImaginary)#
Top-level function for processing custom layers for all the contrasts.
- targetFunctions.nonPolarisedTF.customXY.processCustomFunction(contrastBulkIns, contrastBulkOuts, bulkInArray, bulkOutArray, cCustFiles, numberOfContrasts, customFiles, params)#
Top-level function for processing custom XY profiles for all the contrasts.
Domains Target Functions (domainsTF)#
- targetFunctions.domainsTF.customLayers.processCustomFunction(contrastBulkIns, contrastBulkOuts, bulkInArray, bulkOutArray, cCustFiles, numberOfContrasts, customFiles, params, useImaginary)#
Top-level function for processing custom layers for all the contrasts.
- targetFunctions.domainsTF.customXY.processCustomFunction(contrastBulkIns, contrastBulkOuts, bulkInArray, bulkOutArray, cCustFiles, numberOfContrasts, customFiles, params)#
Top-level function for processing custom XY profiles for all the contrasts.