This fit bug, with a multi fit with tied parameters, is also observed in the Muon Interface but seems to be more general.
Expected behavior
The calculated curves in the output workspaces should be the function evaluated at the final parameter values, so for a good fit the Calc and Data curves should be nearly equal and Diff nearly zero
Actual behaviour
Even with a good fit, for all but the first function, the Calc curves are wrong. Diff is the difference between the data and this wrong curve. Are some of the tied parameters not being copied across properly, despite appearing in the xx_Parameters tables as normal?
Steps to reproduce the behavior
Try this script. It fits the same two spectra in either order, and gets the same parameters as expected, but it’s always the second one’s Calc and Diff curves that are wrong.
w=LoadMuonNexus("//musr/data/musr00062301.nxs")
for selection in ( ("set06", 0,6), ("set60", 6,0) ):
function="""composite=MultiDomainFunction,NumDeriv=true;
(composite=CompositeFunction,$domains=0;
name=UserFunction,Formula=N0*exp(-x/2.19703)*(1+A*cos(2*3.14159265*Freq*x+Phi)),N0=1500.000000,A=0.260000,Freq=0.338750,Phi=4.7);
(composite=CompositeFunction,$domains=1;
name=UserFunction,Formula=N0*exp(-x/2.19703)*(1+A*cos(2*3.14159265*Freq*x+Phi)),N0=1500.000000,A=0.260000,Freq=0.338750,Phi=4.7);
ties=(f1.f0.Freq=f0.f0.Freq)"""
args={'StartX_1': 0.1, 'StartX': 0.1, 'MaxIterations': 200, 'InputWorkspace': w[0], 'InputWorkspace_1':w[0],
'EndX': 8.0, 'WorkspaceIndex': selection[1], 'WorkspaceIndex_1': selection[2], 'Output': selection[0],
'Minimizer': 'Levenberg-MarquardtMD,MuMax=1e+06,AbsError=0.0001,Debug=0', 'EndX_1': 8.0}
print "Fitting to spectra ",selection
f=Fit(function,**args)
print "Cost Function",f[1]
plot_spectrum(f[4][0],range(3))
plot_spectrum(f[4][1],range(3))
Platforms affected
Mantid 3.9.0 and 3.9.1 (running on Windows, maybe others)