forked from fitbenchmarking/fitbenchmarking
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request fitbenchmarking#1405 from fitbenchmarking/add_spin…
…w_1d_slices Added support for SpinW 1D cuts of 2D powder data
- Loading branch information
Showing
15 changed files
with
482 additions
and
73 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file added
BIN
+3.48 KB
examples/benchmark_problems/SpinW_powder_data/data_files/tri_AFM_powder.mat
Binary file not shown.
3 changes: 3 additions & 0 deletions
3
examples/benchmark_problems/SpinW_powder_data/m_scripts/functions/tri_AFM_powder.m
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
function y = tri_AFM_powder(x, p) | ||
|
||
y = @(x, p) matparser(x, 'param', p, 'mat', {'J_1'}, 'init', true); |
43 changes: 43 additions & 0 deletions
43
...s/benchmark_problems/SpinW_powder_data/m_scripts/simulate_functions/fb_simulate_tri_AFM.m
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
function y = fb_simulate_IX_1D_test1(w,fitpars,msk) | ||
% simulate loop to solve for the parameters | ||
|
||
fit_func = @tri_AFM_powder; | ||
model_param = reshape(fitpars(1), 1, []); | ||
|
||
Ei = 20; % meV | ||
% Resolution for MARI with Gd chopper running at 200Hz and Ei=20meV (from PyChop) | ||
eres = @(en) 2.1750e-04*sqrt((Ei-en).^3 .* ( (32.27217*(0.168+0.400*(Ei./(Ei-en)).^1.5)).^2 + (14.53577*(1.168+0.400*(Ei./(Ei-en)).^1.5)).^2) ); | ||
% Q-resolution (parameters for MARI) | ||
e2k = @(en) sqrt( en .* (2*1.67492728e-27*1.60217653e-22) )./1.05457168e-34./1e10; | ||
L1 = 11.8; % Moderator to Sample distance in m | ||
L2 = 4.0; % Sample to detector distance in m | ||
ws = 0.05; % Width of sample in m | ||
wm = 0.12; % Width of moderator in m | ||
wd = 0.025; % Width of detector in m | ||
ki = e2k(Ei); | ||
a1 = ws/L1; % Angular width of sample seen from moderator | ||
a2 = wm/L1; % Angular width of moderator seen from sample | ||
a3 = wd/L2; % Angular width of detector seen from sample | ||
a4 = ws/L2; % Angular width of sample seen from detector | ||
dQ = 2.35 * sqrt( (ki*a1)^2/12 + (ki*a2)^2/12 + (ki*a3)^2/12 + (ki*a4)^2/12 ); | ||
|
||
tri = sw_model('triAF',1); | ||
fitpow = sw_fitpowder(tri, w, fit_func, model_param, 'independent'); | ||
|
||
% set parameters passed to powspec | ||
fitpow.powspec_args.dE = eres; % energy resolution | ||
fitpow.powspec_args.fastmode = true; | ||
fitpow.powspec_args.neutron_output = true; | ||
fitpow.powspec_args.nRand = 2e2; % low for speed (typically want > 1e3) | ||
fitpow.powspec_args.hermit = true; | ||
% set parameters passsed to sw_instrument | ||
fitpow.sw_instrument_args = struct('dQ', dQ, 'ThetaMin', 3.5, 'Ei', Ei); | ||
|
||
fitpow.powspec_args.dE = eres; | ||
fitpow.powspec_args.fastmode = true; | ||
fitpow.powspec_args.neutron_output = true; | ||
|
||
[y, bg] = fitpow.calc_spinwave_spec(fitpars) | ||
y = y' | ||
|
||
end |
9 changes: 9 additions & 0 deletions
9
examples/benchmark_problems/SpinW_powder_data/m_scripts/wye_functions/fb_wye_tri_AFM.m
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
function [w, y, e, msk] = fb_wye_tri_AFM(datafile, path) | ||
% Gets w , x, y ,e and msk from the object | ||
|
||
w = load(datafile).w; | ||
y = [w(1).y; w(2).y; w(3).y]; | ||
e = [w(1).e; w(2).e; w(3).e]; | ||
msk = [] | ||
|
||
end |
10 changes: 10 additions & 0 deletions
10
examples/benchmark_problems/SpinW_powder_data/tri_AFM_powder.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
# FitBenchmark Problem | ||
software = 'Horace' | ||
name = 'Triangular AFM Powder Spectrum' | ||
description = 'Simulated powder spectrum of a triangular AFM with constant background and normally distributed noise, fit to 1D cuts rather than 2D data' | ||
input_file = 'tri_AFM_powder.mat' | ||
function = 'foreground=m_scripts/functions/tri_AFM_powder.m,J1=0.85,b1=0,b2=1.4,b3=0,b4=1.4,b5=0,b6=1.4,b7=29.2' | ||
wye_function = 'matlab_script=m_scripts/wye_functions/fb_wye_tri_AFM.m' | ||
simulate_function = 'matlab_script=m_scripts/simulate_functions/fb_simulate_tri_AFM.m' | ||
plot_type = '1D_cuts' | ||
q_cens = '0.8,1.2,1.6' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.