Incoherent Summing with Custom Layers#

This is an example of using incoherent summing (‘domains’) from custom layers models. The sample is a simple two layer of permalloy/gold, with up/down domains

The domain custom model is similar to a normal custom models, except that the input (function arguments) of the custom function contains an additional ‘domains’ parameter as described in Custom Models with Domains.

This parameter tells the function which is the current domain, so the appropriate layer stack can be generated.

This example can be run as a script or interactively using the instructions below.

Note

The custom model used is a MATLAB model - examples/domains/customLayers/alloyDomains.m.

Run Script:

root = getappdata(0, 'root');
cd(fullfile(root, 'examples', 'domains', 'customLayers'));
domainsCustomLayersScript

Run Interactively:

root = getappdata(0, 'root');
cd(fullfile(root, 'examples', 'domains', 'customLayers'));
edit domainsCustomLayersSheet.mlx
Analysing Domains Samples Using Custom Layers Models.

Analysing Domains Samples Using Custom Layers Models.

For custom models, all the work with calculating the reflectivity from the different domains is done within the custom model itself.
To do this, there is an additional input into the custom model file which denotes the domain to be calculated...
functionStart.png
The final 'domain' input is always either 1 or 2, denoting which domain is being calculated. Then, within the custom model, we can calculate the layers structure for whichever domain structure is required in this pass through the function...
switchCase.png
We will make a simple example of a permalloy layer on silicon, which has spin up and spin down domains, each with different SLD's...
samplePic.png
We start by setting up the project....
% Test of custom layers domains prioject...
% Use incoherent summing on a permalloy layer
% as a test
 
problem = createProject(calcType="domains");
problem.modelType = 'custom layers';
problem.geometry = 'substrate/liquid';
 
% Make some parameters...
params = {{'Alloy thick', 100, 150, 200, true}
{'Alloy SLD up', 9e-6, 11e-6, 13e-6, true}
{'Alloy SLD dn', 5e-6, 7e-6, 10e-6, true}
{'Alloy rough', 5, 7, 11, true}
{'Gold thick', 100, 150, 200, true}
{'Gold SLD', 4e-6, 4.5e-6, 5e-6, true}
{'Gold Rough', 5, 7, 11, true}};
 
problem.addParameterGroup(params);
 
% Set the bulk SLD
problem.setBulkIn(1,'name','Silicon','Value',2.073e-6,'max',2.073e-6);
 
% Add the custom file...
problem.addCustomFile('Alloy domains', 'alloyDomains.m', 'matlab', pwd);
 
% Make a contrast...
problem.addContrast('name', 'D2O Conrast', ...
'Data', 'Simulation',...
'Background', 'Background 1',...
'BulkIn', 'Silicon',...
'BulkOut', 'SLD D2O',...
'Scalefactor', 'Scalefactor 1', ...
'Resolution', 'Resolution 1',...
'Resample', false,...
'domainRatio', 'Domain Ratio 1',...
'model', 'Alloy domains');
 
disp(problem)
modelType: 'custom layers' experimentName: '' geometry: 'substrate/liquid' Parameters: ---------------------------------------------------------------------------------------------- p Name Min Value Max Fit? _ _____________________ _____ _______ _______ _____ 1 "Substrate Roughness" 1 3 5 true 2 "Alloy thick" 100 150 200 true 3 "Alloy SLD up" 9e-06 1.1e-05 1.3e-05 true 4 "Alloy SLD dn" 5e-06 7e-06 1e-05 true 5 "Alloy rough" 5 7 11 true 6 "Gold thick" 100 150 200 true 7 "Gold SLD" 4e-06 4.5e-06 5e-06 true 8 "Gold Rough" 5 7 11 true Bulk In: -------------------------------------------------------------------------------------------------- p Name Min Value Max Fit? _ _________ ___ _________ _________ _____ 1 "Silicon" 0 2.073e-06 2.073e-06 false Bulk Out: ------------------------------------------------------------------------------------------------- p Name Min Value Max Fit? _ _________ _______ ________ ________ _____ 1 "SLD D2O" 6.2e-06 6.35e-06 6.35e-06 false Scalefactors: ------------------------------------------------------------------------------------------------- p Name Min Value Max Fit? _ _______________ ____ _____ ____ _____ 1 "Scalefactor 1" 0.02 0.23 0.25 false Domain Ratios: ----------------------------------------------------------------------------------------------- p Name Min Value Max Fit? _ ________________ ___ _____ ___ _____ 1 "Domain Ratio 1" 0.4 0.5 0.6 false Backgrounds: ----------------------------------------------------------------------------------------------- (a) Background Parameters: p Name Min Value Max Fit? _ ____________________ _____ _____ _____ _____ 1 "Background Param 1" 1e-07 1e-06 1e-05 false (b) Backgrounds: p Name Type Source Value 1 Value 2 Value 3 Value 4 Value 5 _ ______________ __________ ____________________ _______ _______ _______ _______ _______ 1 "Background 1" "constant" "Background Param 1" "" "" "" "" "" Resolutions: --------------------------------------------------------------------------------------------- (a) Resolutions Parameters: p Name Min Value Max Fit? _ __________________ ____ _____ ____ _____ 1 "Resolution par 1" 0.01 0.03 0.05 false (b) Resolutions: p Name Type Source Value 1 Value 2 Value 3 Value 4 Value 5 _ ______________ __________ __________________ _______ _______ _______ _______ _______ 1 "Resolution 1" "constant" "Resolution par 1" "" "" "" "" "" Custom Files: ------------------------------------------------------------------------------------------------------ Name Filename Function Name Language Path _______________ ________________ _____________ ________ ________________________________________________________ "Alloy domains" "alloyDomains.m" "-" "matlab" "...RAT-Docs/RAT-Docs/API/examples/domains/customLayers" Data: ------------------------------------------------------------------------------------------------------ Name Data Data Range Simulation Range ____________ _________ __________ _____________________ "Simulation" "No Data" "-" "[ 0.0050 , 0.7000 ]" Contrasts: ----------------------------------------------------------------------------------------------- p 1 ___________________ ________________ "Name" "D2O Conrast" "Data" "Simulation" "Background" "Background 1" "Background Action" "add" "Bulk in" "Silicon" "Bulk out" "SLD D2O" "Scalefactor" "Scalefactor 1" "Resolution" "Resolution 1" "Resample" "false" "Domain Ratio" "Domain Ratio 1" "Model" "Alloy domains"
In the project, we are using a custom function which we have called 'alloyDomains'...
type alloyDomains.m
function [output,subRough] = alloyDomains(params,bulkIn,bulkOut,contrast,domain) % Simple custom model for testing incoherent summing... % Simple two layer of permalloy / gold, with up/down domains.. % Split up the parameters.... subRough = params(1); alloyThick = params(2); alloySLDup = params(3); alloySLDdn = params(4); alloyRough = params(5); goldThick = params(6); goldSLD = params(7); goldRough = params(8); % Make the layers.... alloyUp = [alloyThick, alloySLDup, alloyRough]; alloyDn = [alloyThick, alloySLDdn, alloyRough]; gold = [goldThick, goldSLD, goldRough]; % Make the model dependiong on which domain we are looking at.. if domain==1 output = [alloyUp ; gold]; else output = [alloyDn ; gold]; end end
Note that the main difference between this and a 'normal' custom function is the extra 'domain' input, which we then use to select which domain we compute using the 'switch / case' instruction at the end of the function
To run this, we make a controls block as usual, and send it to RAT....
controls = controlsClass();
[problem,results] = RAT(problem,controls);
Starting RAT ________________________________________________________________________________________________ Elapsed time is 0.012415 seconds. Finished RAT ______________________________________________________________________________________________
 
plotRefSLD(problem,results)