T O P I C R E V I E W |
metalnonmetal |
Posted - 06/10/2017 : 4:48:27 PM Hi I need to fit an equation like
(a^m)*((1-a)^n)*(-ln(1-a)^p)= b*A*integral(exp(-E/(RT))[lower limit, upper limit, dT)
I need to fit these from my data table of (a vs T) and the parameters are (m, n, p, A). (b,E,R) are constants
Please help
metalnonmetal |
11 L A T E S T R E P L I E S (Newest First) |
metalnonmetal |
Posted - 06/20/2017 : 09:37:37 AM Hi, Can I get a solution to this. I tried several things, but it still does not seem to work for me.
metalnonmetal |
metalnonmetal |
Posted - 06/17/2017 : 12:14:43 AM Hello Jacqueline,
That code worked. I need to modify the code somewhat to integrate the left side of the equation and return { 1/ ((a^m)* ((1-a)^n) *(-ln (1-a))^p, lower limit =0, upper limit=a column) So I tried the following code on similar lines. But it results in failed compilation. How do I pass m,n,p in the next function? Can you please help once again.
LT_execute("double xb;"); LT_set_var( "xb", x ); string strLT; strLT = "function double MyIntegrand(double u) { return exp(-17680/(8.314*u)); }; double yb; yb = integral(MyIntegrand,1020.21,xb);"; LT_execute(strLT); double y2; LT_get_var( "yb", &y2 ); LT_execute("double rb;"); LT_set_var( "rb", w ); string strLT1; strLT1 = "function double RHS(double v) { return 1/ ((v^m)* ((1-v)^n) *(-ln (1-v))^p); }; double zb; zb = integral(RHS,0,rb);"; LT_execute(strLT1); double z2; LT_get_var( "zb", &z2 );
f= (A/b)*y2 - z2
metalnonmetal |
metalnonmetal |
Posted - 06/15/2017 : 6:00:25 PM Hi Jacqueline, Thank you for the update. Yes, I was able to modify the code from what you gave earlier. Thank you so much again for giving a good starting point. It really helped a lot.
quote: Originally posted by JacquelineHe
Hi
We checked the code again, and I am not sure whether you miss a () for the (-ln(1-a)^p). I added the () , fixed some problem and change the prameters again. Please try this function body code again.
LT_execute("double xb;");
LT_set_var( "xb", x );
string strLT;
strLT = "function double MyIntegrand(double u) { return exp(-17.68e3/(8.314*u)); }; double yb; yb = integral(MyIntegrand,1020.79,xb);";
LT_execute(strLT);
double y2;
LT_get_var( "yb", &y2 );
f=0.05*A*y2-(w^m)*((1-w)^n)*((-ln(1-w))^p);
Then set the parameter to: m=0.5, n=0.5, p=0.5, A=0.01
If you want to keep m and n at the range of 0 to 1, then you can set their Bounds to 0<m<1 and 0<n<1.
---------------------
Then select you dataset and choose menu Analysis:Fitting:Nonlinear Implicit Curve Fit to open the dialog.
1> Choose your defined function. 2> Go to the Fitted Curvespage under Setting tab. In the right panel, set Data Type of x to Fitted Point for Input Data 3> Fit the Function again.
Thanks Jacqueline OriginLab
metalnonmetal |
JacquelineHe |
Posted - 06/15/2017 : 03:27:19 AM Hi
We checked the code again, and I am not sure whether you miss a () for the (-ln(1-a)^p). I added the () , fixed some problem and change the prameters again. Please try this function body code again.
LT_execute("double xb;");
LT_set_var( "xb", x );
string strLT;
strLT = "function double MyIntegrand(double u) { return exp(-17.68e3/(8.314*u)); }; double yb; yb = integral(MyIntegrand,1020.79,xb);";
LT_execute(strLT);
double y2;
LT_get_var( "yb", &y2 );
f=0.05*A*y2-(w^m)*((1-w)^n)*((-ln(1-w))^p);
Then set the parameter to: m=0.5, n=0.5, p=0.5, A=0.01
If you want to keep m and n at the range of 0 to 1, then you can set their Bounds to 0<m<1 and 0<n<1.
---------------------
Then select you dataset and choose menu Analysis:Fitting:Nonlinear Implicit Curve Fit to open the dialog.
1> Choose your defined function. 2> Go to the Fitted Curvespage under Setting tab. In the right panel, set Data Type of x to Fitted Point for Input Data 3> Fit the Function again.
Thanks Jacqueline OriginLab
|
metalnonmetal |
Posted - 06/14/2017 : 2:51:27 PM Hi Jacqueline, Thanks for your reply. I tried but I get error fit did not converge reason unknown. Can you please send your origin file if possible. My email is metalnonmetal@gmail.com
metalnonmetal |
JacquelineHe |
Posted - 06/14/2017 : 06:56:15 AM Hi
We try to use Origin C code to put the integral function into the implicit function.
When you create the function you can choose "Implicit" and "Origin C " as the Funciton Type.
Variable: x,w Parameters:m,n,p,A
Function body:(All following code)
LT_execute("double xb;");
LT_set_var( "xb", x );
string strLT;
strLT = "function double MyIntegrand(double u) { return exp(-17.68e3/(8.314*u)); }; double yb; yb = integral(MyIntegrand,1020.79,xb);";
LT_execute(strLT);
double y2;
LT_get_var( "yb", &y2 );
f=A*y2-(w^m)*((1-w)^n)*(-ln(1-w)^p)
And I need to set the prameters initial value to m=1,n=1, p=0.33, A=1 then it can simulate a curve. If set m=0, n=0, the curve can not be simulate.
I am not sure this parameters values can be adjusted to better. Using this function, we can not fit your data well. But you can try this method to create the function and try to fit.
If you want to use "piecewise functions“ to fit your dataset, we have a App tp support Piecewise Fit. You also can try it. http://originlab.com/fileExchange/details.aspx?fid=325
Thanks Jacqueline OriginLab
|
metalnonmetal |
Posted - 06/13/2017 : 12:34:45 PM Thank you so much for your reply. I have pasted below sample data. x column is Temperature (T). Y column is conversion (a) range from 0 to 1. My objective is find (a function) or (piecewise functions) g(a)+ constant(c) = A/b* integral(exp(-E/(R*T)dT,Lower limit= starting Temp 1020.79, upper limit T value) and E=17.68e3, b= (0.05) R=8.314. Most likely form of g(a)=(a^m)((1-a)^n)(-ln(1-a))^p. m,n,p most likely range from 0-1, need not all be present. A good initial value for parameters (m,n,p)=(0,0,0.333). The constant(c) most likely would also be 0 i guess. I need to do this for a lot of similar data.
Another way to do I guess would be such that ln(g(a)) vs 1/T should result in a straight line in maximum two piecewise functions like g(a1)= 1-(1-a)^0.5 and g(a2)=(-ln(1-x)^0.33)
1020.79 0 1020.96 0.00671 1021.04 0.00671 1024.53 0.11409 1027.02 0.42953 1028.6 0.55705 1030.92 0.61074 1033.34 0.6443 1035.77 0.66443 1038.21 0.68456 1040.67 0.69799 1043.13 0.71141 1045.58 0.71812 1048.05 0.72483 1050.5 0.73826 1052.97 0.74497 1055.43 0.74497 1057.89 0.75168 1060.36 0.75839 1062.82 0.7651 1065.28 0.77181 1067.75 0.77181 1070.21 0.77852 1072.68 0.78523 1075.14 0.78523 1077.61 0.79195 1080.07 0.79195 1082.54 0.79866 1085 0.79866 1087.47 0.80537 1089.93 0.80537 1092.4 0.81208 1094.86 0.81208 1097.33 0.81879 1099.79 0.81879 1102.26 0.8255 1104.72 0.8255 1107.18 0.83221 1109.65 0.83221 1112.11 0.83221 1114.58 0.83893 1117.04 0.83893 1119.51 0.84564 1121.97 0.84564 1124.43 0.84564 1126.89 0.85235 1129.36 0.85235 1131.82 0.85235 1134.28 0.85906 1136.74 0.85906 1139.2 0.86577 1141.67 0.86577 1144.13 0.86577 1146.59 0.87248 1149.04 0.87248 1151.5 0.87248 1153.96 0.87248 1156.42 0.87919 1158.87 0.87919 1161.33 0.87919 1163.79 0.88591 1166.24 0.88591 1168.7 0.88591 1171.16 0.89262 1173.61 0.89262 1176.07 0.89262 1178.52 0.89262 1180.97 0.89933 1183.43 0.89933 1185.89 0.89933 1188.34 0.90604 1190.8 0.90604 1193.25 0.90604 1195.71 0.90604 1198.17 0.91275 1200.63 0.91275 1203.09 0.91275 1205.55 0.91275 1208.01 0.91946 1210.47 0.91946 1212.94 0.91946 1215.4 0.91946 1217.86 0.91946 1220.33 0.92617 1222.79 0.92617 1225.26 0.92617 1227.72 0.92617 1230.18 0.93289 1232.65 0.93289 1235.11 0.93289 1237.58 0.93289 1240.04 0.93289 1242.51 0.9396 1244.98 0.9396 1247.44 0.9396 1249.9 0.9396 1252.37 0.9396 1254.84 0.94631 1257.3 0.94631 1259.77 0.94631 1262.24 0.94631 1264.7 0.94631 1267.16 0.95302 1269.63 0.95302 1272.09 0.95302 1274.56 0.95302 1277.03 0.95973 1279.49 0.95973 1281.96 0.95973 1284.43 0.95973 1286.89 0.96644 1289.36 0.96644 1291.83 0.96644 1294.3 0.96644 1296.86 0.97315 1299.43 0.97315 1301.98 0.97315 1304.54 0.97315 1307.1 0.97987 1309.66 0.97987 1312.22 0.97987 1314.78 0.98658 1317.34 0.98658 1319.9 0.98658 1322.47 0.98658 1325.02 0.99329 1327.58 0.99329 1330.14 0.99329 1332.7 0.99329 1335.27 0.99329 1337.83 1 1340.39 1 1342.95 1 1345.51 1
Hi metalnonmetal,
If you use "Fitting Function Builder" when you choose implicit function, the integration option is hided.
I am trying to use define the integral function by Labtalk and then put into the funtion again as this sample: http://www.originlab.com/doc/Tutorials/Fitting-2Integral-LabTalk
Could you plesae show us more detail about your function? 1. If (b,E,R) are constants, could you tell us the value? 2. About the lower limit and upper limit, are they the paramters or the constants?
If use the implicit function to fit with integrals, that will lead the fitting slowly, so you need to set a good initial value for the parameters.
Thanks Jacqueline OriginLab
metalnonmetal |
JacquelineHe |
Posted - 06/13/2017 : 06:21:27 AM Hi metalnonmetal,
If you use "Fitting Function Builder" when you choose implicit function, the integration option is hided.
I am trying to use define the integral function by Labtalk and then put into the funtion again as this sample: http://www.originlab.com/doc/Tutorials/Fitting-2Integral-LabTalk
Could you plesae show us more detail about your function? 1. If (b,E,R) are constants, could you tell us the value? 2. About the lower limit and upper limit, are they the paramters or the constants?
If use the implicit function to fit with integrals, that will lead the fitting slowly, so you need to set a good initial value for the parameters.
Thanks Jacqueline OriginLab
|
metalnonmetal |
Posted - 06/13/2017 : 01:16:27 AM Also, if I try to use implict function with equations the include integration during fitting is greyed out.
quote: Originally posted by metalnonmetal
Hi I need to fit an equation like
(a^m)*((1-a)^n)*(-ln(1-a)^p)= b*A*integral(exp(-E/(RT))[lower limit, upper limit, dT)
I need to fit these from my data table of (a vs T) and the parameters are (m, n, p, A). (b,E,R) are constants
Please help
metalnonmetal
metalnonmetal |
metalnonmetal |
Posted - 06/12/2017 : 11:36:17 AM Hello JacquelineHe,
Thanks for the reply. Can you please be more specific. I have tried all that I could. I get error messages like. Failed to fit reasons unknown. Also What my objective is to find the parameters such that I get a straight line between 'a' and 'T' variable and I need to filt both LHS and RHS side of the equation as a result.
Regards,
metalnonmetal |
JacquelineHe |
Posted - 06/12/2017 : 06:18:35 AM Hi,
I suggest you can try to define an implicit function.
Please refer to this help pages and video tutorial: http://www.originlab.com/doc/Quick-Help/Implicit-Function http://www.originlab.com/doc/Origin-Help/Fitting-Implicit http://originlab.com/doc/Tutorials/ImplicitFit-3Var http://www.originlab.com/doc/Origin-Help/Fitting-Implicit
Thanks Jacqueline OriginLab
|
|
|