Hello Everyone,
I am trying to fit an impedance model with real data. I have measured the real and imaginary part of an impedance for a set of frequencies (here from 10kHz to 800kHz). And I want to fit a non linear model (called here: ZeFull[R,Cc,C2,C0,2Pi f], where R,Cc,C2,C0 are parameters (that I want to estimate from the data) and f is the frequency (or w=2 Pi f the pulsation) as showed below:
In[2720]:= Zlist = {{10000, 35292.4 - 335783. I}, {20000, 28850.3 - 173613. I}, {30000,
25831.2 - 119349. I}, {50000, 22358.5 - 76039.9 I}, {80000,
19092.1 - 52161.6 I}, {100000, 17317.4 - 44323.6 I}, {200000,
10797. - 28171.2 I}, {300000, 6879.63 - 21538. I}, {500000,
3260.48 - 14499.7 I}, {800000, 1439.32 - 9671.26 I}};
In[2709]:= ?ZeFull
Global`ZeFull
ZeFull[R_,Cc_,C2_,C0_,w_]=(C2 R Sqrt[I w]+Sqrt[Cc] Sqrt[R] Coth[Sqrt[Cc] Sqrt[R] Sqrt[I w]])/(Sqrt[I w] (Cc+I C0 C2 R w)+I (C0+C2) Sqrt[Cc] Sqrt[R] w Coth[Sqrt[Cc] Sqrt[R] Sqrt[I w]])
In[2719]:= NonlinearModelFit[Zlist,
ZeFull[R, Cc, C2, C0,
2 Pi f], {{R, 30000}, {Cc, 10. 10^-12}, {C2, 10.10^-12}, {C0,
20.10^-12}}, {f}]
During evaluation of In[2719]:= NonlinearModelFit::nrlnum: The function value {-24411.3-1.12602*10^6 I,-17969.3-557314. I,-14950.4-367963. I,-11478.3-216399. I,-8213.2-130691. I,-6439.74-102017. I,70.392 -45241.2 I,3970.71 -27671.5 I,7535.87 -15535.4 I,9228.93 -9857.22 I} is not a list of real numbers with dimensions {10} at {R,Cc,C2,C0} = {30000.,1.*10^-11,8.87449*10^-13,2.29957*10^-16}. >>
Out[2719]= NonlinearModelFit[{{10000, 35292.4 - 335783. I}, {20000,
28850.3 - 173613. I}, {30000, 25831.2 - 119349. I}, {50000,
22358.5 - 76039.9 I}, {80000, 19092.1 - 52161.6 I}, {100000,
17317.4 - 44323.6 I}, {200000, 10797. - 28171.2 I}, {300000,
6879.63 - 21538. I}, {500000, 3260.48 - 14499.7 I}, {800000,
1439.32 - 9671.26 I}}, (
C2 Sqrt[I f] Sqrt[2 \[Pi]] R +
Sqrt[Cc] Sqrt[R] Coth[Sqrt[Cc] Sqrt[I f] Sqrt[2 \[Pi]] Sqrt[R]])/(
Sqrt[I f] Sqrt[2 \[Pi]] (Cc + 2 I C0 C2 f \[Pi] R) +
2 I (C0 + C2) Sqrt[Cc] f \[Pi] Sqrt[R]
Coth[Sqrt[Cc] Sqrt[I f] Sqrt[2 \[Pi]] Sqrt[R]]), {{R, 30000}, {Cc,
1.*10^-11}, {C2, 8.87449*10^-13}, {C0, 2.29957*10^-16}}, {f}]
I think I respected the syntax of the function but it seems that the function NonlinearModelFit does not work on complex numbers. I am thinking to use a NMinimize function on a cost function built with the squared module of the difference between model and data but I wonder if there is a simpler way to do that?
Thanks for your feedback
Christian