The Origin Forum
File Exchange
Try Origin for Free
The Origin Forum
Home | Profile | Register | Active Topics | Members | Search | FAQ | Send File to Tech support
Username:
Password:
Save Password
Forgot your Password? | Admin Options

 All Forums
 Origin Forum
 Origin Forum
 About editing the square of Voigt function
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic Lock Topic Edit Topic Delete Topic New Topic Reply to Topic

gingko

Posts

Posted - 06/29/2006 :  12:14:36 PM  Show Profile  Edit Topic  Reply with Quote  View user's IP address  Delete Topic
Origin Version (Select Help-->About Origin): 7.0
Operating System:xp

Hello to all,

I have a problem with user-defined fitting functions. What I would like to do is to use the square of Voigt function to fit the peak profile. But I have a problem writing the integration function from negative infinity to infinity. How do I edit the function in Code Builder?
Following shows the equation of Voigt function,



Thanks in advance
Gingko

Edited by - gingko on 07/01/2006 03:51:19 AM

Edited by - gingko on 07/04/2006 02:03:55 AM

Edited by - gingko on 07/04/2006 02:13:48 AM

gingko

Posts

Posted - 07/04/2006 :  02:06:29 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Hello to all,

Can someone give me some useful hints?

Thanks in advance

Gingko
Go to Top of Page

zachary_origin

China
Posts

Posted - 07/06/2006 :  01:28:33 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Hi Gingko,


Here is the codes using the algorithm proposed by Humlicek.
Ref:
1. J. Humlicek, J. Quant. Spectrosc. Radiat. Transfer. Vol. 21, pp. 309-313
2. R.J. Wells. J. Quant. Spectrosc. Radiat. Transfer. Vo.62, pp 29-48.

----------------------------------------
You can use the codes in two methods:

1.create a new user-defined fitting function (In Nonlinear Curve Fitting dialog:

select Function> New ), and set as followings:

Parameter Names (select User Defined Param. Names): y0, x0, A, wG, wL
Independent Var: x
Dependent Var: y
Formula:

const double sqrtln2 = 0.832554611;
double T[] = {0.0, .314240376, .947788391, 1.59768264,

2.27950708, 3.02063703, 3.8897249};
double C[] = {0.0, 1.01172805, -.75197147, 1.2557727e-2,

1.00220082e-2, -2.42068135e-4, 5.00848061e-7};
double S[] = {0.0, 1.39323, .231152406, -.155351466,

6.21836624e-3, 9.19082986e-5, -6.27525958e-7};
double wr = 0.0;
double wi = 0.0;
double X, Y, y1, y2, y3, d, d1, d2, d3, d4, r, r2;
int i;

double temp;

X = 2*sqrtln2*(x - x0)/wG;
Y = sqrtln2*wL/wG;

y1 = Y + 1.5;
y2 = y1 * y1;

if(Y > 0.85 || fabs(X) < 18.1*Y+1.65)
{
for(i=1; i<=6; i++)
{
r = X - T[i];
d = 1.0/(r*r + y2);
d1 = y1*d;
d2 = r*d;
r = X + T[i];
d = 1.0/(r*r + y2);
d3 = y1*d;
d4 = r*d;
wr = wr + C[i]*(d1 + d3) - S[i]*(d2 - d4);
wi = wi + C[i]*(d2 + d4) + S[i]*(d1 - d3);
}
}
else
{
if(fabs(X) < 12.0)
{
wr = exp(-X*X);
}
y3 = Y + 3.0;
for(i=1; i<=6; i++)
{
r = X - T[i];
r2 = r * r;
d = 1.0/(r2 + y2);
d1 = y1 * d;
d2 = r * d;
wr = wr + Y*(C[i]*(r*d2 - 1.5*d1) + S[i]*y3*d2)/(r2 + 2.25);
r = X + T[i];
r2 = r * r;
d = 1.0/(r2 + y2);
d3 = y1 * d;
d4 = r * d;
wr = wr + Y*(C[i]*(r*d4 - 1.5*d3) - S[i]*y3*d4)/(r2 + 2.25);
wi = wi + C[i]*(d2 + d4) + S[i]*(d1 - d3);
}
}
temp = A*wr*0.939437278/wG;

y = y0 + temp * temp;




Then in the Parameter Initialization (In Nonlinear Curve Fitting dialog: select Scripts>

Parameter Initialization), select Enable Antomatic Parameter Initialization and Use Origin C.
Copy the following to the edit box:

sort(x_y_curve);
smooth(x_y_curve);
y0 = yatxmin( x_y_curve );
wG = 0.85 * fwhm( x_y_curve, y0 );
wL = wG;
A = area( x_y_curve, y0 );
if ( A > 0 ) x0 = xatymax( x_y_curve );
else x0 = xatymin( x_y_curve );

-----------------------------------------------------------------
2. Using fdf file: The fdf file named as Squre_Voigt.fdf was attached in the message, you aslo can directly add this fitting function by the following steps,
a. Open the nonlinear curve fitting dialog: Select Analysis>Non-linear Curve fit > Advanced fitting dialog in the menu ( ctrl+ y).

b. In the dialog, select Function > Select, then select Function > Add.. in the menu. Then a file open dialog pops up, select the Squre_Voigt.fdf file.

c. Do nonlinear fitting like build-in functions.




Zachary
OriginLab GZ Office


Edited by - zachary_origin on 07/06/2006 01:33:12 AM
Go to Top of Page

zachary_origin

China
Posts

Posted - 07/06/2006 :  01:35:30 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Sorry, the fdf file can not be attached. If you need it, please send me a mail: zachary@originlab.com.cn

Zachary
OriginLab GZ Office
Go to Top of Page

gingko

Posts

Posted - 07/07/2006 :  07:54:39 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Hi Zachary,

Thanks for your help.
I tried the first method and it worked good!
From the settings of this equation,
it shows the description of the integration part depends on different cases. Right?
I need to use another function to fit my experimental data now.
The function is squred Lorentzian function convolute with squred Gaussian function:

How do I edit this function?
It's very important for me, please give me some hints.

Thanks in advance
Gingko
Go to Top of Page

zachary_origin

China
Posts

Posted - 07/09/2006 :  10:16:37 PM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Hi Gingko,

Since Voigt function is known to be the real part of Faddeeva function, the function can be calculated using numerical methods.

But for the function convoluted from squred Lorentzian function with squred Gaussian function, no earlier study on it and I don't think it is easy to calculate numerically unless you can find the result analytically.
I am regretting that I cannot provide any useful hints about this.

Zachary
OriginLab GZ Office
Go to Top of Page

gingko

Posts

Posted - 07/10/2006 :  02:29:49 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Hi Zachary,
Thanks for your reply!
I have encountered another problem when using squared_Voigt function to fit multiple peaks.
In the peak fitting window
,
I created the squared_Voigt function, and copied the settings that you gave me to the edit box.
But the commends for the function is too long to fit into the edit box.

What can I do ?

Thanks in advanced
Gingko

Go to Top of Page

zachary_origin

China
Posts

Posted - 07/10/2006 :  11:19:55 PM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Hi Gingko,
There are some problems to use this in PFM because for user-defined script functions, the function description field actually defines the function and must follow proper LabTalk syntax. The function wrote in OC level cann't run here. So if you need use it in PFM, you need create the fit function as an external dll file and then invoke it in PFM (For how to use External DLL functions, to see PFM help.)

You can directly use the fitting function through Non-linear Curve fitting dialog. If you want to fit multiple peaks, you can take a look at this post
( http://www.originlab.com/forum/topic.asp?TOPIC_ID=2189 , perhaps this will not work if the manually set parameters are not proper ). Or, you can use the Data Selector tool to select the peaks and then fit the peaks seperately.

Zachary
OriginLab GZ Office
Go to Top of Page
  Previous Topic Topic Next Topic Lock Topic Edit Topic Delete Topic New Topic Reply to Topic
 New Topic  Reply to Topic
 Printer Friendly
Jump To:
The Origin Forum © 2020 Originlab Corporation Go To Top Of Page
Snitz Forums 2000