jdhuang-csm / hybrid-drt

Probabilistic electrochemical analysis with the distribution of relaxation times (DRT)
BSD 3-Clause "New" or "Revised" License
8 stars 2 forks source link

Some basic questions about using and presenting the results #5

Open jianzuo opened 2 weeks ago

jianzuo commented 2 weeks ago

Hi, I am trying to interpret some impedance spectra using your package. As a new user, I followed the procedure described in ``Fitting EIS data.ipynb'' and I have successfully obtained the drt inversion results.

Based on this, I have some basic questions about the DRT optimization and results plotting:

Besides the time constant, is it possible to obtain the frequency range of the identified peaks? (this is useful information for some application scenarios)

And is there a way to export the final drt and peak separation results data for further plots rather than he given plot functions?

I am trying to make sure I understand and present things correctly since I am using it for formal work. Thank you in advance for your help!

jianzuo commented 1 week ago

In my case, I have multiple impedance spectra measured from actual energy systems. The true distribution functions are thus unknown. And some curves seem difficult to get the optimal results. For example, for the following criteria figure, how to decide the optimal number of peaks? image

Concerning the warning:

UserWarning: Solution did not converge within 10 iterations
  warnings.warn(f'Solution did not converge within {max_iter} iterations')

Should we increase the number of interactions in practice? But I did not find out how.

My last observation is that the best model obtained from using RQ and HN can be significantly different, do you have some suggestions on which one to use? Or could this be improved by further optimizing the tunable parameters?

jdhuang-csm commented 1 week ago

Hi,

These are all good questions. I believe that some of them are addressed in the tutorial already, so I will point you to the relevant section when possible.

jdhuang-csm commented 1 week ago

For your second set of questions:

jianzuo commented 1 week ago

Thank you for your professional and informative response. These are very helpful! I will let you know if I have further questions, thank you!

jianzuo commented 1 week ago

I still have problems regarding the results of the final total DRT and the decomposed peaks (I use RQ as the base element in the ECM), specifically:

  1. Q: How to retrieve the generated continuous candidates ($\gamma$ and the corresponding regularization strength), so that I can construct the figure as presented in Fig. 3a) in your paper (https://doi.org/10.1016/j.electacta.2023.141879)?

  2. Q: I got a DRT curve of the best model (using the dual algorithm best_model.plot_eis_fit) as follows: image The best_model.parameter_dict gives {'R_R0': np.float64(1.7253759505369899), 'lnL_L0': np.float64(-13.543433335040868), 'R_RQ1': np.float64(0.06701622751033791), 'lntau_RQ1': np.float64(-11.729064813813391), 'beta_RQ1': np.float64(0.9010920700027231), 'R_RQ2': np.float64(0.1570738484226259), 'lntau_RQ2': np.float64(-6.45271670479093), 'beta_RQ2': np.float64(0.5613884997056322), 'R_RQ3': np.float64(0.1745053723192633), 'lntau_RQ3': np.float64(-4.720535433678493), 'beta_RQ3': np.float64(0.7796951837918176), 'R_RQ4': np.float64(0.03638181338700983), 'lntau_RQ4': np.float64(-0.2761498628368765), 'beta_RQ4': np.float64(0.9999999999999999), 'R_RQ5': np.float64(-0.11434509195485565), 'lntau_RQ5': np.float64(0.922638854832915), 'beta_RQ5': np.float64(0.9999999999999999)}.

When I try to recover the obtained data as you have pointed out using the following codes:

tau_plot = np.logspace(-8, 2, 1001)
gammas = best_model.predict_distribution(tau_plot)
labels = ['', '', 'p1', 'p2', 'p3', 'p4', 'p5']
plt.plot(tau_plot, gammas, label='DRT')
plt.xscale('log')
for i in range(2, 7):
    element_gamma = best_model.predict_element_distribution(tau_plot, i)
    plt.plot(tau_plot, element_gamma, label=labels[i])
    plt.legend()
    plt.xscale('log')

I got image I noticed that peaks 4 and 5 are not visible, I plotted them separately, and then I obtained the following: image This is strange and the total DRT in the second plot is different from the first figure. How to get the correct DRT and the DRT of the i-th element results?

  1. Q: Related to this, I am trying to understand the peak identification and quantification algorithm you have used in the continuous model. I see you have explained the peak identification method in your paper, but I did not see any explanation for the quantification of the identified peaks (I mean the fitting of the peak and calculate the area under the peak). As a beginner in DRT analysis, this is not clear to me.

  2. Q: In the dual regression-classification algorithm, I am confused about the source of the final results after running best_model.plot_eis_fit(axes=axes[1]):

    • The total DRT is given by the continuous regression model, corresponding to the optimal Q (the number of RQ elements in the equivalent circuit)?

    • For the final individual peak (I consider it the same as you have mentioned above, the DRT of the i-th element), are they given by the discrete model, i.e. from the ECM?

    • The final results given by best_model.parameter_dict, are they come from the discrete ECM model?

Thank you in advance for the help!

jdhuang-csm commented 3 days ago

Hi, sorry for the delayed reply!

  1. This is actually generated during a PFRT fit (drt.pfrt_fit_eis). I have added the code to generate the plot you mentioned to the tutorial notebook in the PFRT section.

  2. The reason that peaks 4 and 5 are not visible in your plots is that they are fitted as nearly ideal RC elements (note that the dispersion parameter beta is very close to 1 for both elements). Thus, the analytical DRT for each of these elements is a Dirac delta function, which is infinitely narrow (i.e. gamma=inf for tau=tau_0, 0 otherwise). When you use model.plot_distribution or model.plot_element_distribution, the lines corresponding to singular elements like ideal RC elements are added to the plot separately as vertical lines. When you use model.predict_element_distribution, the returned array will be (nearly) zero everywhere unless your tau grid happens to contain a point extremely close to tau_0. Thus, I would recommend using model.plot_element_distributions, which takes an optional argument element_names, in which you can specify the list of elements that you want to plot (i.e. element_names=["RQ1"] to plot only P1). Otherwise, you can manually plot vertical lines at tau=tau_0 for each singular element.

  3. Can you clarify which function you are referring to?

  4. The object best_model is a discrete model, which contains no information about the continuous model from which it was generated (except the initial guess parameters used to initialize the fit). The total DRT is given by the sum of the DRT contributions of the elements contained in the model. The individual peaks and parameter values in parameter_dict also correspond to the discrete model.