Set default Initial Guesses in User-Defined Function
berger.156
Function alpha_EY_Fit(w,d) : FitFunc
Wave w
Variable d
//CurveFitDialog/ Independent Variables 1
//CurveFitDialog/ d
//CurveFitDialog/ Coefficients 13
//CurveFitDialog/ w[0] = alpha_int
//CurveFitDialog/ w[1] = Ms
//CurveFitDialog/ w[2] = d_FM
//CurveFitDialog/ w[3] = G_ud_1
//CurveFitDialog/ w[4] = lambda_1
//CurveFitDialog/ w[5] = rho_0
//CurveFitDialog/ w[6] = mfp
//CurveFitDialog/ w[7] = sigma_int
//CurveFitDialog/ w[8] = G_ud_2
//CurveFitDialog/ w[9] = lambda_2
//CurveFitDialog/ w[10] = sigma_2
//CurveFitDialog/ w[11] = d_2
//CurveFitDialog/ w[12] = Delta_SML
//initial guesses:
//Ms = 8.4352e+005 A/m
//mfp = 13e-9 m
//rho_0 = 1.6311e-7 ohm*m
//sigma_int = 1.2786e6 ohm^-1 m^-1
//G_ud_2 = 4.79e14 Ohm^-1 m^-2
//lambda_2 = 1e-9 m
//sigma_2 = 3.3e6 ohm^-1 m^-1
return alpha_EY(w[0],w[1],w[2],w[3],w[4],w[5],w[6],w[7],w[8],w[9],w[10],w[11],w[12],d)
End
Why are you hiding the details of the function alpha_EY(...)? Why not put its code fully inside of alpha_EY_fit so that reading and debugging the code is easier?
--
J. J. Weimer
Chemistry / Chemical & Materials Engineering, UAH
September 28, 2017 at 11:49 am - Permalink
How is this done? Do I simply declare the values for each of the elements of Wave w?
Function alpha_EY_Fit(w,d) : FitFunc Wave w Variable d //initial guesses w[0] = .004 //CurveFitDialog/ Independent Variables 1 //CurveFitDialog/ d //CurveFitDialog/ Coefficients 13 //CurveFitDialog/ w[0] = alpha_int //... etc. End
Thanks.
As for your other comment, I didn't need to include the complicated form of alpha_EY(...), but you are right. Including it directly would make the code easier to debug.
September 28, 2017 at 12:49 pm - Permalink
Yes, but as this ...
make/N=.../D/O wcoef
// set initial guesses
wcoef[0] = ...
wcoef[1] = ...
// do curve fit
CurveFit ...
return 0
end
Function alpha_EY_Fit(ww,xx)
wave ww
variable xx
...
variable rtn
rtn = ww[0] ... ww[N]
return rtn
end
Also, you might also use the above convention to avoid overlap of WaveMetrics definitions (w? or d?) and to help make the code legible.
--
J. J. Weimer
Chemistry / Chemical & Materials Engineering, UAH
September 28, 2017 at 02:16 pm - Permalink
DoFit()
?I like using the "Graph Now" functionality as a tweak my initial guesses.
September 28, 2017 at 04:45 pm - Permalink
This will NOT work from a menu call. The option in this case is to define and initialize the coefficient wave using the command line. Then use the menu and select the pre-defined, pre-initialized wave as the coefficient wave. Alternatively, you can
* Learn how to append the initial guess wave to the current graph
* Learn how to include the flags you need in the operation call to CurveFit.
--
J. J. Weimer
Chemistry / Chemical & Materials Engineering, UAH
September 29, 2017 at 05:56 am - Permalink