Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support for constant phase elements in circuit simulation #132

Open
ma-sadeghi opened this issue Jun 11, 2024 · 9 comments
Open

Support for constant phase elements in circuit simulation #132

ma-sadeghi opened this issue Jun 11, 2024 · 9 comments

Comments

@ma-sadeghi
Copy link

I was wondering how difficult it would be to add support for CPE elements for circuit simulations. Currently, the circuit simulator doesn't seem to support it.

@mph-
Copy link
Owner

mph- commented Jun 12, 2024

The stamps for modified nodal analysis should be straightforward to add. I think I know how to handle the inverse Laplace stuff. But, when all is said in done, I imagine that most results will be gnarly. Are you comfortable with fractional derivatives?

@ma-sadeghi
Copy link
Author

I'm very new to fractional derivatives, but willing to dig deeper as I really need to get the V(t) response to an input I(t) for a circuit with a few CPE elements.

@mph-
Copy link
Owner

mph- commented Jun 13, 2024

I had forgotten that I had implement the MNA stamps for CPEs. Thus you can get an answer in the Laplace and ac domains. For example,

>>> a = Circuit("""
V 1 0 ac
CPE 1 2 K alpha
R 2 0""")
>>> a.R.I(t)

                      ⎛       α      ⎞                        ⎛       α      ⎞
        α             ⎜      ⅉ       ⎟         α              ⎜      ⅉ       ⎟
- K⋅V⋅ω₀ ⋅sin(ω₀⋅t)⋅iₘ⎜──────────────⎟ + K⋅V⋅ω₀  ⋅cos(ω₀⋅t)⋅rₑ⎜──────────────⎟
                      ⎜ α       α    ⎟                        ⎜ α       α    ⎟
                      ⎝ⅉ ⋅K⋅R⋅ω₀  + 1⎠                        ⎝ⅉ ⋅K⋅R⋅ω₀  + 1⎠

Unfortunately, SymPy crashes when trying to do an inverse Laplace transform of s^alpha so I'll need to implement this.

Are you modelling the impedance of electrodes?

@ma-sadeghi
Copy link
Author

Thanks for sharing the snippet.

Yes, I'm modeling the impedance of Li-ion battery electrodes. Currently, I want to take it one step further (and not just match simulated Z to experimental Z): Particularly, I want to see the mismatch between experimental V(t) -given a known I(t)- and simulated V(t).

@mph-
Copy link
Owner

mph- commented Jun 14, 2024

If you want the transient response we need the inverse Laplace transform of 1 / (s^a + b)
However, I only know the cases for integer a and a = 0.5.

@ma-sadeghi
Copy link
Author

What about numerical methods? Can lcapy solve circuits numerically?

@mph-
Copy link
Owner

mph- commented Jun 21, 2024

Lcapy can solve circuits numerically but you are better off using SPICE. However, you will need to create an approximate model of a CPE.

Lcapy can create a second order Pade approximation of the impedance of a CPE. For example,

>>> a = CPE('K', 'alpha')
>>> Z = a.Z.approximate('pade', 2)

@ma-sadeghi
Copy link
Author

ma-sadeghi commented Jun 25, 2024

I'm not familiar with SPICE (I found a Python wrapper called PySpice, is that what you're referring to?), and at this point I just need a proof of concept. I'll make sure to look into it to do it properly in SPICE if it turns out to work as I thought it would. In the meantime, Is there any workaround/hack to make it work in Lcapy? Thanks again :)

@mph-
Copy link
Owner

mph- commented Jun 28, 2024

Yes, you can use PySpice for a numerical solution. As I said before, for a symbolic solution we need the inverse Laplace transform of 1 / (s^a + b), which I don't know, or approximate the s-domain result using a Pade approximation before doing an inverse Laplace transform.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants