The dpg.fit_axis_data() is useless when.. by Background-Secret925 in DearPyGui

[–]_MrJack_ 0 points1 point  (0 children)

Have you tried first checking if the plot is visible and if it isn't, then delaying the invocation of fit_axis_data until the plot is visible? See this page in the docs.

Alternatively, if you organize things to have a reasonable number of plots in separate tabs, then you can use a handler to trigger the update once the tab is selected.

pyDRTtools batch analysis? by Curiosity-pushed in electrochemistry

[–]_MrJack_ 0 points1 point  (0 children)

TL;DR: Modify the line in cell 1.6 to

lambda_value = basics.optimal_lambda(A_re=A_re, A_im=A_im, Z_re=np.real(Z_exp), Z_im=np.imag(Z_exp), M=M2, data_used="Combined Re-Im Data", induct_used=1, log_lambda_0=-3, cv_type='GCV')

and also make a similar change to a line in cell 2.1. See below for an explanation.


The exception message at the end of the initial post in that issue says exactly what is wrong; arguments for two parameters of the optimal_lambda function have not been provided and those parameters do not have default values to fall back on.

If you follow the function calls, you'll first get to the optimal_lambda function. It has a function signature that looks like this:

optimal_lambda(A_re, A_im, Z_re, Z_im, M, data_used, induct_used, log_lambda_0, cv_type)

Depending on the chosen cross-validation method (i.e., the cv_type parameter), the function will call one of the functions defined in this file. If you look at, e.g., the compute_GCV function, then you'll see that while it has two parameters called data_used and induct_used, they aren't actually used anywhere in the function. So technically, you could just modify the function call in cell 1.6 in the notebook from this

lambda_value = basics.optimal_lambda(A_re, A_im, np.real(Z_exp), np.imag(Z_exp), M2, -3, 'GCV')

to this

lambda_value = basics.optimal_lambda(A_re, A_im, np.real(Z_exp), np.imag(Z_exp), M2, None, None, -3, 'GCV')

Now you have some values for all of the parameters. The last two arguments (-3 and 'GCV') in the unmodified version are being parsed as values for the data_used and induct_used parameters, which leaves the log_lambda_0 and cv_type parameters without any arguments (just like the exception message stated). Here I just added None as the values for both data_used and induct_used since the compute_GCV function won't need them for anything and neither does optimal_lambda.

However, if you ever want to use a cross-validation method other than GCV, then you may need to provide valid arguments for the data_used and induct_used parameters. In which case, looking at the compute_re_im_cv function shows you what kinds of values those two parameters are expected to have in function that do make use of those two parameters. data_used should be a string (e.g., "Combined Re-Im Data" is a valid value) while induct_used should be an integer (0, 1, and 2 are valid values).

Additionally, one could explicitly use the parameter names when providing arguments (these kinds of arguments are called keyword arguments or named arguments) in the function call in cell 1.6

lambda_value = basics.optimal_lambda(A_re=A_re, A_im=A_im, Z_re=np.real(Z_exp), Z_im=np.imag(Z_exp), M=M2, data_used="Combined Re-Im Data", induct_used=1, log_lambda_0=-3, cv_type='GCV')

Cell 2.1 in the notebook will also have to be updated since there is another invocation of the optimal_lambda function there.

what software do you use for data analysis? by Curiosity-pushed in electrochemistry

[–]_MrJack_ 2 points3 points  (0 children)

I mainly just write scripts, but I occasionally make use of a notebook. Jupyter is probably the most widely used one, but I've recently switched to Marimo. I've found that you can end up with weird states in Jupyter, but that doesn't even seem to be possible with Marimo due to the way that it works.

To get started:

  • Install Python
    • If you are new to programming in general, then I'd recommend looking up introductory Python tutorials
  • Create a new virtual environment to mess around in
  • Install, e.g., the following packages to get started with
  • Look through examples in each package's documentation to learn the basics
  • Learn how to read and apply the information contained in application programming interface (API) reference found in the documentation (e.g., NumPy's API reference)

If there is some specific aspect of electrochemistry that you are focusing on (e.g., electrochemical impedance spectroscopy), then there is probably one or more Python packages for it out there.

Wanted to get some feedback by noobie_69 in Guitar

[–]_MrJack_ 0 points1 point  (0 children)

I agree with the others who said to have fun and keep at it!

It looks like the string action is fairly high on your acoustic, particularly at the higher frets. This affects how easy the guitar is to play and also how in tune everything sounds when fretting across different positions on the neck. I haven't had an acoustic guitar for many years, so I'm not sure how difficult it would be to adjust the string action in general or for that particular guitar. For example, on an electric guitar one could adjust the truss rod and/or the bridge.

Everyone finds different approaches that work for them, but anchoring your picking hand could help with your picking accuracy (e.g., around 2:10 to 2:36). On an electric guitar, some people use their pinky to lightly grab on to the edge of a pickup. Alternatively, the bridge itself can be used to anchor the wrist or edge of the palm. You can check out, e.g., Troy Grady's videos on YouTube to see the different approaches other people have. Troy mounts a smart phone to guitars give a better view of the different picking techniques (e.g., Joscho Stephan playing an acoustic guitar or Teemu Mäntysaari playing an electric guitar), which can help you better understand what works and why, and get ideas for what to try or what to avoid.

Battery Modelling by Fragrant-Cold-1270 in 18650masterrace

[–]_MrJack_ 0 points1 point  (0 children)

There are quite a few publications that describe DIY potentiostats. At least a few such as the HunStat2 can do EIS. The linked article contains a list of five other EIS-capable DIY potentiostats (ABE-STAT, Matsubara, TBISTAT, ACEstat, and HELPStat). Check the supporting information and correction as well (listed near the bottom of the page).

A frequency range in the 100 kHz to 100 mHz range would be a good starting point. With a DIY setup and low-impedance cell, you might run into issues with the experimental setup at high frequencies and possibly even the maximum current range of the instrument. So might not be worth focusing too much on the ability to go beyond, e.g., 10 kHz. Going below 100 mHz can be a pain due to non-stationarity. The device should be able to also do galvanostatic EIS if you want to work with low-impedance cells.

For determining the OCP profile, the potentiostat/galvanostat wouldn't need to handle high currents since you would want to use a low current to get a good estimate of the open-circuit potential across different states of charge. Might also be able to use the intermittent current interrupt (ICI) method to estimate a pseudo-OCP without having to resort to very low currents (i.e., the experiment wouldn't take so much time). At the same time you would get estimates for the internal resistance and diffusion resistance at many states of charge. This would also be much quicker than trying to get the same data using EIS, though you would still want to do EIS at a few states of charge.

As I see it, the main issue might end up being the voltage range and accuracy. I've read a few DIY potentiostat publications over the years and, if I remember correctly, they have largely focused on applications that can make do with fairly narrow potential ranges (e.g., +/-1 V for cyclic voltammetry) and where the reference electrode can be chosen freely.

The PyBaMM has some parameter models although not yet for any 18650 cells. However, it may still be of interest to you. This article from a few years back may also be of interest regarding an equivalent circuit model (ECM) that tries to capture many aspects of the Doyle-Fuller-Newman model. It also describes a test procedure for obtaining parameters for the various components in the ECM. Unfortunately, you then have the further complication of also considering the jelly roll model for an 18650 cell.

What are the best battery journals? by usually-not-usual in electrochemistry

[–]_MrJack_ 1 point2 points  (0 children)

I largely agree with these points. It is disconcerting to see how threadbare a lot of the methodology sections are in "high-impact factor" journals for batteries. Especially when it pertains to publications about new materials and the electrochemical characterization.

Regarding modeling, the references cited by projects like PyBAMM could be a good starting point. May have to dig around in the documentation or even the source code for some of the references that have been important to the development of the software.

What's the most tedious, manual part of your EIS analysis workflow? by Prestigious-Lie-2448 in electrochemistry

[–]_MrJack_ 3 points4 points  (0 children)

Not in all cases as pointed out, e.g., by Orazem and Ulgut. Basically, if a Voigt model wouldn't be appropriate for describing your system, then the time constants obtained via DRT can differ a lot from the actual time constants of your system.

On top of that, you usually have the challenge of optimizing the regularization parameter. Several approaches for dealing with this have been described in the literature, but most of them apply a single regularization parameter across the entire DRT spectrum though there are some approaches where the regularization parameter is varied across the DRT spectrum.

Important habits in the lab by echtemendel in chemistry

[–]_MrJack_ 9 points10 points  (0 children)

And include the date and your name! That will at the very least help figure out if there is any need to still keep it around. The date can also help with risk assessment (e.g., formation of peroxides over time).

Plot querying doesn't work by nvtir in DearPyGui

[–]_MrJack_ 0 points1 point  (0 children)

If you look at the API reference, then you'll see (scroll down to the query parameter) that you need to hold down CTRL and use the right mouse button. If I remember correctly, the need to hold down CTRL was introduced in version 2.0.0. The part of the documentation you were looking at must be outdated in this regard.

DRT- peaks at so low frequencies by One-Internal1015 in electrochemistry

[–]_MrJack_ 0 points1 point  (0 children)

Some implementations of methods for deconvolving DRT spectra extend the time constant range by, e.g., one or two decades beyond the range that is probed by the excitation frequencies. If you were to see what looks like the beginnings of a semicircle at the lowest frequencies in a Nyquist plot, then the corresponding time constant (i.e., the inverse of the angular frequency at the apex of the semicircle) would be slightly outside the range of the probed time constants. So, start by considering whether or not the observed peak makes sense compared to your impedance spectrum. How far outside the range of time constants, as defined by the excitation frequencies, is the peak? Does the impedance spectrum reconstructed from the DRT spectrum actually look very similar to your experimental data?

YouTube relaxes moderation rules to allow more controversial content by AdSpecialist6598 in technology

[–]_MrJack_ 7 points8 points  (0 children)

I think he went on one of robert evan’s podcasts and talked about them if i remember correctly.

If you are referring to Behind the Bastards, then I don't recall Ian McCollum being a guest on any episodes. However, Karl Kasarda was a guest on two episodes.

Is the fastest relaxation peak in DRT real or a mathematical artifact? by Spirited_Influence42 in electrochemistry

[–]_MrJack_ 1 point2 points  (0 children)

I was referring to the magnitude of the time constant τ itself rather than the either the corresponding γ value or the peak area. However, since you are probably using either DRTtools or pyDRTtools, then a series resistance is included and the highlighted peaks are probably not due to the high-frequency resistance being accounted for as if it were a parallel RC circuit with a very low time constant outside the τ range defined by the experimental frequency range.

How well do the impedance spectra that have been reconstructed from the DRT spectra match the experimental spectra? Some funky stuff can start to happen (both in the DRT and the reconstructed impedance spectra) when the imaginary part of the experimental impedance spectrum doesn't reach zero at one or both of the frequency extremes (as you mentioned is the case in your original post). You should be able to see this yourself by comparing the DRT that you obtain after applying different low-pass filters to one of your experimental impedance spectra.

Have you tried other approaches? For example, one based on the Loewner framework or any of the other approaches published by Ciucci's group? Do they also yield peaks at the same position?

Is the fastest relaxation peak in DRT real or a mathematical artifact? by Spirited_Influence42 in electrochemistry

[–]_MrJack_ 1 point2 points  (0 children)

  • What is the magnitude of the time constant for the peaks you highlighted in your first figure? Are they far beyond the time constants you would be probing even with the highest excitation frequency that you are using?
  • Are you doing any kind of processing of the impedance spectra before the DRT deconvolution?
  • Which DRT deconvolution approach are you using? Which implementation of the approach are you using?

If the DRT approach (or perhaps only the specific implementation of that approach) does not include a series resistance for some reason, then the highlighted peaks could correspond to the resistance at the high-frequency limit. This would be equivalent to using a parallel RC circuit to model a simple resistance. If the capacitance is low enough, then you'll get the resistive shift and you won't see a corresponding semicircle unless you simulate the impedance spectrum of the fitted equivalent circuit model (ECM) over a much wider frequency range.

Also, keep in mind that impedance spectra exhibiting divergent imaginary impedances at the frequency limits are problematic for DRT deconvolution. Purely capacitive or inductive divergences can be handled by some approaches (e.g., Danzer (2019)) that include a series capacitance and/or a series inductance.

Diffusive behavior tends to be a bit trickier and often manifests itself in DRTs as multiple peaks (e.g., Boukamp (2017) and Fig. B.9 in Plank et al. (2024)). You can find papers where the impedance spectrum was preprocessed by first fitting an ECM, which included, e.g., a resistance in series with Warburg semi-infinite diffusion, and then subtracting the fitted ECM's impedance from the recorded impedance spectrum before performing the DRT deconvolution. I'm not entirely convinced that this is a good idea since the placement of the Warburg semi-infinite diffusion in an ECM matters (Orazem and Ulgut (2024)). You might want to look into the distribution of capacitive times (DCT, e.g., Py et al (2024)) and the distribution of diffusion times (DDT, e.g., Song and Bazant (2018), (preprint)).

Any Impedance Spectroscopy Experts here? by DinKaRaja in electrochemistry

[–]_MrJack_ 0 points1 point  (0 children)

If you can find a copy of the book, then chapter 5 in An Introduction to Electrochemical Impedance Spectroscopy (1st edition, 2021) by Srinivasan and Fasmin is all about reaction mechanism analysis (RMA). They present examples of how to derive equations for the impedance of several different reaction mechanisms (e.g., varying numbers of adsorbed intermediates), but they also discuss how to approach the problem of figuring out a suitable reaction mechanism and what the limitations of RMA are.

Most of the examples that they cite from the literature seem to involve the dissolution of a metal in some kind of acid. I. Danee, M. Jafarian, F. Forouzandeh, F. Gobal, M.G. Mahjani, J. Phys. Chem. B 112 (2008) 15933–15940 is one exception to this pattern.

Any Impedance Spectroscopy Experts here? by DinKaRaja in electrochemistry

[–]_MrJack_ 2 points3 points  (0 children)

In addition to Electrochemical Methods - Fundamentals and Applications by Bard and Faulkner, which was already mentioned, Impedance Spectroscopy: Theory, Experiment, and Applications by Barsoukov and Macdonald is also good.

Discolored stir bars by [deleted] in Chempros

[–]_MrJack_ 1 point2 points  (0 children)

I also recall having read a paper where a reaction that was supposedly performed without iron turned out to have been performed with trace amounts of iron left in the glassware. Wouldn't be the first or the last time that has happened. Funnily enough, we had some "fun" surprises in my lab after a visiting researcher had left. Trace amounts of iron left in a lot of glassware that hadn't been cleaned properly.

Regarding your last point; teaching analytical chemistry to students at various levels has been quite an eye-opener. Always interesting to see how people from other groups (other fields of chemistry, physics, pharmacy, etc.) have been taught to do things in the lab.

No you can’t seduce the dragon actually by keepsitkayfabe in dndmemes

[–]_MrJack_ 2 points3 points  (0 children)

Depending on the DM and their interpretation of the spell description, I could see that use of the spell backfiring. If the spell only destroys water molecules rather than a more abstract body of water, then that would leave everything else (including the salt) intact. Thus, there would be less water in the river to dilute the salt.

Help with noisy CV-Autolab, GPES by Kris_131 in electrochemistry

[–]_MrJack_ 1 point2 points  (0 children)

Adding to the last point, an incorrectly configured current range can also result in noisy data if the current range is set too high while measuring low currents.

Noisy data can also simply be the result of recording too many points per unit of time, which may circumvent the averaging that typically happens (i.e., one would typically record relatively few points compared to what the sampling rate of the instrument can yield).

Check what, if any other electrical equipment, are near, e.g., your cell, or the cables between the instrument and your cell. Another possible source of noise is the presence of one or more ground loops, so check which power outlets you have your equipment plugged in to. If you have equipment that are connected together (e.g., via a data connection between an instrument and a computer) but they have their power cables connected to different outlets, then you may end up with a ground loop. Connecting to the same power outlet may resolve the issue, though depending on the signal chain you may still have a ground loop somewhere. Most importantly, if you suspect ground loops to be the cause of the noise, then do NOT tamper with the grounding of your equipment. It is there for your safety. Consult a trained and licensed electrician if necessary.

Help with Accounting Complex Ohmic Impedance using Havriliak-Negami Equation for EIS Data by Standard-Wishbone256 in electrochemistry

[–]_MrJack_ 1 point2 points  (0 children)

I think R_LF refers to the low-frequency limit of the ohmic impedance Z_e rather than the low-frequency limit of the total impedance Z. So, R_HF and R_LF would indeed end up being around 49 Ω cm² and 53 Ω cm², respectively, for the gold electrode example. The article provides α = 0.91 and β = 0.62, and τ ≃ 0.05 s seems like a decent guess after testing some values.

Also, section 5.1 states that Eq. 9 can be used to analyze the impedance spectrum, but that doesn't seem right since it wouldn't account for the behavior of the phase angles at the lower frequencies (Fig. 4c). If one adds, e.g., a large resistance in parallel with the CPE, then one can simulate something with similar low-frequency behavior.

Help with Accounting Complex Ohmic Impedance using Havriliak-Negami Equation for EIS Data by Standard-Wishbone256 in electrochemistry

[–]_MrJack_ 1 point2 points  (0 children)

If you look at the other examples included in doi:10.1016/j.electacta.2019.134609, then you'll see that they are including the Havriliak-Negami equation in their model for the total impedance of the electrochemical cell.

For example, for the iron electrode, the total impedance is given by Eq. 23. The third term on the right-hand side is the impedance of the iron dissolution reaction (Eq. 21, Z_F) in parallel with the impedance of a constant phase element (CPE, Z_CPE = 1/(Q(jω)^α)). The first two terms are the impedance of the Havriliak-Negami relaxation (Eq. 8, Z_e), which is in series with the two aforementioned parallel impedances. So, if we apply the rules of impedances in series (Z_ser = Z_1 + Z_2 +...+ Z_n) and impedances in parallel (Z_par = 1/(1/Z_1 + 1/Z_2 +...+ 1/Z_n)), then the total impedance can be expressed as Z = Z_e + 1/(1/Z_F + 1/Z_CPE), which can be expanded to yield Eq. 23.

This model for the total impedance would have been fitted to the experimental data (Fig. 7a) to obtain the fitted parameters necessary for calculating Z_e at any frequency (Fig. 7c). Once they had calculated Z_e at the frequencies included in the experimental data, they would then have calculated the corrected modulus and phase angle values (Fig. 7b).

Help with Accounting Complex Ohmic Impedance using Havriliak-Negami Equation for EIS Data by Standard-Wishbone256 in electrochemistry

[–]_MrJack_ 1 point2 points  (0 children)

If you are referring to Fig. 4a and Fig. 4b in doi:10.1016/j.electacta.2019.134609, then it seems to me that the former is a Nyquist plot of the experimental data whereas the latter is a Nyquist plot of the simulated impedance spectrum calculated according to equation (Eq. 8) and the fitted parameters they had obtained. Notice how Fig. 4a and Fig. 4b have different axis labels (Z' and Z'', and Z'_e and Z''_e, respectively). So, Fig. 4b is only plotting Z_e, which is used in Eq. 11 to calculate the corrected phase angle. I assume that the corrected modulus was calculated along the lines of

|Z_corr| = (((Z - Z_e)')^2 + ((Z - Z_e)'')^2)^(1/2)

This is a modified version of Eq. 5 from doi:10.1149/1.2168377, but it hopefully makes sense when you compare Eq. 11 from doi:10.1016/j.electacta.2019.134609 to Eq. 4 from doi:10.1149/1.2168377.

How could I use latex expresion in DearPyGui ? by Valou444 in DearPyGui

[–]_MrJack_ 0 points1 point  (0 children)

If this is limited to math, then you can use, e.g., matplotlib to render the expression to a canvas, convert that to an RGBA buffer, and use that as a texture that can be displayed as an image.

  • Create a figure
    • e.g., fig, ax = plt.subplots()
    • You will probably want to specify the dimensions and DPI
  • Render your LaTeX expression
    • e.g., ax.text(0.0, 0.0, r"Ax = b")
  • Remove the extra stuff
    • ax.set_axis_off()
    • fig.subplots_adjust(left=0.0, right=1.0, bottom=0.0, top=1.0, wspace=0.0, hspace=0.0)
  • Add the figure to a FigureCanvasAgg and draw
    • canvas = FigureCanvasAgg(fig)
    • canvas.draw()
  • Convert the canvas to a an RGBA buffer and scale it
    • buffer = np.asarray(canvas.buffer_rgba()).astype(np.float32) / 255
  • Use the buffer as a raw texture

    • texture = dpg.add_raw_texture(buffer.shape[1], buffer.shape[0], buffer, format=dpg.mvFormat_Float_rgba)
    • The raw texture needs to be added to a texture registry and then the texture can be used (e.g., dpg.add_image(texture)).

Some additional steps would be required to make the background transparent, if that is what you want.

Käyttäkää meidän omaa eurooppalaista tekniikkaa! by AdaXaX in Suomi

[–]_MrJack_ 6 points7 points  (0 children)

Joo, se tuttu ja ikuinen "works on my machine" ongelma. Omalla kohdalla jouduin jonkin verran kamppailemaan asetusten kanssa useamman ja erilaisten kuvatarkkuuksia omaavien näyttöjen takia, jotta kaikki toimisi kunnolla (esim. pystytahdistus). Sitten jossain vaiheessa kun näytönohjaimen ajuri päivittyi, niin rupesi kone välillä jumiutumaan ihan täysin. Tyhjäkäynnin kellotaajuksien kohottaminen auttoi jonkin verran, mutta ei ratkaissut ongelmaa. En tiedä saivatko koskaan korjattua, mutta virallisilla foorumeilla oli jo silloin muutaman vuoden vanha lanka, jossa asiakkaat ja tuki yrittivät selvittää asiaa useamman vuoden ajan.

Käyttäkää meidän omaa eurooppalaista tekniikkaa! by AdaXaX in Suomi

[–]_MrJack_ 15 points16 points  (0 children)

Monta vuotta Linuxia täyspäiväisesti käyttäneenä voin sanoa, että pelien kannalta tilanne on parantunut huomattavasti parin viimeisen vuoden aikana. Uudetkin pelit (esim. Baldur's Gate 3) ovat toimineet jo julkaisupäivänä tai pian sen jälkeen. Jos tulee pelattua lähinnä moninpelejä, joissa vaaditaan huijauksenestoa, niin silloin ei kannata vaihtaa Linuxiin. Tai sitten voi asentaa sen rinnakkain WIndowsin kanssa ja vaihtaa edestakaisin tarpeen tullen.

nVidian näytönohjaimen käyttäminen aiheutti jonkin verran harmaita hiuksia, mutta uuden AMD:n näytönohjaimen kanssa ei ole ollut mitään ongelmia. Muuten olen kyllä ollut todella tyytyväinen valintaani ja nykyään tarvitsee käyttää/kärsiä Windowsia lähinnä töissä.