0
$\begingroup$

I am trying to fit experimental data with data file given below function, but I am not able to find the best fit. Constant value is A=6.26 and B=0.0041684

data = Import["https://pastebin.com/raw/WB4RX3Bi", "RawJSON"];

γ1 = 72*10^-3; d = 1.0*10^3; g = 9.8; w = 175*10^-6;
lc = Sqrt[γ1/(g*d)];
B = (w/lc)^2;
c = 3*10^8;
n1 = 1;
n2 = 1.33;
P1 = ((4*3)/(c*Pi*w^2))*(n1)*((n2 - n1)/(n2 + n1));
cd[(az_)?NumericQ, (t_)?NumericQ] := 
  1*10^9*P1*w^2/(4*γ1)*
   Quiet[NIntegrate[
     Exp[-(x^2)/
        8]*(1/(1 + B/x^2))*(1 - Exp[-(t/az)*x (1 + B/x^2)/(1 + B)])/
       x, {x, 0, 10}]];
fit3 = NonlinearModelFit[data, {cd[az, t], az > 0}, az, t]
Show[DiscretePlot[fit3[t], {t, 0, .15, .005}, PlotRange -> All, 
  Frame -> True, ImageSize -> 560, PlotStyle -> Red, 
  PlotRange -> All], 
 ListLinePlot[d5r, PlotStyle -> Blue, Frame -> True, 
  PlotRange -> All]]

plots that I want to fit

$\endgroup$
  • $\begingroup$ Could you please post the data -points( I cannot access your link!) $\endgroup$ – Ulrich Neumann Aug 12 at 9:07
  • $\begingroup$ @Neumann, I added data file. $\endgroup$ – Gopal Verma Aug 12 at 9:27
  • $\begingroup$ Thanks! In your modell equation -(t/a) seems to be wrong. $\endgroup$ – Ulrich Neumann Aug 12 at 9:29
  • $\begingroup$ @Neumann, It is correct. $\endgroup$ – Gopal Verma Aug 12 at 9:36
  • $\begingroup$ If so, please clarify your modell. NIntegratecan't evaluate if t,a isn't known! $\endgroup$ – Ulrich Neumann Aug 12 at 9:45
2
$\begingroup$

This problem can be solved in three seconds (on my laptop). But as Ulrich Neumann correctly noted, the function is chosen incorrectly. Pre-calculate and interpolate the integral depending on the parameter (this takes 2.9 seconds):

 \[Gamma]1 = 72*10^-3; d = 1.0*10^3; g = 9.8; w = 175*10^-6;
 lc = Sqrt[\[Gamma]1/(g*d)]; B = (w/lc)^2; c = 
  3*10^8; n1 = 1; n2 = 1.33;
  P1 = ((4*3)/(c*Pi*w^2))*(n1)*((n2 - n1)/(n2 + n1));
lst = Table[{s, 
      NIntegrate[
       Exp[-(x^2)/
          8]*(1/(1 + B/x^2))*(1 - Exp[-s*x (1 + B/x^2)/(1 + B)])/
         x, {x, 10^-6, 10}]}, {s, 0, 50, .1}]; // Quiet // AbsoluteTiming

f = Interpolation[lst];

Then we find the parameter az (this takes 0.01 s):

data = {{0, 0.01172}, {0.001, 6.23548}, {0.002, 8.3244}, {0.003, 
    9.2106}, {0.004, 9.37318}, {0.005, 9.9102}, {0.006, 
    10.1176}, {0.007, 10.3073}, {0.008, 10.6963}, {0.009, 
    10.874}, {0.01, 11.034}, {0.011, 11.0045}, {0.012, 
    11.2776}, {0.013, 11.305}, {0.014, 11.4793}, {0.015, 
    11.6099}, {0.016, 11.691}, {0.017, 11.718}, {0.018, 
    12.0219}, {0.019, 11.8255}, {0.02, 12.0732}, {0.021, 
    12.0837}, {0.022, 12.1648}, {0.023, 12.074}, {0.024, 
    12.2191}, {0.025, 12.3367}, {0.026, 12.5222}, {0.027, 
    12.5023}, {0.028, 12.536}, {0.029, 12.5234}, {0.03, 
    12.5596}, {0.031, 12.8146}, {0.032, 12.9112}, {0.033, 
    12.7478}, {0.034, 12.825}, {0.035, 12.8779}, {0.036, 
    12.8668}, {0.037, 12.9696}, {0.038, 12.8714}, {0.039, 
    13.0408}, {0.04, 13.1484}, {0.041, 13.1499}, {0.042, 
    13.1902}, {0.043, 13.2082}, {0.044, 13.0781}, {0.045, 
    13.255}, {0.046, 13.1519}, {0.047, 13.3301}, {0.048, 
    13.3384}, {0.049, 13.2736}, {0.05, 13.3463}, {0.051, 
    13.3512}, {0.052, 13.4537}, {0.053, 13.4734}, {0.054, 
    13.4174}, {0.055, 13.4653}, {0.056, 13.7339}, {0.057, 
    13.5058}, {0.058, 13.6605}, {0.059, 13.6965}, {0.06, 
    13.5999}, {0.061, 13.7753}, {0.062, 13.6785}, {0.063, 
    13.9492}, {0.064, 13.8257}, {0.065, 13.9978}, {0.066, 
    13.9168}, {0.067, 14.0393}, {0.068, 13.9264}, {0.069, 
    13.8798}, {0.07, 14.0839}, {0.071, 14.0549}, {0.072, 
    13.9781}, {0.073, 13.9947}, {0.074, 13.9951}, {0.075, 
    14.0768}, {0.076, 14.1712}, {0.077, 13.9664}, {0.078, 
    14.1032}, {0.079, 14.2659}, {0.08, 14.1357}, {0.081, 
    14.2042}, {0.082, 14.2916}, {0.083, 14.2316}, {0.084, 
    14.3284}, {0.085, 14.1925}, {0.086, 14.3797}, {0.087, 
    14.1594}, {0.088, 14.2352}, {0.089, 14.2466}, {0.09, 
    14.2859}, {0.091, 14.233}, {0.092, 14.3774}, {0.093, 
    14.4911}, {0.094, 14.5253}, {0.095, 14.2847}, {0.096, 
    14.4617}, {0.097, 14.3361}, {0.098, 14.4019}, {0.099, 
    14.3737}, {0.1, 14.351}, {0.101, 14.4912}, {0.102, 
    14.4534}, {0.103, 14.6539}, {0.104, 14.6208}, {0.105, 
    14.4896}, {0.106, 14.6649}, {0.107, 14.5448}, {0.108, 
    14.5012}, {0.109, 14.6028}, {0.11, 14.608}, {0.111, 
    14.5389}, {0.112, 14.6703}, {0.113, 14.5858}, {0.114, 
    14.7303}, {0.115, 14.6637}, {0.116, 14.831}, {0.117, 
    14.7325}, {0.118, 14.8648}, {0.119, 14.8289}, {0.12, 
    14.9094}, {0.121, 14.855}, {0.122, 14.9639}, {0.123, 
    14.9003}, {0.124, 14.813}, {0.125, 14.9014}, {0.126, 
    14.8026}, {0.127, 14.81}, {0.128, 15.0311}, {0.129, 
    14.8367}, {0.13, 15.0784}, {0.131, 14.8689}, {0.132, 
    14.9648}, {0.133, 14.9325}, {0.134, 14.9264}, {0.135, 
    14.9104}, {0.136, 14.9641}, {0.137, 14.915}, {0.138, 
    14.9932}, {0.139, 15.1191}, {0.14, 15.1196}, {0.141, 
    15.0484}, {0.142, 15.1241}, {0.143, 15.0201}, {0.144, 
    15.0168}, {0.145, 15.0083}, {0.146, 15.1844}, {0.147, 
    15.2427}, {0.148, 15.1382}};
p = 1*10^9*P1*w^2/(4*\[Gamma]1);
fit = NonlinearModelFit[data, p f[k t], {k}, t]
Show[DiscretePlot[fit[t], {t, 0, .15, .005}, PlotRange -> All, 
  Frame -> True, ImageSize -> 560, PlotStyle -> Red, 
  PlotRange -> All], 
 ListLinePlot[data, PlotStyle -> Blue, Frame -> True, 
  PlotRange -> All]]

I recommend using the function

fit3 = NonlinearModelFit[data, a p f[k t] + b, {a, b, k}, t]
Show[DiscretePlot[fit3[t], {t, 0, .15, .005}, PlotRange -> All, 
  Frame -> True, ImageSize -> 560, PlotStyle -> Red, 
  PlotRange -> All], 
 ListLinePlot[data, PlotStyle -> Blue, Frame -> True, 
  PlotRange -> All]]

Compare two functions Figure1

$\endgroup$
  • $\begingroup$ @Trounev, Thanks, But as for as I understand integral is correct. I used integral from this research article(PHYSICAL REVIEW E 73, 036315 2006). $\endgroup$ – Gopal Verma Aug 12 at 17:00
  • $\begingroup$ @GopalVerma Is this the integral (13) from the article? $\endgroup$ – Alex Trounev Aug 12 at 17:12
  • $\begingroup$ @GopalVerma It is possible that parameter B is not defined correctly. Then it must also be calculated using the data. $\endgroup$ – Alex Trounev Aug 12 at 17:42
  • $\begingroup$ @Trounev, B is constant and it is correctly defined. $\endgroup$ – Gopal Verma Aug 13 at 4:19
  • $\begingroup$ @GopalVerma This means that the theory presented in the article does not cover your case. You will have to develop your own theory. $\endgroup$ – Alex Trounev Aug 13 at 4:52

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.