Note: You must be registered in order to post a reply. To register, click here. Registration is FREE!
T O P I C R E V I E W
aekalavya
Posted - 01/26/2012 : 02:54:24 AM Origin Ver. and Service Release (Select Help-->About Origin): 8.6 Operating System: Win7
I am trying to create a external dll file using gsl library with the help of the example given in the sample file for Voigt function/GslVoigtExIntegQag. Here is the sample code for Voigt function. ----------------------------- #include <gsl/gsl_integration.h> static double f_callback(double t, void* params) { double* p = (double*)params; #define Wl p[0] #define Wg p[1] #define xv p[2] #define xc p[3] return exp(-t * t) / (log(2) * (Wl/Wg) * (Wl/Wg) + pow((sqrt(4 * log(2)) * (xv - xc)/Wg - t), 2));
#undef Wl #undef Wg #undef xv #undef xc }
#define PI (3.14159265359) #define WORKSPACE_SIZE 1000 int FAR PASCAL GslVoigtExIntegQag(FIT_PARA_LIST) { //params #define y0 p[1] #define A p[2] #define Wl p[3] #define Wg p[4] #define a p[5] #define b p[6] #define xc p[7] #define xVal x[1] #define yVal y[1]
if ( HAS_FUNC_DERIV ) { return NONE; } if ( GET_FUNC_VALUE ) { double result = 0, err = 0; gsl_integration_workspace* pWorkspace = gsl_integration_workspace_alloc(WORKSPACE_SIZE); gsl_function Function;
#define A p[0] //Decay rate #define B p[1] //Recovery rate #define T p[2] //Sample temperature #define F p[3] //Energy factor in boltzman distribution #define time p[4] //time is the variable in the fitting function. #define I p[5] //Pump beam Intensity
double dd = x-A*I/B*exp(-(x*B-A*I)*time);
return x * (x*B-A*I) * exp(-F*pow(x,0.66)/(8.617E-5*T)) / dd;
#undef A #undef B #undef T #undef F #undef time #undef I
}
int FAR PASCAL IntTheoryIntegral(FIT_PARA_LIST) { //params #define A p[1] //Decay rate #define B p[2] //Recovery rate #define T p[3] //Sample temperature #define F p[4] //Energy factor in boltzman distribution #define I p[5] //Pump beam Intensity #define Nm p[6] #define M p[7] #define xVal x[1] #define yVal y[1]
if ( HAS_FUNC_DERIV ) { return NONE; } if ( GET_FUNC_VALUE ) { double result = 0, err = 0 ; gsl_integration_workspace* ww = gsl_integration_workspace_alloc(WORKSPACE_SIZE); gsl_function F21;
if ( MATH_ERR ) { RETURN_ERR; } return 0; } if ( GET_FUNC_DERIV ) { RETURN_ERR; }
return 0;
#undef A #undef B #undef T #undef F #undef I #undef Nm #undef M #undef xVal #undef yVal } ---------------------------------------- I created the dll file including my function and built a fitting function using DLL option FitFuncs.IntTheoryIntegral
When I tried the 'Quick check' option in the fitting function builder, a window pops up and below error appears.
run-time check failure #2 stack around the variable 'F12' was corrupted. with three options : debug, abort and Ignore. When I choose ignore twice, it gives a value in the quick check box which looks reasonably correct.
But when I tries to simulate the curve using the above fitting function, the origin hangs up and needs to close it.
Can anybody please help me out how to go about this.
thank you very much.
SHIVA
-Shiva
2 L A T E S T R E P L I E S (Newest First)
aekalavya
Posted - 01/27/2012 : 04:00:42 AM Problem found.
double params[5]; should read double params[6];
-Shiva
aekalavya
Posted - 01/26/2012 : 03:00:19 AM Small correction:
The error reads run-time check failure #2 stack around the variable 'F21' was corrupted