impedance.py icon indicating copy to clipboard operation
impedance.py copied to clipboard

high frequency fitting problem

Open z1q0831 opened this issue 2 years ago • 12 comments

hallo, i have a question about high freq fitting. I have used RL to fit but seems does not work. the fitting of positive Zimg is not possible can anyone maybe know why?plz Snipaste_2023-10-25_21-55-16 Snipaste_2023-10-25_21-55-32

z1q0831 avatar Oct 25 '23 19:10 z1q0831

@Yugal0

z1q0831 avatar Oct 26 '23 12:10 z1q0831

Although I will give it a try myself tomorrow, but for now I think you can try increasing the value of inductance in the initial guess.

Yugal0 avatar Oct 26 '23 15:10 Yugal0

Although I will give it a try myself tomorrow, but for now I think you can try increasing the value of inductance in the initial guess.

thank you for the suggestion. I have tried to increase the value of inductor, but still can not get the the fitting of positive Zimag. the csv i use is from the exampleData.csv.

z1q0831 avatar Oct 26 '23 15:10 z1q0831

Although I will give it a try myself tomorrow, but for now I think you can try increasing the value of inductance in the initial guess.

thank you for the suggestion. I have tried to increase the value of inductor, but still can not get the the fitting of positive Zimag. the csv i use is from the exampleData.csv.

Ok I will try fitting myself.(tommorow)

Yugal0 avatar Oct 26 '23 15:10 Yugal0

What I got in the first try:

from impedance.models.circuits import CustomCircuit import numpy as np import pandas as pd import matplotlib.pyplot as plt

initial_guess=[0.01,0.01,100,0.01,0.05,100,1,1,0.1] c=CustomCircuit("R0-p(R1,C1)-p(R2-Wo1,C2)-p(L1,R3)",initial_guess=initial_guess) df=pd.read_csv("../exampleData.csv") gthbdata=df.to_numpy() datanew=np.transpose(gthbdata) freq=datanew[0] z_data=datanew[1]+1j*datanew[2] plt.plot(np.real(z_data),-np.imag(z_data)) image

c.fit(frequencies=freq,impedance=z_data) print(c) z_fit=c.predict(frequencies=freq) plt.plot(np.real(z_fit),-np.imag(z_fit)) plt.plot(np.real(z_data),-np.imag(z_data)) print(c.conf_) image image

Yugal0 avatar Oct 27 '23 19:10 Yugal0

What I got in the first try:

from impedance.models.circuits import CustomCircuit import numpy as np import pandas as pd import matplotlib.pyplot as plt

initial_guess=[0.01,0.01,100,0.01,0.05,100,1,1,0.1] c=CustomCircuit("R0-p(R1,C1)-p(R2-Wo1,C2)-p(L1,R3)",initial_guess=initial_guess) df=pd.read_csv("../exampleData.csv") gthbdata=df.to_numpy() datanew=np.transpose(gthbdata) freq=datanew[0] z_data=datanew[1]+1j*datanew[2] plt.plot(np.real(z_data),-np.imag(z_data)) image

c.fit(frequencies=freq,impedance=z_data) print(c) z_fit=c.predict(frequencies=freq) plt.plot(np.real(z_fit),-np.imag(z_fit)) plt.plot(np.real(z_data),-np.imag(z_data)) image image

thank you for your try, so as I see in the last picture, the fitting line also can not reach the positive Zimag?

z1q0831 avatar Oct 27 '23 20:10 z1q0831

What I got in the first try: from impedance.models.circuits import CustomCircuit import numpy as np import pandas as pd import matplotlib.pyplot as plt initial_guess=[0.01,0.01,100,0.01,0.05,100,1,1,0.1] c=CustomCircuit("R0-p(R1,C1)-p(R2-Wo1,C2)-p(L1,R3)",initial_guess=initial_guess) df=pd.read_csv("../exampleData.csv") gthbdata=df.to_numpy() datanew=np.transpose(gthbdata) freq=datanew[0] z_data=datanew[1]+1j*datanew[2] plt.plot(np.real(z_data),-np.imag(z_data)) image c.fit(frequencies=freq,impedance=z_data) print(c) z_fit=c.predict(frequencies=freq) plt.plot(np.real(z_fit),-np.imag(z_fit)) plt.plot(np.real(z_data),-np.imag(z_data)) image image

thank you for your try, so as I see in the last picture, the fitting line also can not reach the positive Zimag?

Yes, same problem as yours happening. But I made another mistake, the plots are not 1:1 in aspect ratio. And also, seems like the fit you are getting and what I am getting are different, why so? what method are you using for fitting? YOUR FIT: image MY FIT: (now its 1:1) image

Yugal0 avatar Oct 27 '23 20:10 Yugal0

What I got in the first try: from impedance.models.circuits import CustomCircuit import numpy as np import pandas as pd import matplotlib.pyplot as plt initial_guess=[0.01,0.01,100,0.01,0.05,100,1,1,0.1] c=CustomCircuit("R0-p(R1,C1)-p(R2-Wo1,C2)-p(L1,R3)",initial_guess=initial_guess) df=pd.read_csv("../exampleData.csv") gthbdata=df.to_numpy() datanew=np.transpose(gthbdata) freq=datanew[0] z_data=datanew[1]+1j*datanew[2] plt.plot(np.real(z_data),-np.imag(z_data)) image c.fit(frequencies=freq,impedance=z_data) print(c) z_fit=c.predict(frequencies=freq) plt.plot(np.real(z_fit),-np.imag(z_fit)) plt.plot(np.real(z_data),-np.imag(z_data)) image image

thank you for your try, so as I see in the last picture, the fitting line also can not reach the positive Zimag?

Yes, same problem as yours happening. But I made another mistake, the plots are not 1:1 in aspect ratio. And also, seems like the fit you are getting and what I am getting are different, why so? what method are you using for fitting? YOUR FIT: image MY FIT: (now its 1:1) image

do you have the same initial guess of mine? Maybe i have add another (RC) component, because (RC) is responsible for semicircle part.

z1q0831 avatar Oct 27 '23 20:10 z1q0831

yes I put the exact same initial guess (and the same elements) as you showed in the code in your very first snapshot in the question. YOUR SNAPSHOT of CODE: image

Actually just now, what I found is if I take L=100 as the initial guess the I am getting a pretty good fit MY FIT NOW: image In your snapshot it was L=1, with that I was getting not a good fit (as shown in my previous comments) MY FIT BEFORE: image

But still how you getting good fit with L=1 as initial guess? YOUR FIT as shown in your first comment: image

Yugal0 avatar Oct 27 '23 20:10 Yugal0

yes I put the exact same initial guess (and the same elements) as you showed in the code in your very first snapshot in the question. YOUR SNAPSHOT of CODE: image

Actually just now, what I found is if I take L=100 as the initial guess the I am getting a pretty good fit MY FIT NOW: image In your snapshot it was L=1, with that I was getting not a good fit (as shown in my previous comments) MY FIT BEFORE: image

But still how you getting good fit with L=1 as initial guess? YOUR FIT as shown in your first comment: image

Maybe I have changed the value of L , but the problem still remains. The high frequency fitting can not be reached.

z1q0831 avatar Oct 27 '23 20:10 z1q0831

Yeah, that is the main problem. I will let you know here, If I get any solutions for this.

(And also, please don't quote the previous comments in the chat, every time you write a new comment, it makes the chat difficult to read sometimes)

Yugal0 avatar Oct 27 '23 20:10 Yugal0

Yeah, that is the main problem. I will let you know here, If I get any solutions for this.

But totally thank you for replying me! If I find any solutions, I will post here

z1q0831 avatar Oct 27 '23 20:10 z1q0831