I am trying to fit data to an integral whose limits vary for each point - the Callaway model for thermal conductivity. I have a wave with x data and a wave with y data (Nine points in each wave). I need to fit the data to an integral whose limits go from 0 to a constant/x[i] for each x[i] and y[i] pair. Everything compiles, but IGOR tells me I have a BAD USER FUNCTION FORMAT when I try to fit the data. Below is what I have tried so far. Any help would be appreciated!
//This is the user-defined fitting function:
Variable/G Alpha=A, Beta1=B1, Beta2=B2, Length = L //Parameters to be fitted
Variable/G Temp=T //Wave with the independent variable
f(T) = Real(Integrate1d(eqn, .001, 281/Temp)) //This is what I want to do, but ...
//This is the function it calls:
NVAR Alpha, Beta1, Beta2, Length
// A bunch of variables - The constants are defined at the top of the procedure file as they should be, I just stuck them below for now
Variable Pre = (kB/(2*Pi*Pi*c))*((kB*Temp/hbar)^3)
Variable Tp = Alpha*x^4*Temp^4
Variable Tb = c/Length
Variable Tu = Beta1*exp(-ThetaDebye/(a*Temp))*(T^5)*(x^2)
Variable Tn = Beta2*(Temp^5)*(x^2)
Variable Tc = (Tp+Tb+Tu+Tn)^-1
// The equation I want to integrate
Constant kB = 1.38e-23
Constant ThetaDebye = 281
Constant a= 1
Since the FuncFit operation has to be able to assemble data and call your fit function itself, there are strict rules on the inputs to a fitting function. Your function doesn't fit those rules. You can read about the rules by executing this command on Igor's command line:
DisplayHelpTopic "User-Defined Fitting Function: Detailed Description"
FuncFit accepts a variety of different format in order to handle various situations.
Your function lacks an input wave corresponding to the coefficient wave. That wave has the adjustable parameters that are the point of the curve fit. So my next question is- what are the adjustable parameters in your function?
Your subject line says you want to get the limits of integration from a wave, but in fact you have an equation for the limit that depends on X (which I presume is the independent variable in your curve fit). So you don't need to get the limits from a wave, you need to compute it depending on the value of X.
Oh, wait- I just understood your bits of code and commands. You need to wrap up the three lines at the top in a user-defined function of the appropriate format. Something like this:
Function fitEqn(pw, Temp)
Wave pw // coefficient wave
// pw = Alpha
// pw = Beta1
// pw = Beta2
// pw = Length
// Globals are required to transmit the parameters to the integrand function
Variable/G Alpha=pw, Beta1=pw, Beta2=pw, Length = pw //Parameters to be fitted
return Integrate1d(eqn, .001, 281/Temp) //This is what I want to do, but ...
Thanks!! The problem was in the line f(T) = Real(Integrate1d(eqn, .001, 281/Temp)). To get this fuction, I had edited another fit function that integrated over complex values and missed the "Real" in that line. The program works perfectly now. Thanks again.
Back to top