I have one quick question about how we could determine the number of times the code will call the f function. The f function could be the ODE function as shown in the example "cvRoberts_dns.c".
I have tested my code, I can get some general sense about the calling times: 1. The calling times will be related to the output time interval, like the tout, if the tout is larger, the number of calls will be larger; 2. The calling times will be reduced as the code process, for example, the number of calls could be 5000 at the first few output step, but then it could be reduced to 500, and even 50 as the output step increases.
But here my question is, how does the code determine the number of calls? Do we have some equation to calculate that or does it have some parameters that we can control the number of call in Sundials? Thank you
—
Reply to this email directly, view it on GitHub, or unsubscribe.
You are receiving this because you are subscribed to this thread.
To unsubscribe from the SUNDIALS-USERS list: write to: mailto:SUNDIALS-USERS-...@LISTSERV.LLNL.GOV
You could count it yourself. int numfcalls=0; int my_f_func(...) { numfcalls++; ... } Maybe I'm not understanding your question?
…
-John Weeks
On Jul 22, 2022, at 8:57 AM, Jianqi Xi @.> wrote: I have one quick question about how we could determine the number of times the code will call the f function. The f function could be the ODE function as shown in the example "cvRoberts_dns.c". I have tested my code, I can get some general sense about the calling times: 1. The calling times will be related to the output time interval, like the tout, if the tout is larger, the number of calls will be larger; 2. The calling times will be reduced as the code process, for example, the number of calls could be 5000 at the first few output step, but then it could be reduced to 500, and even 50 as the output step increases. But here my question is, how does the code determine the number of calls? Do we have some equation to calculate that or does it have some parameters that we can control the number of call in Sundials? Thank you — Reply to this email directly, view it on GitHub, or unsubscribe. You are receiving this because you are subscribed to this thread. To unsubscribe from the SUNDIALS-USERS list: write to: @.
Thank you for your reply. Actually, I have used this way to count the number of calls, but I don't know why it gives those numbers, does it have one specific equation to determine the number of calls? Thank you
—
Reply to this email directly, view it on GitHub, or unsubscribe.
You are receiving this because you commented.
The number of function evaluations will depend on several factors (e.g., tolerances, nonlinear/linear solver, etc.) and dynamics of the problem your are solving. What nonlinear/linear solver are you using? If using the dense or banded linear solver, are you supplying a Jacobian function? What is the evolution of the system like e.g., does the problem have an initial transient period followed by slow dynamics or tend toward a steady state?
—
Reply to this email directly, view it on GitHub, or unsubscribe.
You are receiving this because you commented.
@gardner48 Thank you for your response. Currently, I am using the Dense solver, and because the Jacobian function is too complex, I didn't supply the Jacobian function. For my system, it is used to describe the evolution of composition, and eventually, it will become a steady state. Thank you for your asking.
—
Reply to this email directly, view it on GitHub, or unsubscribe.
You are receiving this because you commented.
Thank you for your comments, in my case, I am using the iteration one based on some criteria, like Atol = 1e-10 and Rtol=1e-7. I see your point, it could be related to the specific equations that I used in my code, but I am wondering why the number of calls is pretty large at the first few step, and then become smaller and smaller as the step increases. Since my understanding is that each step should only depend on the initial values we provided, the number of the calls in each step could be independent. Maybe I am wrong, could you clarify it for me? Thank you,
—
Reply to this email directly, view it on GitHub, or unsubscribe.
You are receiving this because you commented.
@jianqixi In your case (with the dense linear solver), the number of function evaluations depends on the number of time steps (which depends on the time-step sizes), the number of nonlinear iterations, and the number of times the Jacobian is recomputed (internally, via difference quotients since you have not provided an analytical Jacobian).
If your solution has initial transients that go to a steady state, it makes sense that CVODE is calling the right-hand side function more frequently early on in the simulation. This is because CVODE is adapting the time-step size to resolve the solution to the requested tolerance. It is likely that the initial transients are requiring CVODE to use smaller time-steps than what it uses when the problem is at steady-state. In addition, at steady-state less nonlinear iterations are likely needed, and the Jacobian does not need to be updated as frequently.
You can output the number of time steps, number of nonlinear iterations, and number of jacobian evaluations throughout the simulation and see if this is all the case for your problem.
—
Reply to this email directly, view it on GitHub, or unsubscribe.
You are receiving this because you commented.
@balos1 Thank you for your clarification. I will try to output these values and check them. By the way, I know CVODE can automatically update the time-step size, but I wonder if we could control the time-step size by ourselves?
—
Reply to this email directly, view it on GitHub, or unsubscribe.
You are receiving this because you commented.