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
 All Forums
 Origin Forum
 Origin Forum
 d01smc fitting

Note: You must be registered in order to post a reply.
To register, click here. Registration is FREE!

Screensize:
UserName:
Password:
Anti-Spam Code:
Format Mode:
Format: BoldItalicizedUnderlineStrikethrough Align LeftCenteredAlign Right Horizontal Rule Insert HyperlinkUpload FileInsert Image Insert CodeInsert QuoteInsert List
   
Message:

* HTML is OFF
* Forum Code is ON
Smilies
Smile [:)] Big Smile [:D] Cool [8D] Blush [:I]
Tongue [:P] Evil [):] Wink [;)] Clown [:o)]
Black Eye [B)] Eight Ball [8] Frown [:(] Shy [8)]
Shocked [:0] Angry [:(!] Dead [xx(] Sleepy [|)]
Kisses [:X] Approve [^] Disapprove [V] Question [?]

 
Check here to subscribe to this topic.
   

T O P I C    R E V I E W
strömi Posted - 10/02/2012 : 10:01:26 AM
Hello,

i just try to work with d01smc.

I have experimental results wich follow an exponential function:

f=exp{k1*c}

k1: const.
c: variable

Furthermore i know the correlation of differential equotation which is: dc/dt=k1*c

Now i want to identify the const. k1 with the help of the d01smc.
My first try :

#include <origin.h>


struct user // parameters in the integrand
{
double amp;
};


static double NAG_CALL f_callback(double t, Nag_User *comm)
{
struct user *sp = (struct user *)(comm->p);
double amp; // temp variable to accept the parameters in the Nag_User communication struct
amp = sp->amp;

return exp(amp*t);
}


// Add your special include files here.
// For example, if you want to fit with functions from the NAG library,
// add the header file for the NAG functions here.

// Add code here for other Origin C functions that you want to define in this file,
// and access in your fitting function.

// You can access C functions defined in other files, if those files are loaded and compiled
// in your workspace, and the functions have been prototyped in a header file that you have
// included above.

// You can access NLSF object methods and properties directly in your function code.

// You should follow C-language syntax in defining your function.
// For instance, if your parameter name is P1, you cannot use p1 in your function code.
// When using fractions, remember that integer division such as 1/2 is equal to 0, and not 0.5
// Use 0.5 or 1/2.0 to get the correct value.

// For more information and examples, please refer to the "User-Defined Fitting Function"
// section of the Origin Help file.

//----------------------------------------------------------
//
void _nlsfnag_integration_fitting(
// Fit Parameter(s):
double k1,
// Independent Variable(s):
double t,
// Dependent Variable(s):
double& c)
{
// Beginning of editable part
double epsabs = 0.0, epsrel = 0.0001, a = 0.0;


Integer max_num_subint = 200;


double result, abserr;


Nag_QuadProgress qp;


static NagError fail;


Nag_User comm;
struct user s;
s.amp = k1;
comm.p = (Pointer)&s;


nag_1d_quad_inf_1(f, Nag_UpperSemiInfinite, a, epsabs, epsrel,
max_num_subint, &result, &abserr, &qp, &comm, &fail);


NAG_FREE(qp.sub_int_beg_pts);
NAG_FREE(qp.sub_int_end_pts);
NAG_FREE(qp.sub_int_result);
NAG_FREE(qp.sub_int_error);


return exp(t*k1);




// End of editable part
}


The error: line 19 : illegal function argument typ & syntax error in function declaration
2   L A T E S T    R E P L I E S    (Newest First)
strömi Posted - 10/19/2012 : 08:07:35 AM
okay now i got the first problem i think. But i have a new one =):

this is my code now:

#pragma numlittype(push, TRUE)
#pragma numlittype(push, TRUE)
#pragma numlittype(push, TRUE)
#pragma numlittype(push, TRUE)
#pragma numlittype(push, TRUE)
#pragma numlittype(push, TRUE)
#pragma numlittype(push, TRUE)
#pragma numlittype(push, TRUE)
#pragma numlittype(push, TRUE)
#pragma numlittype(push, TRUE)
#pragma numlittype(push, TRUE)


#include <OC_nag.h>

struct user // parameters in the integrand
{
double amp;
};





static double NAG_CALL f(double t, Nag_User *comm) // nehme callback raus siehe d01smc
{
struct user *sp = (struct user *)(comm->p);
double amp; // temp variable to accept the parameters in the Nag_User communication struct
amp = sp->amp;

return amp*t;
}






// Add your special include files here.
// For example, if you want to fit with functions from the NAG library,
// add the header file for the NAG functions here.

// Add code here for other Origin C functions that you want to define in this file,
// and access in your fitting function.

// You can access C functions defined in other files, if those files are loaded and compiled
// in your workspace, and the functions have been prototyped in a header file that you have
// included above.

// You can access NLSF object methods and properties directly in your function code.

// You should follow C-language syntax in defining your function.
// For instance, if your parameter name is P1, you cannot use p1 in your function code.
// When using fractions, remember that integer division such as 1/2 is equal to 0, and not 0.5
// Use 0.5 or 1/2.0 to get the correct value.

// For more information and examples, please refer to the "User-Defined Fitting Function"
// section of the Origin Help file.

//----------------------------------------------------------
//
void _nlsfnag_integration_fitting(
// Fit Parameter(s):
double k1,
// Independent Variable(s):
double t,
// Dependent Variable(s):
double& c)
{
// Beginning of editable part
double epsabs = 0.0, epsrel = 0.0001, a = 0.0;


Integer max_num_subint = 200;


double result, abserr;


Nag_QuadProgress qp;


static NagError fail;


Nag_User comm;
struct user s;
s.amp = k1;
comm.p = (Pointer)&s;

nag_1d_quad_inf_1(f, Nag_UpperSemiInfinite, a, epsabs, epsrel,
max_num_subint, &result, &abserr, &qp, &comm, &fail);




t*k1;
// End of editable part
}



The problem is : When i push the simulate button i get no curve. Furthermore i have to indicate k1.



tenagadalam Posted - 10/04/2012 : 12:04:13 PM
curious about that too :)

_________________________
www.energi-positif.net

The Origin Forum © 2020 Originlab Corporation Go To Top Of Page
Snitz Forums 2000