0
$\begingroup$

Here is the data I am trying to fit

``` data={{0.06, 1.01639, 0.0121617}, {0.13, 1.00026, 0.00916985}, {0.2, 
      0.908723, 0.00828259}, {0.275, 1.01714, 0.00821439}, {0.35, 1.03227,
       0.0143054}, {0.5, 0.959998, 0.0157588}, {0.75, 0.930953, 
      0.0135328}, {0.875, 0.837181, 0.00844368}, {1, 0.788837, 
      0.0117245}, {1.125, 0.731066, 0.00903227}, {1.175, 0.710571, 
      0.0122025}, {1.25, 0.529901, 0.016269}}```

The first is a temperature, the second the superfluid density, the third the error.

Some manipulations to get the data and the error set up for the fit:

    ```nn = Drop[data, None, {3}];
        m = Length[nn];
       en = Table[{data[[i, 1]], Around[data[[i, 2]], data[[i, 3]]]}, {i, 1, m}];
     errn = Flatten[Take[data, All, {3}]]```

Some parameters:

``` \[Xi] = 116;
\[Lambda] = 5952;
\[Kappa]  = \[Lambda]/\[Xi]
       Tc = 1.85;```

The functions I need for integration:

```En[eps_, \[Phi]_, T_, \[CapitalDelta]0_] := Sqrt[eps^2 + Abs[dk[\[Phi], T, \[CapitalDelta]0]]^2]
dk[\[Phi]_, T_, \[CapitalDelta]0_] := \[CapitalDelta]0 Sqrt[2]Cos[2 \[Phi]]Tanh[1.74 Sqrt[1 - T/Tc]]
\[Rho]s[T_?NumberQ, \[CapitalDelta]0_?NumberQ] :=1 - 1/( 4*Pi*T)NIntegrate[(1/2(Cosh[2 En[eps, phi, T, \[CapitalDelta]0]/(2 T)]) + 1)^-1, {eps,0, 100 T}, {phi, 0, 2*Pi}]
Ts[\[CapitalDelta]0_] := \[CapitalDelta]0/\[Kappa]
ns[T_, Ts_, \[CapitalDelta]0_]:= 1 - (1 - \[Rho]s[T, \[CapitalDelta]0 ])*((Tc + Ts[\[CapitalDelta]0])/Tc) (T/(T + Ts[\[CapitalDelta]0]))```

When I plot the function ns I am starting to get an error:

```Show[ListPlot[Table[{T, ns[T, Ts, 2 Tc ]}, {T, 0.01*Tc, 0.95*Tc, 0.05*Tc}],Joined -> True], ListPlot[en]]```

However,it still shows the function.

But if I try a Levenberg-Marquart fit, it fails:

```one = NonlinearModelFit[nn, 
ns[T, Ts[\[CapitalDelta]0], \[CapitalDelta]0], {{\[CapitalDelta]0, 2 Tc}}, T, Weights -> errn, Method -> LevenbergMarquardt]```

The integral is 1 over the square of Cosh, which is a well behaved function, so I am not sure, where I am going wrong.

Thanks a lot for helping.

$\endgroup$
2
  • 2
    $\begingroup$ nsis a function with the second argument another function. However in ns[T, Ts[\[CapitalDelta]0], \[CapitalDelta]0] you feed it a number. $\endgroup$ Commented May 29, 2022 at 11:29
  • $\begingroup$ Thanks so much, I was once again barking up the wrong tree. I made the fit function just a function of parameters as you suggested and now it works! $\endgroup$
    – majeriisli
    Commented May 29, 2022 at 19:28

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Browse other questions tagged or ask your own question.