Giter Club home page Giter Club logo

Comments (6)

mdmurbach avatar mdmurbach commented on June 12, 2024 3

Wow @BGerwe this is a fantastic write up of your exploration ๐Ÿš€ thanks for working on getting this implemented correctly!!!

from impedance.py.

BGerwe avatar BGerwe commented on June 12, 2024

I started working on this again last night, and came to the conclusion that our implementation of LinKK treats the ohmic resistance as a fitting parameter, rather than holding it constant. In the case presented above, the simulated data above has a high-frequency intercept of 100.323 ฮฉ, but the "under-fitting" uses 100.65 ฮฉ and the "over-fitting" case uses ฮฉ. OK, maybe that's not so convincing. So, I simulated another circuit with only RC elements and an ohmic resistance.

circ = 'R0-p(R1,C1)-p(R2,C2)-p(R3,C3)-p(R4,C4)'

vals = [10, 100, 1e-6, 60, 1e-5, 200, 3e-4, 300, 1e-5]

circuit = CustomCircuit(circ, initial_guess=vals)

Simulated_RC_circuit

When I apply LinKK and look at the circuit string, I see s([R([7.602373651530629],[100000.0,... proving the ohmic resistor can change values, since the RC-elements are represented by a K element in this case. After making some changes to (hopefully) hold the ohmic resistance constant, I verify that's true by looking at the circuit string again s([R([10.025830624944371],[100000.0,... Now, checking out how the fits compare:
Simulated_RC_LinKK

As another accuracy check, I went through the hassle of installing the LinKK Test Software M. Schonleber et al wrote, and cross-checked my results by forcing their software to use the same M:
LinKKSoft_RC_sim_NyquistPlot
LinKKSoft_RC_sim_ResidualPlot

With the ohmic resistance held constant this looks better but still doesn't match the results from their software. A particularly noticeable feature is the maximum residuals from their software peaked above 2% around 20-30 Hz. In my analysis we see a similar peak above 2%, but it occurs around 1 kHz. So, I reincorporated a change mentioned in my first comment, namely that the paper uses radial frequencies, but our implementation used linear frequencies.
Simulated_RC_LinKK_fixed

Now, our residuals look nearly identical except for mild discrepancies at the highest frequencies.

As a final check, I let their software detect the appropriate number of RC elements instead of manual enforcing a number. Unfortunately, their software doesn't report a final ยต-value for their fit, but it does report using 66 RC-elements for the fit.
LinKKSoft_RC_sim_autoNyquistPlot
LinKKSoft_RC_sim_autoResidualPlot

On the other hand, if we set a c = 0.75 (vs their recommended 0.85), we reach ยต=0.747 at 23 RC-elements. I think the fit looks pretty good, if a little under-fitted. But, if we increase M to 66 I see no difference between their results and ours (not shown).
Simulated_RC_LinKK_fixed_auto

The final thing, which has me rather stumped still, is these changes make LinKK fail for data with a low-frequency warburg even if they're simulated. Even using a high M (M=45 vs #data=71)
Sim_LiB_LinKK

On the other hand, their software finds a nice fit with M=32, though a little oscillation in the residuals is still evident at the lowest frequencies.
LinKKSoft_LiB_sim_autoNyquistPlot
LinKKSoft_LiB_sim_autoResidualPlot

For an apples-to-apples comparison, I used M=32 in our software:
Sim_LiB_LinKK_32

As you can see, there's quite a bit of oscillation with my changes that occur in the original implementation. My guess is they have a more sophisticated algorithm for guessing initial values, but I have no way to verify.

Final Thoughts

Despite failing to totally fit data with a low-frequency Warburg, I think we should move forward with my changes. With them, LinKK correctly validates data it failed to validate before (there are several iterations of circuit simulations I looked at but didn't present here). Further, it closely matches results from their published software (under the same conditions) whereas the current method often gives very different results.

from impedance.py.

BGerwe avatar BGerwe commented on June 12, 2024

Quoting from PR #87 so I can close that but keep the conversation going:

Looks great! Nice job ๐Ÿš€ only thought is if there's an relatively easy way to repurpose all your exploratory comparisons with the Lin-KK tool into a test for linKK()?

Do you mean something for unit testing? Or a way to test if the result appears underfit?

from impedance.py.

mdmurbach avatar mdmurbach commented on June 12, 2024

Unit testing (although building on their algorithm is also an interesting thought). validation is by far our weakest remaining point in terms of test coverage. I was thinking that you've got through and manually figured out what should be "right," maybe it would be straightforward to add that as a test. ๐Ÿค”

If it's not simple to just plop in your exploratory code, I think this is a separate issue and we should come up with a circuit-derived impedance that should pass and an intentionally bad impedance (e.g. imag shifted) that doesn't (or something like that) at some point.

from impedance.py.

BGerwe avatar BGerwe commented on June 12, 2024

Yeah, I don't think my exploration would be a good drop-in test. That said, I have ideas for validation unit testing that I'll write up fairly soon.

from impedance.py.

mdmurbach avatar mdmurbach commented on June 12, 2024

sounds good! ๐Ÿ˜Ž

from impedance.py.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.