Converting from Horace 3 to Horace 4
Horace 4 has been a major rewrite and refactoring effort on the code from Horace 3. This document outlines the breaking changes between versions as well as describing a fast way to convert existing scripts from Horace 3 to Horace 4.
Projections
In Horace 4, projections have been expanded and reworked to be generalised for other shapes of cuts (e.g. spherical, cylindrical). As a result, the old-style projections, e.g.:
proj1 = struct('u', [1 0 0], 'v', [0 1 0]);
proj2 = projaxes([1 0 0], [0 1 0]);
proj3 = ortho_proj([1 0 0], [0 1 0]);
proj4.u = [1 0 0];
proj4.v = [0 1 0];
have been deprecated and a warning will be issued if they are
used. For old-style projections the conversion is as simple as
replacing the struct
, projaxes
or ortho_proj
with line_proj
(c.f. projections).
proj1 = line_proj([1 0 0], [0 1 0]);
proj2 = line_proj([1 0 0], [0 1 0]);
proj3 = line_proj([1 0 0], [0 1 0]);
proj4 = line_proj([1 0 0], [0 1 0]);
Symmetrisation
The function sqw.symmetrise_sqw
has been significantly rewritten
to generalise it and allow rotational symmetry reduction. As part of
this rewrite, it now takes Symop
s as arguments rather than a pair
of vectors.
To update e.g.:
symmetrised = win.symmetrise_sqw([1 0 0], [0 1 0], [1 1 1]);
it simply becomes:
symmetrised = win.symmetrise_sqw(SymopReflection([1 0 0], [0 1 0], [1 1 1]);
Note
The SymopReflection
can also be constructed earlier and reused:
sym = SymopReflection([1 0 0], [0 1 0], [1 1 1]);
symmetrised = win.symmetrise_sqw(sym);
Passing a pair of vectors will still be accepted and be internally
transformed into the correct Symop
, however, it is still best to
switch.
Crystal Alignment
Crystal alignment in Horace 4 has changed slightly in that only one object is returned from the realignment functions. This object contains all the data necessary for the realignment.
Note
The subsequent procedure is identical to the Horace 3 procedure for using
rlu_corrections
, however the object is not a plain matrix.
To convert files, it is simply a case of removing the use of the extra arguments, e.g.:
[rlu_corr,alatt,angdeg] = refine_crystal(rlu0, alatt, angdeg, bp,'fix_angdeg','fix_alatt_ratio');
becomes:
rlu_corr = refine_crystal(rlu0, alatt, angdeg, bp,'fix_angdeg','fix_alatt_ratio');
And simply pass rlu_corr
to all operations as normal.
Multifit
As of Horace 4, the deprecated legacy multifit syntax (i.e. all in one line):
[wfit, fitdata] = multifit_sqw(my_new_cut, @sr122_xsec, pars, pfree, pbind, 'list', 1);
has been fully removed. This means that trying to use this syntax will result in an error. The modern syntax uses an object-based form which looks like:
kk = multifit(my_new_cut);
kk = kk.set_fun(@sr122_xsec);
kk = kk.set_pin(pars);
kk = kk.set_free(pfree);
kk = kk.set_bind(pbind);
kk = kk.set_options('listing', 1);
[wfit, fitdata] = kk.fit();
While this would be a lot of effort to translate manually, thankfully,
Horace 4.0 comes with a function (mf_leg_to_new
) to translate the
legacy tyle to the new format:
mf_leg_to_new("[wfit, fitdata] = multifit_sqw(my_new_cut, @sr122_xsec, pars, pfree, pbind, 'list', 1)")
ans =
kk = multifit(my_new_cut);
kk = kk.set_fun(@sr122_xsec);
kk = kk.set_pin(pars);
kk = kk.set_free(pfree);
kk = kk.set_bind(pbind);
kk = kk.set_options('listing', 1);
[wfit, fitdata] = kk.fit();
ready to be put into your code.
Warning
The reason for not translating files directly is that this function is provided in a caveat emptor state and the parameters should be double checked to ensure they are what you expect. Any erroneous parameters should be reported to the developers at Horace Help
Deprecated Functions
Note
All deprecation warning IDs in horace are of the form
HORACE:function:deprecated
. A complete list is below [1]
The table below lists functions have been deprecated and their Horace 4 equivalent.
Old |
New |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|