[petsc-users] Question about how to solve the DAE step by step using PETSC4PY.
Zhang, Hong
hongzhang at anl.gov
Sun Mar 27 21:19:35 CDT 2022
On Mar 25, 2022, at 1:14 PM, Xiong, Jing via petsc-users <petsc-users at mcs.anl.gov<mailto:petsc-users at mcs.anl.gov>> wrote:
Good afternoon,
Thanks for all your help.
I got a question about how to solve the DAE step by step using PETSC4PY.
I got two DAE systems, let's say f1(x1, u1) and f2(x2, u2). The simplified algorithm I need to implement is as follows:
Step 1: solve f1 for 1 step.
Step 2: use part of x1 as input for f2, which means u2 = x1[:n].
Step 3: solve f2 for one step with u2 = x1[:n].
Step 4: use part of x2 as input for f1, which means u1 = x2[:m].
I'm not able to find any examples of how to use PETSC4PY in such scenarios. If using the "scikits.odes.dae" package, it is like:
daesolver.init_step(timeInit, XInit, XpInit)
daesolver.step(time)
Jing,
You can certainly do the same thing in petsc4py with
ts.setMaxTime(t1)
ts.solve() // integrate over time interval [0,t1]
ts.setTime(t1)
ts.setMaxTime(t2)
ts.solve() // integrate over time interval [t1,t2]
...
There are also APIs that allow you to control the step size (ts.setTimeStep) and the final step behavior (ts.setExactFinalTime).
The C example src/ts/tutorials/power_grid/stability_9bus/ex9busdmnetwork.c might be helpful to you. Most of the C examples can be reproduced in python with similar APIs.
Hong
Please let me know if there are any examples I can refer to. Thank you.
Best,
Jing
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.mcs.anl.gov/pipermail/petsc-users/attachments/20220328/8ce826d0/attachment.html>
More information about the petsc-users
mailing list