Simulation
From Horace
There are a variety of simulation tools available in Horace, so that if you have a theoretical model to describe your data you can simulate the results for the specific data points that you measured.
IMPORTANT When simulating an S(Q,w) model (see sqw_eval below), bear in mind the difference between what is calculated for equivalent dnd and sqw datasets. See FAQ.
func_eval
This evaluates a user-supplied function at the x, y, z, ... values of an n-dimensional dataset, or array of datasets. The syntax is as follows:
wout = func_eval(win, @myfunc, p); wout = func_eval(win, @myfunc, p, 'all');
win is the input dataset or array of datasets (sqw or dnd type) for which you wish to perform a simulation.
myfunc is the name of a user-defined function to calculate the intensity at the points in the dataset(s). The function must be of the form y = mfunc(x1, x2, ..., xn, pars), e.g. y = gauss2d(x1, x2, [amplitude, centre1, centre2, width1, width2, background]) and accept equal sized arrays that contain the x1, x2, ... values.
p can be a row-vector containing the parameters needed by the function. More generally it is a cell array containing information for the function myfunc.
The optional keyword 'all' is used if you wish to calculate the intensity from the function over the whole domain covered by the input dataset. In other words, your dataset may contain gaps due to the trajectory of the detectors through reciprocal space, but you may wish to simulate the scattering even in the gaps.
disp2sqw_plot
Generate a plot of a dispersion relation.
disp2sqw_plot(rlp,dispreln,pars,ebins,fwhh)
OR
weight=disp2sqw_plot(lattice,rlp,dispreln,pars,ebins,fwhh,'ndiv',n,'noplot')
rlp is an array of reciprocal lattice points between which the dispersion relation will be calculated - e.g. [0,0,0; 0,0,1; 0,-1,1; 1,-1,1; 1,0,1; 1,0,0].
dispreln is a handle to a function that calculates the dispersion relation w(Q) and spectrl weight, s(Q). It must have the following form:
[w,s] = dispreln (qh,qk,ql,p)
where qh,qk,ql, are arrays containing the coordinates of a set of points in reciprocal lattice units, pis a vector of parameters needed by dispersion function. The output wis an array of corresponding energies, or, if more than one dispersion relation is called, a cell array of arrays.
pars are the parameters p mentioned above.
ebins gives the energy grid on which the dispersion will be plotted. Is given by a vector of the form [energy_lo,step,energy_hi].
fwhh is a scalar which gives the width of Gaussian broadening in energy applied to the dispersion relation - i.e. a very crude way of approximating the effect of resolution.
There are some additional optional inputs and outputs.
'noplot' can be used when an output object is specified, and you do not wish to plot it.
'ndiv' is a scalar specifying the number of points between adjacent q-points in the list rlp.
The output weight is a Libisis IXTdataset_2d object corresponding to the Q-E dispersion plot.
sqw_eval
wout = sqw(win, @my_sqw_func, p); wout = sqw(win, @my_sqw_func, p, 'all');
The syntax for sqw is almost identical to that of func_eval. The only difference is the form of the function required my_sqw_func.
my_sqw_func must be of the form
weight = my_sqw_func(qh, qk, ql, en, p)
where qh, qk, ql, en area arrays that contain the co-ordinates in h, k, l and energy of every point in the dataset, irrespective of the dimensionality of that dataset. As before, p is a row-vector containing the parameters required by the function.
One would generally use sqw_eval in preference to func_eval if, for example, one had a model of the spin-wave cross-section for magnetic scattering.