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
 User Def Fit Error (compiles well!)
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic Lock Topic Edit Topic Delete Topic New Topic Reply to Topic

Mastertikiman

USA
1 Posts

Posted - 11/05/2010 :  11:01:40 AM  Show Profile  Edit Topic  Reply with Quote  View user's IP address  Delete Topic
Origin Ver. and Service Release (Select Help-->About Origin): 7 SR2
Operating System:Windows

Hey all,

I'm trying to use a script for NLSF that I adapted from the built-in competitive binding fit for ITC from Origin. It's compiling well, but once I try and use it to fit, I get an error message 28037. This error presents itself as arising from poor parameter initialization and problems in user-defined functions.

Any help is much appreciated! Thanks!

Im not sure if there's a problem in my coding, but I'll include it anyway:


#include <stdio.h>
#include <data.h>
#include <math.h>
#include <utilities.h>
/*
You should follow C-language syntax in defining your function. For instance, if your parameter is P1, you cannot use p1
in your function code. To use temporary variables, you will need to first declare them.
In your function, you can use C functions defined elsewhere, you can access the NLSF object methods and properties etc.
For more information and examples, please refer to the "User-Defined Fitting Function" section of the Origin Help file.
*/

//----------------------------------------------------------
//
void _nlsfCompBind(
// Fit Parameter(s):
double Na, double Nb, double Ka, double Kb, double dHa, double dHb,
// Independent Variable(s):
double InjV, double xMt, double Xt, double Mt,
// Dependent Variable(s):
double& NDH)
{
// Beginning of editable part

double P0, V0, Asyr, B0, Vti, Vti1, Ati, Ati1, Mti, Mti1, Bti, Bti1, Fi, Asti, Asti1, Bsti, Bsti1, cA, cA1, cB, cB1, rA, rA1, rB, rB1, a, a1, b, b1, c, c1, u, u1, su, su1, theta, theta1, Xp, Xp1, IcA, IcA1, IcB, IcB1, XpA, XpA1, XpB, XpB1;

LT_get_var( "P0", &P0 );
LT_get_var( "V0", &V0 );
LT_get_var( "Asyr", &Asyr );
LT_get_var( "B0", &B0 );


Vti=P0*V0/Mt;
Vti1=Vti-InjV;
Ati=Xt;
Ati1=Ati*Vti/Vti1-InjV*Asyr/Vti1;
Mti=Mt;
Mti1=Mti*Vti/Vti1;
Bti=B0*V0/Vti;
Bti1=Bti*Vti/Vti1;
Fi=exp(-InjV/V0);
Asti=Na*Ati;
Asti1=Na*Ati1;
Bsti=Nb*Bti;
Bsti1=Nb*Bti1;
cA=Ka*Mti;
cA1=Ka*Mti1;
cB=Kb*Mti;
cB1=Kb*Mti1;
rA=Ati/Mti;
rA1=Ati1/Mti1;
rB=Bti/Mti;
rB1=Bti1/Mti1;
a=1.0/cA+1.0/cB+rA+rB-1.0;
a1=1.0/cA1+1.0/cB1+rA1+rB1-1.0;
b=(rA-1.0)/cB+(rB-1.0)/cA+1.0/cA/cB;
b1=(rA1-1.0)/cB1+(rB1-1.0)/cA1+1.0/cA1/cB1;
c=-1.0/cA/cB;
c1=-1.0/cA1/cB1;
u=a*a-3*b;
u1=a1*a1-3*b1;
su=sqrt(a*b);
su1=sqrt(a1*b1);
theta=acos((-2*a*a*a+9*a*b-27*c)/2/su/u);
theta1=acos((-2*a1*a1*a1+9*a1*b1-27*c1)/2/su1/u1);
Xp=(2*sqrt(u)*cos(theta/3)-a)/3;
Xp1=(2*sqrt(u1)*cos(theta1/3)-a1)/3;
IcA=1/cA+Xp;
IcA1=1/cA1+Xp1;
IcB=1/cB+Xp;
IcB1=1/cB1+Xp1;
XpA=rA*Xp/IcA;
XpA1=rA1*Xp1/IcA1;
XpB=rB*Xp/IcB;
XpB1=rB1*Xp1/IcB1;
NDH=V0*(dHa*(XpA-Fi*XpA1)+dHb*(XpB-Fi*XpB1));
// End of editable part
}
  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