sundials icon indicating copy to clipboard operation
sundials copied to clipboard

Using IDA for circuit equations

Open ibaned opened this issue 7 months ago • 7 comments

Hello,

I don't have a lot of experience with SUNDIALS IDA but I've been using it successfully for a fairly complex set of circuit equations recently. The only trouble I'm having now is with equations where the residual is of the form:

r[eeq] = yp[eeq] - (y[veq] * y[ieq])

Trying to express the power of a circuit component as the product of its voltage and current. Is this something that SUNDIALS IDA supports and if so do I need to use different APIs to support nonlinear terms?

Thank you!

ibaned avatar May 28 '25 01:05 ibaned

Hello Dan,

This equation is the same as an ODE for y[eeq] so should not itself be a cause for difficulty.  Are there ODEs for y[veq] and y[ieq]? If not, there may be some issue with the whole system not being well-posed.

Alan H

On 5/27/25 6:17 PM, Dan Ibanez wrote:

ibaned created an issue (LLNL/sundials#711)

Hello,

I don't have a lot of experience with SUNDIALS IDA but I've been using it successfully for a fairly complex set of circuit equations recently. The only trouble I'm having now is with equations where the residual is of the form:

r[eeq] = yp[eeq] - (y[veq] * y[ieq])

Trying to express the power of a circuit component as the product of its voltage and current. Is this something that SUNDIALS IDA supports and if so do I need to use different APIs to support nonlinear terms?

Thank you!

Yes, there are other ODEs for those two equations as well (algebraic for voltage veq and differential for current ieq). I've put diagnostics into my residual callback and notice that the residual for the energy equation eeq is quite high (10000 compared to 1.0e-13 for others) when the solver fails

ibaned avatar May 28 '25 19:05 ibaned

Hi Dan,

Are you confident that the DAE system is well-posed?  E.g., is the algebraic equation for the voltage solvable for the voltage as a function of the other variables? If so, I see nothing in the system that should give IDA trouble -- certainly not the mild nonlinearity in r[eeq]. Possibly the linear systems that IDA solves to take a BDF time step are extremely ill-conditioned.  A rescaling or other reformulation might fix that.

-Alan H

On 5/28/25 12:09 PM, Dan Ibanez wrote:

ibaned left a comment (LLNL/sundials#711)

Yes, there are other ODEs for those two equations as well (algebraic for voltage veq and differential for current ieq). I've put diagnostics into my residual callback and notice that the residual for the energy equation eeq is quite high (10000 compared to 1.0e-13 for others) when the solver fails

Hi Dan,

There is nothing obviously wrong with the equation you posted and nothing that would prevent IDA from solving it. Your instinct is right -- isolated large residual sometimes can point to an issue at that part of the circuit. I would check what is connected to the component for which you are computing the power. Common culprits are inductors connected in series with current sources and capacitors connected in parallel to voltage sources, leading to index 2 DAEs. It can be also an incorrect sign for current and/or voltage in that equation.

I would also print voltage, current and power as they are computed and check how their values are changing and if they pass the sanity check.

Finally, if you could reproduce your issue in a small problem, it would be helpful to share that. With information you provided, one can only guess.

Cheers, Slaven

From: @.> on behalf of Dan Ibanez @.> Reply-To: LLNL/sundials @.> Date: Wednesday, May 28, 2025 at 3:16 PM To: @." @.***> Subject: [EXTERNAL] Re: [sundials-users] [LLNL/sundials] Usind IDA with nonlinear terms (Issue #711)

ibaned left a comment (LLNL/sundials#711) Yes, there are other ODEs for those two equations as well (algebraic for voltage veq and differential for current ieq). I've put diagnostics into my residual callback and notice that the residual for

[Image removed by sender.]ibaned left a comment (LLNL/sundials#711)https://urldefense.us/v3/__https:/github.com/LLNL/sundials/issues/711*issuecomment-2917345551__;Iw!!G2kpM7uM-TzIFchu!11uhMuF4L5KOtOkq8KIB3gRzC272PnocmS0Oq-sCQ9y3t1mEBi0jV1vVslnNtSaDlkB8zb6oAE8GYwP8vb5nM5hcmAoXxw$

Yes, there are other ODEs for those two equations as well (algebraic for voltage veq and differential for current ieq). I've put diagnostics into my residual callback and notice that the residual for the energy equation eeq is quite high (10000 compared to 1.0e-13 for others) when the solver fails

— Reply to this email directly, view it on GitHubhttps://urldefense.us/v3/__https:/github.com/LLNL/sundials/issues/711*issuecomment-2917345551__;Iw!!G2kpM7uM-TzIFchu!11uhMuF4L5KOtOkq8KIB3gRzC272PnocmS0Oq-sCQ9y3t1mEBi0jV1vVslnNtSaDlkB8zb6oAE8GYwP8vb5nM5hcmAoXxw$, or unsubscribehttps://urldefense.us/v3/__https:/github.com/notifications/unsubscribe-auth/AXXIGEWHNHIJTWG7JEU4UJL3AYCWHAVCNFSM6AAAAAB6BOKM2KVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDSMJXGM2DKNJVGE__;!!G2kpM7uM-TzIFchu!11uhMuF4L5KOtOkq8KIB3gRzC272PnocmS0Oq-sCQ9y3t1mEBi0jV1vVslnNtSaDlkB8zb6oAE8GYwP8vb5nM5jNqaZwrg$. You are receiving this because you commented.Message ID: @.***>


To unsubscribe from the SUNDIALS-USERS list: write to: @.***

Hi folks, I managed to develop a single-C-file reproducer of the problematic time step in my circuit.

Could someone on the team compile this against SUNDIALS and help me understand what I'm likely doing wrong?

I'm happy to answer questions about what this code is doing.

Thank you!

reproducer.tar.gz

ibaned avatar Jun 11 '25 18:06 ibaned

For full transparency, when I run this program I get the following:

[ERROR][rank 0][/Users/daibane/smash/source/sundials/src/ida/ida.c:2359][IDAHandleFailure] At t = 8.04287392670521e-08 and h = 1.06878831831429e-20the error test failed repeatedly or with |h| = hmin.
Circuit time integration to new_time=8.04760827177796686e-08 failed.

ibaned avatar Jun 11 '25 18:06 ibaned

Further clarification: I have removed the equations that I believe to be nonlinear and I am still seeing IDA solver failures. Thus I'm changing the name of this issue because its more about being able to solve this particular system even though its linear.

ibaned avatar Jun 11 '25 18:06 ibaned

Follow-ups have been taken offline so I'm closing the issue.

balos1 avatar Sep 03 '25 18:09 balos1